arkgate 4.6.7 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/README.md +20 -9
  3. package/SECURITY.md +1 -1
  4. package/bin/ark-check-runtime.mjs +13 -1
  5. package/bin/ark-mcp-runtime.mjs +65 -3
  6. package/bin/lib/adapter-contract.mjs +17 -36
  7. package/bin/lib/analysis-engine.mjs +6 -6
  8. package/bin/lib/ark-run-doctor.mjs +144 -0
  9. package/bin/lib/ark-run-facts.mjs +472 -0
  10. package/bin/lib/ark-run-report.mjs +57 -0
  11. package/bin/lib/ark-run-sensors.mjs +309 -0
  12. package/bin/lib/config-contract.mjs +86 -11
  13. package/bin/lib/diagnostic-catalog.mjs +8 -0
  14. package/bin/lib/doctor-advisories.mjs +45 -8
  15. package/bin/lib/doctor-human.mjs +10 -0
  16. package/bin/lib/doctor-plan.mjs +20 -16
  17. package/bin/lib/extra-merge-teeth.mjs +187 -0
  18. package/bin/lib/html-report-advisories.mjs +2 -0
  19. package/bin/lib/html-report-depth.mjs +22 -2
  20. package/bin/lib/html-report.mjs +16 -0
  21. package/bin/lib/remediation.mjs +132 -0
  22. package/bin/lib/resolved-candidate-facts.mjs +67 -2
  23. package/bin/lib/rules-under-contract.mjs +37 -89
  24. package/bin/lib/snippet-analysis.mjs +43 -2
  25. package/bin/lib/status-command.mjs +28 -0
  26. package/bin/lib/status-manifest.mjs +23 -0
  27. package/dist/{configTypes-l6XiwiC1.d.ts → configTypes-CgJimx9o.d.ts} +17 -3
  28. package/dist/eslint/index.cjs +6 -2
  29. package/dist/eslint/index.d.ts +70 -2
  30. package/dist/eslint/index.js +6 -2
  31. package/dist/index.cjs +35 -35
  32. package/dist/index.d.ts +787 -272
  33. package/dist/index.js +35 -35
  34. package/docs/README.md +2 -1
  35. package/docs/agent-guide.md +21 -15
  36. package/docs/ai-gates.md +13 -0
  37. package/docs/configuration.md +24 -11
  38. package/docs/develop.md +12 -3
  39. package/docs/diagnostics.md +75 -0
  40. package/docs/enthusiast/README.md +4 -3
  41. package/docs/package-surface.md +16 -13
  42. package/docs/product-voice.md +6 -3
  43. package/docs/threat-model.md +1 -1
  44. package/docs/use.md +5 -4
  45. package/package.json +1 -1
  46. package/schemas/ark.config.schema.json +41 -2
  47. package/schemas/ark.resolved-candidate-facts.schema.json +1 -1
  48. package/schemas/ark.status-manifest.schema.json +47 -0
  49. package/server.json +2 -2
  50. package/templates/agent-skills/README.md +1 -1
  51. package/templates/agent-skills/ark-adopt/SKILL.md +23 -2
  52. package/templates/agent-skills/ark-place/SKILL.md +26 -2
  53. package/templates/agent-skills/ark-runtime/SKILL.md +66 -24
  54. package/templates/skills/ark-adopt.md +23 -2
  55. package/templates/skills/ark-place.md +26 -2
  56. package/templates/skills/ark-runtime.md +66 -24
@@ -1,3 +1,7 @@
1
- "use strict";var _e=Object.create;var N=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var De=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},Q=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pe(t))!je.call(e,s)&&s!==r&&N(e,s,{get:()=>t[s],enumerable:!(n=Te(t,s))||n.enumerable});return e};var ee=(e,t,r)=>(r=e!=null?_e($e(e)):{},Q(t||!e||!e.__esModule?N(r,"default",{value:e,enumerable:!0}):r,e)),ve=e=>Q(N({},"__esModule",{value:!0}),e);var ht={};De(ht,{default:()=>yt,findConfigPath:()=>j,globToRegExp:()=>L,isEdgeDenied:()=>M,layerForRelativePath:()=>S,loadArkConfig:()=>D,noDeniedCapabilities:()=>Oe,noDomainInfraImports:()=>Le,noForbiddenGlobals:()=>Ne,noRawEventPublish:()=>Ce,patternSpecificity:()=>V,plugin:()=>$,readTsconfigPathAliases:()=>Ae,requirePublishSource:()=>we,resolveImportSpecifier:()=>ke,resolveRelativeImport:()=>Ie});module.exports=ve(ht);var R=ee(require("fs"),1),p=ee(require("path"),1);var te=new Map;function re(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}function O(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}function Ve(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}function L(e){let t=te.get(e);if(t)return t;let r=O(e),n=Ve(r),s="",o=0;for(let c=0;c<r.length;c+=1){let g=r[c];g==="\\"&&c+1<r.length?(s+=re(r[c+1]),c+=1):g==="*"?r[c+1]==="*"?r[c+2]==="/"?(s+="(?:.*/)?",c+=2):(s+=".*",c+=1):s+="[^/]*":g==="?"?s+="[^/]":g==="{"&&n?(s+="(?:",o+=1):g==="}"&&n&&o>0?(s+=")",o-=1):g===","&&n&&o>0?s+="|":s+=re(g)}let a=new RegExp(`^${s}$`);return te.set(e,a),a}function Ke(e){return O(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}function V(e,t){let r=O(String(e)),n=Ke(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let a=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let c=0,g=-1;for(let f of n){let d=-1;for(let i=c;i<a.length;i+=1)if(a[i]===f){d=i;break}if(d<0)return o;g=d,c=d+1}return(g+1)*1e6+n.length*1e4+s}function S(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(a=>L(a).test(r))){for(let a of o.patterns??[])if(L(a).test(r)){let c=V(a,r);c>s&&(s=c,n=o.name)}}return n}function ne(e,t){if(!t?.length)return;let r=String(e).split(/[/\\]/).filter(Boolean),n=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<r.length-1;s+=1)if(n.has(r[s].toLowerCase()))return`${r[s].toLowerCase()}/${r[s+1].toLowerCase()}`}function Me(e){let t=new Set;for(let r of e??[]){let s=O(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let a=s[o];if((a==="**"||a==="*")&&o>0){let c=s[o-1];c&&!c.includes("*")&&!c.includes("{")&&!c.includes("}")&&t.add(c)}}}return[...t]}function He(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 Me(n?.patterns)}function Fe(e){return!e.fromPath||!e.toPath||e.folderCount<=0||!e.fromSlice||!e.toSlice?!0:e.fromSlice!==e.toSlice}function K(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,a=n?.toPath,c=He(s,t,n?.layers),g=o&&a?ne(o,c):void 0,f=o&&a?ne(a,c):void 0;if(Fe({fromPath:o,toPath:a,folderCount:c.length,fromSlice:g,toSlice:f}))return s;continue}if(t!==r)return s}}function M(e,t,r,n){return K(e,t,r,n)!==void 0}var Ue=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Be(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:Ue,...t]}function se(e,t){let r=String(e).split(/[/\\]/).join("/");return Be(t).some(n=>L(n).test(r))}var ie=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),Ge=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),It=Object.freeze(Object.keys(Ge).sort()),H=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"}),qe=Object.freeze({process:Object.freeze(["process","node:process"])});function oe(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=H[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=H[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:H[e.slice(0,o)]??null}function F(e,t){for(let r of t)if(qe[r]?.includes(e))return r;return null}function ae(e){if(e?.pure===!0)return[...ie].sort();let r=(e?.capabilities?.deny??[]).filter(n=>ie.includes(n));return[...new Set(r)].sort()}var U="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",le=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],We=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Ye(){let e=[];for(let t of le)for(let r of le)t===r||We.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}var de=Ye(),B=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"}],I={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},ce={$schema:"https://json-schema.org/draft/2020-12/schema",$id:U,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:U,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:"1.1",default:"1.1"},name:{type:"string",minLength:1},include:{...I,minItems:1,default:["src"]},exclude:{...I,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:de,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...I,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},stewards:{...I,default:[]}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...I,minItems:1},exclude:I,intentPrefixes:I,description:{type:"string",minLength:1},forbiddenGlobals:I,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:{...I,minItems:1}}},safety:{type:"object",additionalProperties:!1,properties:{maxTsSuppressions:{type:"integer",minimum:0,default:0},maxAnyCasts:{type:"integer",minimum:0,default:0},allowInMemory:{type:"boolean",default:!1},allowDisabledPeerIsolation:{type:"boolean",default:!1}}}}},k=class extends Error{issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
1
+ "use strict";var gt=Object.create;var H=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var ht=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var At=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},Ae=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of yt(t))!Rt.call(e,s)&&s!==r&&H(e,s,{get:()=>t[s],enumerable:!(n=mt(t,s))||n.enumerable});return e};var j=(e,t,r)=>(r=e!=null?gt(ht(e)):{},Ae(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),kt=e=>Ae(H({},"__esModule",{value:!0}),e);var Pr={};At(Pr,{default:()=>Dr,findConfigPath:()=>K,globToRegExp:()=>v,isEdgeDenied:()=>te,layerForRelativePath:()=>S,loadArkConfig:()=>M,noArkRunDirectNew:()=>lt,noArkRunKernelInDomain:()=>at,noArkRunTransportBypass:()=>ct,noDeniedCapabilities:()=>it,noDomainInfraImports:()=>rt,noForbiddenGlobals:()=>ot,noRawEventPublish:()=>nt,patternSpecificity:()=>Q,plugin:()=>Z,readTsconfigPathAliases:()=>Ye,requirePublishSource:()=>st,resolveImportSpecifier:()=>ge,resolveRelativeImport:()=>Je});module.exports=kt(Pr);var x=j(require("fs"),1),g=j(require("path"),1);var ke=new Map;function be(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}function V(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}function bt(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}function v(e){let t=ke.get(e);if(t)return t;let r=V(e),n=bt(r),s="",i=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=be(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",i+=1):l==="}"&&n&&i>0?(s+=")",i-=1):l===","&&n&&i>0?s+="|":s+=be(l)}let o=new RegExp(`^${s}$`);return ke.set(e,o),o}function St(e){return V(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}function Q(e,t){let r=V(String(e)),n=St(r),s=r.replace(/\*/g,"").length,i=n.length*1e4+s;if(t==null||t==="")return i;let o=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,l=-1;for(let d of n){let u=-1;for(let c=a;c<o.length;c+=1)if(o[c]===d){u=c;break}if(u<0)return i;l=u,a=u+1}return(l+1)*1e6+n.length*1e4+s}function S(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let i of t??[])if(!(i.exclude??[]).some(o=>v(o).test(r))){for(let o of i.patterns??[])if(v(o).test(r)){let a=Q(o,r);a>s&&(s=a,n=i.name)}}return n}function Se(e,t){if(!t?.length)return;let r=String(e).split(/[/\\]/).filter(Boolean),n=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<r.length-1;s+=1)if(n.has(r[s].toLowerCase()))return`${r[s].toLowerCase()}/${r[s+1].toLowerCase()}`}function Et(e){let t=new Set;for(let r of e??[]){let s=V(String(r)).split("/").filter(Boolean);for(let i=0;i<s.length;i+=1){let o=s[i];if((o==="**"||o==="*")&&i>0){let a=s[i-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}function It(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 Et(n?.patterns)}function xt(e){return!e.fromPath||!e.toPath||e.folderCount<=0||!e.fromSlice||!e.toSlice?!0:e.fromSlice!==e.toSlice}function ee(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===!1){if(s.peerIsolation){let i=n?.fromPath,o=n?.toPath,a=It(s,t,n?.layers),l=i&&o?Se(i,a):void 0,d=i&&o?Se(o,a):void 0;if(xt({fromPath:i,toPath:o,folderCount:a.length,fromSlice:l,toSlice:d}))return s;continue}if(t!==r)return s}}function te(e,t,r,n){return ee(e,t,r,n)!==void 0}var Nt=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Ct(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:Nt,...t]}function Ee(e,t){let r=String(e).split(/[/\\]/).join("/");return Ct(t).some(n=>v(n).test(r))}var Ie=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),vt=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Ur=Object.freeze(Object.keys(vt).sort()),re=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"}),_t=Object.freeze({process:Object.freeze(["process","node:process"])});function xe(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=re[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=re[n];if(s)return s;let i=e.indexOf("/",r+1);return i<0?null:re[e.slice(0,i)]??null}function ne(e,t){for(let r of t)if(_t[r]?.includes(e))return r;return null}function Ne(e){if(e?.pure===!0)return[...Ie].sort();let r=(e?.capabilities?.deny??[]).filter(n=>Ie.includes(n));return[...new Set(r)].sort()}var se="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",Ce=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],wt=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Lt(){let e=[];for(let t of Ce)for(let r of Ce)t===r||wt.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}var _e=Lt(),oe=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"}],b={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},ve={$schema:"https://json-schema.org/draft/2020-12/schema",$id:se,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:se,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:"1.2",default:"1.2"},name:{type:"string",minLength:1},include:{...b,minItems:1,default:["src"]},exclude:{...b,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:_e,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...b,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},stewards:{...b,default:[]}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...b,minItems:1},exclude:b,intentPrefixes:b,description:{type:"string",minLength:1},forbiddenGlobals:b,capabilities:{type:"object",additionalProperties:!1,properties:{deny:{type:"array",uniqueItems:!0,items:{type:"string",enum:["network","filesystem","clock","randomness","environment","process","persistence"]}}}},pure:{type:"boolean"},mayImportInfrastructure:{type:"boolean"},optional:{type:"boolean"},reserved:{type:"boolean"},allowEmpty:{type:"boolean"}}},rule:{type:"object",additionalProperties:!1,required:["from","to","allowed"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},allowed:{type:"boolean"},message:{type:"string",minLength:1},peerIsolation:{type:"boolean"},sliceFolders:{...b,minItems:1}}},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}}},arkRun:{type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...b,default:[]},managedLayers:{...b,default:[]},requireDeclarations:{type:"boolean",default:!0}}}}},E=class extends Error{issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
2
2
  ${r.map(n=>`- ${n.path}: ${n.message}`).join(`
3
- `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function pe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function x(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function ze(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}function C(e,t,r,n,s){if(t.$ref){let o=ze(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}C(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(!pe(e)){s.push({path:r,message:`must be an object; received ${x(e)}`});return}let o=t.properties??{};for(let a of t.required??[])e[a]===void 0&&s.push({path:_(r,a),message:"is required"});if(t.additionalProperties===!1)for(let a of Object.keys(e))a in o||s.push({path:_(r,a),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let a=t.additionalProperties;for(let c of Object.keys(e))c in o||C(e[c],a,_(r,c),n,s)}for(let[a,c]of Object.entries(o))e[a]!==void 0&&C(e[a],c,_(r,a),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${x(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(a=>JSON.stringify(a));new Set(o).size!==o.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((o,a)=>C(o,t.items,`${r}[${a}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${x(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 ${x(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${x(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}function Je(e){return{...e,$schema:e.$schema===void 0?U:e.$schema,schemaVersion:e.schemaVersion===void 0?"1.1":e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?de.map(t=>({...t})):e.rules}}function Xe(){let e=new Set(["1.1"]);for(let t of B)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}function Ze(e,t="ark.config.json"){if(!pe(e))throw new k(t,[{path:"$",message:`must be an object; received ${x(e)}`}]);let r=Xe(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new k(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected 1.1`}]);if(n!=="unversioned"&&!r.has(n))throw new k(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected 1.1`}]);let s=n,o={...e},a=0;for(;s!=="1.1"&&a<B.length+1;){a+=1;let g=B.find(f=>f.from===s);if(!g)throw new k(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected 1.1`}]);s=g.to,o.schemaVersion=s}if(s!=="1.1")throw new k(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected 1.1`}]);let c=n==="unversioned"?"unversioned":n==="1.0"?"1.0":null;return{candidate:Je(o),migratedFrom:c}}function Qe(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Ze(e,t),s=[];if(C(r,ce,"$",ce,s),s.length>0)throw new k(t,s);return{config:r,migratedFrom:n}}function ue(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new k(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return Qe(r,t)}var et=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,tt=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,rt=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function nt(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return et.test(r)?"pure-shared":n==="PersistenceAdapters"&&(tt.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":rt.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}function fe(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=nt(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."}var st="docs/diagnostics.md";function y(e){return typeof e=="string"&&e.length>0?e:void 0}function ge(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}function it(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("|")}function ot(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")}`}function at(e){return`${st}#${e}`}function lt(e,t,r){if(e==="LAYER_IMPORT_VIOLATION")return fe({ruleId:e,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:r.targetTypeOnlyExports===!0,namedBindingsTypeOnly:r.namedBindingsTypeOnly===!0,peerIsolation:r.peerIsolation===!0,portProofEligible:r.portProofEligible===!0,fromLayer:y(t.fromLayer)??void 0,toLayer:y(t.toLayer)??void 0,target:y(t.target)??y(r.target)??void 0});if(e==="FORBIDDEN_GLOBAL")return`Inject ${t.target??"the capability"} through a port, test at the public interface, then preflight again.`;if(e==="CAPABILITY_VIOLATION")return`Define a ${y(r.capability)??"capability"} port in ${t.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;if(e==="CIRCULAR_DEPENDENCY")return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";if(e==="RAW_EVENT_PUBLISH")return"Publish through a registered intent creator, then run Ark again.";if(e==="PUBLISH_MISSING_SOURCE")return"Add metadata.source to the publish call, then run Ark again.";if(e==="ARKRULE_STRUCTURE"||e==="ARKRULE_INVARIANT"||e==="INVARIANT_UNCOVERED"||e.startsWith("ARKRULE_")){let n=t.arkruleSource??"arkrules/<Layer>.json";return`Fix the structure or invariant for ${t.arkruleId??"the ArkRule"} (declared in ${n}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`}return`Resolve ${e} without weakening ark.config.json, then run Ark again.`}function me(e,t="error",r){let n=y(e.ruleId)??y(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...y(e.target)?{target:y(e.target)}:{},...y(e.fromLayer)?{fromLayer:y(e.fromLayer)}:{},...y(e.toLayer)?{toLayer:y(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}:{},...y(e.capability)?{capability:y(e.capability)}:{},...y(e.edgeKind)?{edgeKind:y(e.edgeKind)}:{},...y(e.arkruleId)?{arkruleId:y(e.arkruleId)}:{},...y(e.arkruleSource)?{arkruleSource:y(e.arkruleSource)}:{}},a=r??it(e),c=ot(a);return{ruleId:n,severity:s,message:y(e.message)??n,location:{file:y(e.file)??"<unknown>",line:ge(e.line,1),column:ge(e.column,1)},evidence:o,nextAction:y(e.nextAction)??lt(n,o,e),findingRef:c,targetKey:a,docsCodePath:at(n)}}var ye={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."},Lt=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 ct(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}function G(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&ct(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:ye.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:ye.PUBLISH_MISSING_SOURCE}),t}function w(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""}function E(e,t,r,n,s){let o=me({...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}function j(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=p.default.dirname(p.default.resolve(e));for(;;){let r=p.default.join(t,"ark.config.json");if(R.default.existsSync(r))return r;let n=p.default.dirname(t);if(n===t)return null;t=n}}var he=new Map;function D(e){if(!R.default.existsSync(e))return null;let t=R.default.readFileSync(e,"utf8"),r=he.get(e);if(r?.source===t)return r.config;let n=ue(t,e).config;return he.set(e,{source:t,config:n}),n}function W(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!se(t,e)}function be(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,p.default.join(e,"index.ts"),p.default.join(e,"index.tsx"),p.default.join(e,"index.js")];for(let r of t)try{if(R.default.existsSync(r)&&R.default.statSync(r).isFile())return r}catch{}return null}function Ae(e){let t=p.default.resolve(e),r=null;for(;;){let f=p.default.join(t,"tsconfig.json");if(R.default.existsSync(f)){r=f;break}let d=p.default.dirname(t);if(d===t)break;t=d}if(!r)return{baseUrl:e,aliases:[]};let n=f=>{try{let d=R.default.readFileSync(f,"utf8");return d=d.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(d)}catch{return null}},s=(f,d)=>{if(d>4)return{};let i=n(f);if(!i)return{};let l=i.compilerOptions??{},u=l.baseUrl,m=l.paths,h=i.extends;if(typeof h=="string"&&!h.startsWith("@")){let b=p.default.resolve(p.default.dirname(f),h.endsWith(".json")?h:`${h}.json`);if(R.default.existsSync(b)){let A=s(b,d+1);u=u??A.baseUrl,m={...A.paths??{},...m??{}}}}return{baseUrl:u,paths:m}},o=s(r,0),a=p.default.dirname(r),c=p.default.resolve(a,o.baseUrl||"."),g=[];for(let[f,d]of Object.entries(o.paths||{})){if(!Array.isArray(d)||d.length===0)continue;let i=f.replace(/\*$/,"");i&&g.push({from:i,to:String(d[0]).replace(/\*$/,"")})}return g.sort((f,d)=>d.from.length-f.from.length),{baseUrl:c,aliases:g}}function Ie(e,t){if(!t.startsWith("."))return null;let r=p.default.resolve(p.default.dirname(e),t);return be(r)}function ke(e,t,r){if(!t)return null;if(t.startsWith("."))return Ie(e,t);let n=r||p.default.dirname(e),{baseUrl:s,aliases:o}=Ae(n),a=o.find(g=>t.startsWith(g.from));if(!a)return null;let c=p.default.resolve(s,`${a.to}${t.slice(a.from.length)}`);return be(c)}function v(e){return typeof e?.value=="string"?e.value:void 0}function Y(e){return e?.name??v(e)}function z(e){return e.sourceCode??e.getSourceCode?.()}function Re(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}}function T(e,t,r){let n=Re(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}function dt(e,t){let r=Re(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}function Se(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=Se(e.object),n=Y(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}function pt(e){return Y(e.callee?.property)}function xe(e,t){return e?.properties?.find(r=>Y(r.key)===t)}function P(e,t){return xe(e,t)!==void 0}function ut(e){let t=xe(e,"metadata")?.value;return P(t,"source")}function Ee(e){return pt(e)==="publish"}function q(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")}function ft(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}function gt(e){let t=ft(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!q(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(!q(n))return!1;r=!0;continue}return!1}}return r}var Le={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=w(e),r=j(t),n=r?D(r):null,s=r?p.default.dirname(r):null,o=a=>{let c=v(a.source);if(c&&n&&s&&t){let g=p.default.isAbsolute(t)?t:p.default.resolve(t),f=p.default.relative(s,g).split(p.default.sep).join("/");if(!W(n,f))return;let d=S(f,n.layers);if(!d)return;let i=ke(g,c,s);if(!i)return;let l=p.default.relative(s,i).split(p.default.sep).join("/");if(l.startsWith(".."))return;let u=S(l,n.layers);if(!u)return;let m={fromPath:f,toPath:l,layers:n.layers},h=K(n.rules,d,u,m);if(h||M(n.rules,d,u,m)){let b=a.type?.startsWith("Export")?"export":"import",A=q(a),J=!!h?.peerIsolation,X=A&&!J,Z=h?.message??`${d} must not ${b} ${u}.`;E(e,a,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:f,fromLayer:d,toLayer:u,target:l,edgeKind:b,...J?{peerIsolation:!0}:{},...A?{typeOnly:!0}:{},...X?{severity:"warning"}:{},...gt(a)?{sourcePureTypeModule:!0}:{},message:X?`${Z} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:Z},{fromLayer:d,toLayer:u,specifier:c})}return}};return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},Ce={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=v(r),s=G({publishCall:Ee(t),rawIntentName:n,objectHasIntent:P(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(a=>a.ruleId==="RAW_EVENT_PUBLISH");E(e,t,"rawPublish",{...o,file:w(e)})}}}}},we={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=G({publishCall:Ee(t),rawIntentName:v(r),objectHasIntent:P(r,"intent"),arkPublishCandidate:!0,hasSource:ut(r)||P(n,"source")}).find(a=>a.ruleId==="PUBLISH_MISSING_SOURCE");o&&E(e,t,"missingSource",{...o,file:w(e)})}}}},Ne={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=w(e),r=e.options?.[0],n=j(t),s=n?D(n):null,o=n?p.default.dirname(n):null,a=null,c="this layer";if(s&&o&&t){let i=p.default.isAbsolute(t)?t:p.default.resolve(t),l=p.default.relative(o,i).split(p.default.sep).join("/");if(!W(s,l))return{};let u=s.layers?.find(m=>m.name===S(l,s.layers));u?.forbiddenGlobals?.length?(a=new Set(u.forbiddenGlobals),c=u.name):a=null}else r?.globals&&(a=new Set(r.globals));if(!a)return{};let g=typeof z(e)?.getScope=="function",f=(i,l)=>{let u=p.default.isAbsolute(t)?t:p.default.resolve(t),m=o?p.default.relative(o,u).split(p.default.sep).join("/"):t;E(e,i,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:m,fromLayer:c,target:l,message:`${c} must not use the ambient global "${l}".`},{name:l,layer:c})},d=(i,l,u,m)=>{if(u||typeof l!="string")return;let h=F(l,a);if(!h)return;let b=p.default.isAbsolute(t)?t:p.default.resolve(t),A=o?p.default.relative(o,b).split(p.default.sep).join("/"):t;E(e,i,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:A,fromLayer:c,target:l,edgeKind:m,message:`${c} must not use module "${l}" because it is the import form of forbidden global "${h}".`},{layer:c,name:h,specifier:l,importKind:m})};return{MemberExpression(i){if(i.parent?.type==="MemberExpression"&&i.parent.object===i)return;let l=Se(i);if(!l||T(e,l.root,l.segments[0]))return;let u=l.segments[0]==="globalThis",m=u?l.segments.slice(1):l.segments,h;for(let b=m.length;b>=(u?1:2);b-=1){let A=m.slice(0,b).join(".");if(a.has(A)){h=A;break}}h?f(i,h):!g&&a.has(l.segments[0])&&f(i,l.segments[0])},CallExpression(i){let l=i;if(l.callee?.type==="Identifier"&&l.callee.name==="require"&&l.arguments?.[0]?.type==="Literal"&&!T(e,i,"require")&&d(i,l.arguments[0].value,!1,"require"),g)return;let u=l.callee?.type==="Identifier"?l.callee.name:void 0;u&&a.has(u)&&f(i,u)},ImportDeclaration(i){let l=i,u=(l.specifiers??[]).filter(h=>h.type==="ImportSpecifier"),m=u.length>0&&u.length===(l.specifiers??[]).length&&u.every(h=>h.importKind==="type");d(i,l.source?.value,l.importKind==="type"||m,"import")},ImportExpression(i){let l=i;l.source?.type==="Literal"&&d(i,l.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let l=i;d(i,l.moduleReference?.expression?.value,l.importKind==="type"||l.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let l=i;if(!l.source)return;let u=l.specifiers??[],m=u.length>0&&u.every(h=>h.exportKind==="type");d(i,l.source.value,l.exportKind==="type"||m,"export")},ExportAllDeclaration(i){let l=i;d(i,l.source?.value,l.exportKind==="type","export")},NewExpression(i){if(g)return;let l=i.callee?.type==="Identifier"?i.callee.name:void 0;l&&a.has(l)&&f(i,l)},Identifier(i){!g||!i.name||!a.has(i.name)||!dt(e,i)||T(e,i,i.name)||f(i,i.name)}}}},Oe={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=w(e),r=j(t),n=r?D(r):null,s=r?p.default.dirname(r):null;if(!n||!s||!t)return{};let o=p.default.isAbsolute(t)?t:p.default.resolve(t),a=p.default.relative(s,o).split(p.default.sep).join("/");if(!W(n,a))return{};let c=n.layers?.find(d=>d.name===S(a,n.layers));if(!c)return{};let g=new Set(ae(c));if(g.size===0)return{};let f=(d,i,l,u)=>{if(l||typeof i!="string"||F(i,c.forbiddenGlobals??[]))return;let m=oe(i);!m||!g.has(m)||E(e,d,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:a,fromLayer:c.name,target:i,capability:m,edgeKind:u,message:`${c.name} denies the ${m} capability; found import of "${i}".`},{layer:c.name,capability:m,specifier:i})};return{ImportDeclaration(d){let i=d,l=(i.specifiers??[]).filter(m=>m.type==="ImportSpecifier"),u=l.length>0&&l.length===(i.specifiers??[]).length&&l.every(m=>m.importKind==="type");f(d,i.source?.value,i.importKind==="type"||u,"import")},ImportExpression(d){let i=d;i.source?.type==="Literal"&&f(d,i.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let i=d;f(d,i.moduleReference?.expression?.value,i.importKind==="type"||i.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let i=d;if(!i.source)return;let l=i.specifiers??[],u=l.length>0&&l.every(m=>m.exportKind==="type");f(d,i.source.value,i.exportKind==="type"||u,"export")},ExportAllDeclaration(d){let i=d;f(d,i.source?.value,i.exportKind==="type","export")},CallExpression(d){let i=d;i.callee?.type==="Identifier"&&i.callee.name==="require"&&i.arguments?.[0]?.type==="Literal"&&!T(e,d,"require")&&f(d,i.arguments[0].value,!1,"require")}}}},mt={"no-domain-infra-imports":Le,"no-raw-event-publish":Ce,"require-publish-source":we,"no-forbidden-globals":Ne,"no-denied-capabilities":Oe},$={rules:mt};$.configs={recommended:{plugins:{ark:$},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"}}};var yt=$;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
3
+ `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function D(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function B(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function w(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Tt(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}function O(e,t,r,n,s){if(t.$ref){let i=Tt(t.$ref,n);if(!i){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}O(e,i,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(i=>Object.is(i,e))){s.push({path:r,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!D(e)){s.push({path:r,message:`must be an object; received ${w(e)}`});return}let i=t.properties??{};for(let o of t.required??[])e[o]===void 0&&s.push({path:B(r,o),message:"is required"});if(t.additionalProperties===!1)for(let o of Object.keys(e))o in i||s.push({path:B(r,o),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let o=t.additionalProperties;for(let a of Object.keys(e))a in i||O(e[a],o,B(r,a),n,s)}for(let[o,a]of Object.entries(i))e[o]!==void 0&&O(e[o],a,B(r,o),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${w(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 i=e.map(o=>JSON.stringify(o));new Set(i).size!==i.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((i,o)=>O(i,t.items,`${r}[${o}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${w(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 ${w(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${w(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}function Ft(e){return D(e)?{...e,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}:e}function Ot(e){let t={...e,$schema:e.$schema===void 0?se:e.$schema,schemaVersion:e.schemaVersion===void 0?"1.2":e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?_e.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Ft(e.arkRun)),t}function Dt(e,t){let r=e.arkRun;if(r===void 0||!D(r))return;let n=new Set;if(Array.isArray(e.layers))for(let i of e.layers)D(i)&&typeof i.name=="string"&&i.name.length>0&&n.add(i.name);let s=r.managedLayers;if(Array.isArray(s)&&s.forEach((i,o)=>{typeof i=="string"&&i.length>0&&!n.has(i)&&t.push({path:`$.arkRun.managedLayers[${o}]`,message:`layer ${JSON.stringify(i)} is not declared in layers[]`})}),r.mode==="enforced"){let i=r.compositionRoots;(!Array.isArray(i)||i.length===0)&&t.push({path:"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one composition root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}function Pt(e){return e==="1.2"?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"?e:null}function Kt(){let e=new Set(["1.2"]);for(let t of oe)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}function Mt(e,t="ark.config.json"){if(!D(e))throw new E(t,[{path:"$",message:`must be an object; received ${w(e)}`}]);let r=Kt(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new E(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected 1.2`}]);if(n!=="unversioned"&&!r.has(n))throw new E(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected 1.2`}]);let s=n,i={...e},o=0;for(;s!=="1.2"&&o<oe.length+1;){o+=1;let a=oe.find(l=>l.from===s);if(!a)throw new E(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected 1.2`}]);s=a.to,i.schemaVersion=s}if(s!=="1.2")throw new E(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected 1.2`}]);return{candidate:Ot(i),migratedFrom:Pt(n)}}function $t(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Mt(e,t),s=[];if(O(r,ve,"$",ve,s),Dt(r,s),s.length>0)throw new E(t,s);return{config:r,migratedFrom:n}}function we(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new E(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return $t(r,t)}var Ut=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Ht=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,jt=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Vt(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Ut.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Ht.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":jt.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}function Bt(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=Vt(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."}function Gt(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}function zt(e){let t=Gt(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 (never a removed arkgate/runtime shim) 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, never a removed arkgate/runtime shim, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from @arkgate/runtime, never a removed arkgate/runtime shim, 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.`}}function G(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Bt(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"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return zt(e);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.`}}var qt="docs/diagnostics.md";function y(e){return typeof e=="string"&&e.length>0?e:void 0}function Le(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}function Wt(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,i=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",i??""].join("|")}function Zt(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")}`}function Yt(e){return`${qt}#${e}`}function Jt(e,t,r){return G({ruleId:e,target:y(t.target)??y(r.target)??void 0,fromLayer:y(t.fromLayer)??void 0,toLayer:y(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:y(t.edgeKind)??void 0,capability:y(t.capability)??y(r.capability)??void 0,arkruleId:y(t.arkruleId)??void 0,arkruleSource:y(t.arkruleSource)??void 0})}function Te(e,t="error",r){let n=y(e.ruleId)??y(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,i={...y(e.target)?{target:y(e.target)}:{},...y(e.fromLayer)?{fromLayer:y(e.fromLayer)}:{},...y(e.toLayer)?{toLayer:y(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}:{},...y(e.capability)?{capability:y(e.capability)}:{},...y(e.edgeKind)?{edgeKind:y(e.edgeKind)}:{},...y(e.arkruleId)?{arkruleId:y(e.arkruleId)}:{},...y(e.arkruleSource)?{arkruleSource:y(e.arkruleSource)}:{}},o=r??Wt(e),a=Zt(o);return{ruleId:n,severity:s,message:y(e.message)??n,location:{file:y(e.file)??"<unknown>",line:Le(e.line,1),column:Le(e.column,1)},evidence:i,nextAction:y(e.nextAction)??Jt(n,i,e),findingRef:a,targetKey:o,docsCodePath:Yt(n)}}var Fe={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."},zr=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 Xt(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}function ie(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Xt(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:Fe.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:Fe.PUBLISH_MISSING_SOURCE}),t}var pe=j(require("fs"),1),N=j(require("path"),1);var Qt=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var er=new Set(Qt),tr=new Set(["AggregateError","Array","ArrayBuffer","BigInt64Array","BigUint64Array","Boolean","DataView","Date","Error","EvalError","FinalizationRegistry","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Number","Object","Promise","Proxy","RangeError","ReferenceError","RegExp","Set","SharedArrayBuffer","String","Symbol","SyntaxError","TypeError","URIError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","WeakRef","WeakSet"]),rr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function L(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}var nr=["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"],ae=new Set(nr);function Pe(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(ae.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(ae.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:ae.has(e.slice(0,n))}function Oe(e){if(er.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}}function Ke(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}function le(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}function sr(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}function De(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)}function z(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]??"")}function Me(e,t){z(le(e),t)}function or(e){let t=new Map,r=new Set;return z(e,(n,s)=>{if(!L(s))return;let i=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);i?.[1]&&r.add(i[1]);let o=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());o?.[1]&&t.set(o[1],o[1]);let a=/\{([^}]*)\}/.exec(n);if(a?.[1])for(let l of a[1].split(",")){let d=l.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 c=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(d);c?.[1]&&t.set(c[1],c[1])}}),{named:t,namespaces:r}}function ir(e,t){let r=new Set(t);return z(e,(n,s)=>{let i=/\{([^}]*)\}/.exec(n);if(i?.[1])for(let o of i[1].split(",")){let a=o.trim();if(!a||a.startsWith("type "))continue;let l=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),d=l?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],u=l?.[1]??d;!d||!u||!/^[A-Z]/.test(u)||(L(s)||t.has(u)||t.has(d))&&(r.add(d),r.add(u))}}),r}function ar(e,t){let r;return z(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}function q(e,t){let r=le(t),n=or(r),s=[],i=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=i.exec(r))!==null;){let a=o[1],l=o.index;if(De(r,l,"function")||De(r,l,"class"))continue;let u=r.slice(0,l).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],c=n.named.get(a)??a,p=Oe(c)??Oe(a);if(!p)continue;let f=n.named.has(a)||u!==void 0&&n.namespaces.has(u);if(p!=="factory"&&(!f&&u===void 0||u&&rr.has(u)&&!f))continue;let m=sr(r,l+o[0].length);s.push({file:e,line:Ke(t,l),kind:p,callee:a,viaImport:f,...u?{receiver:u}:{},...m?{nameLiteral:m}:{}})}return s}function ce(e,t,r){let n=le(t),s=ir(n,r),i=[],o=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=o.exec(n))!==null;){let l=a[1];if(tr.has(l)||!s.has(l))continue;let d=ar(n,l);i.push({file:e,line:Ke(t,a.index),typeName:l,...d?{importedFrom:d}:{}})}return i}function ue(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 i=s[1],o=s.index+s[0].length,a=1,l=o;for(;l<t.length&&a>0;){let k=t[l];k==="{"?a+=1:k==="}"&&(a-=1),l+=1}let d=t.slice(o,l-1),u=d.split(`
4
+ `).map(k=>/^\s*\/\//.test(k)||/^\s*\/\*|\*\//.test(k)?k:k.replace(/(?:public\s+|protected\s+)?readonly\s+[a-zA-Z_][a-zA-Z0-9_]*\s*(?::[^=;]+)?(?:=\s*[^;]+)?[;,]?/g,"").replace(/(?:^|[\s;{])readonly\s+[a-zA-Z_][a-zA-Z0-9_]*\s*(?::[^=;]+)?(?:=\s*[^;]+)?[;,]?/g," ")).join(`
5
+ `),c=/(?:^|\n)\s*(?:public\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/m.test(u.replace(/(?:public\s+|private\s+|protected\s+|static\s+|async\s+|get\s+|set\s+)/g,""))&&/(?:^|\n)\s*(public\s+)?(?!constructor|static|get|set|private|protected|readonly)[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/m.test(u),p=/(?:^|\n)\s*public\s+(?!static|async|get|set|constructor|readonly)[a-zA-Z_]/.test(u)||/(?:^|[\n;])\s*[a-zA-Z_][a-zA-Z0-9_]*\s*:\s*[^=;\n]+[;=]/m.test(u.split(`
6
+ `).filter(k=>!/^\s*(private|protected|static|constructor|get |set |async |\/)/.test(k)).join(`
7
+ `)),f=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(d),m=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(d),h=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(d)&&!m,R=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(d)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(d),A=[],$=new Set(["if","match","when"]),U=/(?:^|\n)\s*(?:public\s+|private\s+|protected\s+|async\s+)*(?!constructor|get|set|static)([a-zA-Z_][a-zA-Z0-9_]*)\s*\([^)]*\)\s*(?::\s*[^{]+)?\{/g,C;for(;(C=U.exec(d))!==null;){let k=C[1];if($.has(k))continue;let he=C.index+C[0].length,X=1,F=he;for(;F<d.length&&X>0;)d[F]==="{"?X+=1:d[F]==="}"&&(X-=1),F+=1;let Re=d.slice(he,F-1);if(!/this\.\w+\s*=/.test(Re))continue;let ft=/\b(ensureInvariants|assertInvariants|validate|publish|emit|raise|record)\b/.test(Re);A.push({name:k,referencesGuardOrPublish:ft})}let ut=(d.match(/(?:^|\n)\s*(?:public\s+|private\s+|protected\s+)?(?:async\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*\(/g)??[]).length,dt=(u.match(/(?:^|[\n;])\s*(?:public\s+)?(?!constructor|static|get|set|private|protected|readonly)[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/g)??[]).length,pt=ut<=1&&dt>=2&&(p||c);r.push({file:e,className:i,exported:!0,hasPublicMutableFields:p||c,hasPublicSetters:f,hasPublicConstructor:h,hasStaticFactory:R,mutatingMethods:[...A],dataOnly:pt})}return r}function lr(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}}function $e(e){let t=lr(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}var cr=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],ur=new Set(cr);function dr(e){return ur.has(e)}var Ue={"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"},pr="ARKRUN_INTERACTION_NAME_INCOMPLETE";function Ve(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.")})}function fr(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}function I(e,t,r,n,s,i,o){let a=e.mode==="enforced"&&o;return{ruleId:Ue[t],sensor:t,message:s,file:r,line:n,...i?.fromLayer?{fromLayer:i.fromLayer}:{},...i?.target?{target:i.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:G({ruleId:Ue[t],fromLayer:i?.fromLayer,target:i?.target})}}function gr(e,t){let r=[],n=[],s=[],i=[];for(let o of e)o.file===t&&(r.push(...o.uses),n.push(...o.reactsTo),s.push(...o.raises),i.push(...o.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(i)}}function He(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}function je(e){return e==="subscribe"||e==="register-handler"}function mr(e){return e==="resolve"||e==="resolve-singleton"}function yr(e,t,r){let n=[],s=e.compositionRoots;if(s.length===0)return n.push(I(e,"arkrun-missing-root","ark.config.json",1,"ArkRun compositionRoots is empty; no createArkKernel factory site is declared.",void 0,r)),n;let i=new Map;for(let o of t){let a=i.get(o.matchedRoot)??[];a.push(o),i.set(o.matchedRoot,a)}for(let o of s){let a=[...i.get(o)??[]].sort((d,u)=>d.file.localeCompare(u.file));if(a.length===0){n.push(I(e,"arkrun-missing-root","ark.config.json",1,`ArkRun composition root ${JSON.stringify(o)} matched no governed files and has no createArkKernel factory.`,{target:o},r));continue}if(a.some(d=>d.hasKernelFactory))continue;let l=a[0];n.push(I(e,"arkrun-missing-root",l.file,1,`ArkRun composition root ${JSON.stringify(o)} has no createArkKernel / createStrictArkKernel factory.`,{target:o},r))}return n}function hr(e,t,r,n,s){let i=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),o=[];for(let a of r){let l=a.specifier;if(!l||!L(l))continue;let d=n(a.from);d&&Ve(d,i.get(d)??[])&&o.push(I(e,"arkrun-kernel-in-domain",a.from,a.line,`${d} must not import kernel module ${JSON.stringify(l)}.`,{fromLayer:d,target:l},s))}return o}function Rr(e,t,r,n,s,i){let o=new Set(e.managedLayers);if(o.size===0)return[];let a=new Map(t.map(u=>[u.name,u.intentPrefixes??[]])),l=new Set(n.filter(u=>u.hasKernelFactory).map(u=>u.file)),d=[];for(let u of r){if(l.has(u.file))continue;let c=s(u.file);!c||!o.has(c)||Ve(c,a.get(c)??[])||d.push(I(e,"arkrun-direct-new",u.file,u.line,`${c} must not construct ${u.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:c,target:u.typeName},i))}return d}function Ar(e,t,r,n,s){let i=[],o=[];if(e.requireDeclarations!==!0)return{findings:i,completenessReasons:o};let a=new Set(e.managedLayers);if(a.size===0)return{findings:i,completenessReasons:o};for(let l of t){if(!He(l.kind)&&!je(l.kind)&&!mr(l.kind))continue;let d=n(l.file);if(!d||!a.has(d))continue;if(!l.nameLiteral){e.mode==="enforced"&&o.push({code:pr,file:l.file,message:`ArkRun ${l.kind} call in ${l.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let u=gr(r,l.file);if(He(l.kind)){if(u.raises.has(l.nameLiteral)||u.sends.has(l.nameLiteral))continue;i.push(I(e,"arkrun-undeclared-emit",l.file,l.line,`Emit ${JSON.stringify(l.nameLiteral)} is not declared in raises or sends.`,{fromLayer:d,target:l.nameLiteral},s));continue}if(je(l.kind)){if(u.reactsTo.has(l.nameLiteral))continue;i.push(I(e,"arkrun-undeclared-handle",l.file,l.line,`Handle ${JSON.stringify(l.nameLiteral)} is not declared in reactsTo.`,{fromLayer:d,target:l.nameLiteral},s));continue}u.uses.has(l.nameLiteral)||i.push(I(e,"arkrun-undeclared-depend",l.file,l.line,`Depend ${JSON.stringify(l.nameLiteral)} is not declared in uses.`,{fromLayer:d,target:l.nameLiteral},s))}return{findings:i,completenessReasons:o}}function kr(e,t,r,n){let s=new Set(e.managedLayers);if(s.size===0)return[];let i=[];for(let o of t){if(o.typeOnly)continue;let a=o.specifier;if(!a||!Pe(a))continue;let l=r(o.from);!l||!s.has(l)||i.push(I(e,"arkrun-transport-bypass",o.from,o.line,`${l} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:l,target:a},n))}return i}function br(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=$e(e.classification),n=Ar(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...yr(t,e.compositionRootHits,r),...hr(t,e.layers,e.dependencies,e.layerForFile,r),...Rr(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...kr(t,e.dependencies,e.layerForFile,r)].sort(fr),i=[...n.completenessReasons].sort((o,a)=>{let l=`${o.code}\0${o.file??""}\0${o.message}`,d=`${a.code}\0${a.file??""}\0${a.message}`;return l<d?-1:l>d?1:0});return{findings:s,completenessReasons:i}}function de(e){return{findings:br(e).findings.filter(r=>dr(r.sensor)),completenessReasons:[]}}function Sr(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")}function Ge(e){try{return pe.default.existsSync(e)?pe.default.readFileSync(e,"utf8"):null}catch{return null}}function Be(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 i=N.default.dirname(n),o=N.default.isAbsolute(r)?r:N.default.resolve(r),a=N.default.relative(i,o).split(N.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let l=S(a,s.layers);return l?{extra:s.arkRun,config:s,root:i,absFile:o,relFile:a,fromLayer:l}:null}function Er(e,t,r){let n=q(t,r).some(i=>i.kind==="factory"),s=[];for(let i of e.compositionRoots){try{if(!v(i).test(t))continue}catch{continue}s.push({file:t,matchedRoot:i,hasKernelFactory:n})}return s}function Ir(e,t,r){let n=new Set(ue(t.relFile,r).map(s=>s.className));return Me(r,(s,i)=>{if(L(i))return;let o=e.resolveImportSpecifier(t.absFile,i,t.root);if(!o)return;let a=N.default.relative(t.root,o).split(N.default.sep).join("/");if(a.startsWith(".."))return;let l=Ge(o);if(l!==null)for(let d of ue(a,l))n.add(d.className)}),n}function ze(e,t,r,n,s,i){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},i)}function xr(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}function Nr(e,t){return e.type?.startsWith("Export")?"export":t}function Cr(e,t,r,n,s){let i=(o,a,l,d)=>{if(typeof a!="string"||a.length===0)return;let u=o.loc?.start?.line??1,c={from:r.relFile,specifier:a,kind:d,typeOnly:l,line:u,resolution:"resolved-external"},{findings:p}=de({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[c],layerForFile:f=>f===r.relFile?r.fromLayer:S(f,r.config.layers)});for(let f of p)f.sensor===n&&ze(e,t,o,s,f,{fromLayer:f.fromLayer??r.fromLayer,specifier:a,target:f.target??a})};return{ImportDeclaration(o){let a=o,l=(a.specifiers??[]).filter(u=>u.type==="ImportSpecifier"),d=l.length>0&&l.length===(a.specifiers??[]).length&&l.every(u=>u.importKind==="type");i(o,a.source?.value,a.importKind==="type"||d||Sr(o),"import")},ImportExpression(o){let a=o;a.source?.type==="Literal"&&i(o,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(o){let a=o;i(o,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(o){let a=o;if(!a.source)return;let l=a.specifiers??[],d=l.length>0&&l.every(u=>u.exportKind==="type");i(o,a.source.value,a.exportKind==="type"||d,Nr(o,"export"))},ExportAllDeclaration(o){let a=o;i(o,a.source?.value,a.exportKind==="type","export")},CallExpression(o){let a=o;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,o,"require")&&i(o,a.arguments[0].value,!1,"require")}}}function vr(e,t,r){let n=Ge(r.absFile)??"",s=Ir(e,r,n),i=ce(r.relFile,n,s),{findings:o}=de({arkRun:r.extra,layers:r.config.layers,kernelCalls:q(r.relFile,n),managedNews:i,compositionRootHits:Er(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:l=>l===r.relFile?r.fromLayer:S(l,r.config.layers)}),a=o.filter(l=>l.sensor==="arkrun-direct-new");return{NewExpression(l){let d=xr(l);if(!d)return;let u=l.loc?.start?.line,c=a.find(p=>p.target===d&&(u===void 0||p.line===u))??a.find(p=>p.target===d);c&&ze(e,t,l,"directNew",c,{fromLayer:c.fromLayer??r.fromLayer,typeName:d,target:c.target??d})}}}function qe(e){let t=(r,n,s,i)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:i},schema:[]},create(o){let a=Be(e,o);return a?Cr(e,o,a,r,s):{}}});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=Be(e,r);return n?vr(e,r,n):{}}}}}function T(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""}function _(e,t,r,n,s){let i=Te({...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:i}),i}function K(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=g.default.dirname(g.default.resolve(e));for(;;){let r=g.default.join(t,"ark.config.json");if(x.default.existsSync(r))return r;let n=g.default.dirname(t);if(n===t)return null;t=n}}var We=new Map;function M(e){if(!x.default.existsSync(e))return null;let t=x.default.readFileSync(e,"utf8"),r=We.get(e);if(r?.source===t)return r.config;let n=we(t,e).config;return We.set(e,{source:t,config:n}),n}function Y(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!Ee(t,e)}function Ze(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,g.default.join(e,"index.ts"),g.default.join(e,"index.tsx"),g.default.join(e,"index.js")];for(let r of t)try{if(x.default.existsSync(r)&&x.default.statSync(r).isFile())return r}catch{}return null}function Ye(e){let t=g.default.resolve(e),r=null;for(;;){let d=g.default.join(t,"tsconfig.json");if(x.default.existsSync(d)){r=d;break}let u=g.default.dirname(t);if(u===t)break;t=u}if(!r)return{baseUrl:e,aliases:[]};let n=d=>{try{let u=x.default.readFileSync(d,"utf8");return u=u.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(u)}catch{return null}},s=(d,u)=>{if(u>4)return{};let c=n(d);if(!c)return{};let p=c.compilerOptions??{},f=p.baseUrl,m=p.paths,h=c.extends;if(typeof h=="string"&&!h.startsWith("@")){let R=g.default.resolve(g.default.dirname(d),h.endsWith(".json")?h:`${h}.json`);if(x.default.existsSync(R)){let A=s(R,u+1);f=f??A.baseUrl,m={...A.paths??{},...m??{}}}}return{baseUrl:f,paths:m}},i=s(r,0),o=g.default.dirname(r),a=g.default.resolve(o,i.baseUrl||"."),l=[];for(let[d,u]of Object.entries(i.paths||{})){if(!Array.isArray(u)||u.length===0)continue;let c=d.replace(/\*$/,"");c&&l.push({from:c,to:String(u[0]).replace(/\*$/,"")})}return l.sort((d,u)=>u.from.length-d.from.length),{baseUrl:a,aliases:l}}function Je(e,t){if(!t.startsWith("."))return null;let r=g.default.resolve(g.default.dirname(e),t);return Ze(r)}function ge(e,t,r){if(!t)return null;if(t.startsWith("."))return Je(e,t);let n=r||g.default.dirname(e),{baseUrl:s,aliases:i}=Ye(n),o=i.find(l=>t.startsWith(l.from));if(!o)return null;let a=g.default.resolve(s,`${o.to}${t.slice(o.from.length)}`);return Ze(a)}function J(e){return typeof e?.value=="string"?e.value:void 0}function me(e){return e?.name??J(e)}function ye(e){return e.sourceCode??e.getSourceCode?.()}function Xe(e,t){let r=ye(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}function P(e,t,r){let n=Xe(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=ye(e)?.getScope?.(t);for(;s;){let i=s.set?.get(r);if(i)return(i.defs?.length??0)>0;s=s.upper??void 0}return!1}function _r(e,t){let r=Xe(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}function Qe(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=Qe(e.object),n=me(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}function wr(e){return me(e.callee?.property)}function et(e,t){return e?.properties?.find(r=>me(r.key)===t)}function W(e,t){return et(e,t)!==void 0}function Lr(e){let t=et(e,"metadata")?.value;return W(t,"source")}function tt(e){return wr(e)==="publish"}function fe(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")}function Tr(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}function Fr(e){let t=Tr(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!fe(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(!fe(n))return!1;r=!0;continue}return!1}}return r}var rt={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=T(e),r=K(t),n=r?M(r):null,s=r?g.default.dirname(r):null,i=o=>{let a=J(o.source);if(a&&n&&s&&t){let l=g.default.isAbsolute(t)?t:g.default.resolve(t),d=g.default.relative(s,l).split(g.default.sep).join("/");if(!Y(n,d))return;let u=S(d,n.layers);if(!u)return;let c=ge(l,a,s);if(!c)return;let p=g.default.relative(s,c).split(g.default.sep).join("/");if(p.startsWith(".."))return;let f=S(p,n.layers);if(!f)return;let m={fromPath:d,toPath:p,layers:n.layers},h=ee(n.rules,u,f,m);if(h||te(n.rules,u,f,m)){let R=o.type?.startsWith("Export")?"export":"import",A=fe(o),$=!!h?.peerIsolation,U=A&&!$,C=h?.message??`${u} must not ${R} ${f}.`;_(e,o,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:d,fromLayer:u,toLayer:f,target:p,edgeKind:R,...$?{peerIsolation:!0}:{},...A?{typeOnly:!0}:{},...U?{severity:"warning"}:{},...Fr(o)?{sourcePureTypeModule:!0}:{},message:U?`${C} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:C},{fromLayer:u,toLayer:f,specifier:a})}return}};return{ImportDeclaration:i,ExportNamedDeclaration:i,ExportAllDeclaration:i}}},nt={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=J(r),s=ie({publishCall:tt(t),rawIntentName:n,objectHasIntent:W(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(i=>i.ruleId==="RAW_EVENT_PUBLISH")){let i=s.find(o=>o.ruleId==="RAW_EVENT_PUBLISH");_(e,t,"rawPublish",{...i,file:T(e)})}}}}},st={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],i=ie({publishCall:tt(t),rawIntentName:J(r),objectHasIntent:W(r,"intent"),arkPublishCandidate:!0,hasSource:Lr(r)||W(n,"source")}).find(o=>o.ruleId==="PUBLISH_MISSING_SOURCE");i&&_(e,t,"missingSource",{...i,file:T(e)})}}}},ot={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=T(e),r=e.options?.[0],n=K(t),s=n?M(n):null,i=n?g.default.dirname(n):null,o=null,a="this layer";if(s&&i&&t){let c=g.default.isAbsolute(t)?t:g.default.resolve(t),p=g.default.relative(i,c).split(g.default.sep).join("/");if(!Y(s,p))return{};let f=s.layers?.find(m=>m.name===S(p,s.layers));f?.forbiddenGlobals?.length?(o=new Set(f.forbiddenGlobals),a=f.name):o=null}else r?.globals&&(o=new Set(r.globals));if(!o)return{};let l=typeof ye(e)?.getScope=="function",d=(c,p)=>{let f=g.default.isAbsolute(t)?t:g.default.resolve(t),m=i?g.default.relative(i,f).split(g.default.sep).join("/"):t;_(e,c,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:m,fromLayer:a,target:p,message:`${a} must not use the ambient global "${p}".`},{name:p,layer:a})},u=(c,p,f,m)=>{if(f||typeof p!="string")return;let h=ne(p,o);if(!h)return;let R=g.default.isAbsolute(t)?t:g.default.resolve(t),A=i?g.default.relative(i,R).split(g.default.sep).join("/"):t;_(e,c,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:A,fromLayer:a,target:p,edgeKind:m,message:`${a} must not use module "${p}" because it is the import form of forbidden global "${h}".`},{layer:a,name:h,specifier:p,importKind:m})};return{MemberExpression(c){if(c.parent?.type==="MemberExpression"&&c.parent.object===c)return;let p=Qe(c);if(!p||P(e,p.root,p.segments[0]))return;let f=p.segments[0]==="globalThis",m=f?p.segments.slice(1):p.segments,h;for(let R=m.length;R>=(f?1:2);R-=1){let A=m.slice(0,R).join(".");if(o.has(A)){h=A;break}}h?d(c,h):!l&&o.has(p.segments[0])&&d(c,p.segments[0])},CallExpression(c){let p=c;if(p.callee?.type==="Identifier"&&p.callee.name==="require"&&p.arguments?.[0]?.type==="Literal"&&!P(e,c,"require")&&u(c,p.arguments[0].value,!1,"require"),l)return;let f=p.callee?.type==="Identifier"?p.callee.name:void 0;f&&o.has(f)&&d(c,f)},ImportDeclaration(c){let p=c,f=(p.specifiers??[]).filter(h=>h.type==="ImportSpecifier"),m=f.length>0&&f.length===(p.specifiers??[]).length&&f.every(h=>h.importKind==="type");u(c,p.source?.value,p.importKind==="type"||m,"import")},ImportExpression(c){let p=c;p.source?.type==="Literal"&&u(c,p.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(c){let p=c;u(c,p.moduleReference?.expression?.value,p.importKind==="type"||p.isTypeOnly===!0,"require")},ExportNamedDeclaration(c){let p=c;if(!p.source)return;let f=p.specifiers??[],m=f.length>0&&f.every(h=>h.exportKind==="type");u(c,p.source.value,p.exportKind==="type"||m,"export")},ExportAllDeclaration(c){let p=c;u(c,p.source?.value,p.exportKind==="type","export")},NewExpression(c){if(l)return;let p=c.callee?.type==="Identifier"?c.callee.name:void 0;p&&o.has(p)&&d(c,p)},Identifier(c){!l||!c.name||!o.has(c.name)||!_r(e,c)||P(e,c,c.name)||d(c,c.name)}}}},it={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=T(e),r=K(t),n=r?M(r):null,s=r?g.default.dirname(r):null;if(!n||!s||!t)return{};let i=g.default.isAbsolute(t)?t:g.default.resolve(t),o=g.default.relative(s,i).split(g.default.sep).join("/");if(!Y(n,o))return{};let a=n.layers?.find(u=>u.name===S(o,n.layers));if(!a)return{};let l=new Set(Ne(a));if(l.size===0)return{};let d=(u,c,p,f)=>{if(p||typeof c!="string"||ne(c,a.forbiddenGlobals??[]))return;let m=xe(c);!m||!l.has(m)||_(e,u,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:o,fromLayer:a.name,target:c,capability:m,edgeKind:f,message:`${a.name} denies the ${m} capability; found import of "${c}".`},{layer:a.name,capability:m,specifier:c})};return{ImportDeclaration(u){let c=u,p=(c.specifiers??[]).filter(m=>m.type==="ImportSpecifier"),f=p.length>0&&p.length===(c.specifiers??[]).length&&p.every(m=>m.importKind==="type");d(u,c.source?.value,c.importKind==="type"||f,"import")},ImportExpression(u){let c=u;c.source?.type==="Literal"&&d(u,c.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(u){let c=u;d(u,c.moduleReference?.expression?.value,c.importKind==="type"||c.isTypeOnly===!0,"require")},ExportNamedDeclaration(u){let c=u;if(!c.source)return;let p=c.specifiers??[],f=p.length>0&&p.every(m=>m.exportKind==="type");d(u,c.source.value,c.exportKind==="type"||f,"export")},ExportAllDeclaration(u){let c=u;d(u,c.source?.value,c.exportKind==="type","export")},CallExpression(u){let c=u;c.callee?.type==="Identifier"&&c.callee.name==="require"&&c.arguments?.[0]?.type==="Literal"&&!P(e,u,"require")&&d(u,c.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:at,noArkRunDirectNew:lt,noArkRunTransportBypass:ct}=qe({findConfigPath:K,loadArkConfig:M,resolveImportSpecifier:ge,lintedFilename:T,sourceIsInAnalysisScope:Y,isLocallyBound:P,reportAdapterDiagnostic:_});var Or={"no-domain-infra-imports":rt,"no-raw-event-publish":nt,"require-publish-source":st,"no-forbidden-globals":ot,"no-denied-capabilities":it,"no-arkrun-kernel-in-domain":at,"no-arkrun-direct-new":lt,"no-arkrun-transport-bypass":ct},Z={rules:Or};Z.configs={recommended:{plugins:{ark:Z},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"}}};var Dr=Z;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
@@ -1,4 +1,32 @@
1
- import { A as ArkConfig } from '../configTypes-l6XiwiC1.js';
1
+ import { A as ArkConfig } from '../configTypes-CgJimx9o.js';
2
+
3
+ type RuleContext$1 = {
4
+ report(descriptor: Record<string, unknown>): void;
5
+ filename?: string;
6
+ physicalFilename?: string;
7
+ getFilename?: () => string;
8
+ options?: unknown[];
9
+ };
10
+ type AstNode$1 = {
11
+ type?: string;
12
+ name?: string;
13
+ value?: unknown;
14
+ source?: AstNode$1;
15
+ callee?: AstNode$1;
16
+ object?: AstNode$1;
17
+ property?: AstNode$1;
18
+ arguments?: AstNode$1[];
19
+ importKind?: string;
20
+ exportKind?: string;
21
+ specifiers?: AstNode$1[];
22
+ loc?: {
23
+ start?: {
24
+ line?: number;
25
+ column?: number;
26
+ };
27
+ };
28
+ computed?: boolean;
29
+ };
2
30
 
3
31
  /**
4
32
  * Pure layer-glob matching for ark.config.json.
@@ -167,6 +195,46 @@ declare const noRawEventPublish: ArkRule;
167
195
  declare const requirePublishSource: ArkRule;
168
196
  declare const noForbiddenGlobals: ArkRule;
169
197
  declare const noDeniedCapabilities: ArkRule;
198
+ declare const noArkRunKernelInDomain: {
199
+ meta: {
200
+ type: "problem";
201
+ docs: {
202
+ description: string;
203
+ };
204
+ messages: Record<string, string>;
205
+ schema: unknown[];
206
+ };
207
+ create(context: RuleContext$1): {
208
+ [x: string]: (node: AstNode$1) => void;
209
+ };
210
+ };
211
+ declare const noArkRunDirectNew: {
212
+ meta: {
213
+ type: "problem";
214
+ docs: {
215
+ description: string;
216
+ };
217
+ messages: Record<string, string>;
218
+ schema: unknown[];
219
+ };
220
+ create(context: RuleContext$1): {
221
+ [x: string]: (node: AstNode$1) => void;
222
+ };
223
+ };
224
+ declare const noArkRunTransportBypass: {
225
+ meta: {
226
+ type: "problem";
227
+ docs: {
228
+ description: string;
229
+ };
230
+ messages: Record<string, string>;
231
+ schema: unknown[];
232
+ };
233
+ create(context: RuleContext$1): {
234
+ [x: string]: (node: AstNode$1) => void;
235
+ };
236
+ };
237
+
170
238
  declare const plugin: ArkEslintPlugin;
171
239
 
172
- export { plugin as default, findConfigPath, globToRegExp, isEdgeDenied, layerForRelativePath, loadArkConfig, noDeniedCapabilities, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, patternSpecificity, plugin, readTsconfigPathAliases, requirePublishSource, resolveImportSpecifier, resolveRelativeImport };
240
+ export { plugin as default, findConfigPath, globToRegExp, isEdgeDenied, layerForRelativePath, loadArkConfig, noArkRunDirectNew, noArkRunKernelInDomain, noArkRunTransportBypass, noDeniedCapabilities, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, patternSpecificity, plugin, readTsconfigPathAliases, requirePublishSource, resolveImportSpecifier, resolveRelativeImport };