arkgate 4.8.3 → 4.8.4

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 (54) hide show
  1. package/CHANGELOG.md +242 -0
  2. package/README.md +10 -3
  3. package/bin/ark-check-runtime.mjs +340 -5
  4. package/bin/ark-layer-match.mjs +170 -13
  5. package/bin/ark-mcp-runtime.mjs +9 -2
  6. package/bin/lib/analysis-completeness.mjs +86 -0
  7. package/bin/lib/analysis-engine.mjs +5 -5
  8. package/bin/lib/architecture-scan.mjs +2 -0
  9. package/bin/lib/arkrules-contract.mjs +8 -1
  10. package/bin/lib/check-args.mjs +66 -0
  11. package/bin/lib/config-contract.mjs +26 -0
  12. package/bin/lib/design-smells.mjs +85 -0
  13. package/bin/lib/diagnostic-catalog.mjs +6 -1
  14. package/bin/lib/first-run-help.mjs +12 -0
  15. package/bin/lib/invariant-coverage-io.mjs +175 -19
  16. package/bin/lib/invariant-coverage.mjs +110 -7
  17. package/bin/lib/literal-path-drift-io.mjs +569 -0
  18. package/bin/lib/literal-path-drift.mjs +761 -0
  19. package/bin/lib/policy-delta-io.mjs +5 -0
  20. package/bin/lib/remediation.mjs +15 -0
  21. package/bin/lib/rules-under-contract.mjs +5 -0
  22. package/bin/lib/scan-files.mjs +54 -0
  23. package/bin/lib/sensor-promote-cli.mjs +372 -0
  24. package/bin/lib/sensor-promote-io.mjs +246 -0
  25. package/bin/lib/sensor-promotion.mjs +363 -0
  26. package/dist/{configTypes-dNJ2C0yx.d.ts → configTypes-dy5PfTqS.d.ts} +31 -0
  27. package/dist/{diagnosticCatalog-C5GgeyEE.d.ts → diagnosticCatalog-DgTs0abp.d.ts} +75 -7
  28. package/dist/eslint/index.cjs +6 -6
  29. package/dist/eslint/index.d.ts +34 -1
  30. package/dist/eslint/index.js +6 -6
  31. package/dist/index.cjs +32 -32
  32. package/dist/index.d.ts +65 -4
  33. package/dist/index.js +29 -29
  34. package/dist/nestjs/index.cjs +5 -5
  35. package/dist/nestjs/index.d.ts +3 -3
  36. package/dist/nestjs/index.js +5 -5
  37. package/dist/runtime/index.cjs +15 -15
  38. package/dist/runtime/index.d.ts +6 -6
  39. package/dist/runtime/index.js +15 -15
  40. package/dist/{types-dK24fDZa.d.ts → types-BuM8WNqe.d.ts} +1 -1
  41. package/dist/{types-DeK7SYGC.d.ts → types-D95drJ3_.d.ts} +1 -1
  42. package/docs/README.md +1 -1
  43. package/docs/agent-guide.md +182 -0
  44. package/docs/configuration.md +77 -1
  45. package/docs/develop.md +1 -0
  46. package/docs/diagnostics.md +70 -1
  47. package/docs/package-surface.md +32 -2
  48. package/package.json +2 -2
  49. package/schemas/ark.config.schema.json +63 -0
  50. package/server.json +3 -3
  51. package/templates/agent-skills/ark-adopt/SKILL.md +5 -0
  52. package/templates/agent-skills/ark-coverage/SKILL.md +1 -0
  53. package/templates/skills/ark-adopt.md +5 -0
  54. package/templates/skills/ark-coverage.md +1 -0
@@ -1,5 +1,5 @@
1
- import { e as CreateArchitectureProfileOptions, b as ArchitectureProfile, d as ArkCheckConfig, C as CreateArchitectureProfileFromArkConfigOptions, f as CreateElevenLayerArkConfigOptions, i as Policy, j as IntentCreator, I as IntentName } from './types-dK24fDZa.js';
2
- import { A as ArkConfig, c as ArkConfigLoadResult } from './configTypes-dNJ2C0yx.js';
1
+ import { e as CreateArchitectureProfileOptions, b as ArchitectureProfile, d as ArkCheckConfig, C as CreateArchitectureProfileFromArkConfigOptions, f as CreateElevenLayerArkConfigOptions, i as Policy, j as IntentCreator, I as IntentName } from './types-BuM8WNqe.js';
2
+ import { A as ArkConfig, c as ArkConfigLoadResult } from './configTypes-dy5PfTqS.js';
3
3
 
4
4
  /** Versioned public result contract shared by every ArkGate enforcement adapter. */
5
5
  /**
@@ -409,7 +409,7 @@ declare const ARK_ANALYSIS_RESULT_SCHEMA: {
409
409
  };
410
410
 
411
411
  /** ArkGate library version — single source of truth. */
412
- declare const version = "4.8.3";
412
+ declare const version = "4.8.4";
413
413
 
414
414
  /**
415
415
  * AI Code Gate (basic).
@@ -1753,10 +1753,21 @@ type InvariantCoverageEvidence = {
1753
1753
  /** When no test globs were supplied, coverage cannot be proven. */
1754
1754
  partial: boolean;
1755
1755
  description: string;
1756
+ /** Test file that supplied the `test-title` evidence, when there was one. */
1757
+ testEvidenceFile?: string;
1758
+ /**
1759
+ * The only covering test found sits outside `coverage.coverageRoots` — the
1760
+ * places the project declares its runner executes. ArkGate never runs tests,
1761
+ * so a title match outside those roots is a test that exists, not a test that
1762
+ * runs. Absent (undefined) when no roots were declared: without a declaration
1763
+ * there is nothing to compare against, and silence is honest.
1764
+ */
1765
+ outsideDeclaredRoots?: boolean;
1756
1766
  };
1757
1767
  type InvariantUncoveredKind = 'never-had-tests' | 'tests-disappeared';
1768
+ type InvariantCoverageRuleId = 'INVARIANT_UNCOVERED' | 'INVARIANT_COVERAGE_OUTSIDE_ROOTS';
1758
1769
  type InvariantCoverageViolation = {
1759
- ruleId: 'INVARIANT_UNCOVERED';
1770
+ ruleId: InvariantCoverageRuleId;
1760
1771
  message: string;
1761
1772
  file: string;
1762
1773
  line: number;
@@ -1765,8 +1776,12 @@ type InvariantCoverageViolation = {
1765
1776
  fromLayer: string;
1766
1777
  severity: 'error' | 'warning';
1767
1778
  failsStrict: boolean;
1768
- /** Adopt residual (no test suite) vs regression (suite exists, coverage gone). */
1769
- kind: InvariantUncoveredKind;
1779
+ /**
1780
+ * Adopt residual (no test suite) vs regression (suite exists, coverage gone).
1781
+ * Only INVARIANT_UNCOVERED carries it: an outside-roots finding is about
1782
+ * WHERE the covering test lives, not about whether one exists.
1783
+ */
1784
+ kind?: InvariantUncoveredKind;
1770
1785
  };
1771
1786
  type EvaluateInvariantCoverageInput = {
1772
1787
  arkRules: EffectiveArkRules;
@@ -1781,6 +1796,55 @@ type EvaluateInvariantCoverageInput = {
1781
1796
  * the suite may exist outside the scan budget.
1782
1797
  */
1783
1798
  coverageBudgetExhausted?: boolean;
1799
+ /** Numbers behind the scan: what was loaded, what was discarded and why. */
1800
+ coverageStats?: InvariantCoverageStats;
1801
+ /**
1802
+ * Declared (`coverage.coverageRoots`) path prefixes where the project says its
1803
+ * runner actually executes tests. ArkGate never executes anything: this is a
1804
+ * second DECLARATION to compare the first against. Absent or empty means no
1805
+ * declaration was made, so no outside-roots claim is possible.
1806
+ */
1807
+ coverageRoots?: readonly string[];
1808
+ };
1809
+ /**
1810
+ * What the Tooling scan actually saw. Every discard has a counted reason —
1811
+ * a silent drop would make an uncovered verdict unexplainable.
1812
+ */
1813
+ type InvariantCoverageStats = {
1814
+ /**
1815
+ * Files actually opened and read. Always >= filesLoaded: a test is read
1816
+ * before it can be judged for naming an invariant, so the file budget bounds
1817
+ * RETENTION, not I/O. Reporting only the retained count made
1818
+ * `coverage.maxFiles` read as a knob on how much the scan opens.
1819
+ */
1820
+ filesRead?: number;
1821
+ /** Files retained as coverage evidence (tests + production). */
1822
+ filesLoaded: number;
1823
+ /** Test files retained (subset of filesLoaded). */
1824
+ testFilesRetained: number;
1825
+ /** The file budget in force for this scan (config `coverage.maxFiles` or the default). */
1826
+ maxFiles: number;
1827
+ discarded: {
1828
+ /** Reached the file budget. */
1829
+ budget: number;
1830
+ /** Test file naming no catalogued invariant (scanned, then dropped). */
1831
+ noInvariantMention: number;
1832
+ /** Larger than the per-file byte cap. */
1833
+ oversize: number;
1834
+ /**
1835
+ * stat/read failed on a file or a directory: permissions, a broken symlink,
1836
+ * or something that moved mid-scan. Files and directories share one counter.
1837
+ */
1838
+ unreadable: number;
1839
+ /** Directory deeper than the walk depth limit — its files were never seen. */
1840
+ depthLimited: number;
1841
+ /**
1842
+ * Symlink inside the tree whose target resolves outside the project root.
1843
+ * Refused as evidence: a file that is not in this repo must not prove an
1844
+ * invariant covered.
1845
+ */
1846
+ outOfRoot: number;
1847
+ };
1784
1848
  };
1785
1849
  declare function evaluateInvariantCoverage(input: EvaluateInvariantCoverageInput): {
1786
1850
  coverage: InvariantCoverageEvidence[];
@@ -1972,6 +2036,10 @@ type AnalyzeResolvedProjectInput = {
1972
2036
  testFiles?: readonly string[];
1973
2037
  testGlobsMissing?: boolean;
1974
2038
  coverageBudgetExhausted?: boolean;
2039
+ /** Declared `coverage.coverageRoots`: where the project says its runner runs. */
2040
+ coverageRoots?: readonly string[];
2041
+ /** Counted scan facts: files loaded, tests retained, discards by reason. */
2042
+ stats?: InvariantCoverageStats;
1975
2043
  };
1976
2044
  /**
1977
2045
  * AR07 — Tooling-supplied orchestration/thin-adapter heuristics per file.
@@ -2336,7 +2404,7 @@ type ArkDesignDeltaResult = {
2336
2404
  declare const DIAGNOSTIC_DOCS_RELATIVE_PATH: "docs/diagnostics.md";
2337
2405
  /** Schema id for serializing the catalog snapshot (agents / install projection). */
2338
2406
  declare const DIAGNOSTIC_CATALOG_SCHEMA_VERSION: "1.0";
2339
- type DiagnosticCategory = 'layer' | 'capability' | 'publish' | 'safety' | 'arkrules' | 'arkrun' | 'arkorder' | 'preflight' | 'analysis' | 'snippet-policy' | 'config' | 'adapter' | 'meta';
2407
+ type DiagnosticCategory = 'layer' | 'capability' | 'publish' | 'safety' | 'arkrules' | 'arkrun' | 'arkorder' | 'preflight' | 'analysis' | 'drift' | 'snippet-policy' | 'config' | 'adapter' | 'meta';
2340
2408
  type DiagnosticCatalogEntry = {
2341
2409
  /** Stable public violation / diagnostic id. */
2342
2410
  ruleId: string;
@@ -1,8 +1,8 @@
1
- "use strict";var Ur=Object.create;var H=Object.defineProperty;var Hr=Object.getOwnPropertyDescriptor;var jr=Object.getOwnPropertyNames;var Vr=Object.getPrototypeOf,Br=Object.prototype.hasOwnProperty;var c=(e,r)=>H(e,"name",{value:r,configurable:!0});var Gr=(e,r)=>{for(var t in r)H(e,t,{get:r[t],enumerable:!0})},Ce=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of jr(r))!Br.call(e,s)&&s!==t&&H(e,s,{get:()=>r[s],enumerable:!(n=Hr(r,s))||n.enumerable});return e};var Y=(e,r,t)=>(t=e!=null?Ur(Vr(e)):{},Ce(r||!e||!e.__esModule?H(t,"default",{value:e,enumerable:!0}):t,e)),Wr=e=>Ce(H({},"__esModule",{value:!0}),e);var gn={};Gr(gn,{default:()=>fn,findConfigPath:()=>M,globToRegExp:()=>L,isEdgeDenied:()=>ue,layerForRelativePath:()=>E,loadArkConfig:()=>$,noArkOrderGenericUpdate:()=>Fr,noArkOrderKernelInDomain:()=>Dr,noArkRunDirectNew:()=>Lr,noArkRunKernelInDomain:()=>vr,noArkRunTransportBypass:()=>Tr,noDeniedCapabilities:()=>wr,noDomainInfraImports:()=>Nr,noForbiddenGlobals:()=>Or,noRawEventPublish:()=>_r,patternSpecificity:()=>le,plugin:()=>oe,readTsconfigPathAliases:()=>kr,requirePublishSource:()=>Cr,resolveImportSpecifier:()=>Se,resolveRelativeImport:()=>br});module.exports=Wr(gn);var C=Y(require("fs"),1),m=Y(require("path"),1);var Oe=new Map;function we(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(we,"escapeLiteral");function X(e){let r="";for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="\\"&&t+1<e.length){let s=e[t+1];if("*?{}[],".includes(s)||s==="\\"){r+="\\"+s,t+=1;continue}r+="/";continue}r+=n}return r}c(X,"normalizeGlobSeparators");function zr(e){let r=0;for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="\\"){t+=1;continue}if(n==="{")r+=1;else if(n==="}"&&(r-=1,r<0))return!1}return r===0}c(zr,"bracesBalanced");function L(e){let r=Oe.get(e);if(r)return r;let t=X(e),n=zr(t),s="",o=0;for(let a=0;a<t.length;a+=1){let l=t[a];l==="\\"&&a+1<t.length?(s+=we(t[a+1]),a+=1):l==="*"?t[a+1]==="*"?t[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=we(l)}let i=new RegExp(`^${s}$`);return Oe.set(e,i),i}c(L,"globToRegExp");function qr(e){return X(String(e)).split("/").filter(Boolean).filter(t=>t!=="**"&&t!=="*"&&!t.includes("*")&&!t.includes("?")&&!t.includes("{")&&!t.includes("["))}c(qr,"concreteGlobSegments");function le(e,r){let t=X(String(e)),n=qr(t),s=t.replace(/\*/g,"").length,o=n.length*1e4+s;if(r==null||r==="")return o;let i=String(r).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,l=-1;for(let d of n){let u=-1;for(let p=a;p<i.length;p+=1)if(i[p]===d){u=p;break}if(u<0)return o;l=u,a=u+1}return(l+1)*1e6+n.length*1e4+s}c(le,"patternSpecificity");function E(e,r){let t=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of r??[])if(!(o.exclude??[]).some(i=>L(i).test(t))){for(let i of o.patterns??[])if(L(i).test(t)){let a=le(i,t);a>s&&(s=a,n=o.name)}}return n}c(E,"layerForRelativePath");function ve(e,r){if(!r?.length)return;let t=String(e).split(/[/\\]/).filter(Boolean),n=new Set(r.map(s=>String(s).toLowerCase()));for(let s=0;s<t.length-1;s+=1)if(n.has(t[s].toLowerCase()))return`${t[s].toLowerCase()}/${t[s+1].toLowerCase()}`}c(ve,"sliceIdForPath");function Zr(e){let r=new Set;for(let t of e??[]){let s=X(String(t)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&r.add(a)}}}return[...r]}c(Zr,"inferSliceFoldersFromPatterns");function Yr(e,r,t){if(Array.isArray(e.sliceFolders)&&e.sliceFolders.length>0)return e.sliceFolders.filter(s=>typeof s=="string"&&s.length>0);let n=(t??[]).find(s=>s.name===r);return Zr(n?.patterns)}c(Yr,"resolveSliceFolders");function Xr(e){return!e.fromPath||!e.toPath||e.folderCount<=0||!e.fromSlice||!e.toSlice?!0:e.fromSlice!==e.toSlice}c(Xr,"peerIsolationMustDeny");function ce(e,r,t,n){for(let s of e??[])if(!(s.from!==r||s.to!==t)&&s.allowed===!1){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,a=Yr(s,r,n?.layers),l=o&&i?ve(o,a):void 0,d=o&&i?ve(i,a):void 0;if(Xr({fromPath:o,toPath:i,folderCount:a.length,fromSlice:l,toSlice:d}))return s;continue}if(r!==t)return s}}c(ce,"findDeniedEdgeRule");function ue(e,r,t,n){return ce(e,r,t,n)!==void 0}c(ue,"isEdgeDenied");var Jr=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Qr(e){let r=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:Jr,...r]}c(Qr,"scanExcludePatterns");function Le(e,r){let t=String(e).split(/[/\\]/).join("/");return Qr(r).some(n=>L(n).test(t))}c(Le,"isScanExcludedRelative");var Te=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),et=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),An=Object.freeze(Object.keys(et).sort()),de=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"}),rt=Object.freeze({process:Object.freeze(["process","node:process"])});function De(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let r=de[e];if(r)return r;let t=e.indexOf("/");if(t<0)return null;let n=e.slice(0,t),s=de[n];if(s)return s;let o=e.indexOf("/",t+1);return o<0?null:de[e.slice(0,o)]??null}c(De,"capabilityForModuleSpecifier");function pe(e,r){for(let t of r)if(rt[t]?.includes(e))return t;return null}c(pe,"forbiddenGlobalForModuleSpecifier");function Fe(e){if(e?.pure===!0)return[...Te].sort();let t=(e?.capabilities?.deny??[]).filter(n=>Te.includes(n));return[...new Set(t)].sort()}c(Fe,"effectiveCapabilityDeny");var D={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Ke={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...D,default:[]},kernelRoots:{...D},managedLayers:{...D,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},Pe={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...D,default:[]},managedLayers:{...D,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...D,default:[]}}};function j(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(j,"isObject");function Me(e){let r=new Set;if(!Array.isArray(e.layers))return r;for(let t of e.layers)j(t)&&typeof t.name=="string"&&t.name.length>0&&r.add(t.name);return r}c(Me,"declaredLayerNames");function $e(e){if(!j(e))return e;let r={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(r.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(r.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...r}}c($e,"defaultedArkRun");function Ue(e){if(!j(e))return e;let r=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:r,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}c(Ue,"defaultedArkOrder");function He(e,r){let t=e.arkRun;if(t===void 0||!j(t))return;let n=Me(e),s=t.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&r.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),t.mode==="enforced"){let o=t.kernelRoots??t.compositionRoots;(!Array.isArray(o)||o.length===0)&&r.push({path:t.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&r.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(He,"validateArkRunExtra");function je(e,r){let t=e.arkOrder;if(t===void 0||!j(t))return;let n=Me(e),s=t.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&r.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),t.mode==="enforced"){let o=t.planeRoots;(!Array.isArray(o)||o.length===0)&&r.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&r.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(je,"validateArkOrderExtra");var S="1.3",fe="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",Ve=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],tt=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function nt(){let e=[];for(let r of Ve)for(let t of Ve)r===t||tt.has(`${r}->${t}`)||e.push({from:r,to:t,allowed:!1});return e}c(nt,"createDefaultRules");var Ge=nt(),ge=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],x={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Be={$schema:"https://json-schema.org/draft/2020-12/schema",$id:fe,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:fe,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:S,default:S},name:{type:"string",minLength:1},include:{...x,minItems:1,default:["src"]},exclude:{...x,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:Ge,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...x,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"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...x,default:[]}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...x,minItems:1},exclude:x,intentPrefixes:x,description:{type:"string",minLength:1},forbiddenGlobals:x,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:{...x,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:Ke,arkOrder:Pe}},I=class extends Error{static{c(this,"ArkConfigValidationError")}issues;source;constructor(r,t){super(`Invalid ArkGate config (${r}):
2
- ${t.map(n=>`- ${n.path}: ${n.message}`).join(`
3
- `)}`),this.name="ArkConfigValidationError",this.source=r,this.issues=t}};function We(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(We,"isObject");function J(e,r){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(r)?`${e}.${r}`:`${e}[${JSON.stringify(r)}]`}c(J,"propertyPath");function F(e){return e===null?"null":Array.isArray(e)?"array":typeof e}c(F,"valueType");function st(e,r){let t="#/$defs/";if(e.startsWith(t))return r.$defs[e.slice(t.length)]}c(st,"resolveSchemaRef");function V(e,r,t,n,s){if(r.$ref){let o=st(r.$ref,n);if(!o){s.push({path:t,message:`schema reference ${r.$ref} cannot be resolved`});return}V(e,o,t,n,s);return}if(r.const!==void 0&&!Object.is(e,r.const)){s.push({path:t,message:`must equal ${JSON.stringify(r.const)}`});return}if(r.enum&&!r.enum.some(o=>Object.is(o,e))){s.push({path:t,message:`must be one of ${r.enum.map(String).join(", ")}`});return}if(r.type==="object"){if(!We(e)){s.push({path:t,message:`must be an object; received ${F(e)}`});return}let o=r.properties??{};for(let i of r.required??[])e[i]===void 0&&s.push({path:J(t,i),message:"is required"});if(r.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:J(t,i),message:"unknown field"});else if(r.additionalProperties!==void 0&&r.additionalProperties!==!0&&typeof r.additionalProperties=="object"){let i=r.additionalProperties;for(let a of Object.keys(e))a in o||V(e[a],i,J(t,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&V(e[i],a,J(t,i),n,s);return}if(r.type==="array"){if(!Array.isArray(e)){s.push({path:t,message:`must be an array; received ${F(e)}`});return}if(r.minItems!==void 0&&e.length<r.minItems&&s.push({path:t,message:`must contain at least ${r.minItems} item(s)`}),r.uniqueItems){let o=e.map(i=>JSON.stringify(i));new Set(o).size!==o.length&&s.push({path:t,message:"must not contain duplicate items"})}r.items&&e.forEach((o,i)=>V(o,r.items,`${t}[${i}]`,n,s));return}if(r.type==="string"){if(typeof e!="string"){s.push({path:t,message:`must be a string; received ${F(e)}`});return}r.minLength!==void 0&&e.length<r.minLength&&s.push({path:t,message:`must contain at least ${r.minLength} character(s)`});return}if(r.type==="boolean"){typeof e!="boolean"&&s.push({path:t,message:`must be a boolean; received ${F(e)}`});return}if(r.type==="integer"){if(!Number.isInteger(e)){s.push({path:t,message:`must be an integer; received ${F(e)}`});return}r.minimum!==void 0&&e<r.minimum&&s.push({path:t,message:`must be at least ${r.minimum}`})}}c(V,"validateNode");function ot(e){let r={...e,$schema:e.$schema===void 0?fe:e.$schema,schemaVersion:e.schemaVersion===void 0?S:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?Ge.map(t=>({...t})):e.rules};return e.arkRun!==void 0&&(r.arkRun=$e(e.arkRun)),e.arkOrder!==void 0&&(r.arkOrder=Ue(e.arkOrder)),r}c(ot,"defaultedConfig");function it(e){return e===S?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}c(it,"migratedFromOf");function at(){let e=new Set([S]);for(let r of ge)r.from!=="unversioned"&&e.add(r.from),e.add(r.to);return e}c(at,"knownInputVersions");function lt(e,r="ark.config.json"){if(!We(e))throw new I(r,[{path:"$",message:`must be an object; received ${F(e)}`}]);let t=at(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new I(r,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${S}`}]);if(n!=="unversioned"&&!t.has(n))throw new I(r,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${S}`}]);let s=n,o={...e},i=0;for(;s!==S&&i<ge.length+1;){i+=1;let a=ge.find(l=>l.from===s);if(!a)throw new I(r,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${S}`}]);s=a.to,o.schemaVersion=s}if(s!==S)throw new I(r,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${S}`}]);return{candidate:ot(o),migratedFrom:it(n)}}c(lt,"migrateArkConfig");function ct(e,r="ark.config.json"){let{candidate:t,migratedFrom:n}=lt(e,r),s=[];if(V(t,Be,"$",Be,s),He(t,s),je(t,s),s.length>0)throw new I(r,s);return{config:t,migratedFrom:n}}c(ct,"loadArkConfigContract");function ze(e,r="ark.config.json"){let t;try{t=JSON.parse(e)}catch(n){throw new I(r,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return ct(t,r)}c(ze,"parseArkConfigJson");var ut=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,dt=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,pt=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function ft(e,r){let t=String(e??"").replace(/\\/g,"/").trim(),n=String(r?.fromLayer??""),s=String(r?.toLayer??"");return ut.test(t)?"pure-shared":n==="PersistenceAdapters"&&(dt.test(t)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${t}`))?"kernel-emit":pt.test(t)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}c(ft,"classifyLayerImportKind");function gt(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 r=ft(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return r==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":r==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":r==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}c(gt,"layerImportNextAction");function mt(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}c(mt,"arkRunCallSiteName");function yt(e){let r=mt(e),t=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return r?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${r} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return r?`Move the kernel import of ${r} out of ${t??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return r?`Resolve ${r} 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 r?`Add ${r} 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 r?`Add ${r} 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 r?`Add ${r} 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 r?`Send through the ArkRun kernel transport instead of importing ${r}, 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.`}}c(yt,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return gt(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 yt(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Use release() to freeze \u03BE or proposeRelease() for a pattern change with blast radius, then preflight again. Never mechanical-safe.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate only. Change \u03BE with proposeRelease + release. Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Do not persist slow key ${e.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease(), then preflight again.`:"Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease(), then preflight again. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(K,"deterministicNextAction");var Rt="docs/diagnostics.md";function R(e){return typeof e=="string"&&e.length>0?e:void 0}c(R,"text");function qe(e,r){return Number.isInteger(e)&&Number(e)>0?Number(e):r}c(qe,"positiveInteger");function ht(e){let r=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,t=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[r,t,n??"",s??"",o??""].join("|")}c(ht,"adapterFindingTargetKey");function At(e){let r=2166136261;for(let t=0;t<e.length;t+=1)r^=e.charCodeAt(t),r=Math.imul(r,16777619);return`fnv1a-${(r>>>0).toString(16).padStart(8,"0")}`}c(At,"adapterFindingRefFromTargetKey");function kt(e){return`${Rt}#${e}`}c(kt,"adapterDocsCodePath");function bt(e,r,t){return K({ruleId:e,target:R(r.target)??R(t.target)??void 0,fromLayer:R(r.fromLayer)??void 0,toLayer:R(r.toLayer)??void 0,typeOnly:r.typeOnly===!0,targetTypeOnlyExports:r.targetTypeOnlyExports===!0,namedBindingsTypeOnly:r.namedBindingsTypeOnly===!0,portProofEligible:r.portProofEligible===!0,peerIsolation:r.peerIsolation===!0,sourcePureTypeModule:r.sourcePureTypeModule===!0,edgeKind:R(r.edgeKind)??void 0,capability:R(r.capability)??R(t.capability)??void 0,arkruleId:R(r.arkruleId)??void 0,arkruleSource:R(r.arkruleSource)??void 0})}c(bt,"nextActionForDiagnostic");function Ze(e,r="error",t){let n=R(e.ruleId)??R(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":r,o={...R(e.target)?{target:R(e.target)}:{},...R(e.fromLayer)?{fromLayer:R(e.fromLayer)}:{},...R(e.toLayer)?{toLayer:R(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}:{},...R(e.capability)?{capability:R(e.capability)}:{},...R(e.edgeKind)?{edgeKind:R(e.edgeKind)}:{},...R(e.arkruleId)?{arkruleId:R(e.arkruleId)}:{},...R(e.arkruleSource)?{arkruleSource:R(e.arkruleSource)}:{}},i=t??ht(e),a=At(i);return{ruleId:n,severity:s,message:R(e.message)??n,location:{file:R(e.file)??"<unknown>",line:qe(e.line,1),column:qe(e.column,1)},evidence:o,nextAction:R(e.nextAction)??bt(n,o,e),findingRef:a,targetKey:i,docsCodePath:kt(n)}}c(Ze,"toAdapterDiagnostic");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."},Ln=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 Et(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}c(Et,"looksLikeArkIntent");function me(e){if(!e.publishCall)return[];let r=[];return(e.rawIntentName!==void 0&&Et(e.rawIntentName)||e.objectHasIntent)&&r.push({ruleId:"RAW_EVENT_PUBLISH",message:Ye.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&r.push({ruleId:"PUBLISH_MISSING_SOURCE",message:Ye.PUBLISH_MISSING_SOURCE}),r}c(me,"classifyPublishFacts");var be=Y(require("fs"),1),O=Y(require("path"),1);var St=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var xt=new Set(St),It=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"]),Nt=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function P(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}c(P,"isArkRunKernelModuleSpecifier");var _t=["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"],ye=new Set(_t);function Qe(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(ye.has(e))return!0;let r=e.indexOf("/");if(r<0)return!1;let t=e.slice(0,r);if(ye.has(t))return!0;let n=e.indexOf("/",r+1);return n<0?!1:ye.has(e.slice(0,n))}c(Qe,"isArkRunTransportBypassSpecifier");function Xe(e){if(xt.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}}c(Xe,"arkRunKernelCallKind");function er(e,r){let t=1;for(let n=0;n<r;n+=1)e.charCodeAt(n)===10&&(t+=1);return t}c(er,"lineAt");function Re(e){return e.replace(/\/\*[\s\S]*?\*\//g,r=>r.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,r=>r.replace(/\/\/.*$/,t=>" ".repeat(t.length)))}c(Re,"stripCommentsPreservingLines");function Ct(e,r){let t=e.slice(r),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(t);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}c(Ct,"firstStringLiteralArg");function Je(e,r,t){let n=Math.max(0,r-t.length-8),s=e.slice(n,r);return new RegExp(`\\b${t}\\s+$`).test(s)}c(Je,"keywordBefore");function Q(e,r){let t=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=t.exec(e))!==null;)n[1]||r(n[2]??"",n[3]??"")}c(Q,"parseValueImportClause");function rr(e,r){Q(Re(e),r)}c(rr,"forEachArkRunValueImportClause");function Ot(e){let r=new Map,t=new Set;return Q(e,(n,s)=>{if(!P(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&t.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&r.set(i[1],i[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){r.set(u[2],u[1]);continue}let p=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(d);p?.[1]&&r.set(p[1],p[1])}}),{named:r,namespaces:t}}c(Ot,"collectKernelImportBindings");function wt(e,r){let t=new Set(r);return Q(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let 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)||(P(s)||r.has(u)||r.has(d))&&(t.add(d),t.add(u))}}),t}c(wt,"collectImportedConstructors");function vt(e,r){let t;return Q(e,(n,s)=>{!t&&new RegExp(`\\b${r}\\b`).test(n)&&(t=s)}),t}c(vt,"importedFromForName");function ee(e,r){let t=Re(r),n=Ot(t),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(t))!==null;){let a=i[1],l=i.index;if(Je(t,l,"function")||Je(t,l,"class"))continue;let u=t.slice(0,l).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],p=n.named.get(a)??a,f=Xe(p)??Xe(a);if(!f)continue;let g=n.named.has(a)||u!==void 0&&n.namespaces.has(u);if(f!=="factory"&&(!g&&u===void 0||u&&Nt.has(u)&&!g))continue;let y=Ct(t,l+i[0].length);s.push({file:e,line:er(r,l),kind:f,callee:a,viaImport:g,...u?{receiver:u}:{},...y?{nameLiteral:y}:{}})}return s}c(ee,"extractArkRunKernelCallsFromSource");function he(e,r,t){let n=Re(r),s=wt(n,t),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let l=a[1];if(It.has(l)||!s.has(l))continue;let d=vt(n,l);o.push({file:e,line:er(r,a.index),typeName:l,...d?{importedFrom:d}:{}})}return o}c(he,"extractArkRunManagedNewsFromSource");function Ae(e,r){let t=[],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(r))!==null;){let o=s[1],i=s.index+s[0].length,a=1,l=i;for(;l<r.length&&a>0;){let b=r[l];b==="{"?a+=1:b==="}"&&(a-=1),l+=1}let d=r.slice(i,l-1),u=d.split(`
1
+ "use strict";var Gt=Object.create;var V=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var qt=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty;var c=(e,t)=>V(e,"name",{value:t,configurable:!0});var Yt=(e,t)=>{for(var r in t)V(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of zt(t))!Zt.call(e,s)&&s!==r&&V(e,s,{get:()=>t[s],enumerable:!(n=Wt(t,s))||n.enumerable});return e};var J=(e,t,r)=>(r=e!=null?Gt(qt(e)):{},we(t||!e||!e.__esModule?V(r,"default",{value:e,enumerable:!0}):r,e)),Xt=e=>we(V({},"__esModule",{value:!0}),e);var Sn={};Yt(Sn,{default:()=>En,findConfigPath:()=>M,globToRegExp:()=>x,isEdgeDenied:()=>$e,layerForRelativePath:()=>E,loadArkConfig:()=>U,noArkOrderGenericUpdate:()=>jt,noArkOrderKernelInDomain:()=>Ht,noArkRunDirectNew:()=>Mt,noArkRunKernelInDomain:()=>$t,noArkRunTransportBypass:()=>Ut,noDeniedCapabilities:()=>Kt,noDomainInfraImports:()=>Tt,noForbiddenGlobals:()=>Pt,noRawEventPublish:()=>Dt,patternSpecificity:()=>de,plugin:()=>ae,readTsconfigPathAliases:()=>_t,requirePublishSource:()=>Ft,resolveImportSpecifier:()=>Ie,resolveRelativeImport:()=>Ct});module.exports=Xt(Sn);var w=J(require("fs"),1),m=J(require("path"),1);var Oe=new Map;function ve(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(ve,"escapeLiteral");function Q(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}c(Q,"normalizeGlobSeparators");function Jt(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}c(Jt,"bracesBalanced");function x(e){let t=Oe.get(e);if(t)return t;let r=Q(e),n=Jt(r),s="",o=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=ve(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=ve(l)}let i=new RegExp(`^${s}$`);return Oe.set(e,i),i}c(x,"globToRegExp");function Qt(e){return Q(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}c(Qt,"concreteGlobSegments");function de(e,t){let r=Q(String(e)),n=Qt(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,l=-1;for(let u of n){let d=-1;for(let p=a;p<i.length;p+=1)if(i[p]===u){d=p;break}if(d<0)return o;l=d,a=d+1}return(l+1)*1e6+n.length*1e4+s}c(de,"patternSpecificity");function E(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>x(i).test(r))){for(let i of o.patterns??[])if(x(i).test(r)){let a=de(i,r);a>s&&(s=a,n=o.name)}}return n}c(E,"layerForRelativePath");function Le(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()}`}c(Le,"sliceIdForPath");function er(e){let t=new Set;for(let r of e??[]){let s=Q(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}c(er,"inferSliceFoldersFromPatterns");function tr(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 er(n?.patterns)}c(tr,"resolveSliceFolders");function Te(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}c(Te,"normalizeSegments");function Pe(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}c(Pe,"trimTrailingSlashes");var rr=["src","app"];function nr(e){let t=Pe(e.replace(/^[./]+/,""));return t==="*"||t==="**"}c(nr,"isBlanketRoot");function De(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Te(r);for(let o of t){if(typeof o!="string"||o.length===0||nr(o))continue;if(o.includes("*")){let l=Pe(o.toLowerCase());if(x(l).test(n)||x(`${l}/**`).test(n))return!0;continue}let i=Te(o);if(i.length===0)continue;let a=rr.includes(s[0])&&i[0]!==s[0]?[0,1]:[0];for(let l of a){if(l+i.length>s.length)continue;let u=!0;for(let d=0;d<i.length;d+=1)if(s[l+d]!==i[d]){u=!1;break}if(u)return!0}}return!1}c(De,"pathUnderSharedRoot");function Fe(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}c(Fe,"sliceMatchesDeclaration");function sr(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Fe(n.from,t)&&Fe(n.to,r))}c(sr,"crossSliceEdgeAllowed");function or(e){if(!e.fromPath||!e.toPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0,r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}c(or,"peerIsolationDecision");function Ke(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"unclassifiable-path":{let r=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${r.length>0?` (${r.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}c(Ke,"peerIsolationDenyExplanation");function ir(e,t,r,n){return ue(e,t,r,n)?.rule}c(ir,"findDeniedEdgeRule");function ue(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===!1){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,a=tr(s,t,n?.layers),l=o&&i?Le(o,a):void 0,u=o&&i?Le(i,a):void 0,d=or({fromPath:o,toPath:i,folderCount:a.length,fromSlice:l,toSlice:u,fromShared:!l&&De(o,s.sharedRoots),toShared:!u&&De(i,s.sharedRoots),crossSliceAllowed:sr(s.allowedCrossSlice,l,u)});if(d.denied)return{rule:s,peerIsolationReason:d.reason,fromSlice:l,toSlice:u};continue}if(t!==r)return{rule:s}}}c(ue,"findDeniedEdgeDecision");function $e(e,t,r,n){return ir(e,t,r,n)!==void 0}c($e,"isEdgeDenied");var ar=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function lr(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:ar,...t]}c(lr,"scanExcludePatterns");function Me(e,t){let r=String(e).split(/[/\\]/).join("/");return lr(t).some(n=>x(n).test(r))}c(Me,"isScanExcludedRelative");var Ue=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),cr=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Cn=Object.freeze(Object.keys(cr).sort()),pe=Object.freeze({fs:"filesystem","node:fs":"filesystem","fs/promises":"filesystem","node:fs/promises":"filesystem","fs-extra":"filesystem","graceful-fs":"filesystem",memfs:"filesystem",chokidar:"filesystem",http:"network",https:"network",http2:"network",net:"network",tls:"network",dgram:"network",dns:"network","node:http":"network","node:https":"network","node:http2":"network","node:net":"network","node:tls":"network","node:dgram":"network","node:dns":"network",axios:"network",undici:"network","node-fetch":"network",got:"network",ky:"network",superagent:"network",ws:"network",process:"process","node:process":"process",child_process:"process","node:child_process":"process","@prisma/client":"persistence",prisma:"persistence",pg:"persistence",mysql:"persistence",mysql2:"persistence",mongodb:"persistence",mongoose:"persistence",sqlite3:"persistence","better-sqlite3":"persistence",redis:"persistence",ioredis:"persistence",typeorm:"persistence",knex:"persistence","drizzle-orm":"persistence",sequelize:"persistence",kysely:"persistence","@supabase/supabase-js":"persistence"}),dr=Object.freeze({process:Object.freeze(["process","node:process"])});function He(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=pe[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=pe[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:pe[e.slice(0,o)]??null}c(He,"capabilityForModuleSpecifier");function fe(e,t){for(let r of t)if(dr[r]?.includes(e))return r;return null}c(fe,"forbiddenGlobalForModuleSpecifier");function je(e){if(e?.pure===!0)return[...Ue].sort();let r=(e?.capabilities?.deny??[]).filter(n=>Ue.includes(n));return[...new Set(r)].sort()}c(je,"effectiveCapabilityDeny");var F={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Ve={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...F,default:[]},kernelRoots:{...F},managedLayers:{...F,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},Be={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...F,default:[]},managedLayers:{...F,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...F,default:[]}}};function B(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(B,"isObject");function Ge(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)B(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}c(Ge,"declaredLayerNames");function We(e){if(!B(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}c(We,"defaultedArkRun");function ze(e){if(!B(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}c(ze,"defaultedArkOrder");function qe(e,t){let r=e.arkRun;if(r===void 0||!B(r))return;let n=Ge(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(qe,"validateArkRunExtra");function Ze(e,t){let r=e.arkOrder;if(r===void 0||!B(r))return;let n=Ge(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(Ze,"validateArkOrderExtra");var I="1.3",ge="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",Ye=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],ur=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function pr(){let e=[];for(let t of Ye)for(let r of Ye)t===r||ur.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}c(pr,"createDefaultRules");var Je=pr(),me=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],S={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Xe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:ge,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:ge,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:I,default:I},name:{type:"string",minLength:1},include:{...S,minItems:1,default:["src"]},exclude:{...S,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:Je,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...S,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...S,default:[]}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...S,minItems:1},exclude:S,intentPrefixes:S,description:{type:"string",minLength:1},forbiddenGlobals:S,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:{...S,minItems:1},sharedRoots:{...S,minItems:1},allowedCrossSlice:{type:"array",minItems:1,items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}}}},safety:{type:"object",additionalProperties:!1,properties:{maxTsSuppressions:{type:"integer",minimum:0,default:0},maxAnyCasts:{type:"integer",minimum:0,default:0},allowInMemory:{type:"boolean",default:!1},allowDisabledPeerIsolation:{type:"boolean",default:!1}}},coverage:{type:"object",additionalProperties:!1,description:"Invariant coverage scan controls. testGlobs replaces the built-in test-name heuristic; maxFiles raises or lowers the evidence file budget; coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant.",properties:{testGlobs:{...S,minItems:1},maxFiles:{type:"integer",minimum:1},coverageRoots:{...S,minItems:1}}},arkRun:Ve,arkOrder:Be}},N=class extends Error{static{c(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
2
+ ${r.map(n=>`- ${n.path}: ${n.message}`).join(`
3
+ `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function Qe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(Qe,"isObject");function ee(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}c(ee,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}c(P,"valueType");function fr(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}c(fr,"resolveSchemaRef");function G(e,t,r,n,s){if(t.$ref){let o=fr(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}G(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(!Qe(e)){s.push({path:r,message:`must be an object; received ${P(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:ee(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:ee(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let a of Object.keys(e))a in o||G(e[a],i,ee(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&G(e[i],a,ee(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${P(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:r,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let o=e.map(i=>JSON.stringify(i));new Set(o).size!==o.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((o,i)=>G(o,t.items,`${r}[${i}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${P(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${P(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${P(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}c(G,"validateNode");function gr(e){let t={...e,$schema:e.$schema===void 0?ge:e.$schema,schemaVersion:e.schemaVersion===void 0?I:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?Je.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=We(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=ze(e.arkOrder)),t}c(gr,"defaultedConfig");function mr(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}c(mr,"migratedFromOf");function yr(){let e=new Set([I]);for(let t of me)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}c(yr,"knownInputVersions");function hr(e,t="ark.config.json"){if(!Qe(e))throw new N(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=yr(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new N(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new N(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<me.length+1;){i+=1;let a=me.find(l=>l.from===s);if(!a)throw new N(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new N(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:gr(o),migratedFrom:mr(n)}}c(hr,"migrateArkConfig");function Rr(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=hr(e,t),s=[];if(G(r,Xe,"$",Xe,s),qe(r,s),Ze(r,s),s.length>0)throw new N(t,s);return{config:r,migratedFrom:n}}c(Rr,"loadArkConfigContract");function et(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new N(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return Rr(r,t)}c(et,"parseArkConfigJson");var Ar=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,kr=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,br=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Er(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Ar.test(r)?"pure-shared":n==="PersistenceAdapters"&&(kr.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":br.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}c(Er,"classifyLayerImportKind");function Sr(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=Er(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."}c(Sr,"layerImportNextAction");function Ir(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}c(Ir,"arkRunCallSiteName");function xr(e){let t=Ir(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(xr,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Sr(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"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 xr(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Use release() to freeze \u03BE or proposeRelease() for a pattern change with blast radius, then preflight again. Never mechanical-safe.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate only. Change \u03BE with proposeRelease + release. Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Do not persist slow key ${e.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease(), then preflight again.`:"Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease(), then preflight again. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(K,"deterministicNextAction");var Nr="docs/diagnostics.md";function h(e){return typeof e=="string"&&e.length>0?e:void 0}c(h,"text");function tt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}c(tt,"positiveInteger");function _r(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("|")}c(_r,"adapterFindingTargetKey");function Cr(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")}`}c(Cr,"adapterFindingRefFromTargetKey");function wr(e){return`${Nr}#${e}`}c(wr,"adapterDocsCodePath");function Or(e,t,r){return K({ruleId:e,target:h(t.target)??h(r.target)??void 0,fromLayer:h(t.fromLayer)??void 0,toLayer:h(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:h(t.edgeKind)??void 0,capability:h(t.capability)??h(r.capability)??void 0,arkruleId:h(t.arkruleId)??void 0,arkruleSource:h(t.arkruleSource)??void 0})}c(Or,"nextActionForDiagnostic");function rt(e,t="error",r){let n=h(e.ruleId)??h(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...h(e.target)?{target:h(e.target)}:{},...h(e.fromLayer)?{fromLayer:h(e.fromLayer)}:{},...h(e.toLayer)?{toLayer:h(e.toLayer)}:{},...typeof e.typeOnly=="boolean"?{typeOnly:e.typeOnly}:{},...typeof e.targetTypeOnlyExports=="boolean"?{targetTypeOnlyExports:e.targetTypeOnlyExports}:{},...typeof e.sourcePureTypeModule=="boolean"?{sourcePureTypeModule:e.sourcePureTypeModule}:{},...typeof e.namedBindingsTypeOnly=="boolean"?{namedBindingsTypeOnly:e.namedBindingsTypeOnly}:{},...typeof e.portProofEligible=="boolean"?{portProofEligible:e.portProofEligible}:{},...typeof e.peerIsolation=="boolean"?{peerIsolation:e.peerIsolation}:{},...h(e.capability)?{capability:h(e.capability)}:{},...h(e.edgeKind)?{edgeKind:h(e.edgeKind)}:{},...h(e.arkruleId)?{arkruleId:h(e.arkruleId)}:{},...h(e.arkruleSource)?{arkruleSource:h(e.arkruleSource)}:{}},i=r??_r(e),a=Cr(i);return{ruleId:n,severity:s,message:h(e.message)??n,location:{file:h(e.file)??"<unknown>",line:tt(e.line,1),column:tt(e.column,1)},evidence:o,nextAction:h(e.nextAction)??Or(n,o,e),findingRef:a,targetKey:i,docsCodePath:wr(n)}}c(rt,"toAdapterDiagnostic");var nt={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."},Hn=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 vr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}c(vr,"looksLikeArkIntent");function ye(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&vr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:nt.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:nt.PUBLISH_MISSING_SOURCE}),t}c(ye,"classifyPublishFacts");var Ee=J(require("fs"),1),O=J(require("path"),1);var Lr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Tr=new Set(Lr),Dr=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"]),Fr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function $(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}c($,"isArkRunKernelModuleSpecifier");var Pr=["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"],he=new Set(Pr);function it(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(he.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(he.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:he.has(e.slice(0,n))}c(it,"isArkRunTransportBypassSpecifier");function st(e){if(Tr.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}}c(st,"arkRunKernelCallKind");function at(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}c(at,"lineAt");function Re(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(Re,"stripCommentsPreservingLines");function Kr(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}c(Kr,"firstStringLiteralArg");function ot(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)}c(ot,"keywordBefore");function te(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]??"")}c(te,"parseValueImportClause");function lt(e,t){te(Re(e),t)}c(lt,"forEachArkRunValueImportClause");function $r(e){let t=new Map,r=new Set;return te(e,(n,s)=>{if(!$(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&r.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&t.set(i[1],i[1]);let a=/\{([^}]*)\}/.exec(n);if(a?.[1])for(let l of a[1].split(",")){let u=l.trim();if(!u||u.startsWith("type "))continue;let d=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(u);if(d){t.set(d[2],d[1]);continue}let p=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(u);p?.[1]&&t.set(p[1],p[1])}}),{named:t,namespaces:r}}c($r,"collectKernelImportBindings");function Mr(e,t){let r=new Set(t);return te(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let l=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),u=l?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],d=l?.[1]??u;!u||!d||!/^[A-Z]/.test(d)||($(s)||t.has(d)||t.has(u))&&(r.add(u),r.add(d))}}),r}c(Mr,"collectImportedConstructors");function Ur(e,t){let r;return te(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}c(Ur,"importedFromForName");function re(e,t){let r=Re(t),n=$r(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],l=i.index;if(ot(r,l,"function")||ot(r,l,"class"))continue;let d=r.slice(0,l).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],p=n.named.get(a)??a,f=st(p)??st(a);if(!f)continue;let g=n.named.has(a)||d!==void 0&&n.namespaces.has(d);if(f!=="factory"&&(!g&&d===void 0||d&&Fr.has(d)&&!g))continue;let y=Kr(r,l+i[0].length);s.push({file:e,line:at(t,l),kind:f,callee:a,viaImport:g,...d?{receiver:d}:{},...y?{nameLiteral:y}:{}})}return s}c(re,"extractArkRunKernelCallsFromSource");function Ae(e,t,r){let n=Re(t),s=Mr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let l=a[1];if(Dr.has(l)||!s.has(l))continue;let u=Ur(n,l);o.push({file:e,line:at(t,a.index),typeName:l,...u?{importedFrom:u}:{}})}return o}c(Ae,"extractArkRunManagedNewsFromSource");function ke(e,t){let r=[],n=/export\s+(?:abstract\s+)?class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:extends\s+[^{]+)?(?:implements\s+[^{]+)?\{/g,s;for(;(s=n.exec(t))!==null;){let o=s[1],i=s.index+s[0].length,a=1,l=i;for(;l<t.length&&a>0;){let b=t[l];b==="{"?a+=1:b==="}"&&(a-=1),l+=1}let u=t.slice(i,l-1),d=u.split(`
4
4
  `).map(b=>/^\s*\/\//.test(b)||/^\s*\/\*|\*\//.test(b)?b:b.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
- `),p=/(?:^|\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),f=/(?:^|\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(`
5
+ `),p=/(?:^|\n)\s*(?:public\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/m.test(d.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(d),f=/(?:^|\n)\s*public\s+(?!static|async|get|set|constructor|readonly)[a-zA-Z_]/.test(d)||/(?:^|[\n;])\s*[a-zA-Z_][a-zA-Z0-9_]*\s*:\s*[^=;\n]+[;=]/m.test(d.split(`
6
6
  `).filter(b=>!/^\s*(private|protected|static|constructor|get |set |async |\/)/.test(b)).join(`
7
- `)),g=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(d),y=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(d),h=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(d)&&!y,A=/(?:^|[\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),k=[],q=new Set(["if","match","when"]),Z=/(?:^|\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,v;for(;(v=Z.exec(d))!==null;){let b=v[1];if(q.has(b))continue;let Ne=v.index+v[0].length,ae=1,U=Ne;for(;U<d.length&&ae>0;)d[U]==="{"?ae+=1:d[U]==="}"&&(ae-=1),U+=1;let _e=d.slice(Ne,U-1);if(!/this\.\w+\s*=/.test(_e))continue;let $r=/\b(ensureInvariants|assertInvariants|validate|publish|emit|raise|record)\b/.test(_e);k.push({name:b,referencesGuardOrPublish:$r})}let Kr=(d.match(/(?:^|\n)\s*(?:public\s+|private\s+|protected\s+)?(?:async\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*\(/g)??[]).length,Pr=(u.match(/(?:^|[\n;])\s*(?:public\s+)?(?!constructor|static|get|set|private|protected|readonly)[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/g)??[]).length,Mr=Kr<=1&&Pr>=2&&(f||p);t.push({file:e,className:o,exported:!0,hasPublicMutableFields:f||p,hasPublicSetters:g,hasPublicConstructor:h,hasStaticFactory:A,mutatingMethods:[...k],dataOnly:Mr})}return t}c(Ae,"extractClassShapesFromSource");function Lt(e){if(!e)return{};let r=typeof e.governedPercent=="number"?e.governedPercent:null,t=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return t==null&&typeof e.classifiedFiles=="number"&&(t=e.classifiedFiles>0?1:0),{governedPercent:r,populatedLayerCount:t}}c(Lt,"normalizeExtraMergeTeethClassification");function re(e){let r=Lt(e),t=typeof r.governedPercent=="number"?r.governedPercent:null,n=typeof r.populatedLayerCount=="number"?r.populatedLayerCount:null;return t==null&&n==null?!0:(t??0)>=50&&(n??0)>=1}c(re,"extraMergeTeethAllowed");var Tt=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],Dt=new Set(Tt);function Ft(e){return Dt.has(e)}c(Ft,"isArkRunEditorSensor");var tr={"arkrun-missing-root":"ARKRUN_MISSING_ROOT","arkrun-kernel-in-domain":"ARKRUN_KERNEL_IN_DOMAIN","arkrun-direct-new":"ARKRUN_DIRECT_NEW","arkrun-undeclared-emit":"ARKRUN_UNDECLARED_EMIT","arkrun-undeclared-handle":"ARKRUN_UNDECLARED_HANDLE","arkrun-undeclared-depend":"ARKRUN_UNDECLARED_DEPEND","arkrun-transport-bypass":"ARKRUN_TRANSPORT_BYPASS"},Kt="ARKRUN_INTERACTION_NAME_INCOMPLETE";function or(e,r=[]){let t=e.trim();return/^domain(?:model)?$/i.test(t)||/^domain(?=[A-Z_\-\s])/i.test(t)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(t)?!0:r.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(or,"isDomainRoleLayer");function Pt(e,r){return e.file.localeCompare(r.file)||e.ruleId.localeCompare(r.ruleId)||e.line-r.line||e.message.localeCompare(r.message)}c(Pt,"compareFindings");function N(e,r,t,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:tr[r],sensor:r,message:s,file:t,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:tr[r],fromLayer:o?.fromLayer,target:o?.target})}}c(N,"finding");function Mt(e,r){let t=[],n=[],s=[],o=[];for(let i of e)i.file===r&&(t.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(t),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}c(Mt,"bagForFile");function nr(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}c(nr,"emitKinds");function sr(e){return e==="subscribe"||e==="register-handler"}c(sr,"handleKinds");function $t(e){return e==="resolve"||e==="resolve-singleton"}c($t,"dependKinds");function Ut(e,r,t){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(N(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,t)),n;let o=new Map;for(let i of r){let a=o.get(i.matchedRoot)??[];a.push(i),o.set(i.matchedRoot,a)}for(let i of s){let a=[...o.get(i)??[]].sort((d,u)=>d.file.localeCompare(u.file));if(a.length===0){n.push(N(e,"arkrun-missing-root","ark.config.json",1,`ArkRun kernel root ${JSON.stringify(i)} matched no governed files and has no createArkKernel factory.`,{target:i},t));continue}if(a.some(d=>d.hasKernelFactory))continue;let l=a[0];n.push(N(e,"arkrun-missing-root",l.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},t))}return n}c(Ut,"evaluateMissingRoot");function Ht(e,r,t,n,s){let o=new Map(r.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of t){let l=a.specifier;if(!l||!P(l))continue;let d=n(a.from);d&&or(d,o.get(d)??[])&&i.push(N(e,"arkrun-kernel-in-domain",a.from,a.line,`${d} must not import kernel module ${JSON.stringify(l)}.`,{fromLayer:d,target:l},s))}return i}c(Ht,"evaluateKernelInDomain");function jt(e,r,t,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let a=new Map(r.map(u=>[u.name,u.intentPrefixes??[]])),l=new Set(n.filter(u=>u.hasKernelFactory).map(u=>u.file)),d=[];for(let u of t){if(l.has(u.file))continue;let p=u.typeName;if(e.ignoreDirectNewForErrors!==!1&&(p.endsWith("Error")||p==="Error")||p.endsWith("DTO")||p.endsWith("VO"))continue;let f=s(u.file);!f||!i.has(f)||or(f,a.get(f)??[])||d.push(N(e,"arkrun-direct-new",u.file,u.line,`${f} must not construct ${u.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:f,target:u.typeName},o))}return d}c(jt,"evaluateDirectNew");function Vt(e,r,t,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let l of r){if(!nr(l.kind)&&!sr(l.kind)&&!$t(l.kind))continue;let d=n(l.file);if(!d||!a.has(d))continue;if(!l.nameLiteral){e.mode==="enforced"&&i.push({code:Kt,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=Mt(t,l.file);if(nr(l.kind)){if(u.raises.has(l.nameLiteral)||u.sends.has(l.nameLiteral))continue;o.push(N(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(sr(l.kind)){if(u.reactsTo.has(l.nameLiteral))continue;o.push(N(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)||o.push(N(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:o,completenessReasons:i}}c(Vt,"evaluateUndeclared");function Bt(e,r,t,n){let s=new Set(e.managedLayers);if(s.size===0)return[];let o=[];for(let i of r){if(i.typeOnly)continue;let a=i.specifier;if(!a||!Qe(a))continue;let l=t(i.from);!l||!s.has(l)||o.push(N(e,"arkrun-transport-bypass",i.from,i.line,`${l} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:l,target:a},n))}return o}c(Bt,"evaluateTransportBypass");function Gt(e){let r=e.arkRun;if(!r)return{findings:[],completenessReasons:[]};let t=re(e.classification),n=Vt(r,e.kernelCalls,e.declarations,e.layerForFile,t),s=[...Ut(r,e.compositionRootHits,t),...Ht(r,e.layers,e.dependencies,e.layerForFile,t),...jt(r,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,t),...n.findings,...Bt(r,e.dependencies,e.layerForFile,t)].sort(Pt),o=[...n.completenessReasons].sort((i,a)=>{let l=`${i.code}\0${i.file??""}\0${i.message}`,d=`${a.code}\0${a.file??""}\0${a.message}`;return l<d?-1:l>d?1:0});return{findings:s,completenessReasons:o}}c(Gt,"evaluateArkRunSensors");function ke(e){return{findings:Gt(e).findings.filter(t=>Ft(t.sensor)),completenessReasons:[]}}c(ke,"evaluateArkRunEditorSensors");function Wt(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let r=e.specifiers??[];return r.length===0?!1:r.every(t=>t.type==="ImportSpecifier")?r.every(t=>t.importKind==="type"):r.every(t=>t.exportKind==="type")}c(Wt,"declarationIsTypeOnly");function ar(e){try{return be.default.existsSync(e)?be.default.readFileSync(e,"utf8"):null}catch{return null}}c(ar,"readUtf8");function ir(e,r){let t=e.lintedFilename(r),n=e.findConfigPath(t),s=n?e.loadArkConfig(n):null;if(!s?.arkRun||!n||!t)return null;let o=O.default.dirname(n),i=O.default.isAbsolute(t)?t:O.default.resolve(t),a=O.default.relative(o,i).split(O.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let l=E(a,s.layers);return l?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:l}:null}c(ir,"loadEditorFile");function zt(e,r,t){let n=ee(r,t).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!L(o).test(r))continue}catch{continue}s.push({file:r,matchedRoot:o,hasKernelFactory:n})}return s}c(zt,"compositionRootHitsForFile");function qt(e,r,t){let n=new Set(Ae(r.relFile,t).map(s=>s.className));return rr(t,(s,o)=>{if(P(o))return;let i=e.resolveImportSpecifier(r.absFile,o,r.root);if(!i)return;let a=O.default.relative(r.root,i).split(O.default.sep).join("/");if(a.startsWith(".."))return;let l=ar(i);if(l!==null)for(let d of Ae(a,l))n.add(d.className)}),n}c(qt,"admittedTypeNamesForEditor");function lr(e,r,t,n,s,o){e.reportAdapterDiagnostic(r,t,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}c(lr,"reportFinding");function Zt(e){let r=e.callee;if(r?.type==="Identifier"&&r.name&&/^[A-Z]/.test(r.name))return r.name;let t=r?.property?.name;if(t&&/^[A-Z]/.test(t)&&r?.computed!==!0)return t}c(Zt,"constructedTypeName");function Yt(e,r){return e.type?.startsWith("Export")?"export":r}c(Yt,"specifierEdgeKind");function Xt(e,r,t,n,s){let o=c((i,a,l,d)=>{if(typeof a!="string"||a.length===0)return;let u=i.loc?.start?.line??1,p={from:t.relFile,specifier:a,kind:d,typeOnly:l,line:u,resolution:"resolved-external"},{findings:f}=ke({arkRun:t.extra,layers:t.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[p],layerForFile:c(g=>g===t.relFile?t.fromLayer:E(g,t.config.layers),"layerForFile")});for(let g of f)g.sensor===n&&lr(e,r,i,s,g,{fromLayer:g.fromLayer??t.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,l=(a.specifiers??[]).filter(u=>u.type==="ImportSpecifier"),d=l.length>0&&l.length===(a.specifiers??[]).length&&l.every(u=>u.importKind==="type");o(i,a.source?.value,a.importKind==="type"||d||Wt(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let l=a.specifiers??[],d=l.length>0&&l.every(u=>u.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||d,Yt(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(r,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}c(Xt,"importListeners");function Jt(e,r,t){let n=ar(t.absFile)??"",s=qt(e,t,n),o=he(t.relFile,n,s),{findings:i}=ke({arkRun:t.extra,layers:t.config.layers,kernelCalls:ee(t.relFile,n),managedNews:o,compositionRootHits:zt(t.extra,t.relFile,n),declarations:[],dependencies:[],layerForFile:c(l=>l===t.relFile?t.fromLayer:E(l,t.config.layers),"layerForFile")}),a=i.filter(l=>l.sensor==="arkrun-direct-new");return{NewExpression(l){let d=Zt(l);if(!d)return;let u=l.loc?.start?.line,p=a.find(f=>f.target===d&&(u===void 0||f.line===u))??a.find(f=>f.target===d);p&&lr(e,r,l,"directNew",p,{fromLayer:p.fromLayer??t.fromLayer,typeName:d,target:p.target??d})}}}c(Jt,"directNewListener");function cr(e){let r=c((t,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=ir(e,i);return a?Xt(e,i,a,t,s):{}}}),"createImportRule");return{noArkRunKernelInDomain:r("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:r("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(t){let n=ir(e,t);return n?Jt(e,t,n):{}}}}}c(cr,"createArkRunEslintRules");var Qt="createOrderPlane";var en=/\bfrom\s+['"](?:@?prisma\/client|@supabase\/|drizzle-orm|typeorm|knex|mongodb|pg|mysql2|mongoose|better-sqlite3|ioredis|redis|kysely|sequelize)['"]|require\(\s*['"](?:@?prisma\/client|pg|knex|typeorm|mongoose)/,rn=/\.(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))\s*\(|\bINSERT\s+INTO\b|\bUPDATE\s+[A-Za-z_][\w.]*\s+SET\b|\bDELETE\s+FROM\b/i;function te(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(te,"escapeRegExp");function ne(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}c(ne,"isArkOrderModuleSpecifier");function B(e,r){let t=1;for(let n=0;n<r&&n<e.length;n+=1)e[n]===`
8
- `&&(t+=1);return t}c(B,"lineAt");function G(e){return e.replace(/\/\*[\s\S]*?\*\//g,r=>r.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,r=>r.replace(/\/\/.*$/,t=>" ".repeat(t.length)))}c(G,"stripCommentsPreservingLines");function ur(e,r){let t=G(r),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(t))!==null;)n.push({file:e,line:B(r,o.index),callee:Qt});return n}c(ur,"extractArkOrderPlaneCallsFromSource");function dr(e,r){let t=G(r),n=[],s=/\.((?:update|patch|set|mutate))\s*\(/g,o;for(;(o=s.exec(t))!==null;){let i=o[1],a=t.slice(Math.max(0,o.index-80),o.index);!/\b(?:plane|orderPlane|order)\s*$/.test(a)&&!/\bcreateOrderPlane\b/.test(t)||n.push({file:e,line:B(r,o.index),method:i})}return n}c(dr,"extractArkOrderGenericUpdatesFromSource");function pr(e,r,t){if(t.length===0)return[];let n=G(r);if(!en.test(n)||!rn.test(n))return[];let s=[],o=new Set;for(let i of t){if(!i)continue;let a=new RegExp(`(?:\\b${te(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${te(i)}['"]\\s*:|[{\\,]\\s*${te(i)}\\s*[\\,}]|\\.${te(i)}\\s*=)`,"g"),l;for(;(l=a.exec(n))!==null;){let d=`${i}:${l.index}`;if(!o.has(d)){o.add(d),s.push({file:e,line:B(r,l.index),key:i});break}}}return s}c(pr,"extractArkOrderXiFieldWritesFromSource");function fr(e,r){let t=G(r),n=[],s=/(?:\b(?:xi|release|current|pattern|house)\w*|\.xi)\s*=\s*[^\n;]{0,160}?\bingest\s*\(/gi,o;for(;(o=s.exec(t))!==null;)n.push({file:e,line:B(r,o.index)});return n}c(fr,"extractArkOrderIngestWritesXiFromSource");function gr(e,r){let t=G(r),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(t))!==null;){let a=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];a.length!==0&&n.push({file:e,line:B(r,o.index),keyCount:a.length})}return n}c(gr,"extractArkOrderReleaseKeyCountsFromSource");var mr={"arkorder-missing-plane":"ARKORDER_MISSING_PLANE","arkorder-kernel-in-domain":"ARKORDER_KERNEL_IN_DOMAIN","arkorder-generic-update":"ARKORDER_GENERIC_UPDATE","arkorder-too-many-params":"ARKORDER_TOO_MANY_PARAMS","arkorder-ingest-writes-xi":"ARKORDER_INGEST_WRITES_XI","arkorder-xi-field-write":"ARKORDER_XI_FIELD_WRITE"};function tn(e,r=[]){let t=e.trim();return/^domain(?:model)?$/i.test(t)||/^domain(?=[A-Z_\-\s])/i.test(t)?!0:r.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(tn,"isDomainRoleLayer");function _(e,r,t,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:mr[r],sensor:r,message:s,file:t,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:mr[r],fromLayer:o?.fromLayer,target:o?.target})}}c(_,"finding");function nn(e){let r=e.arkOrder;if(!r)return{findings:[],completenessReasons:[]};let t=re(e.classification),n=[],s=r.planeRoots;if(r.mode==="enforced"&&s.length===0)n.push(_(r,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,t));else{let l=new Map;for(let d of e.planeRootHits){let u=l.get(d.matchedRoot)??[];u.push(d),l.set(d.matchedRoot,u)}for(let d of s){let u=l.get(d)??[];if(u.length===0){n.push(_(r,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(d)} matched no governed files and has no createOrderPlane factory.`,{target:d},t));continue}u.some(p=>p.hasPlaneFactory)||n.push(_(r,"arkorder-missing-plane",u[0].file,1,`ArkOrder plane root ${JSON.stringify(d)} has no createOrderPlane factory.`,{target:d},t))}}let o=new Map(e.layers.map(l=>[l.name,l.intentPrefixes??[]]));for(let l of e.dependencies){let d=l.specifier;if(!d||!ne(d))continue;let u=e.layerForFile(l.from);u&&tn(u,o.get(u)??[])&&n.push(_(r,"arkorder-kernel-in-domain",l.from,l.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:u,target:d},t))}for(let l of e.genericUpdates)n.push(_(r,"arkorder-generic-update",l.file,l.line,`Generic ${l.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:l.method},t));let i=r.xiKeys??[];i.length>r.maxXiKeys&&n.push(_(r,"arkorder-too-many-params","ark.config.json",1,`arkOrder.xiKeys has ${i.length} keys; maxXiKeys is ${r.maxXiKeys} (few slow modes).`,{target:String(i.length)},t));for(let l of e.releaseKeyCounts??[])l.keyCount<=r.maxXiKeys||n.push(_(r,"arkorder-too-many-params",l.file,l.line,`release() freezes ${l.keyCount} keys; maxXiKeys is ${r.maxXiKeys} (few slow modes).`,{target:String(l.keyCount)},t));for(let l of e.ingestWritesXi??[])n.push(_(r,"arkorder-ingest-writes-xi",l.file,l.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,t));let a=new Set(r.managedLayers);for(let l of i.length===0?[]:e.xiFieldWrites??[]){let d=e.layerForFile(l.file);!d||!a.has(d)||n.push(_(r,"arkorder-xi-field-write",l.file,l.line,`File writes slow key ${JSON.stringify(l.key)} through a persistence driver; route the field through ingest or a pattern change through proposeRelease.`,{fromLayer:d,target:l.key},t))}return n.sort((l,d)=>l.file.localeCompare(d.file)||l.ruleId.localeCompare(d.ruleId)||l.line-d.line),{findings:n,completenessReasons:[]}}c(nn,"evaluateArkOrderSensors");function yr(e){if(!e.arkOrder)return[];let r=ur(e.file,e.source),t=dr(e.file,e.source),n=e.arkOrder.xiKeys??[];return nn({arkOrder:e.arkOrder,layers:[],planeCalls:r,genericUpdates:t,planeRootHits:[],xiFieldWrites:pr(e.file,e.source,n),ingestWritesXi:fr(e.file,e.source),releaseKeyCounts:gr(e.file,e.source),dependencies:[],layerForFile:c(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}c(yr,"evaluateArkOrderEditorSensors");function sn(e){let r=e;return r.sourceCode?.getText?.()??r.getSourceCode?.()?.getText?.()??""}c(sn,"eslintSourceText");function Rr(e){function r(t){return{meta:{type:"problem",docs:{description:t},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let l=E(a,i.layers);return{ImportDeclaration(d){let u=typeof d.source?.value=="string"?d.source.value:"";if(t==="ARKORDER_KERNEL_IN_DOMAIN"){if(!ne(u)||l!=="DomainModel"&&!/^domain/i.test(l??""))return;e.reportAdapterDiagnostic(n,d,"denied",{ruleId:t,file:a,line:d.loc?.start?.line??1,message:"Domain-role layer imports arkgate/order; Domain stays plane-free."})}},Program(){if(t!=="ARKORDER_GENERIC_UPDATE")return;let d=sn(n),u=yr({arkOrder:i.arkOrder,file:a,source:d,fromLayer:l}).filter(p=>p.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let p of u)e.reportAdapterDiagnostic(n,{loc:{start:{line:p.line}}},"denied",{ruleId:p.ruleId,file:p.file,line:p.line,message:p.message})}}}}}return c(r,"createImportRule"),{noArkOrderKernelInDomain:r("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:r("ARKORDER_GENERIC_UPDATE")}}c(Rr,"createArkOrderEslintRules");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 r=e.getFilename();if(typeof r=="string"&&r.length>0)return r}catch{}return""}c(T,"lintedFilename");function w(e,r,t,n,s){let o=Ze({...n,line:n.line??r.loc?.start?.line,column:n.column??(typeof r.loc?.start?.column=="number"?r.loc.start.column+1:void 0)});return e.report({node:r,messageId:t,...s?{data:s}:{},diagnostic:o}),o}c(w,"reportAdapterDiagnostic");function M(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let r=m.default.dirname(m.default.resolve(e));for(;;){let t=m.default.join(r,"ark.config.json");if(C.default.existsSync(t))return t;let n=m.default.dirname(r);if(n===r)return null;r=n}}c(M,"findConfigPath");var hr=new Map;function $(e){if(!C.default.existsSync(e))return null;let r=C.default.readFileSync(e,"utf8"),t=hr.get(e);if(t?.source===r)return t.config;let n=ze(r,e).config;return hr.set(e,{source:r,config:n}),n}c($,"loadArkConfig");function z(e,r){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||r===s||r.startsWith(`${s}/`)})&&!Le(r,e)}c(z,"sourceIsInAnalysisScope");function Ar(e){let r=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.default.join(e,"index.ts"),m.default.join(e,"index.tsx"),m.default.join(e,"index.js")];for(let t of r)try{if(C.default.existsSync(t)&&C.default.statSync(t).isFile())return t}catch{}return null}c(Ar,"existingSourceFile");function kr(e){let r=m.default.resolve(e),t=null;for(;;){let d=m.default.join(r,"tsconfig.json");if(C.default.existsSync(d)){t=d;break}let u=m.default.dirname(r);if(u===r)break;r=u}if(!t)return{baseUrl:e,aliases:[]};let n=c(d=>{try{let u=C.default.readFileSync(d,"utf8");return u=u.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(u)}catch{return null}},"loadJsonc"),s=c((d,u)=>{if(u>4)return{};let p=n(d);if(!p)return{};let f=p.compilerOptions??{},g=f.baseUrl,y=f.paths,h=p.extends;if(typeof h=="string"&&!h.startsWith("@")){let A=m.default.resolve(m.default.dirname(d),h.endsWith(".json")?h:`${h}.json`);if(C.default.existsSync(A)){let k=s(A,u+1);g=g??k.baseUrl,y={...k.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(t,0),i=m.default.dirname(t),a=m.default.resolve(i,o.baseUrl||"."),l=[];for(let[d,u]of Object.entries(o.paths||{})){if(!Array.isArray(u)||u.length===0)continue;let p=d.replace(/\*$/,"");p&&l.push({from:p,to:String(u[0]).replace(/\*$/,"")})}return l.sort((d,u)=>u.from.length-d.from.length),{baseUrl:a,aliases:l}}c(kr,"readTsconfigPathAliases");function br(e,r){if(!r.startsWith("."))return null;let t=m.default.resolve(m.default.dirname(e),r);return Ar(t)}c(br,"resolveRelativeImport");function Se(e,r,t){if(!r)return null;if(r.startsWith("."))return br(e,r);let n=t||m.default.dirname(e),{baseUrl:s,aliases:o}=kr(n),i=o.find(l=>r.startsWith(l.from));if(!i)return null;let a=m.default.resolve(s,`${i.to}${r.slice(i.from.length)}`);return Ar(a)}c(Se,"resolveImportSpecifier");function ie(e){return typeof e?.value=="string"?e.value:void 0}c(ie,"stringValue");function xe(e){return e?.name??ie(e)}c(xe,"propertyName");function Ie(e){return e.sourceCode??e.getSourceCode?.()}c(Ie,"sourceCodeFor");function Er(e,r){let t=Ie(e)?.getScope?.(r);for(;t;){let n=t.references?.find(s=>s.identifier===r);if(n)return n;t=t.upper??void 0}}c(Er,"referenceFor");function W(e,r,t){let n=Er(e,r);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=Ie(e)?.getScope?.(r);for(;s;){let o=s.set?.get(t);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}c(W,"isLocallyBound");function on(e,r){let t=Er(e,r);return t?t.isValueReference!==!1:r.parent?.type==="VariableDeclarator"&&r.parent.init===r}c(on,"isValueIdentifierReference");function Sr(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 t=Sr(e.object),n=xe(e.property);if(!(!t||!n))return{root:t.root,segments:[...t.segments,n]}}c(Sr,"memberExpressionPath");function an(e){return xe(e.callee?.property)}c(an,"calleePropertyName");function xr(e,r){return e?.properties?.find(t=>xe(t.key)===r)}c(xr,"objectProperty");function se(e,r){return xr(e,r)!==void 0}c(se,"objectHasProperty");function ln(e){let r=xr(e,"metadata")?.value;return se(r,"source")}c(ln,"objectHasMetadataSource");function Ir(e){return an(e)==="publish"}c(Ir,"isPublishCall");function Ee(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let r=e.specifiers??[];return r.length===0?!1:r.every(t=>t.type==="ImportSpecifier")?r.every(t=>t.importKind==="type"):r.every(t=>t.exportKind==="type")}c(Ee,"declarationIsTypeOnly");function cn(e){let r=e;for(;r?.parent;)r=r.parent;return r?.type==="Program"?r:void 0}c(cn,"containingProgram");function un(e){let r=cn(e)?.body;if(!r)return!1;let t=!1;for(let n of r){if(n.type==="ImportDeclaration"){if(!Ee(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(!Ee(n))return!1;t=!0;continue}return!1}}return t}c(un,"sourceProgramExportsOnlyTypes");var Nr={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 r=T(e),t=M(r),n=t?$(t):null,s=t?m.default.dirname(t):null,o=c(i=>{let a=ie(i.source);if(a&&n&&s&&r){let l=m.default.isAbsolute(r)?r:m.default.resolve(r),d=m.default.relative(s,l).split(m.default.sep).join("/");if(!z(n,d))return;let u=E(d,n.layers);if(!u)return;let p=Se(l,a,s);if(!p)return;let f=m.default.relative(s,p).split(m.default.sep).join("/");if(f.startsWith(".."))return;let g=E(f,n.layers);if(!g)return;let y={fromPath:d,toPath:f,layers:n.layers},h=ce(n.rules,u,g,y);if(h||ue(n.rules,u,g,y)){let A=i.type?.startsWith("Export")?"export":"import",k=Ee(i),q=!!h?.peerIsolation,Z=k&&!q,v=h?.message??`${u} must not ${A} ${g}.`;w(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:d,fromLayer:u,toLayer:g,target:f,edgeKind:A,...q?{peerIsolation:!0}:{},...k?{typeOnly:!0}:{},...Z?{severity:"warning"}:{},...un(i)?{sourcePureTypeModule:!0}:{},message:Z?`${v} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:v},{fromLayer:u,toLayer:g,specifier:a})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},_r={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(r){let t=r.arguments?.[0],n=ie(t),s=me({publishCall:Ir(r),rawIntentName:n,objectHasIntent:se(t,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");w(e,r,"rawPublish",{...o,file:T(e)})}}}}},Cr={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(r){let t=r.arguments?.[0],n=r.arguments?.[2],o=me({publishCall:Ir(r),rawIntentName:ie(t),objectHasIntent:se(t,"intent"),arkPublishCandidate:!0,hasSource:ln(t)||se(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&w(e,r,"missingSource",{...o,file:T(e)})}}}},Or={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 r=T(e),t=e.options?.[0],n=M(r),s=n?$(n):null,o=n?m.default.dirname(n):null,i=null,a="this layer";if(s&&o&&r){let p=m.default.isAbsolute(r)?r:m.default.resolve(r),f=m.default.relative(o,p).split(m.default.sep).join("/");if(!z(s,f))return{};let g=s.layers?.find(y=>y.name===E(f,s.layers));g?.forbiddenGlobals?.length?(i=new Set(g.forbiddenGlobals),a=g.name):i=null}else t?.globals&&(i=new Set(t.globals));if(!i)return{};let l=typeof Ie(e)?.getScope=="function",d=c((p,f)=>{let g=m.default.isAbsolute(r)?r:m.default.resolve(r),y=o?m.default.relative(o,g).split(m.default.sep).join("/"):r;w(e,p,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:a,target:f,message:`${a} must not use the ambient global "${f}".`},{name:f,layer:a})},"report"),u=c((p,f,g,y)=>{if(g||typeof f!="string")return;let h=pe(f,i);if(!h)return;let A=m.default.isAbsolute(r)?r:m.default.resolve(r),k=o?m.default.relative(o,A).split(m.default.sep).join("/"):r;w(e,p,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:k,fromLayer:a,target:f,edgeKind:y,message:`${a} must not use module "${f}" because it is the import form of forbidden global "${h}".`},{layer:a,name:h,specifier:f,importKind:y})},"reportModule");return{MemberExpression(p){if(p.parent?.type==="MemberExpression"&&p.parent.object===p)return;let f=Sr(p);if(!f||W(e,f.root,f.segments[0]))return;let g=f.segments[0]==="globalThis",y=g?f.segments.slice(1):f.segments,h;for(let A=y.length;A>=(g?1:2);A-=1){let k=y.slice(0,A).join(".");if(i.has(k)){h=k;break}}h?d(p,h):!l&&i.has(f.segments[0])&&d(p,f.segments[0])},CallExpression(p){let f=p;if(f.callee?.type==="Identifier"&&f.callee.name==="require"&&f.arguments?.[0]?.type==="Literal"&&!W(e,p,"require")&&u(p,f.arguments[0].value,!1,"require"),l)return;let g=f.callee?.type==="Identifier"?f.callee.name:void 0;g&&i.has(g)&&d(p,g)},ImportDeclaration(p){let f=p,g=(f.specifiers??[]).filter(h=>h.type==="ImportSpecifier"),y=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(h=>h.importKind==="type");u(p,f.source?.value,f.importKind==="type"||y,"import")},ImportExpression(p){let f=p;f.source?.type==="Literal"&&u(p,f.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(p){let f=p;u(p,f.moduleReference?.expression?.value,f.importKind==="type"||f.isTypeOnly===!0,"require")},ExportNamedDeclaration(p){let f=p;if(!f.source)return;let g=f.specifiers??[],y=g.length>0&&g.every(h=>h.exportKind==="type");u(p,f.source.value,f.exportKind==="type"||y,"export")},ExportAllDeclaration(p){let f=p;u(p,f.source?.value,f.exportKind==="type","export")},NewExpression(p){if(l)return;let f=p.callee?.type==="Identifier"?p.callee.name:void 0;f&&i.has(f)&&d(p,f)},Identifier(p){!l||!p.name||!i.has(p.name)||!on(e,p)||W(e,p,p.name)||d(p,p.name)}}}},wr={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 r=T(e),t=M(r),n=t?$(t):null,s=t?m.default.dirname(t):null;if(!n||!s||!r)return{};let o=m.default.isAbsolute(r)?r:m.default.resolve(r),i=m.default.relative(s,o).split(m.default.sep).join("/");if(!z(n,i))return{};let a=n.layers?.find(u=>u.name===E(i,n.layers));if(!a)return{};let l=new Set(Fe(a));if(l.size===0)return{};let d=c((u,p,f,g)=>{if(f||typeof p!="string"||pe(p,a.forbiddenGlobals??[]))return;let y=De(p);!y||!l.has(y)||w(e,u,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:a.name,target:p,capability:y,edgeKind:g,message:`${a.name} denies the ${y} capability; found import of "${p}".`},{layer:a.name,capability:y,specifier:p})},"check");return{ImportDeclaration(u){let p=u,f=(p.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=f.length>0&&f.length===(p.specifiers??[]).length&&f.every(y=>y.importKind==="type");d(u,p.source?.value,p.importKind==="type"||g,"import")},ImportExpression(u){let p=u;p.source?.type==="Literal"&&d(u,p.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(u){let p=u;d(u,p.moduleReference?.expression?.value,p.importKind==="type"||p.isTypeOnly===!0,"require")},ExportNamedDeclaration(u){let p=u;if(!p.source)return;let f=p.specifiers??[],g=f.length>0&&f.every(y=>y.exportKind==="type");d(u,p.source.value,p.exportKind==="type"||g,"export")},ExportAllDeclaration(u){let p=u;d(u,p.source?.value,p.exportKind==="type","export")},CallExpression(u){let p=u;p.callee?.type==="Identifier"&&p.callee.name==="require"&&p.arguments?.[0]?.type==="Literal"&&!W(e,u,"require")&&d(u,p.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:vr,noArkRunDirectNew:Lr,noArkRunTransportBypass:Tr}=cr({findConfigPath:M,loadArkConfig:$,resolveImportSpecifier:Se,lintedFilename:T,sourceIsInAnalysisScope:z,isLocallyBound:W,reportAdapterDiagnostic:w});function dn(e,r){let t=m.default.dirname(m.default.resolve(e));return m.default.relative(t,m.default.resolve(r)).split(m.default.sep).join("/")}c(dn,"toProjectRelative");var{noArkOrderKernelInDomain:Dr,noArkOrderGenericUpdate:Fr}=Rr({findConfigPath:M,loadArkConfig:$,lintedFilename:T,sourceIsInAnalysisScope:z,reportAdapterDiagnostic:w,toProjectRelative:dn});var pn={"no-domain-infra-imports":Nr,"no-raw-event-publish":_r,"require-publish-source":Cr,"no-forbidden-globals":Or,"no-denied-capabilities":wr,"no-arkrun-kernel-in-domain":vr,"no-arkrun-direct-new":Lr,"no-arkrun-transport-bypass":Tr,"no-arkorder-kernel-in-domain":Dr,"no-arkorder-generic-update":Fr},oe={rules:pn};oe.configs={recommended:{plugins:{ark:oe},rules:{"ark/no-domain-infra-imports":"error","ark/no-raw-event-publish":"error","ark/require-publish-source":"error","ark/no-forbidden-globals":"error","ark/no-denied-capabilities":"error","ark/no-arkrun-kernel-in-domain":"error","ark/no-arkrun-direct-new":"error","ark/no-arkrun-transport-bypass":"error","ark/no-arkorder-kernel-in-domain":"error","ark/no-arkorder-generic-update":"error"}}};var fn=oe;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
7
+ `)),g=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(u),y=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(u),R=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(u)&&!y,A=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(u)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(u),k=[],Y=new Set(["if","match","when"]),H=/(?:^|\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,L;for(;(L=H.exec(u))!==null;){let b=L[1];if(Y.has(b))continue;let _e=L.index+L[0].length,ce=1,j=_e;for(;j<u.length&&ce>0;)u[j]==="{"?ce+=1:u[j]==="}"&&(ce-=1),j+=1;let Ce=u.slice(_e,j-1);if(!/this\.\w+\s*=/.test(Ce))continue;let Bt=/\b(ensureInvariants|assertInvariants|validate|publish|emit|raise|record)\b/.test(Ce);k.push({name:b,referencesGuardOrPublish:Bt})}let D=(u.match(/(?:^|\n)\s*(?:public\s+|private\s+|protected\s+)?(?:async\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*\(/g)??[]).length,X=(d.match(/(?:^|[\n;])\s*(?:public\s+)?(?!constructor|static|get|set|private|protected|readonly)[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/g)??[]).length,Vt=D<=1&&X>=2&&(f||p);r.push({file:e,className:o,exported:!0,hasPublicMutableFields:f||p,hasPublicSetters:g,hasPublicConstructor:R,hasStaticFactory:A,mutatingMethods:[...k],dataOnly:Vt})}return r}c(ke,"extractClassShapesFromSource");function Hr(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}}c(Hr,"normalizeExtraMergeTeethClassification");function ne(e){let t=Hr(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}c(ne,"extraMergeTeethAllowed");var jr=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],Vr=new Set(jr);function Br(e){return Vr.has(e)}c(Br,"isArkRunEditorSensor");var ct={"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"},Gr="ARKRUN_INTERACTION_NAME_INCOMPLETE";function pt(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.")})}c(pt,"isDomainRoleLayer");function Wr(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}c(Wr,"compareFindings");function _(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:ct[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:ct[t],fromLayer:o?.fromLayer,target:o?.target})}}c(_,"finding");function zr(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}c(zr,"bagForFile");function dt(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}c(dt,"emitKinds");function ut(e){return e==="subscribe"||e==="register-handler"}c(ut,"handleKinds");function qr(e){return e==="resolve"||e==="resolve-singleton"}c(qr,"dependKinds");function Zr(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(_(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,r)),n;let o=new Map;for(let i of t){let a=o.get(i.matchedRoot)??[];a.push(i),o.set(i.matchedRoot,a)}for(let i of s){let a=[...o.get(i)??[]].sort((u,d)=>u.file.localeCompare(d.file));if(a.length===0){n.push(_(e,"arkrun-missing-root","ark.config.json",1,`ArkRun kernel root ${JSON.stringify(i)} matched no governed files and has no createArkKernel factory.`,{target:i},r));continue}if(a.some(u=>u.hasKernelFactory))continue;let l=a[0];n.push(_(e,"arkrun-missing-root",l.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}c(Zr,"evaluateMissingRoot");function Yr(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let l=a.specifier;if(!l||!$(l))continue;let u=n(a.from);u&&pt(u,o.get(u)??[])&&i.push(_(e,"arkrun-kernel-in-domain",a.from,a.line,`${u} must not import kernel module ${JSON.stringify(l)}.`,{fromLayer:u,target:l},s))}return i}c(Yr,"evaluateKernelInDomain");function Xr(e,t,r,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let a=new Map(t.map(d=>[d.name,d.intentPrefixes??[]])),l=new Set(n.filter(d=>d.hasKernelFactory).map(d=>d.file)),u=[];for(let d of r){if(l.has(d.file))continue;let p=d.typeName;if(e.ignoreDirectNewForErrors!==!1&&(p.endsWith("Error")||p==="Error")||p.endsWith("DTO")||p.endsWith("VO"))continue;let f=s(d.file);!f||!i.has(f)||pt(f,a.get(f)??[])||u.push(_(e,"arkrun-direct-new",d.file,d.line,`${f} must not construct ${d.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:f,target:d.typeName},o))}return u}c(Xr,"evaluateDirectNew");function Jr(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let l of t){if(!dt(l.kind)&&!ut(l.kind)&&!qr(l.kind))continue;let u=n(l.file);if(!u||!a.has(u))continue;if(!l.nameLiteral){e.mode==="enforced"&&i.push({code:Gr,file:l.file,message:`ArkRun ${l.kind} call in ${l.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let d=zr(r,l.file);if(dt(l.kind)){if(d.raises.has(l.nameLiteral)||d.sends.has(l.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-emit",l.file,l.line,`Emit ${JSON.stringify(l.nameLiteral)} is not declared in raises or sends.`,{fromLayer:u,target:l.nameLiteral},s));continue}if(ut(l.kind)){if(d.reactsTo.has(l.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-handle",l.file,l.line,`Handle ${JSON.stringify(l.nameLiteral)} is not declared in reactsTo.`,{fromLayer:u,target:l.nameLiteral},s));continue}d.uses.has(l.nameLiteral)||o.push(_(e,"arkrun-undeclared-depend",l.file,l.line,`Depend ${JSON.stringify(l.nameLiteral)} is not declared in uses.`,{fromLayer:u,target:l.nameLiteral},s))}return{findings:o,completenessReasons:i}}c(Jr,"evaluateUndeclared");function Qr(e,t,r,n){let s=new Set(e.managedLayers);if(s.size===0)return[];let o=[];for(let i of t){if(i.typeOnly)continue;let a=i.specifier;if(!a||!it(a))continue;let l=r(i.from);!l||!s.has(l)||o.push(_(e,"arkrun-transport-bypass",i.from,i.line,`${l} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:l,target:a},n))}return o}c(Qr,"evaluateTransportBypass");function en(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=Jr(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...Zr(t,e.compositionRootHits,r),...Yr(t,e.layers,e.dependencies,e.layerForFile,r),...Xr(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...Qr(t,e.dependencies,e.layerForFile,r)].sort(Wr),o=[...n.completenessReasons].sort((i,a)=>{let l=`${i.code}\0${i.file??""}\0${i.message}`,u=`${a.code}\0${a.file??""}\0${a.message}`;return l<u?-1:l>u?1:0});return{findings:s,completenessReasons:o}}c(en,"evaluateArkRunSensors");function be(e){return{findings:en(e).findings.filter(r=>Br(r.sensor)),completenessReasons:[]}}c(be,"evaluateArkRunEditorSensors");function tn(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")}c(tn,"declarationIsTypeOnly");function gt(e){try{return Ee.default.existsSync(e)?Ee.default.readFileSync(e,"utf8"):null}catch{return null}}c(gt,"readUtf8");function ft(e,t){let r=e.lintedFilename(t),n=e.findConfigPath(r),s=n?e.loadArkConfig(n):null;if(!s?.arkRun||!n||!r)return null;let o=O.default.dirname(n),i=O.default.isAbsolute(r)?r:O.default.resolve(r),a=O.default.relative(o,i).split(O.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let l=E(a,s.layers);return l?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:l}:null}c(ft,"loadEditorFile");function rn(e,t,r){let n=re(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!x(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}c(rn,"compositionRootHitsForFile");function nn(e,t,r){let n=new Set(ke(t.relFile,r).map(s=>s.className));return lt(r,(s,o)=>{if($(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=O.default.relative(t.root,i).split(O.default.sep).join("/");if(a.startsWith(".."))return;let l=gt(i);if(l!==null)for(let u of ke(a,l))n.add(u.className)}),n}c(nn,"admittedTypeNamesForEditor");function mt(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}c(mt,"reportFinding");function sn(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}c(sn,"constructedTypeName");function on(e,t){return e.type?.startsWith("Export")?"export":t}c(on,"specifierEdgeKind");function an(e,t,r,n,s){let o=c((i,a,l,u)=>{if(typeof a!="string"||a.length===0)return;let d=i.loc?.start?.line??1,p={from:r.relFile,specifier:a,kind:u,typeOnly:l,line:d,resolution:"resolved-external"},{findings:f}=be({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[p],layerForFile:c(g=>g===r.relFile?r.fromLayer:E(g,r.config.layers),"layerForFile")});for(let g of f)g.sensor===n&&mt(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,l=(a.specifiers??[]).filter(d=>d.type==="ImportSpecifier"),u=l.length>0&&l.length===(a.specifiers??[]).length&&l.every(d=>d.importKind==="type");o(i,a.source?.value,a.importKind==="type"||u||tn(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let l=a.specifiers??[],u=l.length>0&&l.every(d=>d.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||u,on(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}c(an,"importListeners");function ln(e,t,r){let n=gt(r.absFile)??"",s=nn(e,r,n),o=Ae(r.relFile,n,s),{findings:i}=be({arkRun:r.extra,layers:r.config.layers,kernelCalls:re(r.relFile,n),managedNews:o,compositionRootHits:rn(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:c(l=>l===r.relFile?r.fromLayer:E(l,r.config.layers),"layerForFile")}),a=i.filter(l=>l.sensor==="arkrun-direct-new");return{NewExpression(l){let u=sn(l);if(!u)return;let d=l.loc?.start?.line,p=a.find(f=>f.target===u&&(d===void 0||f.line===d))??a.find(f=>f.target===u);p&&mt(e,t,l,"directNew",p,{fromLayer:p.fromLayer??r.fromLayer,typeName:u,target:p.target??u})}}}c(ln,"directNewListener");function yt(e){let t=c((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=ft(e,i);return a?an(e,i,a,r,s):{}}}),"createImportRule");return{noArkRunKernelInDomain:t("arkrun-kernel-in-domain","Disallow Domain-role imports of arkgate/runtime when arkRun is on (same sensor as ark-check).","kernelInDomain",'{{fromLayer}} must not import kernel module "{{specifier}}".'),noArkRunTransportBypass:t("arkrun-transport-bypass","Disallow homemade broker/queue/emitter imports in arkRun managed layers (same sensor as ark-check).","transportBypass",'{{fromLayer}} must not import broker/queue/emitter "{{specifier}}"; use the ArkRun kernel transport.'),noArkRunDirectNew:{meta:{type:"problem",docs:{description:"Disallow `new` of ArkRun-admitted types outside a composition-root factory (on-disk import/`new` envelope)."},messages:{directNew:"{{fromLayer}} must not construct {{typeName}} with new outside an ArkRun composition-root factory."},schema:[]},create(r){let n=ft(e,r);return n?ln(e,r,n):{}}}}}c(yt,"createArkRunEslintRules");var cn="createOrderPlane";var dn=/\bfrom\s+['"](?:@?prisma\/client|@supabase\/|drizzle-orm|typeorm|knex|mongodb|pg|mysql2|mongoose|better-sqlite3|ioredis|redis|kysely|sequelize)['"]|require\(\s*['"](?:@?prisma\/client|pg|knex|typeorm|mongoose)/,un=/\.(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))\s*\(|\bINSERT\s+INTO\b|\bUPDATE\s+[A-Za-z_][\w.]*\s+SET\b|\bDELETE\s+FROM\b/i;function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(se,"escapeRegExp");function oe(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}c(oe,"isArkOrderModuleSpecifier");function W(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
8
+ `&&(r+=1);return r}c(W,"lineAt");function z(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(z,"stripCommentsPreservingLines");function ht(e,t){let r=z(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:W(t,o.index),callee:cn});return n}c(ht,"extractArkOrderPlaneCallsFromSource");function Rt(e,t){let r=z(t),n=[],s=/\.((?:update|patch|set|mutate))\s*\(/g,o;for(;(o=s.exec(r))!==null;){let i=o[1],a=r.slice(Math.max(0,o.index-80),o.index);!/\b(?:plane|orderPlane|order)\s*$/.test(a)&&!/\bcreateOrderPlane\b/.test(r)||n.push({file:e,line:W(t,o.index),method:i})}return n}c(Rt,"extractArkOrderGenericUpdatesFromSource");function At(e,t,r){if(r.length===0)return[];let n=z(t);if(!dn.test(n)||!un.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${se(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${se(i)}['"]\\s*:|[{\\,]\\s*${se(i)}\\s*[\\,}]|\\.${se(i)}\\s*=)`,"g"),l;for(;(l=a.exec(n))!==null;){let u=`${i}:${l.index}`;if(!o.has(u)){o.add(u),s.push({file:e,line:W(t,l.index),key:i});break}}}return s}c(At,"extractArkOrderXiFieldWritesFromSource");function kt(e,t){let r=z(t),n=[],s=/(?:\b(?:xi|release|current|pattern|house)\w*|\.xi)\s*=\s*[^\n;]{0,160}?\bingest\s*\(/gi,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:W(t,o.index)});return n}c(kt,"extractArkOrderIngestWritesXiFromSource");function bt(e,t){let r=z(t),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(r))!==null;){let a=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];a.length!==0&&n.push({file:e,line:W(t,o.index),keyCount:a.length})}return n}c(bt,"extractArkOrderReleaseKeyCountsFromSource");var Et={"arkorder-missing-plane":"ARKORDER_MISSING_PLANE","arkorder-kernel-in-domain":"ARKORDER_KERNEL_IN_DOMAIN","arkorder-generic-update":"ARKORDER_GENERIC_UPDATE","arkorder-too-many-params":"ARKORDER_TOO_MANY_PARAMS","arkorder-ingest-writes-xi":"ARKORDER_INGEST_WRITES_XI","arkorder-xi-field-write":"ARKORDER_XI_FIELD_WRITE"};function pn(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(pn,"isDomainRoleLayer");function C(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:Et[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:Et[t],fromLayer:o?.fromLayer,target:o?.target})}}c(C,"finding");function fn(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(C(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,r));else{let l=new Map;for(let u of e.planeRootHits){let d=l.get(u.matchedRoot)??[];d.push(u),l.set(u.matchedRoot,d)}for(let u of s){let d=l.get(u)??[];if(d.length===0){n.push(C(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(u)} matched no governed files and has no createOrderPlane factory.`,{target:u},r));continue}d.some(p=>p.hasPlaneFactory)||n.push(C(t,"arkorder-missing-plane",d[0].file,1,`ArkOrder plane root ${JSON.stringify(u)} has no createOrderPlane factory.`,{target:u},r))}}let o=new Map(e.layers.map(l=>[l.name,l.intentPrefixes??[]]));for(let l of e.dependencies){let u=l.specifier;if(!u||!oe(u))continue;let d=e.layerForFile(l.from);d&&pn(d,o.get(d)??[])&&n.push(C(t,"arkorder-kernel-in-domain",l.from,l.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:d,target:u},r))}for(let l of e.genericUpdates)n.push(C(t,"arkorder-generic-update",l.file,l.line,`Generic ${l.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:l.method},r));let i=t.xiKeys??[];i.length>t.maxXiKeys&&n.push(C(t,"arkorder-too-many-params","ark.config.json",1,`arkOrder.xiKeys has ${i.length} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(i.length)},r));for(let l of e.releaseKeyCounts??[])l.keyCount<=t.maxXiKeys||n.push(C(t,"arkorder-too-many-params",l.file,l.line,`release() freezes ${l.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(l.keyCount)},r));for(let l of e.ingestWritesXi??[])n.push(C(t,"arkorder-ingest-writes-xi",l.file,l.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let a=new Set(t.managedLayers);for(let l of i.length===0?[]:e.xiFieldWrites??[]){let u=e.layerForFile(l.file);!u||!a.has(u)||n.push(C(t,"arkorder-xi-field-write",l.file,l.line,`File writes slow key ${JSON.stringify(l.key)} through a persistence driver; route the field through ingest or a pattern change through proposeRelease.`,{fromLayer:u,target:l.key},r))}return n.sort((l,u)=>l.file.localeCompare(u.file)||l.ruleId.localeCompare(u.ruleId)||l.line-u.line),{findings:n,completenessReasons:[]}}c(fn,"evaluateArkOrderSensors");function St(e){if(!e.arkOrder)return[];let t=ht(e.file,e.source),r=Rt(e.file,e.source),n=e.arkOrder.xiKeys??[];return fn({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:At(e.file,e.source,n),ingestWritesXi:kt(e.file,e.source),releaseKeyCounts:bt(e.file,e.source),dependencies:[],layerForFile:c(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}c(St,"evaluateArkOrderEditorSensors");function gn(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}c(gn,"eslintSourceText");function It(e){function t(r){return{meta:{type:"problem",docs:{description:r},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let l=E(a,i.layers);return{ImportDeclaration(u){let d=typeof u.source?.value=="string"?u.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!oe(d)||l!=="DomainModel"&&!/^domain/i.test(l??""))return;e.reportAdapterDiagnostic(n,u,"denied",{ruleId:r,file:a,line:u.loc?.start?.line??1,message:"Domain-role layer imports arkgate/order; Domain stays plane-free."})}},Program(){if(r!=="ARKORDER_GENERIC_UPDATE")return;let u=gn(n),d=St({arkOrder:i.arkOrder,file:a,source:u,fromLayer:l}).filter(p=>p.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let p of d)e.reportAdapterDiagnostic(n,{loc:{start:{line:p.line}}},"denied",{ruleId:p.ruleId,file:p.file,line:p.line,message:p.message})}}}}}return c(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}c(It,"createArkOrderEslintRules");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""}c(T,"lintedFilename");function v(e,t,r,n,s){let o=rt({...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}c(v,"reportAdapterDiagnostic");function M(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=m.default.dirname(m.default.resolve(e));for(;;){let r=m.default.join(t,"ark.config.json");if(w.default.existsSync(r))return r;let n=m.default.dirname(t);if(n===t)return null;t=n}}c(M,"findConfigPath");var xt=new Map;function U(e){if(!w.default.existsSync(e))return null;let t=w.default.readFileSync(e,"utf8"),r=xt.get(e);if(r?.source===t)return r.config;let n=et(t,e).config;return xt.set(e,{source:t,config:n}),n}c(U,"loadArkConfig");function Z(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!Me(t,e)}c(Z,"sourceIsInAnalysisScope");function Nt(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.default.join(e,"index.ts"),m.default.join(e,"index.tsx"),m.default.join(e,"index.js")];for(let r of t)try{if(w.default.existsSync(r)&&w.default.statSync(r).isFile())return r}catch{}return null}c(Nt,"existingSourceFile");function _t(e){let t=m.default.resolve(e),r=null;for(;;){let u=m.default.join(t,"tsconfig.json");if(w.default.existsSync(u)){r=u;break}let d=m.default.dirname(t);if(d===t)break;t=d}if(!r)return{baseUrl:e,aliases:[]};let n=c(u=>{try{let d=w.default.readFileSync(u,"utf8");return d=d.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(d)}catch{return null}},"loadJsonc"),s=c((u,d)=>{if(d>4)return{};let p=n(u);if(!p)return{};let f=p.compilerOptions??{},g=f.baseUrl,y=f.paths,R=p.extends;if(typeof R=="string"&&!R.startsWith("@")){let A=m.default.resolve(m.default.dirname(u),R.endsWith(".json")?R:`${R}.json`);if(w.default.existsSync(A)){let k=s(A,d+1);g=g??k.baseUrl,y={...k.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.default.dirname(r),a=m.default.resolve(i,o.baseUrl||"."),l=[];for(let[u,d]of Object.entries(o.paths||{})){if(!Array.isArray(d)||d.length===0)continue;let p=u.replace(/\*$/,"");p&&l.push({from:p,to:String(d[0]).replace(/\*$/,"")})}return l.sort((u,d)=>d.from.length-u.from.length),{baseUrl:a,aliases:l}}c(_t,"readTsconfigPathAliases");function Ct(e,t){if(!t.startsWith("."))return null;let r=m.default.resolve(m.default.dirname(e),t);return Nt(r)}c(Ct,"resolveRelativeImport");function Ie(e,t,r){if(!t)return null;if(t.startsWith("."))return Ct(e,t);let n=r||m.default.dirname(e),{baseUrl:s,aliases:o}=_t(n),i=o.find(l=>t.startsWith(l.from));if(!i)return null;let a=m.default.resolve(s,`${i.to}${t.slice(i.from.length)}`);return Nt(a)}c(Ie,"resolveImportSpecifier");function le(e){return typeof e?.value=="string"?e.value:void 0}c(le,"stringValue");function xe(e){return e?.name??le(e)}c(xe,"propertyName");function Ne(e){return e.sourceCode??e.getSourceCode?.()}c(Ne,"sourceCodeFor");function wt(e,t){let r=Ne(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}c(wt,"referenceFor");function q(e,t,r){let n=wt(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=Ne(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}c(q,"isLocallyBound");function mn(e,t){let r=wt(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}c(mn,"isValueIdentifierReference");function Ot(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=Ot(e.object),n=xe(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}c(Ot,"memberExpressionPath");function yn(e){return xe(e.callee?.property)}c(yn,"calleePropertyName");function vt(e,t){return e?.properties?.find(r=>xe(r.key)===t)}c(vt,"objectProperty");function ie(e,t){return vt(e,t)!==void 0}c(ie,"objectHasProperty");function hn(e){let t=vt(e,"metadata")?.value;return ie(t,"source")}c(hn,"objectHasMetadataSource");function Lt(e){return yn(e)==="publish"}c(Lt,"isPublishCall");function Se(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")}c(Se,"declarationIsTypeOnly");function Rn(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}c(Rn,"containingProgram");function An(e){let t=Rn(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!Se(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(!Se(n))return!1;r=!0;continue}return!1}}return r}c(An,"sourceProgramExportsOnlyTypes");var Tt={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=M(t),n=r?U(r):null,s=r?m.default.dirname(r):null,o=c(i=>{let a=le(i.source);if(a&&n&&s&&t){let l=m.default.isAbsolute(t)?t:m.default.resolve(t),u=m.default.relative(s,l).split(m.default.sep).join("/");if(!Z(n,u))return;let d=E(u,n.layers);if(!d)return;let p=Ie(l,a,s);if(!p)return;let f=m.default.relative(s,p).split(m.default.sep).join("/");if(f.startsWith(".."))return;let g=E(f,n.layers);if(!g)return;let y={fromPath:u,toPath:f,layers:n.layers},R=ue(n.rules,d,g,y),A=R?.rule;if(A){let k=i.type?.startsWith("Export")?"export":"import",Y=Se(i),H=!!A?.peerIsolation,L=Y&&!H,D=H&&R?Ke(R.peerIsolationReason??"cross-slice",{fromPath:u,toPath:f,fromSlice:R.fromSlice,toSlice:R.toSlice}):void 0,X=A?.message?D?`${A.message} (${D})`:A.message:D?`${d} must not ${k} another slice of ${g} (${u} \u2192 ${f}): ${D}`:`${d} must not ${k} ${g}.`;v(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:u,fromLayer:d,toLayer:g,target:f,edgeKind:k,...H?{peerIsolation:!0}:{},...Y?{typeOnly:!0}:{},...L?{severity:"warning"}:{},...An(i)?{sourcePureTypeModule:!0}:{},message:L?`${X} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:X},{fromLayer:d,toLayer:g,specifier:a})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},Dt={meta:{type:"problem",docs:{description:"Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings."},messages:{rawPublish:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=le(r),s=ye({publishCall:Lt(t),rawIntentName:n,objectHasIntent:ie(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");v(e,t,"rawPublish",{...o,file:T(e)})}}}}},Ft={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=ye({publishCall:Lt(t),rawIntentName:le(r),objectHasIntent:ie(r,"intent"),arkPublishCandidate:!0,hasSource:hn(r)||ie(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&v(e,t,"missingSource",{...o,file:T(e)})}}}},Pt={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=M(t),s=n?U(n):null,o=n?m.default.dirname(n):null,i=null,a="this layer";if(s&&o&&t){let p=m.default.isAbsolute(t)?t:m.default.resolve(t),f=m.default.relative(o,p).split(m.default.sep).join("/");if(!Z(s,f))return{};let g=s.layers?.find(y=>y.name===E(f,s.layers));g?.forbiddenGlobals?.length?(i=new Set(g.forbiddenGlobals),a=g.name):i=null}else r?.globals&&(i=new Set(r.globals));if(!i)return{};let l=typeof Ne(e)?.getScope=="function",u=c((p,f)=>{let g=m.default.isAbsolute(t)?t:m.default.resolve(t),y=o?m.default.relative(o,g).split(m.default.sep).join("/"):t;v(e,p,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:a,target:f,message:`${a} must not use the ambient global "${f}".`},{name:f,layer:a})},"report"),d=c((p,f,g,y)=>{if(g||typeof f!="string")return;let R=fe(f,i);if(!R)return;let A=m.default.isAbsolute(t)?t:m.default.resolve(t),k=o?m.default.relative(o,A).split(m.default.sep).join("/"):t;v(e,p,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:k,fromLayer:a,target:f,edgeKind:y,message:`${a} must not use module "${f}" because it is the import form of forbidden global "${R}".`},{layer:a,name:R,specifier:f,importKind:y})},"reportModule");return{MemberExpression(p){if(p.parent?.type==="MemberExpression"&&p.parent.object===p)return;let f=Ot(p);if(!f||q(e,f.root,f.segments[0]))return;let g=f.segments[0]==="globalThis",y=g?f.segments.slice(1):f.segments,R;for(let A=y.length;A>=(g?1:2);A-=1){let k=y.slice(0,A).join(".");if(i.has(k)){R=k;break}}R?u(p,R):!l&&i.has(f.segments[0])&&u(p,f.segments[0])},CallExpression(p){let f=p;if(f.callee?.type==="Identifier"&&f.callee.name==="require"&&f.arguments?.[0]?.type==="Literal"&&!q(e,p,"require")&&d(p,f.arguments[0].value,!1,"require"),l)return;let g=f.callee?.type==="Identifier"?f.callee.name:void 0;g&&i.has(g)&&u(p,g)},ImportDeclaration(p){let f=p,g=(f.specifiers??[]).filter(R=>R.type==="ImportSpecifier"),y=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(R=>R.importKind==="type");d(p,f.source?.value,f.importKind==="type"||y,"import")},ImportExpression(p){let f=p;f.source?.type==="Literal"&&d(p,f.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(p){let f=p;d(p,f.moduleReference?.expression?.value,f.importKind==="type"||f.isTypeOnly===!0,"require")},ExportNamedDeclaration(p){let f=p;if(!f.source)return;let g=f.specifiers??[],y=g.length>0&&g.every(R=>R.exportKind==="type");d(p,f.source.value,f.exportKind==="type"||y,"export")},ExportAllDeclaration(p){let f=p;d(p,f.source?.value,f.exportKind==="type","export")},NewExpression(p){if(l)return;let f=p.callee?.type==="Identifier"?p.callee.name:void 0;f&&i.has(f)&&u(p,f)},Identifier(p){!l||!p.name||!i.has(p.name)||!mn(e,p)||q(e,p,p.name)||u(p,p.name)}}}},Kt={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=M(t),n=r?U(r):null,s=r?m.default.dirname(r):null;if(!n||!s||!t)return{};let o=m.default.isAbsolute(t)?t:m.default.resolve(t),i=m.default.relative(s,o).split(m.default.sep).join("/");if(!Z(n,i))return{};let a=n.layers?.find(d=>d.name===E(i,n.layers));if(!a)return{};let l=new Set(je(a));if(l.size===0)return{};let u=c((d,p,f,g)=>{if(f||typeof p!="string"||fe(p,a.forbiddenGlobals??[]))return;let y=He(p);!y||!l.has(y)||v(e,d,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:a.name,target:p,capability:y,edgeKind:g,message:`${a.name} denies the ${y} capability; found import of "${p}".`},{layer:a.name,capability:y,specifier:p})},"check");return{ImportDeclaration(d){let p=d,f=(p.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=f.length>0&&f.length===(p.specifiers??[]).length&&f.every(y=>y.importKind==="type");u(d,p.source?.value,p.importKind==="type"||g,"import")},ImportExpression(d){let p=d;p.source?.type==="Literal"&&u(d,p.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let p=d;u(d,p.moduleReference?.expression?.value,p.importKind==="type"||p.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let p=d;if(!p.source)return;let f=p.specifiers??[],g=f.length>0&&f.every(y=>y.exportKind==="type");u(d,p.source.value,p.exportKind==="type"||g,"export")},ExportAllDeclaration(d){let p=d;u(d,p.source?.value,p.exportKind==="type","export")},CallExpression(d){let p=d;p.callee?.type==="Identifier"&&p.callee.name==="require"&&p.arguments?.[0]?.type==="Literal"&&!q(e,d,"require")&&u(d,p.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:$t,noArkRunDirectNew:Mt,noArkRunTransportBypass:Ut}=yt({findConfigPath:M,loadArkConfig:U,resolveImportSpecifier:Ie,lintedFilename:T,sourceIsInAnalysisScope:Z,isLocallyBound:q,reportAdapterDiagnostic:v});function kn(e,t){let r=m.default.dirname(m.default.resolve(e));return m.default.relative(r,m.default.resolve(t)).split(m.default.sep).join("/")}c(kn,"toProjectRelative");var{noArkOrderKernelInDomain:Ht,noArkOrderGenericUpdate:jt}=It({findConfigPath:M,loadArkConfig:U,lintedFilename:T,sourceIsInAnalysisScope:Z,reportAdapterDiagnostic:v,toProjectRelative:kn});var bn={"no-domain-infra-imports":Tt,"no-raw-event-publish":Dt,"require-publish-source":Ft,"no-forbidden-globals":Pt,"no-denied-capabilities":Kt,"no-arkrun-kernel-in-domain":$t,"no-arkrun-direct-new":Mt,"no-arkrun-transport-bypass":Ut,"no-arkorder-kernel-in-domain":Ht,"no-arkorder-generic-update":jt},ae={rules:bn};ae.configs={recommended:{plugins:{ark:ae},rules:{"ark/no-domain-infra-imports":"error","ark/no-raw-event-publish":"error","ark/require-publish-source":"error","ark/no-forbidden-globals":"error","ark/no-denied-capabilities":"error","ark/no-arkrun-kernel-in-domain":"error","ark/no-arkrun-direct-new":"error","ark/no-arkrun-transport-bypass":"error","ark/no-arkorder-kernel-in-domain":"error","ark/no-arkorder-generic-update":"error"}}};var En=ae;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
@@ -1,4 +1,4 @@
1
- import { A as ArkConfig } from '../configTypes-dNJ2C0yx.js';
1
+ import { A as ArkConfig } from '../configTypes-dy5PfTqS.js';
2
2
 
3
3
  type RuleContext$1 = {
4
4
  report(descriptor: Record<string, unknown>): void;
@@ -67,9 +67,42 @@ type EdgeRule = {
67
67
  * When omitted, inferred from the layer's glob patterns (segment before `**`/`*`).
68
68
  */
69
69
  sliceFolders?: string[];
70
+ /**
71
+ * Roots the repo declares **shared on purpose** (`["ui", "hooks", "lib/permissions"]`).
72
+ *
73
+ * A file under a declared shared root is *evidence*, not an unclassifiable path:
74
+ * the repo has said this code belongs to no slice, so peerIsolation stops
75
+ * reporting our inability to place it as a violation of their design.
76
+ * Matched as a contiguous run of path segments anywhere in the repo-relative
77
+ * path (so `ui` covers `src/ui/button.tsx`), case-insensitively; a root
78
+ * containing `*` is matched as a glob. A path that still resolves to a slice
79
+ * id keeps its slice — a shared root never shadows a real slice.
80
+ *
81
+ * Note: this only relaxes the *unclassifiable* branch. A genuine cross-slice
82
+ * edge between two different slices still denies.
83
+ */
84
+ sharedRoots?: string[];
85
+ /**
86
+ * Directed cross-slice edges the repo declares on purpose — same shape as the
87
+ * layer edges in `rules[]`, but between slice ids:
88
+ * `[{ from: "features/checkout", to: "features/catalog" }]`.
89
+ *
90
+ * Each entry allows exactly one direction. Slice ids match either fully
91
+ * (`features/auth`) or by bare slice name (`auth`), case-insensitively — a bare
92
+ * name matches that name under *any* slice folder, so write the full id in a repo
93
+ * with several slice parents. Everything not declared still denies.
94
+ */
95
+ allowedCrossSlice?: CrossSliceEdge[];
70
96
  /** Optional override message for scanners / write-gate. */
71
97
  message?: string;
72
98
  };
99
+ /** A directed slice-to-slice edge the repo declares on purpose (peerIsolation). */
100
+ type CrossSliceEdge = {
101
+ /** Importing slice id (`features/checkout`) or bare slice name (`checkout`). */
102
+ from: string;
103
+ /** Imported slice id or bare slice name. */
104
+ to: string;
105
+ };
73
106
  /** Options for path-aware edge checks (peer isolation). */
74
107
  type EdgeCheckOptions = {
75
108
  /** Repo-relative path of the importing file. */