arkgate 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,15 +5,41 @@ in the immutable pre-2.0 archive linked below.
5
5
 
6
6
  ## Unreleased
7
7
 
8
- ## 4.2.0 — 2026-07-30 (prepared)
8
+ ## 4.2.1 — 2026-08-08 (prepared)
9
+
10
+ **Patch** over 4.2.0. Next.js **16.3** field compatibility: root `proxy.ts` (Next 16 network-boundary
11
+ rename of middleware) is scanned and classified; eval fixtures and release-surface pins track
12
+ `next@16.3.0`. **No required config migration.** Codex remains advisory at write time.
13
+ **Status: prepared** (`arkgate@4.2.1` not published yet).
14
+
15
+ ### Fixed
16
+
17
+ - **Next 16 root `proxy.ts` include:** Next overlay adds existing root (and `src/`)
18
+ `proxy.ts` / `proxy.js` / classic `middleware.ts` / `middleware.js` to `include` so layer
19
+ patterns actually scan them. Patterns alone left package-root `proxy.ts` outside
20
+ `include: ['src','app']` and therefore ungoverned on typical App Router trees.
21
+ - **Physical-cohesion framework names:** treat `proxy` like `middleware` / `route` / `page` as
22
+ framework-owned (Next 16 rename).
23
+
24
+ ### Changed
25
+
26
+ - **Eval Next pins:** `eval/cases/next-core-imports-db` and monorepo frontend fixture use
27
+ **next@16.3.0** (was 15.5.21); q06 release-surface pin accepts 16.x or patched 15.5.21+.
28
+
29
+ ### Security (carried from main)
30
+
31
+ - Transitive overrides remain: `fast-uri` **3.1.5**, `brace-expansion` **2.1.4** / **5.0.9**,
32
+ `nanoid` **3.3.18**.
33
+
34
+ ## 4.2.0 — 2026-07-31 (published)
9
35
 
10
36
  **Minor** over 4.1.1. Phase WI — workspace identity, activation truth, and safe multi-repository
11
37
  skill installation. Adds a stable MCP project-identity contract, exact-root `ark_identity`
12
38
  handshake, and project-bound `ark_manifest`; cross-project/config paths fail before Layers or
13
39
  ArkRules analysis; Codex setup distinguishes files configured on disk from a runtime observed
14
40
  after restart. **No required config migration.** Legacy MCP calls remain callable but explicitly
15
- non-authoritative until bound. Codex remains advisory at write time. **Status: prepared**
16
- (`arkgate@4.2.0` not published yet).
41
+ non-authoritative until bound. Codex remains advisory at write time. **Status: published**
42
+ (`arkgate@4.2.0` on npm `latest`).
17
43
 
18
44
  ### Added
19
45
 
@@ -89,7 +115,7 @@ non-authoritative until bound. Codex remains advisory at write time. **Status: p
89
115
  feedback + public-lane claims audit). Honesty and doctor/CI evidence taxonomy; first-push-safe CI
90
116
  base-ref; report `.gitignore` coverage without defeating `!` exceptions. **No required config
91
117
  migration.** Does not invent hard-write for Codex/Cursor/OpenCode. Does not close Z09 / RB-11.
92
- **Status: published** (`arkgate@4.1.1` on npm `latest`).
118
+ **Status: published** (`arkgate@4.1.1`; superseded by 4.2.0 on `latest`).
93
119
 
94
120
  ### Added
95
121
 
package/README.md CHANGED
@@ -16,9 +16,9 @@ and makes sure a “green” check means something real.
16
16
 
17
17
  </div>
18
18
 
19
- > **ArkGate 4.2.0** is prepared (workspace identity + safe multi-repo skills);
20
- > **4.1.1** remains on npm `latest` until publication.
21
- > [4.2.0 candidate](docs/releases/4.2.0.md) · [4.1.1](docs/releases/4.1.1.md) · [4.1.0](docs/releases/4.1.0.md) · [Docs hub](docs/README.md) · [Product voice](docs/product-voice.md)
19
+ > **ArkGate 4.2.1** is prepared (Next.js 16.3 root `proxy.ts` scan + fixture pins);
20
+ > **4.2.0** remains on npm `latest` until publication.
21
+ > [4.2.1 candidate](docs/releases/4.2.1.md) · [4.2.0](docs/releases/4.2.0.md) · [4.1.1](docs/releases/4.1.1.md) · [Docs hub](docs/README.md) · [Product voice](docs/product-voice.md)
22
22
 
23
23
  ---
24
24
 
@@ -194,8 +194,9 @@ for real systems. Details: [docs/production-hardening.md](docs/production-harden
194
194
  | Config · package surface · TS | [configuration](docs/configuration.md) · [package-surface](docs/package-surface.md) · [typescript-support](docs/typescript-support.md) |
195
195
  | Brownfield | [docs/brownfield-adoption.md](docs/brownfield-adoption.md) |
196
196
  | Security | [SECURITY.md](SECURITY.md) |
197
- | Prepared candidate (4.2.0) | [docs/releases/4.2.0.md](docs/releases/4.2.0.md) · [CHANGELOG](CHANGELOG.md) |
198
- | Current published (4.1.1) | [docs/releases/4.1.1.md](docs/releases/4.1.1.md) |
197
+ | Prepared candidate (4.2.1) | [docs/releases/4.2.1.md](docs/releases/4.2.1.md) · [CHANGELOG](CHANGELOG.md) |
198
+ | Current published (4.2.0) | [docs/releases/4.2.0.md](docs/releases/4.2.0.md) |
199
+ | Previous (4.1.1) | [docs/releases/4.1.1.md](docs/releases/4.1.1.md) |
199
200
  | Previous (4.1.0) | [docs/releases/4.1.0.md](docs/releases/4.1.0.md) |
200
201
  | Previous patch (4.0.1) | [docs/releases/4.0.1.md](docs/releases/4.0.1.md) |
201
202
  | Previous (4.0.0) | [docs/releases/4.0.0.md](docs/releases/4.0.0.md) |
@@ -117,10 +117,11 @@ export function applyFrameworkLayoutOverlays(config, root) {
117
117
  include: [...(config.include ?? ['src'])],
118
118
  };
119
119
 
120
- // Ensure include covers where framework code actually lives.
121
- const ensureInclude = (dir) => {
122
- if (!next.include.includes(dir) && fs.existsSync(path.join(root, dir))) {
123
- next.include.push(dir);
120
+ // Ensure include covers where framework code actually lives (dirs or root files).
121
+ // Single-file entries (e.g. Next 16 root `proxy.ts`) are valid scan roots — see scan-files.mjs.
122
+ const ensureInclude = (entry) => {
123
+ if (!next.include.includes(entry) && fs.existsSync(path.join(root, entry))) {
124
+ next.include.push(entry);
124
125
  }
125
126
  };
126
127
 
@@ -206,6 +207,17 @@ export function applyFrameworkLayoutOverlays(config, root) {
206
207
  ensureInclude('src');
207
208
  ensureInclude('app');
208
209
  ensureInclude('pages');
210
+ // Next network boundary files live at package root (or under src/). Layer patterns
211
+ // alone do not scan them unless they appear in `include` — Next 16 ships `proxy.ts`
212
+ // as the middleware rename; classic `middleware.ts` remains supported.
213
+ ensureInclude('proxy.ts');
214
+ ensureInclude('proxy.js');
215
+ ensureInclude('middleware.ts');
216
+ ensureInclude('middleware.js');
217
+ ensureInclude('src/proxy.ts');
218
+ ensureInclude('src/proxy.js');
219
+ ensureInclude('src/middleware.ts');
220
+ ensureInclude('src/middleware.js');
209
221
  mergeLayerPatterns(next, 'PresentationAdapters', [
210
222
  'src/app/**',
211
223
  'src/pages/**',
@@ -24,7 +24,8 @@ const MAX_FINDINGS = 5;
24
24
  const MAX_ANCHORS = 4;
25
25
  const MAX_MOVE_SAMPLE = 5;
26
26
 
27
- const FRAMEWORK_FILES = /^(route|page|layout|index|loading|error|template|default|not-found|middleware|actions?|handler)$/i;
27
+ // `proxy` = Next.js 16 network-boundary rename of middleware (still framework-owned).
28
+ const FRAMEWORK_FILES = /^(route|page|layout|index|loading|error|template|default|not-found|middleware|proxy|actions?|handler)$/i;
28
29
  const SKIP_SEGMENT = /^(\[.*\]|\(.*\)|src|app|apps|api|lib|libs|pages|packages|modules|components|utils|helpers|hooks|server|client|shared|common|__tests__|tests?|e2e|examples?|dist|build)$/i;
29
30
  const NOISE_TOKEN = /^(use|api|get|set|app|lib|the|new)$/;
30
31
  /** ADR 0010 D7 — framework-owned anchors never move. */
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ot=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var rr=Object.prototype.hasOwnProperty;var sr=(e,t)=>{for(var n in t)Ot(e,n,{get:t[n],enumerable:!0})},ir=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of nr(t))!rr.call(e,s)&&s!==n&&Ot(e,s,{get:()=>t[s],enumerable:!(r=tr(t,s))||r.enumerable});return e};var ar=e=>ir(Ot({},"__esModule",{value:!0}),e);var ws={};sr(ws,{ANALYSIS_IR_SCHEMA_VERSION:()=>lt,ARK_ANALYSIS_RESULT_SCHEMA:()=>on,ARK_ANALYSIS_RESULT_SCHEMA_VERSION:()=>sn,ARK_CONFIG_SCHEMA:()=>rt,ARK_CONFIG_SCHEMA_VERSION:()=>vn,ARK_DESIGN_DELTA_SCHEMA_VERSION:()=>er,ARK_ENFORCEMENT_STATE_SCHEMA_VERSION:()=>Qn,ARK_PROJECT_IDENTITY_SCHEMA:()=>cn,ARK_PROJECT_IDENTITY_SCHEMA_URL:()=>Tt,ARK_PROJECT_IDENTITY_SCHEMA_VERSION:()=>ln,ARK_RULES_SCHEMA:()=>dt,ARK_RULES_SCHEMA_VERSION:()=>$n,ARK_RULE_SENSORS:()=>Wt,EffectiveContractError:()=>Ge,POLICY_DELTA_SCHEMA_VERSION:()=>ht,PROJECT_BINDING_SCHEMA:()=>wt,PROJECT_EXPECTATION_SCHEMA:()=>Pt,RESOLVED_CANDIDATE_FACTS_SCHEMA:()=>ot,RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION:()=>re,analyzeArchitectureConvergence:()=>de,analyzeChange:()=>ze,analyzePolicyDelta:()=>Jt,analyzeProject:()=>Ee,analyzeResolvedProject:()=>Se,buildArkRuleFileHints:()=>St,buildEffectiveArkRules:()=>pt,buildRulesInventory:()=>Zn,canPromoteInvariant:()=>yt,classifyArkPolicyDelta:()=>At,collectAnalysisConfigWarnings:()=>Ye,collectEmptyAppliesToFindings:()=>Ct,collectForbiddenCapabilityUses:()=>le,createAICodeGate:()=>Bt,createAdapterResult:()=>an,createArchitectureProfile:()=>Me,createArchitectureProfileFromArkConfig:()=>zt,createElevenLayerArkConfig:()=>Kt,createProjectId:()=>dn,createProjectIdentity:()=>pn,createResolvedCandidateFacts:()=>at,deriveArkRuleFileHints:()=>Qt,detectArchitectureCycles:()=>It,deterministicHash:()=>P,effectiveContractPolicyPayload:()=>ut,elevenLayerProfile:()=>Fe,emptyEffectiveArkRules:()=>ie,evaluateArchitectureGraph:()=>ye,evaluateArkRuleSensors:()=>Et,evaluateInvariantCoverage:()=>ft,explainViolation:()=>Zt,extractClassShapesFromSource:()=>qn,extractSemanticDependencies:()=>oe,inventoryToExtractionCard:()=>Xn,loadArkConfigContract:()=>Ne,loadArkRulesContract:()=>Ue,loadContract:()=>qe,loadResolvedCandidateFacts:()=>ee,parseArkConfigJson:()=>it,parseArkRulesJson:()=>_n,policyDeltaAcknowledgementMatches:()=>bt,preflightChange:()=>en,preflightResolvedChange:()=>tn,resolveEffectiveContract:()=>Nn,resolvedFactsEvidenceRequirementsHash:()=>Ie,stableSerialize:()=>k,toAdapterDiagnostic:()=>Je,version:()=>nn});module.exports=ar(ws);var nn="4.2.0";var sn="1.4";function E(e){return typeof e=="string"&&e.length>0?e:void 0}function rn(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}function or(e,t,n){if(e==="LAYER_IMPORT_VIOLATION")return t.typeOnly||n.targetTypeOnlyExports===!0||n.namedBindingsTypeOnly===!0?"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.":n.peerIsolation===!0?"Extract the shared dependency to a shared layer, then preflight again.":`Define a port in ${t.fromLayer??"the source layer"}, inject the ${t.toLayer??"outer-layer"} implementation, then preflight again.`;if(e==="FORBIDDEN_GLOBAL")return`Inject ${t.target??"the capability"} through a port, then preflight again.`;if(e==="CAPABILITY_VIOLATION")return`Define a ${E(n.capability)??"capability"} port in ${t.fromLayer??"the walled layer"}, bind the implementation outside it, then preflight again.`;if(e==="CIRCULAR_DEPENDENCY")return"Extract the shared dependency into a third module, then preflight again.";if(e==="RAW_EVENT_PUBLISH")return"Publish through a registered intent creator, then run Ark again.";if(e==="PUBLISH_MISSING_SOURCE")return"Add metadata.source to the publish call, then run Ark again.";if(e==="ARKRULE_STRUCTURE"||e==="ARKRULE_INVARIANT"||e==="INVARIANT_UNCOVERED"||e.startsWith("ARKRULE_")){let r=t.arkruleSource??"arkrules/<Layer>.json";return`Fix the structure or invariant for ${t.arkruleId??"the ArkRule"} (declared in ${r}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`}return`Resolve ${e} without weakening ark.config.json, then run Ark again.`}function Je(e,t="error"){let n=E(e.ruleId)??E(e.code)??"ARK_UNKNOWN",r=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,s={...E(e.target)?{target:E(e.target)}:{},...E(e.fromLayer)?{fromLayer:E(e.fromLayer)}:{},...E(e.toLayer)?{toLayer:E(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}:{},...E(e.capability)?{capability:E(e.capability)}:{},...E(e.edgeKind)?{edgeKind:E(e.edgeKind)}:{},...E(e.arkruleId)?{arkruleId:E(e.arkruleId)}:{},...E(e.arkruleSource)?{arkruleSource:E(e.arkruleSource)}:{}};return{ruleId:n,severity:r,message:E(e.message)??n,location:{file:E(e.file)??"<unknown>",line:rn(e.line,1),column:rn(e.column,1)},evidence:s,nextAction:E(e.nextAction)??or(n,s,e)}}function an(e){let t=e.completeness??"complete",n=e.mode??"lexical-compatibility";if(t==="complete"&&(e.completenessReasons?.length??0)>0)throw new Error("completenessReasons must be empty when completeness is complete.");let r=t==="complete"?[]:e.completenessReasons&&e.completenessReasons.length>0?e.completenessReasons.map(o=>({code:E(o.code)??"ANALYSIS_EVIDENCE_INCOMPLETE",message:E(o.message)??`Analysis ${t}: required evidence is incomplete.`,...E(o.file)?{file:E(o.file)}:{}})):[{code:t==="unavailable"?"ANALYSIS_UNAVAILABLE":"ANALYSIS_EVIDENCE_INCOMPLETE",message:`Analysis ${t}: required evidence is incomplete.`}],s={...E(e.policyHash)?{policyHash:E(e.policyHash)}:{},...E(e.resolverIdentity)?{resolverIdentity:E(e.resolverIdentity)}:{},...E(e.factsHash)?{factsHash:E(e.factsHash)}:{},...E(e.candidateTreeHash)?{candidateTreeHash:E(e.candidateTreeHash)}:{}};if(n==="resolved-candidate-facts"&&t!=="unavailable"){for(let o of["policyHash","resolverIdentity","factsHash","candidateTreeHash"])if(!s[o])throw new Error(`${o} is required for resolved ${t} adapter evidence.`)}let i=[...(e.violations??[]).map(o=>Je(o,"error")),...(e.warnings??[]).map(o=>Je(o,"warning"))],a={schemaVersion:"1.4",completenessReasons:r,diagnostics:i};if(n==="resolved-candidate-facts"){if(t==="unavailable")return{...a,mode:n,valid:!1,completeness:t,...s};let o={policyHash:s.policyHash,resolverIdentity:s.resolverIdentity,factsHash:s.factsHash,candidateTreeHash:s.candidateTreeHash};return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...o}:{...a,mode:n,valid:!1,completeness:t,...o}}return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...s}:{...a,mode:n,valid:!1,completeness:t,...s}}var on={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://unpkg.com/arkgate@3/schemas/ark.analysis-result.schema.json",title:"ArkGate analysis result",type:"object",additionalProperties:!1,required:["schemaVersion","mode","valid","completeness","completenessReasons","diagnostics"],allOf:[{if:{properties:{completeness:{enum:["partial","unavailable"]}},required:["completeness"]},then:{properties:{valid:{const:!1}}}},{if:{properties:{mode:{const:"resolved-candidate-facts"},completeness:{enum:["complete","partial"]}},required:["mode","completeness"]},then:{required:["policyHash","resolverIdentity","factsHash","candidateTreeHash"]}},{if:{properties:{completeness:{const:"complete"}},required:["completeness"]},then:{properties:{completenessReasons:{maxItems:0}}},else:{properties:{completenessReasons:{minItems:1}}}}],properties:{schemaVersion:{const:"1.4"},mode:{enum:["lexical-compatibility","resolved-candidate-facts"]},valid:{type:"boolean"},completeness:{enum:["complete","partial","unavailable"]},completenessReasons:{type:"array",items:{type:"object",additionalProperties:!1,required:["code","message"],properties:{code:{type:"string",minLength:1},message:{type:"string",minLength:1},file:{type:"string",minLength:1}}}},policyHash:{type:"string",minLength:1},resolverIdentity:{type:"string",minLength:1},factsHash:{type:"string",minLength:1},candidateTreeHash:{type:"string",minLength:1},diagnostics:{type:"array",items:{type:"object",additionalProperties:!1,required:["ruleId","severity","message","location","evidence"],properties:{ruleId:{type:"string",minLength:1},severity:{enum:["error","warning"]},message:{type:"string",minLength:1},location:{type:"object",additionalProperties:!1,required:["file","line","column"],properties:{file:{type:"string",minLength:1},line:{type:"integer",minimum:1},column:{type:"integer",minimum:1}}},evidence:{type:"object",additionalProperties:!1,properties:{target:{type:"string"},fromLayer:{type:"string"},toLayer:{type:"string"},typeOnly:{type:"boolean"},targetTypeOnlyExports:{type:"boolean"},sourcePureTypeModule:{type:"boolean"},namedBindingsTypeOnly:{type:"boolean"},portProofEligible:{type:"boolean"},peerIsolation:{type:"boolean"},capability:{type:"string",minLength:1},edgeKind:{type:"string",minLength:1},arkruleId:{type:"string",minLength:1},arkruleSource:{type:"string",minLength:1}}},nextAction:{type:"string",minLength:1}}}}}};var ln="1.0",Tt="https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json",Ze="^sha256:[a-f0-9]{64}$",Pt={type:"object",additionalProperties:!1,properties:{expectedRoot:{type:"string",minLength:1,description:"Absolute expected workspace/project directory. The initial authoritative handshake requires the exact project root; descendant calls also require expectedProjectId."},expectedProjectId:{type:"string",pattern:Ze,description:"Project id previously returned by ark_identity or ark_manifest."}}},wt={type:"object",additionalProperties:!1,required:["status","authoritative"],properties:{status:{enum:["matched","unverified","mismatch"]},authoritative:{type:"boolean"},expectedRoot:{type:"string",minLength:1},expectedProjectId:{type:"string",pattern:Ze},code:{enum:["PROJECT_ROOT_MISMATCH","PROJECT_ID_MISMATCH","INVALID_PROJECT_EXPECTATION"]},message:{type:"string",minLength:1}}},cn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Tt,title:"ArkGate MCP project identity",description:"Stable project binding plus separate runtime and architecture-contract evidence.",type:"object",additionalProperties:!1,required:["schemaVersion","projectId","resolvedRoot","resolvedConfigPath","arkgateVersion","contractHash","contractSource","runtimeId","processStartedAt"],properties:{schemaVersion:{const:"1.0"},projectId:{type:"string",pattern:Ze},resolvedRoot:{type:"string",minLength:1},resolvedConfigPath:{type:"string",minLength:1},arkgateVersion:{type:"string",minLength:1},contractHash:{type:"string",pattern:Ze},contractSource:{enum:["project","default-profile","manifest"]},runtimeId:{type:"string",minLength:1},processStartedAt:{type:"string",format:"date-time"}},$defs:{expectation:Pt,binding:wt}};function dn(e,t,n){if(!e||!t)throw new Error("Project identity requires resolvedRoot and resolvedConfigPath.");let r=n(JSON.stringify({resolvedRoot:e,resolvedConfigPath:t})).toLowerCase();if(!/^[a-f0-9]{64}$/.test(r))throw new Error("Project identity hash adapter must return 64 hexadecimal SHA-256 characters.");return`sha256:${r}`}function pn(e){return{schemaVersion:"1.0",...e}}var _t=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),Nt=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Ft=Object.freeze(Object.keys(Nt).sort()),$t=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"}),Lt=Object.freeze({process:Object.freeze(["process","node:process"])});function Oe(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=$t[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=$t[r];if(s)return s;let i=e.indexOf("/",n+1);return i<0?null:$t[e.slice(0,i)]??null}function te(e,t){for(let n of t)if(Lt[n]?.includes(e))return n;return null}function Xe(e){let t=e.split(".");for(let n=t.length;n>=1;n-=1){let r=t.slice(0,n).join("."),s=Nt[r];if(s)return s}return null}function me(e){if(e?.pure===!0)return[..._t].sort();let n=(e?.capabilities?.deny??[]).filter(r=>_t.includes(r));return[...new Set(n)].sort()}function Te(e,t){if(t.length===0)return!1;let n=new Set(t),r=e.split(".");for(let s=r.length;s>=1;s-=1)if(n.has(r.slice(0,s).join(".")))return!0;return!1}function Qe(e){let t=new Set,n=new Set,r=Object.keys(Nt);for(let s of e?.forbiddenGlobals??[]){let i=r.filter(a=>a===s||a.startsWith(`${s}.`));if(i.length===0)n.add(s);else for(let a of i)t.add(`ambient:${a}`);for(let a of Lt[s]??[])t.add(`import-exact:${a}`)}for(let s of me(e)){if(t.add(`import:${s}`),s==="process")for(let i of Lt.process)t.add(`import-exact:${i}`);for(let i of r)Xe(i)===s&&t.add(`ambient:${i}`)}return{atoms:[...t].sort(),rawGlobals:[...n].sort()}}var un=new Map;function fn(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}function et(e){let t="";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"&&n+1<e.length){let s=e[n+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,n+=1;continue}t+="/";continue}t+=r}return t}function lr(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"){n+=1;continue}if(r==="{")t+=1;else if(r==="}"&&(t-=1,t<0))return!1}return t===0}function ae(e){let t=un.get(e);if(t)return t;let n=et(e),r=lr(n),s="",i=0;for(let o=0;o<n.length;o+=1){let d=n[o];d==="\\"&&o+1<n.length?(s+=fn(n[o+1]),o+=1):d==="*"?n[o+1]==="*"?n[o+2]==="/"?(s+="(?:.*/)?",o+=2):(s+=".*",o+=1):s+="[^/]*":d==="?"?s+="[^/]":d==="{"&&r?(s+="(?:",i+=1):d==="}"&&r&&i>0?(s+=")",i-=1):d===","&&r&&i>0?s+="|":s+=fn(d)}let a=new RegExp(`^${s}$`);return un.set(e,a),a}function cr(e){return et(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}function Mt(e,t){let n=et(String(e)),r=cr(n),s=n.replace(/\*/g,"").length,i=r.length*1e4+s;if(t==null||t==="")return i;let a=String(t).split(/[/\\]/).filter(Boolean);if(r.length===0)return s;let o=0,d=-1;for(let f of r){let g=-1;for(let h=o;h<a.length;h+=1)if(a[h]===f){g=h;break}if(g<0)return i;d=g,o=g+1}return(d+1)*1e6+r.length*1e4+s}function J(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let i of t??[])if(!(i.exclude??[]).some(a=>ae(a).test(n))){for(let a of i.patterns??[])if(ae(a).test(n)){let o=Mt(a,n);o>s&&(s=o,r=i.name)}}return r}function yn(e,t){if(!t?.length)return;let n=String(e).split(/[/\\]/).filter(Boolean),r=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<n.length-1;s+=1)if(r.has(n[s].toLowerCase()))return`${n[s].toLowerCase()}/${n[s+1].toLowerCase()}`}function dr(e){let t=new Set;for(let n of e??[]){let s=et(String(n)).split("/").filter(Boolean);for(let i=0;i<s.length;i+=1){let a=s[i];if((a==="**"||a==="*")&&i>0){let o=s[i-1];o&&!o.includes("*")&&!o.includes("{")&&!o.includes("}")&&t.add(o)}}}return[...t]}function pr(e,t,n){if(Array.isArray(e.sliceFolders)&&e.sliceFolders.length>0)return e.sliceFolders.filter(s=>typeof s=="string"&&s.length>0);let r=(n??[]).find(s=>s.name===t);return dr(r?.patterns)}function Z(e,t,n,r){for(let s of e??[])if(!(s.from!==t||s.to!==n)&&s.allowed===!1){if(s.peerIsolation){let i=r?.fromPath,a=r?.toPath;if(!i||!a)return s;let o=pr(s,t,r?.layers);if(o.length===0)return s;let d=yn(i,o),f=yn(a,o);if(!d||!f||d!==f)return s;continue}if(t!==n)return s}}function ge(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}function hn(e,t){return e.getLineAndCharacterOfPosition(t.getStart(e)).line+1}function mn(e,t){if(e.isImportDeclaration(t)){let r=t.importClause;if(!r)return!1;if(r.isTypeOnly)return!0;let s=r.namedBindings;return!!(s&&e.isNamedImports(s)&&s.elements.length>0&&s.elements.every(i=>i.isTypeOnly))}if(t.isTypeOnly)return!0;let n=t.exportClause;return!!(n&&e.isNamedExports(n)&&n.elements.length>0&&n.elements.every(r=>r.isTypeOnly))}function An(e,t){let n={noLib:!0,noResolve:!0,target:e.ScriptTarget.Latest},r=e.createCompilerHost(n,!0);return r.getSourceFile=s=>s===t.fileName?t:void 0,r.fileExists=s=>s===t.fileName,r.readFile=s=>s===t.fileName?t.text:void 0,e.createProgram([t.fileName],n,r).getTypeChecker()}function Dt(e,t){try{return e.getSymbolAtLocation(t)}catch{return}}function Ht(e,t,n,r){let s=r.parent&&e.isShorthandPropertyAssignment(r.parent)&&r.parent.name===r,i;try{i=s?t.getShorthandAssignmentValueSymbol(r.parent):Dt(t,r)}catch{i=void 0}return!!i?.declarations?.some(a=>a.getSourceFile().fileName===n.fileName)}function oe(e,t){let n,r=[],s=(a,o,d,f=!1)=>r.push({specifier:d,kind:o,line:hn(t,a),typeOnly:f,unresolved:d===void 0,node:a}),i=a=>{if(e.isImportDeclaration(a))s(a,"import",ge(e,a.moduleSpecifier),mn(e,a));else if(e.isExportDeclaration(a)&&a.moduleSpecifier)s(a,"export",ge(e,a.moduleSpecifier),mn(e,a));else if(e.isImportEqualsDeclaration(a)&&e.isExternalModuleReference(a.moduleReference))s(a,"require",ge(e,a.moduleReference.expression),a.isTypeOnly===!0);else if(e.isCallExpression(a)){let o=a.expression.kind===e.SyntaxKind.ImportKeyword,f=e.isIdentifier(a.expression)&&a.expression.text==="require"&&!Ht(e,n??(n=An(e,t)),t,a.expression);(o||f)&&s(a,f?"require":"dynamic-import",ge(e,a.arguments[0]))}e.forEachChild(a,i)};return i(t),r}function ur(e,t){let n=[],r=t;for(;e.isPropertyAccessExpression(r)||e.isElementAccessExpression(r);){if(e.isPropertyAccessExpression(r))n.unshift(r.name.text);else{let s=ge(e,r.argumentExpression);if(s===void 0)return;n.unshift(s)}r=r.expression}if(e.isIdentifier(r))return n.unshift(r.text),{root:r,segments:n}}function fr(e,t){let n=t.parent;return e.isPropertyAccessExpression(n)||e.isElementAccessExpression(n)?!1:e.isExpressionNode(t)&&!e.isInTypeQuery(t)||e.isShorthandPropertyAssignment(n)&&n.name===t}function gn(e,t){let n=t[0]==="globalThis"?t.slice(1):t;for(let r=n.length;r>=1;r-=1){let s=n.slice(0,r).join(".");if(e.has(s))return s}}function le(e,t,n){if(n.length===0)return[];let r=new Set(n),s=An(e,t),i=new Map,a=new Set;for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations)e.isIdentifier(c.name)&&a.add(c.name.text);let o=l=>{let c=ur(e,l);if(!c)return;let p=Dt(s,c.root),y=p?i.get(p):void 0;return y?[...y,...c.segments.slice(1)]:Ht(e,s,t,c.root)||a.has(c.root.text)?void 0:c.segments};for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations){if(!c.initializer||!e.isIdentifier(c.name))continue;let p=o(c.initializer),y=Dt(s,c.name);!p||!y||i.set(y,p)}let d=[],f=new Set,g=(l,c)=>{let p=hn(t,c),y=`${l}:${c.getStart(t)}`;f.has(y)||(f.add(y),d.push({name:l,line:p,node:c}))},h=l=>{let c=l.parent&&(e.isPropertyAccessExpression(l.parent)||e.isElementAccessExpression(l.parent))&&l.parent.expression===l;if((e.isPropertyAccessExpression(l)||e.isElementAccessExpression(l))&&!c){let p=o(l),y=p?gn(r,p):void 0;y&&g(y,l)}else e.isIdentifier(l)&&r.has(l.text)&&fr(e,l)&&!Ht(e,s,t,l)&&g(l.text,l);if(e.isVariableDeclaration(l)&&e.isObjectBindingPattern(l.name)&&l.initializer){let p=o(l.initializer);if(p)for(let y of l.name.elements){if(!e.isIdentifier(y.name))continue;let b=y.propertyName?ge(e,y.propertyName)??y.propertyName.text:y.name.text,I=gn(r,[...p,b]);I&&g(I,l.initializer)}}e.forEachChild(l,h)};return h(t),d}function Vt(e,t,n){let r=[];for(let s of n?.dependencies??oe(e,t)){if(s.typeOnly||!s.specifier)continue;let i=Oe(s.specifier);i&&r.push({capability:i,symbol:s.specifier,line:s.line,source:"import-based"})}for(let s of n?.ambientUses??le(e,t,Ft)){let i=Xe(s.name);i&&r.push({capability:i,symbol:s.name,line:s.line,source:"ambient-global"})}return r.sort((s,i)=>s.line-i.line||s.capability.localeCompare(i.capability)||s.symbol.localeCompare(i.symbol))}var jt={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."},Ut=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 Gt(e,t){return t.flatMap((r,s)=>(r.prefixes??r.intentPrefixes??[]).map(i=>({layer:r.name,layerIndex:s,prefix:i.endsWith(".")?i:`${i}.`}))).filter(({prefix:r})=>e.startsWith(r)).sort((r,s)=>s.prefix.length-r.prefix.length||r.layerIndex-s.layerIndex)[0]?.layer}function ce(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}function Pe(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&ce(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:jt.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:jt.PUBLISH_MISSING_SOURCE}),t}function O(e,t,n){return{ruleId:e,code:e,message:t,...n}}function he(e,t){return e.slice(0,t).split(`
1
+ "use strict";var Ot=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var rr=Object.prototype.hasOwnProperty;var sr=(e,t)=>{for(var n in t)Ot(e,n,{get:t[n],enumerable:!0})},ir=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of nr(t))!rr.call(e,s)&&s!==n&&Ot(e,s,{get:()=>t[s],enumerable:!(r=tr(t,s))||r.enumerable});return e};var ar=e=>ir(Ot({},"__esModule",{value:!0}),e);var ws={};sr(ws,{ANALYSIS_IR_SCHEMA_VERSION:()=>lt,ARK_ANALYSIS_RESULT_SCHEMA:()=>on,ARK_ANALYSIS_RESULT_SCHEMA_VERSION:()=>sn,ARK_CONFIG_SCHEMA:()=>rt,ARK_CONFIG_SCHEMA_VERSION:()=>vn,ARK_DESIGN_DELTA_SCHEMA_VERSION:()=>er,ARK_ENFORCEMENT_STATE_SCHEMA_VERSION:()=>Qn,ARK_PROJECT_IDENTITY_SCHEMA:()=>cn,ARK_PROJECT_IDENTITY_SCHEMA_URL:()=>Tt,ARK_PROJECT_IDENTITY_SCHEMA_VERSION:()=>ln,ARK_RULES_SCHEMA:()=>dt,ARK_RULES_SCHEMA_VERSION:()=>$n,ARK_RULE_SENSORS:()=>Wt,EffectiveContractError:()=>Ge,POLICY_DELTA_SCHEMA_VERSION:()=>ht,PROJECT_BINDING_SCHEMA:()=>wt,PROJECT_EXPECTATION_SCHEMA:()=>Pt,RESOLVED_CANDIDATE_FACTS_SCHEMA:()=>ot,RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION:()=>re,analyzeArchitectureConvergence:()=>de,analyzeChange:()=>ze,analyzePolicyDelta:()=>Jt,analyzeProject:()=>Ee,analyzeResolvedProject:()=>Se,buildArkRuleFileHints:()=>St,buildEffectiveArkRules:()=>pt,buildRulesInventory:()=>Zn,canPromoteInvariant:()=>yt,classifyArkPolicyDelta:()=>At,collectAnalysisConfigWarnings:()=>Ye,collectEmptyAppliesToFindings:()=>Ct,collectForbiddenCapabilityUses:()=>le,createAICodeGate:()=>Bt,createAdapterResult:()=>an,createArchitectureProfile:()=>Me,createArchitectureProfileFromArkConfig:()=>zt,createElevenLayerArkConfig:()=>Kt,createProjectId:()=>dn,createProjectIdentity:()=>pn,createResolvedCandidateFacts:()=>at,deriveArkRuleFileHints:()=>Qt,detectArchitectureCycles:()=>It,deterministicHash:()=>P,effectiveContractPolicyPayload:()=>ut,elevenLayerProfile:()=>Fe,emptyEffectiveArkRules:()=>ie,evaluateArchitectureGraph:()=>ye,evaluateArkRuleSensors:()=>Et,evaluateInvariantCoverage:()=>ft,explainViolation:()=>Zt,extractClassShapesFromSource:()=>qn,extractSemanticDependencies:()=>oe,inventoryToExtractionCard:()=>Xn,loadArkConfigContract:()=>Ne,loadArkRulesContract:()=>Ue,loadContract:()=>qe,loadResolvedCandidateFacts:()=>ee,parseArkConfigJson:()=>it,parseArkRulesJson:()=>_n,policyDeltaAcknowledgementMatches:()=>bt,preflightChange:()=>en,preflightResolvedChange:()=>tn,resolveEffectiveContract:()=>Nn,resolvedFactsEvidenceRequirementsHash:()=>Ie,stableSerialize:()=>k,toAdapterDiagnostic:()=>Je,version:()=>nn});module.exports=ar(ws);var nn="4.2.1";var sn="1.4";function E(e){return typeof e=="string"&&e.length>0?e:void 0}function rn(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}function or(e,t,n){if(e==="LAYER_IMPORT_VIOLATION")return t.typeOnly||n.targetTypeOnlyExports===!0||n.namedBindingsTypeOnly===!0?"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.":n.peerIsolation===!0?"Extract the shared dependency to a shared layer, then preflight again.":`Define a port in ${t.fromLayer??"the source layer"}, inject the ${t.toLayer??"outer-layer"} implementation, then preflight again.`;if(e==="FORBIDDEN_GLOBAL")return`Inject ${t.target??"the capability"} through a port, then preflight again.`;if(e==="CAPABILITY_VIOLATION")return`Define a ${E(n.capability)??"capability"} port in ${t.fromLayer??"the walled layer"}, bind the implementation outside it, then preflight again.`;if(e==="CIRCULAR_DEPENDENCY")return"Extract the shared dependency into a third module, then preflight again.";if(e==="RAW_EVENT_PUBLISH")return"Publish through a registered intent creator, then run Ark again.";if(e==="PUBLISH_MISSING_SOURCE")return"Add metadata.source to the publish call, then run Ark again.";if(e==="ARKRULE_STRUCTURE"||e==="ARKRULE_INVARIANT"||e==="INVARIANT_UNCOVERED"||e.startsWith("ARKRULE_")){let r=t.arkruleSource??"arkrules/<Layer>.json";return`Fix the structure or invariant for ${t.arkruleId??"the ArkRule"} (declared in ${r}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`}return`Resolve ${e} without weakening ark.config.json, then run Ark again.`}function Je(e,t="error"){let n=E(e.ruleId)??E(e.code)??"ARK_UNKNOWN",r=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,s={...E(e.target)?{target:E(e.target)}:{},...E(e.fromLayer)?{fromLayer:E(e.fromLayer)}:{},...E(e.toLayer)?{toLayer:E(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}:{},...E(e.capability)?{capability:E(e.capability)}:{},...E(e.edgeKind)?{edgeKind:E(e.edgeKind)}:{},...E(e.arkruleId)?{arkruleId:E(e.arkruleId)}:{},...E(e.arkruleSource)?{arkruleSource:E(e.arkruleSource)}:{}};return{ruleId:n,severity:r,message:E(e.message)??n,location:{file:E(e.file)??"<unknown>",line:rn(e.line,1),column:rn(e.column,1)},evidence:s,nextAction:E(e.nextAction)??or(n,s,e)}}function an(e){let t=e.completeness??"complete",n=e.mode??"lexical-compatibility";if(t==="complete"&&(e.completenessReasons?.length??0)>0)throw new Error("completenessReasons must be empty when completeness is complete.");let r=t==="complete"?[]:e.completenessReasons&&e.completenessReasons.length>0?e.completenessReasons.map(o=>({code:E(o.code)??"ANALYSIS_EVIDENCE_INCOMPLETE",message:E(o.message)??`Analysis ${t}: required evidence is incomplete.`,...E(o.file)?{file:E(o.file)}:{}})):[{code:t==="unavailable"?"ANALYSIS_UNAVAILABLE":"ANALYSIS_EVIDENCE_INCOMPLETE",message:`Analysis ${t}: required evidence is incomplete.`}],s={...E(e.policyHash)?{policyHash:E(e.policyHash)}:{},...E(e.resolverIdentity)?{resolverIdentity:E(e.resolverIdentity)}:{},...E(e.factsHash)?{factsHash:E(e.factsHash)}:{},...E(e.candidateTreeHash)?{candidateTreeHash:E(e.candidateTreeHash)}:{}};if(n==="resolved-candidate-facts"&&t!=="unavailable"){for(let o of["policyHash","resolverIdentity","factsHash","candidateTreeHash"])if(!s[o])throw new Error(`${o} is required for resolved ${t} adapter evidence.`)}let i=[...(e.violations??[]).map(o=>Je(o,"error")),...(e.warnings??[]).map(o=>Je(o,"warning"))],a={schemaVersion:"1.4",completenessReasons:r,diagnostics:i};if(n==="resolved-candidate-facts"){if(t==="unavailable")return{...a,mode:n,valid:!1,completeness:t,...s};let o={policyHash:s.policyHash,resolverIdentity:s.resolverIdentity,factsHash:s.factsHash,candidateTreeHash:s.candidateTreeHash};return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...o}:{...a,mode:n,valid:!1,completeness:t,...o}}return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...s}:{...a,mode:n,valid:!1,completeness:t,...s}}var on={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://unpkg.com/arkgate@3/schemas/ark.analysis-result.schema.json",title:"ArkGate analysis result",type:"object",additionalProperties:!1,required:["schemaVersion","mode","valid","completeness","completenessReasons","diagnostics"],allOf:[{if:{properties:{completeness:{enum:["partial","unavailable"]}},required:["completeness"]},then:{properties:{valid:{const:!1}}}},{if:{properties:{mode:{const:"resolved-candidate-facts"},completeness:{enum:["complete","partial"]}},required:["mode","completeness"]},then:{required:["policyHash","resolverIdentity","factsHash","candidateTreeHash"]}},{if:{properties:{completeness:{const:"complete"}},required:["completeness"]},then:{properties:{completenessReasons:{maxItems:0}}},else:{properties:{completenessReasons:{minItems:1}}}}],properties:{schemaVersion:{const:"1.4"},mode:{enum:["lexical-compatibility","resolved-candidate-facts"]},valid:{type:"boolean"},completeness:{enum:["complete","partial","unavailable"]},completenessReasons:{type:"array",items:{type:"object",additionalProperties:!1,required:["code","message"],properties:{code:{type:"string",minLength:1},message:{type:"string",minLength:1},file:{type:"string",minLength:1}}}},policyHash:{type:"string",minLength:1},resolverIdentity:{type:"string",minLength:1},factsHash:{type:"string",minLength:1},candidateTreeHash:{type:"string",minLength:1},diagnostics:{type:"array",items:{type:"object",additionalProperties:!1,required:["ruleId","severity","message","location","evidence"],properties:{ruleId:{type:"string",minLength:1},severity:{enum:["error","warning"]},message:{type:"string",minLength:1},location:{type:"object",additionalProperties:!1,required:["file","line","column"],properties:{file:{type:"string",minLength:1},line:{type:"integer",minimum:1},column:{type:"integer",minimum:1}}},evidence:{type:"object",additionalProperties:!1,properties:{target:{type:"string"},fromLayer:{type:"string"},toLayer:{type:"string"},typeOnly:{type:"boolean"},targetTypeOnlyExports:{type:"boolean"},sourcePureTypeModule:{type:"boolean"},namedBindingsTypeOnly:{type:"boolean"},portProofEligible:{type:"boolean"},peerIsolation:{type:"boolean"},capability:{type:"string",minLength:1},edgeKind:{type:"string",minLength:1},arkruleId:{type:"string",minLength:1},arkruleSource:{type:"string",minLength:1}}},nextAction:{type:"string",minLength:1}}}}}};var ln="1.0",Tt="https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json",Ze="^sha256:[a-f0-9]{64}$",Pt={type:"object",additionalProperties:!1,properties:{expectedRoot:{type:"string",minLength:1,description:"Absolute expected workspace/project directory. The initial authoritative handshake requires the exact project root; descendant calls also require expectedProjectId."},expectedProjectId:{type:"string",pattern:Ze,description:"Project id previously returned by ark_identity or ark_manifest."}}},wt={type:"object",additionalProperties:!1,required:["status","authoritative"],properties:{status:{enum:["matched","unverified","mismatch"]},authoritative:{type:"boolean"},expectedRoot:{type:"string",minLength:1},expectedProjectId:{type:"string",pattern:Ze},code:{enum:["PROJECT_ROOT_MISMATCH","PROJECT_ID_MISMATCH","INVALID_PROJECT_EXPECTATION"]},message:{type:"string",minLength:1}}},cn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Tt,title:"ArkGate MCP project identity",description:"Stable project binding plus separate runtime and architecture-contract evidence.",type:"object",additionalProperties:!1,required:["schemaVersion","projectId","resolvedRoot","resolvedConfigPath","arkgateVersion","contractHash","contractSource","runtimeId","processStartedAt"],properties:{schemaVersion:{const:"1.0"},projectId:{type:"string",pattern:Ze},resolvedRoot:{type:"string",minLength:1},resolvedConfigPath:{type:"string",minLength:1},arkgateVersion:{type:"string",minLength:1},contractHash:{type:"string",pattern:Ze},contractSource:{enum:["project","default-profile","manifest"]},runtimeId:{type:"string",minLength:1},processStartedAt:{type:"string",format:"date-time"}},$defs:{expectation:Pt,binding:wt}};function dn(e,t,n){if(!e||!t)throw new Error("Project identity requires resolvedRoot and resolvedConfigPath.");let r=n(JSON.stringify({resolvedRoot:e,resolvedConfigPath:t})).toLowerCase();if(!/^[a-f0-9]{64}$/.test(r))throw new Error("Project identity hash adapter must return 64 hexadecimal SHA-256 characters.");return`sha256:${r}`}function pn(e){return{schemaVersion:"1.0",...e}}var _t=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),Nt=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Ft=Object.freeze(Object.keys(Nt).sort()),$t=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"}),Lt=Object.freeze({process:Object.freeze(["process","node:process"])});function Oe(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=$t[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=$t[r];if(s)return s;let i=e.indexOf("/",n+1);return i<0?null:$t[e.slice(0,i)]??null}function te(e,t){for(let n of t)if(Lt[n]?.includes(e))return n;return null}function Xe(e){let t=e.split(".");for(let n=t.length;n>=1;n-=1){let r=t.slice(0,n).join("."),s=Nt[r];if(s)return s}return null}function me(e){if(e?.pure===!0)return[..._t].sort();let n=(e?.capabilities?.deny??[]).filter(r=>_t.includes(r));return[...new Set(n)].sort()}function Te(e,t){if(t.length===0)return!1;let n=new Set(t),r=e.split(".");for(let s=r.length;s>=1;s-=1)if(n.has(r.slice(0,s).join(".")))return!0;return!1}function Qe(e){let t=new Set,n=new Set,r=Object.keys(Nt);for(let s of e?.forbiddenGlobals??[]){let i=r.filter(a=>a===s||a.startsWith(`${s}.`));if(i.length===0)n.add(s);else for(let a of i)t.add(`ambient:${a}`);for(let a of Lt[s]??[])t.add(`import-exact:${a}`)}for(let s of me(e)){if(t.add(`import:${s}`),s==="process")for(let i of Lt.process)t.add(`import-exact:${i}`);for(let i of r)Xe(i)===s&&t.add(`ambient:${i}`)}return{atoms:[...t].sort(),rawGlobals:[...n].sort()}}var un=new Map;function fn(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}function et(e){let t="";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"&&n+1<e.length){let s=e[n+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,n+=1;continue}t+="/";continue}t+=r}return t}function lr(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"){n+=1;continue}if(r==="{")t+=1;else if(r==="}"&&(t-=1,t<0))return!1}return t===0}function ae(e){let t=un.get(e);if(t)return t;let n=et(e),r=lr(n),s="",i=0;for(let o=0;o<n.length;o+=1){let d=n[o];d==="\\"&&o+1<n.length?(s+=fn(n[o+1]),o+=1):d==="*"?n[o+1]==="*"?n[o+2]==="/"?(s+="(?:.*/)?",o+=2):(s+=".*",o+=1):s+="[^/]*":d==="?"?s+="[^/]":d==="{"&&r?(s+="(?:",i+=1):d==="}"&&r&&i>0?(s+=")",i-=1):d===","&&r&&i>0?s+="|":s+=fn(d)}let a=new RegExp(`^${s}$`);return un.set(e,a),a}function cr(e){return et(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}function Mt(e,t){let n=et(String(e)),r=cr(n),s=n.replace(/\*/g,"").length,i=r.length*1e4+s;if(t==null||t==="")return i;let a=String(t).split(/[/\\]/).filter(Boolean);if(r.length===0)return s;let o=0,d=-1;for(let f of r){let g=-1;for(let h=o;h<a.length;h+=1)if(a[h]===f){g=h;break}if(g<0)return i;d=g,o=g+1}return(d+1)*1e6+r.length*1e4+s}function J(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let i of t??[])if(!(i.exclude??[]).some(a=>ae(a).test(n))){for(let a of i.patterns??[])if(ae(a).test(n)){let o=Mt(a,n);o>s&&(s=o,r=i.name)}}return r}function yn(e,t){if(!t?.length)return;let n=String(e).split(/[/\\]/).filter(Boolean),r=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<n.length-1;s+=1)if(r.has(n[s].toLowerCase()))return`${n[s].toLowerCase()}/${n[s+1].toLowerCase()}`}function dr(e){let t=new Set;for(let n of e??[]){let s=et(String(n)).split("/").filter(Boolean);for(let i=0;i<s.length;i+=1){let a=s[i];if((a==="**"||a==="*")&&i>0){let o=s[i-1];o&&!o.includes("*")&&!o.includes("{")&&!o.includes("}")&&t.add(o)}}}return[...t]}function pr(e,t,n){if(Array.isArray(e.sliceFolders)&&e.sliceFolders.length>0)return e.sliceFolders.filter(s=>typeof s=="string"&&s.length>0);let r=(n??[]).find(s=>s.name===t);return dr(r?.patterns)}function Z(e,t,n,r){for(let s of e??[])if(!(s.from!==t||s.to!==n)&&s.allowed===!1){if(s.peerIsolation){let i=r?.fromPath,a=r?.toPath;if(!i||!a)return s;let o=pr(s,t,r?.layers);if(o.length===0)return s;let d=yn(i,o),f=yn(a,o);if(!d||!f||d!==f)return s;continue}if(t!==n)return s}}function ge(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}function hn(e,t){return e.getLineAndCharacterOfPosition(t.getStart(e)).line+1}function mn(e,t){if(e.isImportDeclaration(t)){let r=t.importClause;if(!r)return!1;if(r.isTypeOnly)return!0;let s=r.namedBindings;return!!(s&&e.isNamedImports(s)&&s.elements.length>0&&s.elements.every(i=>i.isTypeOnly))}if(t.isTypeOnly)return!0;let n=t.exportClause;return!!(n&&e.isNamedExports(n)&&n.elements.length>0&&n.elements.every(r=>r.isTypeOnly))}function An(e,t){let n={noLib:!0,noResolve:!0,target:e.ScriptTarget.Latest},r=e.createCompilerHost(n,!0);return r.getSourceFile=s=>s===t.fileName?t:void 0,r.fileExists=s=>s===t.fileName,r.readFile=s=>s===t.fileName?t.text:void 0,e.createProgram([t.fileName],n,r).getTypeChecker()}function Dt(e,t){try{return e.getSymbolAtLocation(t)}catch{return}}function Ht(e,t,n,r){let s=r.parent&&e.isShorthandPropertyAssignment(r.parent)&&r.parent.name===r,i;try{i=s?t.getShorthandAssignmentValueSymbol(r.parent):Dt(t,r)}catch{i=void 0}return!!i?.declarations?.some(a=>a.getSourceFile().fileName===n.fileName)}function oe(e,t){let n,r=[],s=(a,o,d,f=!1)=>r.push({specifier:d,kind:o,line:hn(t,a),typeOnly:f,unresolved:d===void 0,node:a}),i=a=>{if(e.isImportDeclaration(a))s(a,"import",ge(e,a.moduleSpecifier),mn(e,a));else if(e.isExportDeclaration(a)&&a.moduleSpecifier)s(a,"export",ge(e,a.moduleSpecifier),mn(e,a));else if(e.isImportEqualsDeclaration(a)&&e.isExternalModuleReference(a.moduleReference))s(a,"require",ge(e,a.moduleReference.expression),a.isTypeOnly===!0);else if(e.isCallExpression(a)){let o=a.expression.kind===e.SyntaxKind.ImportKeyword,f=e.isIdentifier(a.expression)&&a.expression.text==="require"&&!Ht(e,n??(n=An(e,t)),t,a.expression);(o||f)&&s(a,f?"require":"dynamic-import",ge(e,a.arguments[0]))}e.forEachChild(a,i)};return i(t),r}function ur(e,t){let n=[],r=t;for(;e.isPropertyAccessExpression(r)||e.isElementAccessExpression(r);){if(e.isPropertyAccessExpression(r))n.unshift(r.name.text);else{let s=ge(e,r.argumentExpression);if(s===void 0)return;n.unshift(s)}r=r.expression}if(e.isIdentifier(r))return n.unshift(r.text),{root:r,segments:n}}function fr(e,t){let n=t.parent;return e.isPropertyAccessExpression(n)||e.isElementAccessExpression(n)?!1:e.isExpressionNode(t)&&!e.isInTypeQuery(t)||e.isShorthandPropertyAssignment(n)&&n.name===t}function gn(e,t){let n=t[0]==="globalThis"?t.slice(1):t;for(let r=n.length;r>=1;r-=1){let s=n.slice(0,r).join(".");if(e.has(s))return s}}function le(e,t,n){if(n.length===0)return[];let r=new Set(n),s=An(e,t),i=new Map,a=new Set;for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations)e.isIdentifier(c.name)&&a.add(c.name.text);let o=l=>{let c=ur(e,l);if(!c)return;let p=Dt(s,c.root),y=p?i.get(p):void 0;return y?[...y,...c.segments.slice(1)]:Ht(e,s,t,c.root)||a.has(c.root.text)?void 0:c.segments};for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations){if(!c.initializer||!e.isIdentifier(c.name))continue;let p=o(c.initializer),y=Dt(s,c.name);!p||!y||i.set(y,p)}let d=[],f=new Set,g=(l,c)=>{let p=hn(t,c),y=`${l}:${c.getStart(t)}`;f.has(y)||(f.add(y),d.push({name:l,line:p,node:c}))},h=l=>{let c=l.parent&&(e.isPropertyAccessExpression(l.parent)||e.isElementAccessExpression(l.parent))&&l.parent.expression===l;if((e.isPropertyAccessExpression(l)||e.isElementAccessExpression(l))&&!c){let p=o(l),y=p?gn(r,p):void 0;y&&g(y,l)}else e.isIdentifier(l)&&r.has(l.text)&&fr(e,l)&&!Ht(e,s,t,l)&&g(l.text,l);if(e.isVariableDeclaration(l)&&e.isObjectBindingPattern(l.name)&&l.initializer){let p=o(l.initializer);if(p)for(let y of l.name.elements){if(!e.isIdentifier(y.name))continue;let b=y.propertyName?ge(e,y.propertyName)??y.propertyName.text:y.name.text,I=gn(r,[...p,b]);I&&g(I,l.initializer)}}e.forEachChild(l,h)};return h(t),d}function Vt(e,t,n){let r=[];for(let s of n?.dependencies??oe(e,t)){if(s.typeOnly||!s.specifier)continue;let i=Oe(s.specifier);i&&r.push({capability:i,symbol:s.specifier,line:s.line,source:"import-based"})}for(let s of n?.ambientUses??le(e,t,Ft)){let i=Xe(s.name);i&&r.push({capability:i,symbol:s.name,line:s.line,source:"ambient-global"})}return r.sort((s,i)=>s.line-i.line||s.capability.localeCompare(i.capability)||s.symbol.localeCompare(i.symbol))}var jt={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."},Ut=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 Gt(e,t){return t.flatMap((r,s)=>(r.prefixes??r.intentPrefixes??[]).map(i=>({layer:r.name,layerIndex:s,prefix:i.endsWith(".")?i:`${i}.`}))).filter(({prefix:r})=>e.startsWith(r)).sort((r,s)=>s.prefix.length-r.prefix.length||r.layerIndex-s.layerIndex)[0]?.layer}function ce(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}function Pe(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&ce(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:jt.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:jt.PUBLISH_MISSING_SOURCE}),t}function O(e,t,n){return{ruleId:e,code:e,message:t,...n}}function he(e,t){return e.slice(0,t).split(`
2
2
  `).length}function yr(e){let t=[],n=/['"`]([A-Za-z][A-Za-z0-9_.]*)['"`]/g,r;for(;(r=n.exec(e))!==null;)t.push({value:r[1],index:r.index});return t}function mr(e){let t=[],n=[{kind:"import",re:/\bimport\s+(?:type\s+)?(?:[^'"]*?\s+from\s*)?['"]([^'"]+)['"]/g},{kind:"export",re:/\bexport\s+(?:type\s+)?[^'"]*?\s+from\s*['"]([^'"]+)['"]/g},{kind:"dynamic-import",re:/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g},{kind:"require",re:/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g}];for(let r of n){let s;for(;(s=r.re.exec(e))!==null;){let i=s.index+s[0].indexOf(s[1]),a=s[0],o=r.kind==="import"&&/\bimport\s+type\b/.test(a)||r.kind==="export"&&/\bexport\s+type\b/.test(a);t.push({value:s[1],index:i,kind:r.kind,typeOnly:o})}}return t.sort((r,s)=>r.index-s.index)}function gr(e,t){let n=e.createSourceFile("generated.ts",t,e.ScriptTarget.Latest,!0),r=[],s=i=>{e.isStringLiteralLike(i)&&r.push({value:i.text,index:i.getStart(n)}),e.forEachChild(i,s)};return s(n),r}function hr(e){let t=e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return["adapter","adapters","infra","infrastructure","persistence","repository","repositories","integration","database","db"].some(n=>t.includes(n))}function Ar(e){let t=e.toLowerCase();return["sequelize","prisma","typeorm","mongoose","knex"].some(n=>t===n||t.startsWith(`${n}/`))}function br(e){let t=e.toLowerCase();return["adapter","infra","persistence","repository","repositories","integration","database"].some(n=>t.includes(n))}function $e(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}function Rr(e,t){if(t&&(e.isIdentifier(t)||e.isStringLiteralLike(t)))return t.text}function bn(e,t,n){if(!(!t||!e.isObjectLiteralExpression(t)))return t.properties.find(r=>!e.isPropertyAssignment(r)&&!e.isShorthandPropertyAssignment(r)?!1:Rr(e,r.name)===n)}function _e(e,t,n){return bn(e,t,n)!==void 0}function we(e,t,n){let r=bn(e,t,n);return r&&e.isPropertyAssignment(r)?r.initializer:void 0}function Ir(e,t){let n=we(e,t,"metadata");return _e(e,n,"source")}function Rn(e,t){return t?e.isIdentifier(t)?/^[A-Z]/.test(t.text):e.isPropertyAccessExpression(t)?Rn(e,t.name):!1:!1}function vr(e,t){if(!e.isCallExpression(t))return!1;let n=t.expression;return e.isPropertyAccessExpression(n)?n.name.text==="publish":e.isIdentifier(n)&&n.text==="publish"}function Er(e,t){if(!e.isCallExpression(t))return!1;let n=t.arguments[0],r=$e(e,n);return r!==void 0&&ce(r)||_e(e,n,"intent")||Rn(e,n)}function Cr(e,t){if(!e.isCallExpression(t))return!1;let[n,r,s]=t.arguments;return Ir(e,n)||_e(e,r,"source")||_e(e,s,"source")}function Sr(e,t){if(!e.isCallExpression(t))return;let[n,r,s]=t.arguments,i=we(e,n,"metadata");return $e(e,we(e,i,"source"))??$e(e,we(e,r,"source"))??$e(e,we(e,s,"source"))}function kr(e,t,n,r){let s=e.createSourceFile("generated.ts",t,e.ScriptTarget.Latest,!0),i=n,a=i?.filePath,o=i?.layer,d=[],f=h=>s.getLineAndCharacterOfPosition(h.getStart(s)).line+1,g=h=>{if(vr(e,h)){let l=h.arguments[0],c=$e(e,l);for(let y of Pe({publishCall:!0,rawIntentName:c,objectHasIntent:_e(e,l,"intent"),arkPublishCandidate:Er(e,h),hasSource:Cr(e,h)}))d.push(O(y.ruleId,y.message,{line:f(h),filePath:a}));let p=Sr(e,h);if(r&&o&&p&&ce(p)){let y=r.resolveLayer(p);y&&y!==o&&d.push(O("PUBLISH_SOURCE_LAYER_MISMATCH",`Publish source "${p}" resolves to ${y}, but the target file is classified as ${o}.`,{line:f(h),filePath:a,target:p,fromLayer:o,toLayer:y}))}}e.forEachChild(h,g)};return g(s),d}function Bt(e={}){let t=new Set((e.intents||[]).map(i=>typeof i=="string"?i:i.name)),n=e.forbiddenPatterns||[],r=new Set(e.infrastructureLayers??[]),s=e.enforceIntentAllowlist??t.size>0;return{validate(i,a){let o=[],d=a,f=d?.filePath,g=d?.layer,h=e.typescript,l=h?h.createSourceFile(f??"generated.ts",i,h.ScriptTarget.Latest,!0):void 0,c=l?oe(e.typescript,l):void 0,p=c?c.filter(u=>u.specifier!==void 0).map(u=>({value:u.specifier,index:u.node.getStart(l),kind:u.kind,typeOnly:u.typeOnly})):mr(i),y=e.typescript?gr(e.typescript,i):yr(i);if(e.typescript&&!e.allowNonLiteralDynamicImport?.(f))for(let u of c?.filter(({unresolved:m})=>m)??[]){let m=u.kind==="require";o.push(O(m?"DYNAMIC_REQUIRE_NOT_ALLOWLISTED":"DYNAMIC_IMPORT_NOT_ALLOWLISTED",`Non-literal ${m?"require call":"dynamic import"} cannot be resolved statically; add the reviewed file to dynamicImportAllowlist.`,{line:u.line,filePath:f}))}let b=g!==void 0&&(r.has(g)||br(g)),I=g!==void 0?` If "${g}" is an infrastructure layer, mark it in ark.config.json with "mayImportInfrastructure": true (or name it with an infra token like Adapters/Persistence/Repository).`:"";for(let u of n)if(u instanceof RegExp){u.lastIndex=0;let m=u.exec(i);u.lastIndex=0,m&&o.push(O("FORBIDDEN_PATTERN",`Forbidden pattern matched: ${u}`,{line:m.index===void 0?void 0:he(i,m.index),filePath:f,suggestion:"Remove infrastructure imports from domain/application layers."+I}))}else i.includes(u)&&o.push(O("FORBIDDEN_SUBSTRING",`Forbidden substring: ${u}`,{line:he(i,i.indexOf(u)),filePath:f}));for(let u of p){let m=e.resolveImportTarget?.(u.value,f)??(e.resolveImportLayer?{layer:e.resolveImportLayer(u.value,f)}:void 0),R=typeof f=="string"?e.resolveImportTarget?.(f)??(e.resolveImportLayer?{layer:g,relPath:void 0}:void 0):void 0,S=m?.layer;if(S&&g){let T=Z(e.architectureProfile?.rules,g,S,{fromPath:R?.relPath,toPath:m?.relPath,layers:e.architectureLayers});if(T){if(u.typeOnly&&!T.peerIsolation)continue;let L=!!T.peerIsolation;o.push(O("LAYER_IMPORT_VIOLATION",T.message??(L?`Layer "${g}" must not import across slices into "${S}".`:`Layer "${g}" must not import "${S}".`),{line:he(i,u.index),source:u.value,target:u.value,filePath:f,fromLayer:g,toLayer:S,suggestion:L?"Extract shared code to a shared layer, or coordinate slices via events/ports \u2014 do not import across feature/context slices.":"Depend on a port/interface owned by an inner layer instead, or move this code to a layer allowed to make this import.",details:{importKind:u.kind,peerIsolation:L,...u.typeOnly?{typeOnly:!0}:{}}}));continue}continue}b||u.typeOnly||!hr(u.value)&&!Ar(u.value)||o.push(O("FORBIDDEN_IMPORT",`Forbidden ${u.kind} target: "${u.value}".`,{line:he(i,u.index),source:u.value,target:u.value,filePath:f,suggestion:"Route infrastructure access through an allowed adapter or port boundary."+I,details:{importKind:u.kind}}))}if(e.policies)for(let u of e.policies){let m=u.check({source:i,context:a});if(m!==!0)if(Array.isArray(m))for(let R of m)o.push(O("POLICY_VIOLATION",R.message,{filePath:f,suggestion:`Fix violation of policy "${u.name}".`}));else m===!1?o.push(O("POLICY_VIOLATION",`Policy ${u.name} failed on generated code`)):o.push(O("POLICY_VIOLATION",m.message))}if(s&&t.size>0)for(let u of y)ce(u.value)&&!t.has(u.value)&&o.push(O("UNKNOWN_INTENT",`Unknown intent reference: "${u.value}"`,{line:he(i,u.index),filePath:f,target:u.value,suggestion:`Register intent "${u.value}" via defineIntent() or remove the reference.`}));if(e.architectureProfile&&g)for(let u of y){if(!ce(u.value))continue;let m=e.architectureProfile.resolveLayer(u.value);if(!m)continue;let R=Z(e.architectureProfile.rules,g,m);R&&o.push(O("LAYER_REFERENCE_VIOLATION",R.message??`Layer "${g}" must not reference "${m}" through "${u.value}".`,{line:he(i,u.index),filePath:f,target:u.value,fromLayer:g,toLayer:m,suggestion:"Route the dependency through an allowed intent, port, or event.",details:{rule:R}}))}if(e.extensions)for(let u of e.extensions)try{let m=u.analyze(i,a);o.push(...m)}catch(m){o.push(O("EXTENSION_ERROR",`Extension "${u.name}" failed: ${m instanceof Error?m.message:String(m)}`))}if(e.typescript&&l&&g&&e.forbiddenGlobals?.[g]?.length)try{let u=e.forbiddenGlobals[g];o.push(...le(e.typescript,l,u).map(m=>O("FORBIDDEN_GLOBAL",`${g} must not use the ambient global "${m.name}".`,{line:m.line,filePath:f,target:m.name,fromLayer:g,suggestion:"Inject the capability through a port (e.g. a Clock, IdGenerator, or HttpPort) instead of reaching for the ambient global."})));for(let m of c??[]){if(m.typeOnly||!m.specifier)continue;let R=te(m.specifier,u);R&&o.push(O("FORBIDDEN_GLOBAL",`${g} must not use module "${m.specifier}" because it is the import form of forbidden global "${R}".`,{line:m.line,filePath:f,source:m.specifier,target:m.specifier,fromLayer:g,details:{importKind:m.kind,forbiddenGlobal:R},suggestion:"Inject the capability through a port instead of importing the ambient global module form."}))}}catch(u){o.push(O("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${u instanceof Error?u.message:String(u)}`))}if(e.typescript&&l&&g&&e.capabilityWalls?.[g]?.length)try{let u=new Set(e.capabilityWalls[g]),m=e.forbiddenGlobals?.[g]??[];for(let R of Vt(e.typescript,l))u.has(R.capability)&&(R.source==="ambient-global"&&Te(R.symbol,m)||R.source==="import-based"&&te(R.symbol,m)||o.push(O("CAPABILITY_VIOLATION",R.source==="import-based"?`${g} denies the ${R.capability} capability; found import of "${R.symbol}".`:`${g} denies the ${R.capability} capability; found ambient "${R.symbol}".`,{line:R.line,filePath:f,target:R.symbol,capability:R.capability,fromLayer:g,suggestion:"Define a small port (ClockPort, HttpPort, StoragePort) and bind the implementation in an adapter layer."})))}catch(u){o.push(O("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${u instanceof Error?u.message:String(u)}`))}if(e.typescript)try{o.push(...kr(e.typescript,i,a,e.architectureProfile))}catch(u){o.push(O("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${u instanceof Error?u.message:String(u)}`))}return{mode:"lexical-compatibility",completeness:"partial",completenessReasons:["LEXICAL_EVIDENCE_INCOMPLETE"],valid:!1,lexicalValid:o.length===0,violations:o}}}}var vn="1.1",nt="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",In=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],xr=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Or(){let e=[];for(let t of In)for(let n of In)t===n||xr.has(`${t}->${n}`)||e.push({from:t,to:n,allowed:!1});return e}var st=Or(),qt=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"}],ne={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},rt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:nt,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:nt,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:"1.1",default:"1.1"},name:{type:"string",minLength:1},include:{...ne,minItems:1,default:["src"]},exclude:{...ne,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:st,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...ne,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...ne,minItems:1},exclude:ne,intentPrefixes:ne,description:{type:"string",minLength:1},forbiddenGlobals:ne,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"}}},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:{...ne,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}}}}},X=class extends Error{issues;source;constructor(t,n){super(`Invalid ArkGate config (${t}):
3
3
  ${n.map(r=>`- ${r.path}: ${r.message}`).join(`
4
4
  `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=n}};function En(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function tt(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function Ae(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Tr(e,t){let n="#/$defs/";if(e.startsWith(n))return t.$defs[e.slice(n.length)]}function Le(e,t,n,r,s){if(t.$ref){let i=Tr(t.$ref,r);if(!i){s.push({path:n,message:`schema reference ${t.$ref} cannot be resolved`});return}Le(e,i,n,r,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:n,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(i=>Object.is(i,e))){s.push({path:n,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!En(e)){s.push({path:n,message:`must be an object; received ${Ae(e)}`});return}let i=t.properties??{};for(let a of t.required??[])e[a]===void 0&&s.push({path:tt(n,a),message:"is required"});if(t.additionalProperties===!1)for(let a of Object.keys(e))a in i||s.push({path:tt(n,a),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let a=t.additionalProperties;for(let o of Object.keys(e))o in i||Le(e[o],a,tt(n,o),r,s)}for(let[a,o]of Object.entries(i))e[a]!==void 0&&Le(e[a],o,tt(n,a),r,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:n,message:`must be an array; received ${Ae(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:n,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let i=e.map(a=>JSON.stringify(a));new Set(i).size!==i.length&&s.push({path:n,message:"must not contain duplicate items"})}t.items&&e.forEach((i,a)=>Le(i,t.items,`${n}[${a}]`,r,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:n,message:`must be a string; received ${Ae(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:n,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:n,message:`must be a boolean; received ${Ae(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:n,message:`must be an integer; received ${Ae(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:n,message:`must be at least ${t.minimum}`})}}function Pr(e){return{...e,$schema:e.$schema===void 0?nt:e.$schema,schemaVersion:e.schemaVersion===void 0?"1.1":e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?st.map(t=>({...t})):e.rules}}function wr(){let e=new Set(["1.1"]);for(let t of qt)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}function $r(e,t="ark.config.json"){if(!En(e))throw new X(t,[{path:"$",message:`must be an object; received ${Ae(e)}`}]);let n=wr(),r=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(r===null)throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected 1.1`}]);if(r!=="unversioned"&&!n.has(r))throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected 1.1`}]);let s=r,i={...e},a=0;for(;s!=="1.1"&&a<qt.length+1;){a+=1;let d=qt.find(f=>f.from===s);if(!d)throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected 1.1`}]);s=d.to,i.schemaVersion=s}if(s!=="1.1")throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected 1.1`}]);let o=r==="unversioned"?"unversioned":r==="1.0"?"1.0":null;return{candidate:Pr(i),migratedFrom:o}}function Ne(e,t="ark.config.json"){let{candidate:n,migratedFrom:r}=$r(e,t),s=[];if(Le(n,rt,"$",rt,s),s.length>0)throw new X(t,s);return{config:n,migratedFrom:r}}function it(e,t="ark.config.json"){let n;try{n=JSON.parse(e)}catch(r){throw new X(t,[{path:"$",message:`invalid JSON: ${r instanceof Error?r.message:String(r)}`}])}return Ne(n,t)}function Cn(e){let t={$schema:typeof e.$schema=="string"&&e.$schema.length>0?e.$schema:nt,schemaVersion:"1.1"};for(let[n,r]of Object.entries(e))n!=="$schema"&&n!=="schemaVersion"&&(t[n]=r);return t}function _r(e){return e.endsWith(".")?e:`${e}.`}function Lr(e,t){let n=e.prefixes.length?Math.max(...e.prefixes.map(s=>s.length)):0;return(t.prefixes.length?Math.max(...t.prefixes.map(s=>s.length)):0)-n}function Me(e){let t=e.layers.map(s=>({...s,prefixes:s.prefixes.map(_r)})),n=[...t].sort(Lr),r=[...e.rules??[]];return{name:e.name,layers:t,rules:r,resolveLayer(s){return t.find(i=>i.match?.(s))?.name??n.find(i=>i.prefixes.some(a=>s.startsWith(a)))?.name}}}function zt(e,t={}){return Me({name:t.name??e.name??"ark.config.json",layers:e.layers.map((n,r)=>({name:n.name,prefixes:n.intentPrefixes??[],description:n.description,order:r+1})),rules:e.rules??[]})}var Nr=[{name:"DomainModel",prefixes:["Domain"],description:"Rich domain model, business rules, and domain events.",order:1},{name:"ApplicationOrchestration",prefixes:["Application"],description:"Use cases and command orchestration.",order:2},{name:"PersistenceAdapters",prefixes:["Adapter.Persistence","Adapter.Repository"],description:"Database, repository, and storage adapters.",order:3},{name:"IntegrationAdapters",prefixes:["Adapter.Integration","Adapter.External"],description:"External systems, APIs, and integration adapters.",order:4},{name:"WorkflowSagaEngine",prefixes:["Workflow"],description:"Sagas, workflows, and long-running processes.",order:5},{name:"BackgroundJobsScheduling",prefixes:["Job"],description:"Background jobs, scheduled work, and async processors.",order:6},{name:"PresentationAdapters",prefixes:["Presentation","Adapter.Presentation","Adapter.Api"],description:"API, UI, controller, and presentation adapters.",order:7},{name:"ReportingReadModels",prefixes:["Reporting"],description:"Read models, projections, and reporting surfaces.",order:8},{name:"ExtensibilityMetadata",prefixes:["Metadata"],description:"Metadata, extensions, and schema contracts.",order:9},{name:"SecurityAuditObservability",prefixes:["Security","Audit","Observability"],description:"Security, audit, and observability concerns.",order:10},{name:"Kernel",prefixes:["Kernel"],description:"Ark-owned governance and kernel signals.",order:11}],Fe=Me({name:"Ark 11-layer Hexagonal Event-Driven Profile",layers:Nr,rules:st.map(e=>({...e}))}),Fr={DomainModel:["domain"],ApplicationOrchestration:["application","app"],PersistenceAdapters:["adapters/persistence","adapters/repository","repositories","infra/persistence"],IntegrationAdapters:["adapters/integration","adapters/external","integrations"],WorkflowSagaEngine:["workflows","sagas"],BackgroundJobsScheduling:["jobs","schedules"],PresentationAdapters:["presentation","adapters/presentation","adapters/api"],ReportingReadModels:["reporting","read-models","projections"],ExtensibilityMetadata:["metadata","extensions"],SecurityAuditObservability:["security","audit","observability"],Kernel:["kernel"]};function Kt(e={}){let t=e.rootDir??"src",n=e.optionalLayers??!0,r=t==="."?"":`${t}/`;return Cn({include:e.include??[t],layers:Fe.layers.map(s=>({name:s.name,patterns:(Fr[s.name]??[s.name]).map(i=>`${r}${i}/**`),intentPrefixes:s.prefixes,optional:n})),rules:[...Fe.rules]})}function P(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}function k(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(k).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${k(t[n])}`).join(",")}}`}var re="1.1";var Sn=["network","filesystem","clock","randomness","environment","process","persistence"];function Q(e,t){let n=k(e),r=k(t);return n<r?-1:n>r?1:0}function Y(e){return[...new Set(e)].sort((t,n)=>t<n?-1:t>n?1:0)}function Ie(e){let t={schemaVersion:"1.1",include:Y(e.include??[]),exclude:Y(e.exclude??[]),excludeGenerated:e.excludeGenerated!==!1,dynamicImportAllowlist:Y(e.dynamicImportAllowlist??[]),layers:e.layers.map(n=>({name:n.name,patterns:Y(n.patterns??[]),exclude:Y(n.exclude??[]),forbiddenGlobals:Y(n.forbiddenGlobals??[]),intentPrefixes:Y(n.intentPrefixes??[]),capabilityDeny:Y(n.capabilities?.deny??[]),pure:n.pure===!0})).sort(Q),safety:{maxTsSuppressions:e.safety?.maxTsSuppressions??0,maxAnyCasts:e.safety?.maxAnyCasts??0,allowInMemory:e.safety?.allowInMemory===!0,allowDisabledPeerIsolation:e.safety?.allowDisabledPeerIsolation===!0}};return P(k(t))}function Mr(e){let t=e.completenessReasons.map(l=>({code:l.code,message:l.message,...l.file?{file:l.file}:{}})).sort(Q),n=e.files.map(l=>({...l,typeOnlyExportNames:Y(l.typeOnlyExportNames)})).sort((l,c)=>l.path<c.path?-1:l.path>c.path?1:0),r=e.dependencies.map(l=>({...l,...l.namedBindings?{namedBindings:Y(l.namedBindings)}:{}})).sort(Q),s=e.capabilityUses.map(l=>({...l})).sort(Q),i=e.ambientUses.map(l=>({...l})).sort(Q),a=e.publishCalls.map(l=>({...l})).sort(Q),o=e.intentReferences.map(l=>({...l})).sort(Q),d=e.safetyUses.map(l=>({...l})).sort(Q),f=(e.classShapes??[]).map(l=>({...l,mutatingMethods:[...l.mutatingMethods??[]].map(c=>({...c}))})).sort(Q),g=e.files.map(({path:l,contentHash:c})=>({path:l,contentHash:c})).sort((l,c)=>l.path<c.path?-1:l.path>c.path?1:0),h=P(k(g));return{schemaVersion:"1.1",completeness:e.completeness,completenessReasons:t,resolverIdentity:e.resolverIdentity,compilerIdentity:e.compilerIdentity,compilerOptionsHash:e.compilerOptionsHash,tsconfigHash:e.tsconfigHash,candidateTreeHash:h,evidenceRequirementsHash:e.evidenceRequirementsHash,...e.projectPackageName?{projectPackageName:e.projectPackageName}:{},files:n,dependencies:r,capabilityUses:s,ambientUses:i,publishCalls:a,intentReferences:o,safetyUses:d,classShapes:f}}function xn(e){let t=Mr(e);return{...t,factsHash:P(k(t))}}function at(e){return xn(Tn(V(e,"$"),!1))}function V(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object.`);return e}function G(e,t,n){let r=new Set(t),s=Object.keys(e).find(i=>!r.has(i));if(s)throw new Error(`${n}.${s} is not part of schema ${"1.1"}.`)}function _(e,t,n){let r=e[t];if(typeof r!="string"||r.length===0)throw new Error(`${n}.${t} must be a non-empty string.`);return r}function be(e,t,n){if(e[t]!==void 0)return _(e,t,n)}function z(e,t,n){let r=_(e,t,n),s=r.replace(/\\/g,"/");if(!s||s.startsWith("/")||/^[A-Za-z]:\//.test(s)||/[\u0000-\u001f\u007f]/.test(s))throw new Error(`${n}.${t} must be a canonical project-relative path.`);let i=[];for(let o of s.split("/"))if(!(!o||o==="."))if(o===".."){if(i.length===0)throw new Error(`${n}.${t} must be a canonical project-relative path.`);i.pop()}else i.push(o);let a=i.join("/");if(!a||a!==r)throw new Error(`${n}.${t} must be a canonical project-relative path.`);return a}function $(e,t,n){if(typeof e[t]!="boolean")throw new Error(`${n}.${t} must be a boolean.`);return e[t]}function On(e,t,n){let r=e[t];if(!Number.isInteger(r)||Number(r)<0)throw new Error(`${n}.${t} must be a non-negative integer.`);return Number(r)}function Re(e,t,n){let r=On(e,t,n);if(r===0)throw new Error(`${n}.${t} must be a positive integer.`);return r}function K(e,t,n){let r=e[t];if(!Array.isArray(r))throw new Error(`${n}.${t} must be an array.`);return r}function se(e,t,n,r){let s=e[t];if(typeof s!="string"||!n.includes(s))throw new Error(`${r}.${t} must be one of ${n.join(", ")}.`);return s}function kn(e,t){if(!Array.isArray(e)||e.some(n=>typeof n!="string"||!n))throw new Error(`${t} must be an array of non-empty strings.`);return[...e]}function Dr(e,t,n){let r=new Set;for(let s of e){let i=t(s);if(r.has(i))throw new Error(`${n} must not contain duplicate facts (${i}).`);r.add(i)}}function Tn(e,t){G(e,["schemaVersion","completeness","completenessReasons","resolverIdentity","compilerIdentity","compilerOptionsHash","tsconfigHash","evidenceRequirementsHash","projectPackageName","files","dependencies","capabilityUses","ambientUses","publishCalls","intentReferences","safetyUses","classShapes",...t?["candidateTreeHash","factsHash"]:[]],"$");let n=se(e,"schemaVersion",["1.0","1.1"],"$"),r=se(e,"completeness",["complete","partial","unavailable"],"$"),s=K(e,"completenessReasons","$").map((b,I)=>{let u=`$.completenessReasons[${I}]`,m=V(b,u);G(m,["code","message","file"],u);let R=m.file===void 0?void 0:z(m,"file",u);return{code:_(m,"code",u),message:_(m,"message",u),...R?{file:R}:{}}});if(r==="complete"&&s.length>0)throw new Error("$.completenessReasons must be empty when completeness is complete.");if(r!=="complete"&&s.length===0)throw new Error("$.completenessReasons must explain partial or unavailable facts.");let i=K(e,"files","$").map((b,I)=>{let u=`$.files[${I}]`,m=V(b,u);return G(m,["path","contentHash","parseStatus","parseDiagnosticCount","exportsOnlyTypes","typeOnlyExportNames","hasTopLevelSideEffects"],u),{path:z(m,"path",u),contentHash:_(m,"contentHash",u),parseStatus:se(m,"parseStatus",["parsed","invalid"],u),parseDiagnosticCount:On(m,"parseDiagnosticCount",u),exportsOnlyTypes:$(m,"exportsOnlyTypes",u),typeOnlyExportNames:kn(m.typeOnlyExportNames,`${u}.typeOnlyExportNames`),hasTopLevelSideEffects:$(m,"hasTopLevelSideEffects",u)}}),a=K(e,"dependencies","$").map((b,I)=>{let u=`$.dependencies[${I}]`,m=V(b,u);G(m,["from","specifier","kind","typeOnly","line","resolution","target","namedBindings","targetTypeOnlyExports","sourcePureTypeModule","namedBindingsTypeOnly","portProofEligible"],u);let R=be(m,"specifier",u),S=be(m,"target",u),T=se(m,"resolution",["resolved-project","resolved-external","unresolved","dynamic"],u);if(T==="resolved-project"&&!S)throw new Error(`${u}.target is required for resolved-project dependencies.`);if(T!=="resolved-project"&&S)throw new Error(`${u}.target is only allowed for resolved-project dependencies.`);if(T!=="dynamic"&&!R)throw new Error(`${u}.specifier is required unless resolution is dynamic.`);return{from:z(m,"from",u),...R?{specifier:R}:{},kind:se(m,"kind",["import","export","dynamic-import","require"],u),typeOnly:$(m,"typeOnly",u),line:Re(m,"line",u),resolution:T,...S?{target:z(m,"target",u)}:{},...m.namedBindings!==void 0?{namedBindings:kn(m.namedBindings,`${u}.namedBindings`)}:{},...m.targetTypeOnlyExports!==void 0?{targetTypeOnlyExports:$(m,"targetTypeOnlyExports",u)}:{},...m.sourcePureTypeModule!==void 0?{sourcePureTypeModule:$(m,"sourcePureTypeModule",u)}:{},...m.namedBindingsTypeOnly!==void 0?{namedBindingsTypeOnly:$(m,"namedBindingsTypeOnly",u)}:{},...m.portProofEligible!==void 0?{portProofEligible:$(m,"portProofEligible",u)}:{}}}),o=K(e,"capabilityUses","$").map((b,I)=>{let u=`$.capabilityUses[${I}]`,m=V(b,u);return G(m,["file","line","symbol","capability","source"],u),{file:z(m,"file",u),line:Re(m,"line",u),symbol:_(m,"symbol",u),capability:se(m,"capability",Sn,u),source:se(m,"source",["ambient-global","import-based"],u)}}),d=K(e,"ambientUses","$").map((b,I)=>{let u=`$.ambientUses[${I}]`,m=V(b,u);return G(m,["file","line","symbol"],u),{file:z(m,"file",u),line:Re(m,"line",u),symbol:_(m,"symbol",u)}}),f=K(e,"publishCalls","$").map((b,I)=>{let u=`$.publishCalls[${I}]`,m=V(b,u);G(m,["file","line","rawIntentName","objectHasIntent","arkPublishCandidate","hasSource","sourceIntent"],u);let R=be(m,"rawIntentName",u),S=be(m,"sourceIntent",u);return{file:z(m,"file",u),line:Re(m,"line",u),...R?{rawIntentName:R}:{},objectHasIntent:$(m,"objectHasIntent",u),arkPublishCandidate:$(m,"arkPublishCandidate",u),hasSource:$(m,"hasSource",u),...S?{sourceIntent:S}:{}}}),g=K(e,"intentReferences","$").map((b,I)=>{let u=`$.intentReferences[${I}]`,m=V(b,u);return G(m,["file","line","intent"],u),{file:z(m,"file",u),line:Re(m,"line",u),intent:_(m,"intent",u)}}),h=K(e,"safetyUses","$").map((b,I)=>{let u=`$.safetyUses[${I}]`,m=V(b,u);G(m,["file","line","kind","symbol"],u);let R=be(m,"symbol",u),S=se(m,"kind",["ts-suppression","any-cast","dynamic-import","dynamic-require","in-memory-store"],u);if(S==="in-memory-store"&&!R)throw new Error(`${u}.symbol is required for in-memory-store facts.`);if(S!=="in-memory-store"&&R)throw new Error(`${u}.symbol is only allowed for in-memory-store facts.`);return{file:z(m,"file",u),line:Re(m,"line",u),kind:S,...R?{symbol:R}:{}}});Dr(i,b=>b.path,"$.files");let l=new Set(i.map(b=>b.path));for(let b of i){if(b.parseStatus==="parsed"&&b.parseDiagnosticCount!==0)throw new Error(`$.files[${b.path}].parseDiagnosticCount must be 0 when parseStatus is parsed.`);if(b.parseStatus==="invalid"&&b.parseDiagnosticCount===0)throw new Error(`$.files[${b.path}].parseDiagnosticCount must be positive when parseStatus is invalid.`)}if(r==="complete"&&i.some(b=>b.parseStatus==="invalid"))throw new Error("$.completeness cannot be complete when a candidate file failed to parse.");for(let b of a)if(!l.has(b.from))throw new Error(`$.dependencies references missing source file ${b.from}.`);for(let[b,I]of[["$.capabilityUses",o],["$.ambientUses",d],["$.publishCalls",f],["$.intentReferences",g],["$.safetyUses",h]])for(let u of I)if(!l.has(u.file))throw new Error(`${b} references missing file ${u.file}.`);let c=be(e,"projectPackageName","$"),y=(e.classShapes===void 0?[]:K(e,"classShapes","$")).map((b,I)=>{let u=`$.classShapes[${I}]`,m=V(b,u);G(m,["file","className","exported","hasPublicMutableFields","hasPublicSetters","hasPublicConstructor","hasStaticFactory","mutatingMethods","dataOnly"],u);let R=K(m,"mutatingMethods",u).map((S,T)=>{let L=`${u}.mutatingMethods[${T}]`,v=V(S,L);return G(v,["name","referencesGuardOrPublish"],L),{name:_(v,"name",L),referencesGuardOrPublish:$(v,"referencesGuardOrPublish",L)}});return{file:z(m,"file",u),className:_(m,"className",u),exported:$(m,"exported",u),hasPublicMutableFields:$(m,"hasPublicMutableFields",u),hasPublicSetters:$(m,"hasPublicSetters",u),hasPublicConstructor:$(m,"hasPublicConstructor",u),hasStaticFactory:$(m,"hasStaticFactory",u),mutatingMethods:R,...m.dataOnly===void 0?{}:{dataOnly:$(m,"dataOnly",u)}}});return{schemaVersion:n,completeness:r,completenessReasons:s,resolverIdentity:_(e,"resolverIdentity","$"),compilerIdentity:_(e,"compilerIdentity","$"),compilerOptionsHash:_(e,"compilerOptionsHash","$"),tsconfigHash:_(e,"tsconfigHash","$"),evidenceRequirementsHash:_(e,"evidenceRequirementsHash","$"),...c?{projectPackageName:c}:{},files:i,dependencies:a,capabilityUses:o,ambientUses:d,publishCalls:f,intentReferences:g,safetyUses:h,classShapes:y}}function ee(e){let t=V(e,"$"),n=_(t,"factsHash","$"),r=_(t,"candidateTreeHash","$"),s=xn(Tn(t,!0));if(s.factsHash!==n)throw new Error(`$.factsHash does not match the canonical payload (${s.factsHash}).`);if(r!==s.candidateTreeHash)throw new Error(`$.candidateTreeHash does not match the canonical file tree (${s.candidateTreeHash}).`);return s}var Hr=["network","filesystem","clock","randomness","environment","process","persistence"],x={type:"string",minLength:1},ve={type:"integer",minimum:1},W={type:"string",minLength:1,pattern:"^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$"},ot={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://unpkg.com/arkgate@3/schemas/ark.resolved-candidate-facts.schema.json",title:"ArkGate resolved candidate facts",type:"object",additionalProperties:!1,required:["schemaVersion","completeness","completenessReasons","resolverIdentity","compilerIdentity","compilerOptionsHash","tsconfigHash","candidateTreeHash","evidenceRequirementsHash","files","dependencies","capabilityUses","ambientUses","publishCalls","intentReferences","safetyUses","factsHash"],properties:{schemaVersion:{enum:["1.0","1.1"]},completeness:{enum:["complete","partial","unavailable"]},completenessReasons:{type:"array",items:{type:"object",additionalProperties:!1,required:["code","message"],properties:{code:x,message:x,file:W}}},resolverIdentity:x,compilerIdentity:x,compilerOptionsHash:x,tsconfigHash:x,candidateTreeHash:x,evidenceRequirementsHash:x,projectPackageName:x,files:{type:"array",uniqueItems:!0,items:{type:"object",additionalProperties:!1,required:["path","contentHash","parseStatus","parseDiagnosticCount","exportsOnlyTypes","typeOnlyExportNames","hasTopLevelSideEffects"],properties:{path:W,contentHash:x,parseStatus:{enum:["parsed","invalid"]},parseDiagnosticCount:{type:"integer",minimum:0},exportsOnlyTypes:{type:"boolean"},typeOnlyExportNames:{type:"array",items:x},hasTopLevelSideEffects:{type:"boolean"}},allOf:[{if:{properties:{parseStatus:{const:"parsed"}}},then:{properties:{parseDiagnosticCount:{const:0}}}},{if:{properties:{parseStatus:{const:"invalid"}}},then:{properties:{parseDiagnosticCount:{minimum:1}}}}]}},dependencies:{type:"array",items:{type:"object",additionalProperties:!1,required:["from","kind","typeOnly","line","resolution"],properties:{from:W,specifier:x,kind:{enum:["import","export","dynamic-import","require"]},typeOnly:{type:"boolean"},line:ve,resolution:{enum:["resolved-project","resolved-external","unresolved","dynamic"]},target:W,namedBindings:{type:"array",items:x},targetTypeOnlyExports:{type:"boolean"},sourcePureTypeModule:{type:"boolean"},namedBindingsTypeOnly:{type:"boolean"},portProofEligible:{type:"boolean"}},allOf:[{if:{properties:{resolution:{const:"resolved-project"}}},then:{required:["target"]},else:{not:{required:["target"]}}},{if:{properties:{resolution:{const:"dynamic"}}},else:{required:["specifier"]}}]}},capabilityUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","symbol","capability","source"],properties:{file:W,line:ve,symbol:x,capability:{enum:Hr},source:{enum:["ambient-global","import-based"]}}}},ambientUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","symbol"],properties:{file:W,line:ve,symbol:x}}},publishCalls:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","objectHasIntent","arkPublishCandidate","hasSource"],properties:{file:W,line:ve,rawIntentName:x,objectHasIntent:{type:"boolean"},arkPublishCandidate:{type:"boolean"},hasSource:{type:"boolean"},sourceIntent:x}}},intentReferences:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","intent"],properties:{file:W,line:ve,intent:x}}},safetyUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","kind"],properties:{file:W,line:ve,kind:{enum:["ts-suppression","any-cast","dynamic-import","dynamic-require","in-memory-store"]},symbol:x},allOf:[{if:{properties:{kind:{const:"in-memory-store"}}},then:{required:["symbol"]},else:{not:{required:["symbol"]}}}]}},classShapes:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","className","exported","hasPublicMutableFields","hasPublicSetters","hasPublicConstructor","hasStaticFactory","mutatingMethods"],properties:{file:W,className:x,exported:{type:"boolean"},hasPublicMutableFields:{type:"boolean"},hasPublicSetters:{type:"boolean"},hasPublicConstructor:{type:"boolean"},hasStaticFactory:{type:"boolean"},dataOnly:{type:"boolean"},mutatingMethods:{type:"array",items:{type:"object",additionalProperties:!1,required:["name","referencesGuardOrPublish"],properties:{name:x,referencesGuardOrPublish:{type:"boolean"}}}}}}},factsHash:x},allOf:[{if:{properties:{completeness:{const:"complete"}}},then:{properties:{completenessReasons:{maxItems:0},files:{items:{properties:{parseStatus:{const:"parsed"}}}}}}},{if:{properties:{completeness:{enum:["partial","unavailable"]}}},then:{properties:{completenessReasons:{minItems:1}}}}]};var lt="1.0";function D(e){return`${e.from}->${e.to}`}function De(e,t,n,r="dependency"){return{id:`${e}:${r}:${D(t)}`,classification:e,subject:"dependency",from:t.from,to:t.to,message:n,...e==="missing"?{nextAction:`Add the planned dependency ${D(t)} to the candidate, then preflight again.`}:e==="contradictory"?{nextAction:`Replace the reverse dependency with ${D(t)}, then preflight again.`}:e==="unplanned"?{nextAction:r==="dependency-removed"?`Restore the removed dependency ${D(t)} in the candidate, then preflight again.`:`Remove the unplanned dependency ${D(t)} from the candidate, then preflight again.`}:{}}}function de(e){let t=[],n=new Map(e.changeMap.map.files.map(l=>[l.path,l])),r=new Map(e.changes.map(l=>[l.path,l])),s=new Map(e.changeMap.map.dependencies.map(l=>[D(l),l])),i=new Map(e.baseDependencies.map(l=>[D(l),l])),a=new Map(e.candidateDependencies.map(l=>[D(l),l]));for(let l of[...n.values()].sort((c,p)=>c.path.localeCompare(p.path))){let c=r.get(l.path);c?c.operation!==l.operation?t.push({id:`contradictory:file:${l.path}`,classification:"contradictory",subject:"file",path:l.path,expectedOperation:l.operation,actualOperation:c.operation,message:`${l.path} was planned as ${l.operation} but the actual operation is ${c.operation}.`,nextAction:`Change ${l.path} to the planned ${l.operation} operation, then preflight again.`}):t.push({id:`satisfied:file:${l.path}`,classification:"satisfied",subject:"file",path:l.path,expectedOperation:l.operation,actualOperation:c.operation,message:`${l.path} matches the planned ${l.operation} operation.`}):t.push({id:`missing:file:${l.path}`,classification:"missing",subject:"file",path:l.path,expectedOperation:l.operation,message:`${l.path} was planned as ${l.operation} but is absent from the actual change.`,nextAction:`${l.operation[0].toUpperCase()}${l.operation.slice(1)} ${l.path} in the complete change set, then preflight again.`})}for(let l of[...r.values()].sort((c,p)=>c.path.localeCompare(p.path)))n.has(l.path)||t.push({id:`unplanned:file:${l.path}`,classification:"unplanned",subject:"file",path:l.path,actualOperation:l.operation,message:`${l.path} has an unplanned ${l.operation} operation.`,nextAction:`Remove ${l.path} from the change set, then preflight again.`});let o=new Set;for(let l of[...s.values()].sort((c,p)=>D(c).localeCompare(D(p)))){if(a.has(D(l))){t.push(De("satisfied",l,`${l.from} -> ${l.to} exists in the candidate architecture.`));continue}let c={from:l.to,to:l.from};a.has(D(c))?(o.add(D(c)),t.push(De("contradictory",l,`${l.from} -> ${l.to} was planned, but the candidate contains the reverse edge.`))):t.push(De("missing",l,`${l.from} -> ${l.to} is absent from the candidate architecture.`))}let d=new Set([...n.keys(),...r.keys()]);for(let[l,c]of[...a].sort(([p],[y])=>p.localeCompare(y)))i.has(l)||s.has(l)||o.has(l)||!d.has(c.from)&&!d.has(c.to)||t.push({...De("unplanned",c,`${c.from} -> ${c.to} was added without a matching planned dependency.`,"dependency-added"),actualOperation:"added"});let f=new Set(e.changeMap.map.files.filter(l=>l.operation==="delete").map(l=>l.path));for(let[l,c]of[...i].sort(([p],[y])=>p.localeCompare(y)))a.has(l)||f.has(c.from)||f.has(c.to)||!d.has(c.from)&&!d.has(c.to)||t.push({...De("unplanned",c,`${c.from} -> ${c.to} was removed without a planned file deletion.`,"dependency-removed"),actualOperation:"removed"});let g={satisfied:0,missing:1,contradictory:2,unplanned:3};t.sort((l,c)=>g[l.classification]-g[c.classification]||(l.subject===c.subject?0:l.subject==="file"?-1:1)||l.id.localeCompare(c.id));let h={satisfied:t.filter(l=>l.classification==="satisfied").length,missing:t.filter(l=>l.classification==="missing").length,contradictory:t.filter(l=>l.classification==="contradictory").length,unplanned:t.filter(l=>l.classification==="unplanned").length};return{schemaVersion:"1.0",readOnly:!0,changeMapHash:e.changeMap.hash,structurallyConverged:h.missing===0&&h.contradictory===0&&h.unplanned===0,behavioralCompletion:"not-evaluated",summary:h,findings:t}}var $n="1.0",Yt="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",Wt=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","no-anemic-model","invariant-coverage"],Vr=["no-anemic-model"],Pn={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},dt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Yt,title:"ArkGate ArkRules (intra-layer contract)",description:"Per-layer structure sensors and invariant catalog consumed by the ArkGate Effective Contract.",type:"object",additionalProperties:!1,required:["schemaVersion","layer"],properties:{$schema:{type:"string",minLength:1,default:Yt},schemaVersion:{type:"string",const:"1.0",default:"1.0"},layer:{type:"string",minLength:1},structure:{type:"array",default:[],items:{$ref:"#/$defs/structureEntry"}},invariants:{type:"array",default:[],items:{$ref:"#/$defs/invariantEntry"}}},$defs:{structureEntry:{type:"object",additionalProperties:!1,required:["id","sensor"],properties:{id:{type:"string",minLength:1},sensor:{type:"string",enum:[...Wt]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:Pn,description:{type:"string",minLength:1}}},invariantEntry:{type:"object",additionalProperties:!1,required:["id","description"],properties:{id:{type:"string",minLength:1},description:{type:"string",minLength:1},aggregate:{type:"string",minLength:1},coverage:{type:"object",additionalProperties:!1,properties:{test:{type:"boolean"},symbol:{type:"string",minLength:1}}},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:Pn}}}},pe=class extends Error{issues;source;constructor(t,n){super(`Invalid ArkRules (${t}):
package/dist/index.d.ts CHANGED
@@ -244,7 +244,7 @@ declare function loadArkConfigContract(input: unknown, source?: string): ArkConf
244
244
  declare function parseArkConfigJson(json: string, source?: string): ArkConfigLoadResult;
245
245
 
246
246
  /** ArkGate library version — single source of truth. */
247
- declare const version = "4.2.0";
247
+ declare const version = "4.2.1";
248
248
 
249
249
  /** Versioned public result contract shared by every ArkGate enforcement adapter. */
250
250
  /** 1.4 adds optional evidence.arkruleId + evidence.arkruleSource (ADR 0012 / AR03). */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Mn="4.2.0";var Dn="1.4";function E(e){return typeof e=="string"&&e.length>0?e:void 0}function Gt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}function Hn(e,t,n){if(e==="LAYER_IMPORT_VIOLATION")return t.typeOnly||n.targetTypeOnlyExports===!0||n.namedBindingsTypeOnly===!0?"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.":n.peerIsolation===!0?"Extract the shared dependency to a shared layer, then preflight again.":`Define a port in ${t.fromLayer??"the source layer"}, inject the ${t.toLayer??"outer-layer"} implementation, then preflight again.`;if(e==="FORBIDDEN_GLOBAL")return`Inject ${t.target??"the capability"} through a port, then preflight again.`;if(e==="CAPABILITY_VIOLATION")return`Define a ${E(n.capability)??"capability"} port in ${t.fromLayer??"the walled layer"}, bind the implementation outside it, then preflight again.`;if(e==="CIRCULAR_DEPENDENCY")return"Extract the shared dependency into a third module, then preflight again.";if(e==="RAW_EVENT_PUBLISH")return"Publish through a registered intent creator, then run Ark again.";if(e==="PUBLISH_MISSING_SOURCE")return"Add metadata.source to the publish call, then run Ark again.";if(e==="ARKRULE_STRUCTURE"||e==="ARKRULE_INVARIANT"||e==="INVARIANT_UNCOVERED"||e.startsWith("ARKRULE_")){let r=t.arkruleSource??"arkrules/<Layer>.json";return`Fix the structure or invariant for ${t.arkruleId??"the ArkRule"} (declared in ${r}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`}return`Resolve ${e} without weakening ark.config.json, then run Ark again.`}function dt(e,t="error"){let n=E(e.ruleId)??E(e.code)??"ARK_UNKNOWN",r=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,s={...E(e.target)?{target:E(e.target)}:{},...E(e.fromLayer)?{fromLayer:E(e.fromLayer)}:{},...E(e.toLayer)?{toLayer:E(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}:{},...E(e.capability)?{capability:E(e.capability)}:{},...E(e.edgeKind)?{edgeKind:E(e.edgeKind)}:{},...E(e.arkruleId)?{arkruleId:E(e.arkruleId)}:{},...E(e.arkruleSource)?{arkruleSource:E(e.arkruleSource)}:{}};return{ruleId:n,severity:r,message:E(e.message)??n,location:{file:E(e.file)??"<unknown>",line:Gt(e.line,1),column:Gt(e.column,1)},evidence:s,nextAction:E(e.nextAction)??Hn(n,s,e)}}function Vn(e){let t=e.completeness??"complete",n=e.mode??"lexical-compatibility";if(t==="complete"&&(e.completenessReasons?.length??0)>0)throw new Error("completenessReasons must be empty when completeness is complete.");let r=t==="complete"?[]:e.completenessReasons&&e.completenessReasons.length>0?e.completenessReasons.map(o=>({code:E(o.code)??"ANALYSIS_EVIDENCE_INCOMPLETE",message:E(o.message)??`Analysis ${t}: required evidence is incomplete.`,...E(o.file)?{file:E(o.file)}:{}})):[{code:t==="unavailable"?"ANALYSIS_UNAVAILABLE":"ANALYSIS_EVIDENCE_INCOMPLETE",message:`Analysis ${t}: required evidence is incomplete.`}],s={...E(e.policyHash)?{policyHash:E(e.policyHash)}:{},...E(e.resolverIdentity)?{resolverIdentity:E(e.resolverIdentity)}:{},...E(e.factsHash)?{factsHash:E(e.factsHash)}:{},...E(e.candidateTreeHash)?{candidateTreeHash:E(e.candidateTreeHash)}:{}};if(n==="resolved-candidate-facts"&&t!=="unavailable"){for(let o of["policyHash","resolverIdentity","factsHash","candidateTreeHash"])if(!s[o])throw new Error(`${o} is required for resolved ${t} adapter evidence.`)}let i=[...(e.violations??[]).map(o=>dt(o,"error")),...(e.warnings??[]).map(o=>dt(o,"warning"))],a={schemaVersion:"1.4",completenessReasons:r,diagnostics:i};if(n==="resolved-candidate-facts"){if(t==="unavailable")return{...a,mode:n,valid:!1,completeness:t,...s};let o={policyHash:s.policyHash,resolverIdentity:s.resolverIdentity,factsHash:s.factsHash,candidateTreeHash:s.candidateTreeHash};return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...o}:{...a,mode:n,valid:!1,completeness:t,...o}}return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...s}:{...a,mode:n,valid:!1,completeness:t,...s}}var jn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://unpkg.com/arkgate@3/schemas/ark.analysis-result.schema.json",title:"ArkGate analysis result",type:"object",additionalProperties:!1,required:["schemaVersion","mode","valid","completeness","completenessReasons","diagnostics"],allOf:[{if:{properties:{completeness:{enum:["partial","unavailable"]}},required:["completeness"]},then:{properties:{valid:{const:!1}}}},{if:{properties:{mode:{const:"resolved-candidate-facts"},completeness:{enum:["complete","partial"]}},required:["mode","completeness"]},then:{required:["policyHash","resolverIdentity","factsHash","candidateTreeHash"]}},{if:{properties:{completeness:{const:"complete"}},required:["completeness"]},then:{properties:{completenessReasons:{maxItems:0}}},else:{properties:{completenessReasons:{minItems:1}}}}],properties:{schemaVersion:{const:"1.4"},mode:{enum:["lexical-compatibility","resolved-candidate-facts"]},valid:{type:"boolean"},completeness:{enum:["complete","partial","unavailable"]},completenessReasons:{type:"array",items:{type:"object",additionalProperties:!1,required:["code","message"],properties:{code:{type:"string",minLength:1},message:{type:"string",minLength:1},file:{type:"string",minLength:1}}}},policyHash:{type:"string",minLength:1},resolverIdentity:{type:"string",minLength:1},factsHash:{type:"string",minLength:1},candidateTreeHash:{type:"string",minLength:1},diagnostics:{type:"array",items:{type:"object",additionalProperties:!1,required:["ruleId","severity","message","location","evidence"],properties:{ruleId:{type:"string",minLength:1},severity:{enum:["error","warning"]},message:{type:"string",minLength:1},location:{type:"object",additionalProperties:!1,required:["file","line","column"],properties:{file:{type:"string",minLength:1},line:{type:"integer",minimum:1},column:{type:"integer",minimum:1}}},evidence:{type:"object",additionalProperties:!1,properties:{target:{type:"string"},fromLayer:{type:"string"},toLayer:{type:"string"},typeOnly:{type:"boolean"},targetTypeOnlyExports:{type:"boolean"},sourcePureTypeModule:{type:"boolean"},namedBindingsTypeOnly:{type:"boolean"},portProofEligible:{type:"boolean"},peerIsolation:{type:"boolean"},capability:{type:"string",minLength:1},edgeKind:{type:"string",minLength:1},arkruleId:{type:"string",minLength:1},arkruleSource:{type:"string",minLength:1}}},nextAction:{type:"string",minLength:1}}}}}};var Un="1.0",Bt="https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json",Ue="^sha256:[a-f0-9]{64}$",qt={type:"object",additionalProperties:!1,properties:{expectedRoot:{type:"string",minLength:1,description:"Absolute expected workspace/project directory. The initial authoritative handshake requires the exact project root; descendant calls also require expectedProjectId."},expectedProjectId:{type:"string",pattern:Ue,description:"Project id previously returned by ark_identity or ark_manifest."}}},zt={type:"object",additionalProperties:!1,required:["status","authoritative"],properties:{status:{enum:["matched","unverified","mismatch"]},authoritative:{type:"boolean"},expectedRoot:{type:"string",minLength:1},expectedProjectId:{type:"string",pattern:Ue},code:{enum:["PROJECT_ROOT_MISMATCH","PROJECT_ID_MISMATCH","INVALID_PROJECT_EXPECTATION"]},message:{type:"string",minLength:1}}},Gn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Bt,title:"ArkGate MCP project identity",description:"Stable project binding plus separate runtime and architecture-contract evidence.",type:"object",additionalProperties:!1,required:["schemaVersion","projectId","resolvedRoot","resolvedConfigPath","arkgateVersion","contractHash","contractSource","runtimeId","processStartedAt"],properties:{schemaVersion:{const:"1.0"},projectId:{type:"string",pattern:Ue},resolvedRoot:{type:"string",minLength:1},resolvedConfigPath:{type:"string",minLength:1},arkgateVersion:{type:"string",minLength:1},contractHash:{type:"string",pattern:Ue},contractSource:{enum:["project","default-profile","manifest"]},runtimeId:{type:"string",minLength:1},processStartedAt:{type:"string",format:"date-time"}},$defs:{expectation:qt,binding:zt}};function Bn(e,t,n){if(!e||!t)throw new Error("Project identity requires resolvedRoot and resolvedConfigPath.");let r=n(JSON.stringify({resolvedRoot:e,resolvedConfigPath:t})).toLowerCase();if(!/^[a-f0-9]{64}$/.test(r))throw new Error("Project identity hash adapter must return 64 hexadecimal SHA-256 characters.");return`sha256:${r}`}function qn(e){return{schemaVersion:"1.0",...e}}var ut=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),yt=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),mt=Object.freeze(Object.keys(yt).sort()),pt=Object.freeze({fs:"filesystem","node:fs":"filesystem","fs/promises":"filesystem","node:fs/promises":"filesystem","fs-extra":"filesystem","graceful-fs":"filesystem",memfs:"filesystem",chokidar:"filesystem",http:"network",https:"network",http2:"network",net:"network",tls:"network",dgram:"network",dns:"network","node:http":"network","node:https":"network","node:http2":"network","node:net":"network","node:tls":"network","node:dgram":"network","node:dns":"network",axios:"network",undici:"network","node-fetch":"network",got:"network",ky:"network",superagent:"network",ws:"network",process:"process","node:process":"process",child_process:"process","node:child_process":"process","@prisma/client":"persistence",prisma:"persistence",pg:"persistence",mysql:"persistence",mysql2:"persistence",mongodb:"persistence",mongoose:"persistence",sqlite3:"persistence","better-sqlite3":"persistence",redis:"persistence",ioredis:"persistence",typeorm:"persistence",knex:"persistence","drizzle-orm":"persistence",sequelize:"persistence",kysely:"persistence","@supabase/supabase-js":"persistence"}),ft=Object.freeze({process:Object.freeze(["process","node:process"])});function Se(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=pt[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=pt[r];if(s)return s;let i=e.indexOf("/",n+1);return i<0?null:pt[e.slice(0,i)]??null}function ee(e,t){for(let n of t)if(ft[n]?.includes(e))return n;return null}function Ge(e){let t=e.split(".");for(let n=t.length;n>=1;n-=1){let r=t.slice(0,n).join("."),s=yt[r];if(s)return s}return null}function pe(e){if(e?.pure===!0)return[...ut].sort();let n=(e?.capabilities?.deny??[]).filter(r=>ut.includes(r));return[...new Set(n)].sort()}function ke(e,t){if(t.length===0)return!1;let n=new Set(t),r=e.split(".");for(let s=r.length;s>=1;s-=1)if(n.has(r.slice(0,s).join(".")))return!0;return!1}function Be(e){let t=new Set,n=new Set,r=Object.keys(yt);for(let s of e?.forbiddenGlobals??[]){let i=r.filter(a=>a===s||a.startsWith(`${s}.`));if(i.length===0)n.add(s);else for(let a of i)t.add(`ambient:${a}`);for(let a of ft[s]??[])t.add(`import-exact:${a}`)}for(let s of pe(e)){if(t.add(`import:${s}`),s==="process")for(let i of ft.process)t.add(`import-exact:${i}`);for(let i of r)Ge(i)===s&&t.add(`ambient:${i}`)}return{atoms:[...t].sort(),rawGlobals:[...n].sort()}}var Kt=new Map;function Yt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}function qe(e){let t="";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"&&n+1<e.length){let s=e[n+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,n+=1;continue}t+="/";continue}t+=r}return t}function zn(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"){n+=1;continue}if(r==="{")t+=1;else if(r==="}"&&(t-=1,t<0))return!1}return t===0}function se(e){let t=Kt.get(e);if(t)return t;let n=qe(e),r=zn(n),s="",i=0;for(let o=0;o<n.length;o+=1){let d=n[o];d==="\\"&&o+1<n.length?(s+=Yt(n[o+1]),o+=1):d==="*"?n[o+1]==="*"?n[o+2]==="/"?(s+="(?:.*/)?",o+=2):(s+=".*",o+=1):s+="[^/]*":d==="?"?s+="[^/]":d==="{"&&r?(s+="(?:",i+=1):d==="}"&&r&&i>0?(s+=")",i-=1):d===","&&r&&i>0?s+="|":s+=Yt(d)}let a=new RegExp(`^${s}$`);return Kt.set(e,a),a}function Kn(e){return qe(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}function gt(e,t){let n=qe(String(e)),r=Kn(n),s=n.replace(/\*/g,"").length,i=r.length*1e4+s;if(t==null||t==="")return i;let a=String(t).split(/[/\\]/).filter(Boolean);if(r.length===0)return s;let o=0,d=-1;for(let f of r){let g=-1;for(let h=o;h<a.length;h+=1)if(a[h]===f){g=h;break}if(g<0)return i;d=g,o=g+1}return(d+1)*1e6+r.length*1e4+s}function J(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let i of t??[])if(!(i.exclude??[]).some(a=>se(a).test(n))){for(let a of i.patterns??[])if(se(a).test(n)){let o=gt(a,n);o>s&&(s=o,r=i.name)}}return r}function Wt(e,t){if(!t?.length)return;let n=String(e).split(/[/\\]/).filter(Boolean),r=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<n.length-1;s+=1)if(r.has(n[s].toLowerCase()))return`${n[s].toLowerCase()}/${n[s+1].toLowerCase()}`}function Yn(e){let t=new Set;for(let n of e??[]){let s=qe(String(n)).split("/").filter(Boolean);for(let i=0;i<s.length;i+=1){let a=s[i];if((a==="**"||a==="*")&&i>0){let o=s[i-1];o&&!o.includes("*")&&!o.includes("{")&&!o.includes("}")&&t.add(o)}}}return[...t]}function Wn(e,t,n){if(Array.isArray(e.sliceFolders)&&e.sliceFolders.length>0)return e.sliceFolders.filter(s=>typeof s=="string"&&s.length>0);let r=(n??[]).find(s=>s.name===t);return Yn(r?.patterns)}function Z(e,t,n,r){for(let s of e??[])if(!(s.from!==t||s.to!==n)&&s.allowed===!1){if(s.peerIsolation){let i=r?.fromPath,a=r?.toPath;if(!i||!a)return s;let o=Wn(s,t,r?.layers);if(o.length===0)return s;let d=Wt(i,o),f=Wt(a,o);if(!d||!f||d!==f)return s;continue}if(t!==n)return s}}function ue(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}function Xt(e,t){return e.getLineAndCharacterOfPosition(t.getStart(e)).line+1}function Jt(e,t){if(e.isImportDeclaration(t)){let r=t.importClause;if(!r)return!1;if(r.isTypeOnly)return!0;let s=r.namedBindings;return!!(s&&e.isNamedImports(s)&&s.elements.length>0&&s.elements.every(i=>i.isTypeOnly))}if(t.isTypeOnly)return!0;let n=t.exportClause;return!!(n&&e.isNamedExports(n)&&n.elements.length>0&&n.elements.every(r=>r.isTypeOnly))}function Qt(e,t){let n={noLib:!0,noResolve:!0,target:e.ScriptTarget.Latest},r=e.createCompilerHost(n,!0);return r.getSourceFile=s=>s===t.fileName?t:void 0,r.fileExists=s=>s===t.fileName,r.readFile=s=>s===t.fileName?t.text:void 0,e.createProgram([t.fileName],n,r).getTypeChecker()}function ht(e,t){try{return e.getSymbolAtLocation(t)}catch{return}}function At(e,t,n,r){let s=r.parent&&e.isShorthandPropertyAssignment(r.parent)&&r.parent.name===r,i;try{i=s?t.getShorthandAssignmentValueSymbol(r.parent):ht(t,r)}catch{i=void 0}return!!i?.declarations?.some(a=>a.getSourceFile().fileName===n.fileName)}function fe(e,t){let n,r=[],s=(a,o,d,f=!1)=>r.push({specifier:d,kind:o,line:Xt(t,a),typeOnly:f,unresolved:d===void 0,node:a}),i=a=>{if(e.isImportDeclaration(a))s(a,"import",ue(e,a.moduleSpecifier),Jt(e,a));else if(e.isExportDeclaration(a)&&a.moduleSpecifier)s(a,"export",ue(e,a.moduleSpecifier),Jt(e,a));else if(e.isImportEqualsDeclaration(a)&&e.isExternalModuleReference(a.moduleReference))s(a,"require",ue(e,a.moduleReference.expression),a.isTypeOnly===!0);else if(e.isCallExpression(a)){let o=a.expression.kind===e.SyntaxKind.ImportKeyword,f=e.isIdentifier(a.expression)&&a.expression.text==="require"&&!At(e,n??(n=Qt(e,t)),t,a.expression);(o||f)&&s(a,f?"require":"dynamic-import",ue(e,a.arguments[0]))}e.forEachChild(a,i)};return i(t),r}function Jn(e,t){let n=[],r=t;for(;e.isPropertyAccessExpression(r)||e.isElementAccessExpression(r);){if(e.isPropertyAccessExpression(r))n.unshift(r.name.text);else{let s=ue(e,r.argumentExpression);if(s===void 0)return;n.unshift(s)}r=r.expression}if(e.isIdentifier(r))return n.unshift(r.text),{root:r,segments:n}}function Zn(e,t){let n=t.parent;return e.isPropertyAccessExpression(n)||e.isElementAccessExpression(n)?!1:e.isExpressionNode(t)&&!e.isInTypeQuery(t)||e.isShorthandPropertyAssignment(n)&&n.name===t}function Zt(e,t){let n=t[0]==="globalThis"?t.slice(1):t;for(let r=n.length;r>=1;r-=1){let s=n.slice(0,r).join(".");if(e.has(s))return s}}function ye(e,t,n){if(n.length===0)return[];let r=new Set(n),s=Qt(e,t),i=new Map,a=new Set;for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations)e.isIdentifier(c.name)&&a.add(c.name.text);let o=l=>{let c=Jn(e,l);if(!c)return;let p=ht(s,c.root),y=p?i.get(p):void 0;return y?[...y,...c.segments.slice(1)]:At(e,s,t,c.root)||a.has(c.root.text)?void 0:c.segments};for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations){if(!c.initializer||!e.isIdentifier(c.name))continue;let p=o(c.initializer),y=ht(s,c.name);!p||!y||i.set(y,p)}let d=[],f=new Set,g=(l,c)=>{let p=Xt(t,c),y=`${l}:${c.getStart(t)}`;f.has(y)||(f.add(y),d.push({name:l,line:p,node:c}))},h=l=>{let c=l.parent&&(e.isPropertyAccessExpression(l.parent)||e.isElementAccessExpression(l.parent))&&l.parent.expression===l;if((e.isPropertyAccessExpression(l)||e.isElementAccessExpression(l))&&!c){let p=o(l),y=p?Zt(r,p):void 0;y&&g(y,l)}else e.isIdentifier(l)&&r.has(l.text)&&Zn(e,l)&&!At(e,s,t,l)&&g(l.text,l);if(e.isVariableDeclaration(l)&&e.isObjectBindingPattern(l.name)&&l.initializer){let p=o(l.initializer);if(p)for(let y of l.name.elements){if(!e.isIdentifier(y.name))continue;let b=y.propertyName?ue(e,y.propertyName)??y.propertyName.text:y.name.text,I=Zt(r,[...p,b]);I&&g(I,l.initializer)}}e.forEachChild(l,h)};return h(t),d}function bt(e,t,n){let r=[];for(let s of n?.dependencies??fe(e,t)){if(s.typeOnly||!s.specifier)continue;let i=Se(s.specifier);i&&r.push({capability:i,symbol:s.specifier,line:s.line,source:"import-based"})}for(let s of n?.ambientUses??ye(e,t,mt)){let i=Ge(s.name);i&&r.push({capability:i,symbol:s.name,line:s.line,source:"ambient-global"})}return r.sort((s,i)=>s.line-i.line||s.capability.localeCompare(i.capability)||s.symbol.localeCompare(i.symbol))}var Rt={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."},It=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 vt(e,t){return t.flatMap((r,s)=>(r.prefixes??r.intentPrefixes??[]).map(i=>({layer:r.name,layerIndex:s,prefix:i.endsWith(".")?i:`${i}.`}))).filter(({prefix:r})=>e.startsWith(r)).sort((r,s)=>s.prefix.length-r.prefix.length||r.layerIndex-s.layerIndex)[0]?.layer}function ie(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}function xe(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&ie(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:Rt.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:Rt.PUBLISH_MISSING_SOURCE}),t}function O(e,t,n){return{ruleId:e,code:e,message:t,...n}}function me(e,t){return e.slice(0,t).split(`
1
+ var Mn="4.2.1";var Dn="1.4";function E(e){return typeof e=="string"&&e.length>0?e:void 0}function Gt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}function Hn(e,t,n){if(e==="LAYER_IMPORT_VIOLATION")return t.typeOnly||n.targetTypeOnlyExports===!0||n.namedBindingsTypeOnly===!0?"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.":n.peerIsolation===!0?"Extract the shared dependency to a shared layer, then preflight again.":`Define a port in ${t.fromLayer??"the source layer"}, inject the ${t.toLayer??"outer-layer"} implementation, then preflight again.`;if(e==="FORBIDDEN_GLOBAL")return`Inject ${t.target??"the capability"} through a port, then preflight again.`;if(e==="CAPABILITY_VIOLATION")return`Define a ${E(n.capability)??"capability"} port in ${t.fromLayer??"the walled layer"}, bind the implementation outside it, then preflight again.`;if(e==="CIRCULAR_DEPENDENCY")return"Extract the shared dependency into a third module, then preflight again.";if(e==="RAW_EVENT_PUBLISH")return"Publish through a registered intent creator, then run Ark again.";if(e==="PUBLISH_MISSING_SOURCE")return"Add metadata.source to the publish call, then run Ark again.";if(e==="ARKRULE_STRUCTURE"||e==="ARKRULE_INVARIANT"||e==="INVARIANT_UNCOVERED"||e.startsWith("ARKRULE_")){let r=t.arkruleSource??"arkrules/<Layer>.json";return`Fix the structure or invariant for ${t.arkruleId??"the ArkRule"} (declared in ${r}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`}return`Resolve ${e} without weakening ark.config.json, then run Ark again.`}function dt(e,t="error"){let n=E(e.ruleId)??E(e.code)??"ARK_UNKNOWN",r=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,s={...E(e.target)?{target:E(e.target)}:{},...E(e.fromLayer)?{fromLayer:E(e.fromLayer)}:{},...E(e.toLayer)?{toLayer:E(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}:{},...E(e.capability)?{capability:E(e.capability)}:{},...E(e.edgeKind)?{edgeKind:E(e.edgeKind)}:{},...E(e.arkruleId)?{arkruleId:E(e.arkruleId)}:{},...E(e.arkruleSource)?{arkruleSource:E(e.arkruleSource)}:{}};return{ruleId:n,severity:r,message:E(e.message)??n,location:{file:E(e.file)??"<unknown>",line:Gt(e.line,1),column:Gt(e.column,1)},evidence:s,nextAction:E(e.nextAction)??Hn(n,s,e)}}function Vn(e){let t=e.completeness??"complete",n=e.mode??"lexical-compatibility";if(t==="complete"&&(e.completenessReasons?.length??0)>0)throw new Error("completenessReasons must be empty when completeness is complete.");let r=t==="complete"?[]:e.completenessReasons&&e.completenessReasons.length>0?e.completenessReasons.map(o=>({code:E(o.code)??"ANALYSIS_EVIDENCE_INCOMPLETE",message:E(o.message)??`Analysis ${t}: required evidence is incomplete.`,...E(o.file)?{file:E(o.file)}:{}})):[{code:t==="unavailable"?"ANALYSIS_UNAVAILABLE":"ANALYSIS_EVIDENCE_INCOMPLETE",message:`Analysis ${t}: required evidence is incomplete.`}],s={...E(e.policyHash)?{policyHash:E(e.policyHash)}:{},...E(e.resolverIdentity)?{resolverIdentity:E(e.resolverIdentity)}:{},...E(e.factsHash)?{factsHash:E(e.factsHash)}:{},...E(e.candidateTreeHash)?{candidateTreeHash:E(e.candidateTreeHash)}:{}};if(n==="resolved-candidate-facts"&&t!=="unavailable"){for(let o of["policyHash","resolverIdentity","factsHash","candidateTreeHash"])if(!s[o])throw new Error(`${o} is required for resolved ${t} adapter evidence.`)}let i=[...(e.violations??[]).map(o=>dt(o,"error")),...(e.warnings??[]).map(o=>dt(o,"warning"))],a={schemaVersion:"1.4",completenessReasons:r,diagnostics:i};if(n==="resolved-candidate-facts"){if(t==="unavailable")return{...a,mode:n,valid:!1,completeness:t,...s};let o={policyHash:s.policyHash,resolverIdentity:s.resolverIdentity,factsHash:s.factsHash,candidateTreeHash:s.candidateTreeHash};return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...o}:{...a,mode:n,valid:!1,completeness:t,...o}}return t==="complete"?{...a,mode:n,valid:e.valid,completeness:t,...s}:{...a,mode:n,valid:!1,completeness:t,...s}}var jn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://unpkg.com/arkgate@3/schemas/ark.analysis-result.schema.json",title:"ArkGate analysis result",type:"object",additionalProperties:!1,required:["schemaVersion","mode","valid","completeness","completenessReasons","diagnostics"],allOf:[{if:{properties:{completeness:{enum:["partial","unavailable"]}},required:["completeness"]},then:{properties:{valid:{const:!1}}}},{if:{properties:{mode:{const:"resolved-candidate-facts"},completeness:{enum:["complete","partial"]}},required:["mode","completeness"]},then:{required:["policyHash","resolverIdentity","factsHash","candidateTreeHash"]}},{if:{properties:{completeness:{const:"complete"}},required:["completeness"]},then:{properties:{completenessReasons:{maxItems:0}}},else:{properties:{completenessReasons:{minItems:1}}}}],properties:{schemaVersion:{const:"1.4"},mode:{enum:["lexical-compatibility","resolved-candidate-facts"]},valid:{type:"boolean"},completeness:{enum:["complete","partial","unavailable"]},completenessReasons:{type:"array",items:{type:"object",additionalProperties:!1,required:["code","message"],properties:{code:{type:"string",minLength:1},message:{type:"string",minLength:1},file:{type:"string",minLength:1}}}},policyHash:{type:"string",minLength:1},resolverIdentity:{type:"string",minLength:1},factsHash:{type:"string",minLength:1},candidateTreeHash:{type:"string",minLength:1},diagnostics:{type:"array",items:{type:"object",additionalProperties:!1,required:["ruleId","severity","message","location","evidence"],properties:{ruleId:{type:"string",minLength:1},severity:{enum:["error","warning"]},message:{type:"string",minLength:1},location:{type:"object",additionalProperties:!1,required:["file","line","column"],properties:{file:{type:"string",minLength:1},line:{type:"integer",minimum:1},column:{type:"integer",minimum:1}}},evidence:{type:"object",additionalProperties:!1,properties:{target:{type:"string"},fromLayer:{type:"string"},toLayer:{type:"string"},typeOnly:{type:"boolean"},targetTypeOnlyExports:{type:"boolean"},sourcePureTypeModule:{type:"boolean"},namedBindingsTypeOnly:{type:"boolean"},portProofEligible:{type:"boolean"},peerIsolation:{type:"boolean"},capability:{type:"string",minLength:1},edgeKind:{type:"string",minLength:1},arkruleId:{type:"string",minLength:1},arkruleSource:{type:"string",minLength:1}}},nextAction:{type:"string",minLength:1}}}}}};var Un="1.0",Bt="https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json",Ue="^sha256:[a-f0-9]{64}$",qt={type:"object",additionalProperties:!1,properties:{expectedRoot:{type:"string",minLength:1,description:"Absolute expected workspace/project directory. The initial authoritative handshake requires the exact project root; descendant calls also require expectedProjectId."},expectedProjectId:{type:"string",pattern:Ue,description:"Project id previously returned by ark_identity or ark_manifest."}}},zt={type:"object",additionalProperties:!1,required:["status","authoritative"],properties:{status:{enum:["matched","unverified","mismatch"]},authoritative:{type:"boolean"},expectedRoot:{type:"string",minLength:1},expectedProjectId:{type:"string",pattern:Ue},code:{enum:["PROJECT_ROOT_MISMATCH","PROJECT_ID_MISMATCH","INVALID_PROJECT_EXPECTATION"]},message:{type:"string",minLength:1}}},Gn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Bt,title:"ArkGate MCP project identity",description:"Stable project binding plus separate runtime and architecture-contract evidence.",type:"object",additionalProperties:!1,required:["schemaVersion","projectId","resolvedRoot","resolvedConfigPath","arkgateVersion","contractHash","contractSource","runtimeId","processStartedAt"],properties:{schemaVersion:{const:"1.0"},projectId:{type:"string",pattern:Ue},resolvedRoot:{type:"string",minLength:1},resolvedConfigPath:{type:"string",minLength:1},arkgateVersion:{type:"string",minLength:1},contractHash:{type:"string",pattern:Ue},contractSource:{enum:["project","default-profile","manifest"]},runtimeId:{type:"string",minLength:1},processStartedAt:{type:"string",format:"date-time"}},$defs:{expectation:qt,binding:zt}};function Bn(e,t,n){if(!e||!t)throw new Error("Project identity requires resolvedRoot and resolvedConfigPath.");let r=n(JSON.stringify({resolvedRoot:e,resolvedConfigPath:t})).toLowerCase();if(!/^[a-f0-9]{64}$/.test(r))throw new Error("Project identity hash adapter must return 64 hexadecimal SHA-256 characters.");return`sha256:${r}`}function qn(e){return{schemaVersion:"1.0",...e}}var ut=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),yt=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),mt=Object.freeze(Object.keys(yt).sort()),pt=Object.freeze({fs:"filesystem","node:fs":"filesystem","fs/promises":"filesystem","node:fs/promises":"filesystem","fs-extra":"filesystem","graceful-fs":"filesystem",memfs:"filesystem",chokidar:"filesystem",http:"network",https:"network",http2:"network",net:"network",tls:"network",dgram:"network",dns:"network","node:http":"network","node:https":"network","node:http2":"network","node:net":"network","node:tls":"network","node:dgram":"network","node:dns":"network",axios:"network",undici:"network","node-fetch":"network",got:"network",ky:"network",superagent:"network",ws:"network",process:"process","node:process":"process",child_process:"process","node:child_process":"process","@prisma/client":"persistence",prisma:"persistence",pg:"persistence",mysql:"persistence",mysql2:"persistence",mongodb:"persistence",mongoose:"persistence",sqlite3:"persistence","better-sqlite3":"persistence",redis:"persistence",ioredis:"persistence",typeorm:"persistence",knex:"persistence","drizzle-orm":"persistence",sequelize:"persistence",kysely:"persistence","@supabase/supabase-js":"persistence"}),ft=Object.freeze({process:Object.freeze(["process","node:process"])});function Se(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=pt[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=pt[r];if(s)return s;let i=e.indexOf("/",n+1);return i<0?null:pt[e.slice(0,i)]??null}function ee(e,t){for(let n of t)if(ft[n]?.includes(e))return n;return null}function Ge(e){let t=e.split(".");for(let n=t.length;n>=1;n-=1){let r=t.slice(0,n).join("."),s=yt[r];if(s)return s}return null}function pe(e){if(e?.pure===!0)return[...ut].sort();let n=(e?.capabilities?.deny??[]).filter(r=>ut.includes(r));return[...new Set(n)].sort()}function ke(e,t){if(t.length===0)return!1;let n=new Set(t),r=e.split(".");for(let s=r.length;s>=1;s-=1)if(n.has(r.slice(0,s).join(".")))return!0;return!1}function Be(e){let t=new Set,n=new Set,r=Object.keys(yt);for(let s of e?.forbiddenGlobals??[]){let i=r.filter(a=>a===s||a.startsWith(`${s}.`));if(i.length===0)n.add(s);else for(let a of i)t.add(`ambient:${a}`);for(let a of ft[s]??[])t.add(`import-exact:${a}`)}for(let s of pe(e)){if(t.add(`import:${s}`),s==="process")for(let i of ft.process)t.add(`import-exact:${i}`);for(let i of r)Ge(i)===s&&t.add(`ambient:${i}`)}return{atoms:[...t].sort(),rawGlobals:[...n].sort()}}var Kt=new Map;function Yt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}function qe(e){let t="";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"&&n+1<e.length){let s=e[n+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,n+=1;continue}t+="/";continue}t+=r}return t}function zn(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"){n+=1;continue}if(r==="{")t+=1;else if(r==="}"&&(t-=1,t<0))return!1}return t===0}function se(e){let t=Kt.get(e);if(t)return t;let n=qe(e),r=zn(n),s="",i=0;for(let o=0;o<n.length;o+=1){let d=n[o];d==="\\"&&o+1<n.length?(s+=Yt(n[o+1]),o+=1):d==="*"?n[o+1]==="*"?n[o+2]==="/"?(s+="(?:.*/)?",o+=2):(s+=".*",o+=1):s+="[^/]*":d==="?"?s+="[^/]":d==="{"&&r?(s+="(?:",i+=1):d==="}"&&r&&i>0?(s+=")",i-=1):d===","&&r&&i>0?s+="|":s+=Yt(d)}let a=new RegExp(`^${s}$`);return Kt.set(e,a),a}function Kn(e){return qe(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}function gt(e,t){let n=qe(String(e)),r=Kn(n),s=n.replace(/\*/g,"").length,i=r.length*1e4+s;if(t==null||t==="")return i;let a=String(t).split(/[/\\]/).filter(Boolean);if(r.length===0)return s;let o=0,d=-1;for(let f of r){let g=-1;for(let h=o;h<a.length;h+=1)if(a[h]===f){g=h;break}if(g<0)return i;d=g,o=g+1}return(d+1)*1e6+r.length*1e4+s}function J(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let i of t??[])if(!(i.exclude??[]).some(a=>se(a).test(n))){for(let a of i.patterns??[])if(se(a).test(n)){let o=gt(a,n);o>s&&(s=o,r=i.name)}}return r}function Wt(e,t){if(!t?.length)return;let n=String(e).split(/[/\\]/).filter(Boolean),r=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<n.length-1;s+=1)if(r.has(n[s].toLowerCase()))return`${n[s].toLowerCase()}/${n[s+1].toLowerCase()}`}function Yn(e){let t=new Set;for(let n of e??[]){let s=qe(String(n)).split("/").filter(Boolean);for(let i=0;i<s.length;i+=1){let a=s[i];if((a==="**"||a==="*")&&i>0){let o=s[i-1];o&&!o.includes("*")&&!o.includes("{")&&!o.includes("}")&&t.add(o)}}}return[...t]}function Wn(e,t,n){if(Array.isArray(e.sliceFolders)&&e.sliceFolders.length>0)return e.sliceFolders.filter(s=>typeof s=="string"&&s.length>0);let r=(n??[]).find(s=>s.name===t);return Yn(r?.patterns)}function Z(e,t,n,r){for(let s of e??[])if(!(s.from!==t||s.to!==n)&&s.allowed===!1){if(s.peerIsolation){let i=r?.fromPath,a=r?.toPath;if(!i||!a)return s;let o=Wn(s,t,r?.layers);if(o.length===0)return s;let d=Wt(i,o),f=Wt(a,o);if(!d||!f||d!==f)return s;continue}if(t!==n)return s}}function ue(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}function Xt(e,t){return e.getLineAndCharacterOfPosition(t.getStart(e)).line+1}function Jt(e,t){if(e.isImportDeclaration(t)){let r=t.importClause;if(!r)return!1;if(r.isTypeOnly)return!0;let s=r.namedBindings;return!!(s&&e.isNamedImports(s)&&s.elements.length>0&&s.elements.every(i=>i.isTypeOnly))}if(t.isTypeOnly)return!0;let n=t.exportClause;return!!(n&&e.isNamedExports(n)&&n.elements.length>0&&n.elements.every(r=>r.isTypeOnly))}function Qt(e,t){let n={noLib:!0,noResolve:!0,target:e.ScriptTarget.Latest},r=e.createCompilerHost(n,!0);return r.getSourceFile=s=>s===t.fileName?t:void 0,r.fileExists=s=>s===t.fileName,r.readFile=s=>s===t.fileName?t.text:void 0,e.createProgram([t.fileName],n,r).getTypeChecker()}function ht(e,t){try{return e.getSymbolAtLocation(t)}catch{return}}function At(e,t,n,r){let s=r.parent&&e.isShorthandPropertyAssignment(r.parent)&&r.parent.name===r,i;try{i=s?t.getShorthandAssignmentValueSymbol(r.parent):ht(t,r)}catch{i=void 0}return!!i?.declarations?.some(a=>a.getSourceFile().fileName===n.fileName)}function fe(e,t){let n,r=[],s=(a,o,d,f=!1)=>r.push({specifier:d,kind:o,line:Xt(t,a),typeOnly:f,unresolved:d===void 0,node:a}),i=a=>{if(e.isImportDeclaration(a))s(a,"import",ue(e,a.moduleSpecifier),Jt(e,a));else if(e.isExportDeclaration(a)&&a.moduleSpecifier)s(a,"export",ue(e,a.moduleSpecifier),Jt(e,a));else if(e.isImportEqualsDeclaration(a)&&e.isExternalModuleReference(a.moduleReference))s(a,"require",ue(e,a.moduleReference.expression),a.isTypeOnly===!0);else if(e.isCallExpression(a)){let o=a.expression.kind===e.SyntaxKind.ImportKeyword,f=e.isIdentifier(a.expression)&&a.expression.text==="require"&&!At(e,n??(n=Qt(e,t)),t,a.expression);(o||f)&&s(a,f?"require":"dynamic-import",ue(e,a.arguments[0]))}e.forEachChild(a,i)};return i(t),r}function Jn(e,t){let n=[],r=t;for(;e.isPropertyAccessExpression(r)||e.isElementAccessExpression(r);){if(e.isPropertyAccessExpression(r))n.unshift(r.name.text);else{let s=ue(e,r.argumentExpression);if(s===void 0)return;n.unshift(s)}r=r.expression}if(e.isIdentifier(r))return n.unshift(r.text),{root:r,segments:n}}function Zn(e,t){let n=t.parent;return e.isPropertyAccessExpression(n)||e.isElementAccessExpression(n)?!1:e.isExpressionNode(t)&&!e.isInTypeQuery(t)||e.isShorthandPropertyAssignment(n)&&n.name===t}function Zt(e,t){let n=t[0]==="globalThis"?t.slice(1):t;for(let r=n.length;r>=1;r-=1){let s=n.slice(0,r).join(".");if(e.has(s))return s}}function ye(e,t,n){if(n.length===0)return[];let r=new Set(n),s=Qt(e,t),i=new Map,a=new Set;for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations)e.isIdentifier(c.name)&&a.add(c.name.text);let o=l=>{let c=Jn(e,l);if(!c)return;let p=ht(s,c.root),y=p?i.get(p):void 0;return y?[...y,...c.segments.slice(1)]:At(e,s,t,c.root)||a.has(c.root.text)?void 0:c.segments};for(let l of t.statements)if(e.isVariableStatement(l))for(let c of l.declarationList.declarations){if(!c.initializer||!e.isIdentifier(c.name))continue;let p=o(c.initializer),y=ht(s,c.name);!p||!y||i.set(y,p)}let d=[],f=new Set,g=(l,c)=>{let p=Xt(t,c),y=`${l}:${c.getStart(t)}`;f.has(y)||(f.add(y),d.push({name:l,line:p,node:c}))},h=l=>{let c=l.parent&&(e.isPropertyAccessExpression(l.parent)||e.isElementAccessExpression(l.parent))&&l.parent.expression===l;if((e.isPropertyAccessExpression(l)||e.isElementAccessExpression(l))&&!c){let p=o(l),y=p?Zt(r,p):void 0;y&&g(y,l)}else e.isIdentifier(l)&&r.has(l.text)&&Zn(e,l)&&!At(e,s,t,l)&&g(l.text,l);if(e.isVariableDeclaration(l)&&e.isObjectBindingPattern(l.name)&&l.initializer){let p=o(l.initializer);if(p)for(let y of l.name.elements){if(!e.isIdentifier(y.name))continue;let b=y.propertyName?ue(e,y.propertyName)??y.propertyName.text:y.name.text,I=Zt(r,[...p,b]);I&&g(I,l.initializer)}}e.forEachChild(l,h)};return h(t),d}function bt(e,t,n){let r=[];for(let s of n?.dependencies??fe(e,t)){if(s.typeOnly||!s.specifier)continue;let i=Se(s.specifier);i&&r.push({capability:i,symbol:s.specifier,line:s.line,source:"import-based"})}for(let s of n?.ambientUses??ye(e,t,mt)){let i=Ge(s.name);i&&r.push({capability:i,symbol:s.name,line:s.line,source:"ambient-global"})}return r.sort((s,i)=>s.line-i.line||s.capability.localeCompare(i.capability)||s.symbol.localeCompare(i.symbol))}var Rt={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."},It=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 vt(e,t){return t.flatMap((r,s)=>(r.prefixes??r.intentPrefixes??[]).map(i=>({layer:r.name,layerIndex:s,prefix:i.endsWith(".")?i:`${i}.`}))).filter(({prefix:r})=>e.startsWith(r)).sort((r,s)=>s.prefix.length-r.prefix.length||r.layerIndex-s.layerIndex)[0]?.layer}function ie(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}function xe(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&ie(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:Rt.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:Rt.PUBLISH_MISSING_SOURCE}),t}function O(e,t,n){return{ruleId:e,code:e,message:t,...n}}function me(e,t){return e.slice(0,t).split(`
2
2
  `).length}function Xn(e){let t=[],n=/['"`]([A-Za-z][A-Za-z0-9_.]*)['"`]/g,r;for(;(r=n.exec(e))!==null;)t.push({value:r[1],index:r.index});return t}function Qn(e){let t=[],n=[{kind:"import",re:/\bimport\s+(?:type\s+)?(?:[^'"]*?\s+from\s*)?['"]([^'"]+)['"]/g},{kind:"export",re:/\bexport\s+(?:type\s+)?[^'"]*?\s+from\s*['"]([^'"]+)['"]/g},{kind:"dynamic-import",re:/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g},{kind:"require",re:/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g}];for(let r of n){let s;for(;(s=r.re.exec(e))!==null;){let i=s.index+s[0].indexOf(s[1]),a=s[0],o=r.kind==="import"&&/\bimport\s+type\b/.test(a)||r.kind==="export"&&/\bexport\s+type\b/.test(a);t.push({value:s[1],index:i,kind:r.kind,typeOnly:o})}}return t.sort((r,s)=>r.index-s.index)}function er(e,t){let n=e.createSourceFile("generated.ts",t,e.ScriptTarget.Latest,!0),r=[],s=i=>{e.isStringLiteralLike(i)&&r.push({value:i.text,index:i.getStart(n)}),e.forEachChild(i,s)};return s(n),r}function tr(e){let t=e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return["adapter","adapters","infra","infrastructure","persistence","repository","repositories","integration","database","db"].some(n=>t.includes(n))}function nr(e){let t=e.toLowerCase();return["sequelize","prisma","typeorm","mongoose","knex"].some(n=>t===n||t.startsWith(`${n}/`))}function rr(e){let t=e.toLowerCase();return["adapter","infra","persistence","repository","repositories","integration","database"].some(n=>t.includes(n))}function Te(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}function sr(e,t){if(t&&(e.isIdentifier(t)||e.isStringLiteralLike(t)))return t.text}function en(e,t,n){if(!(!t||!e.isObjectLiteralExpression(t)))return t.properties.find(r=>!e.isPropertyAssignment(r)&&!e.isShorthandPropertyAssignment(r)?!1:sr(e,r.name)===n)}function Pe(e,t,n){return en(e,t,n)!==void 0}function Oe(e,t,n){let r=en(e,t,n);return r&&e.isPropertyAssignment(r)?r.initializer:void 0}function ir(e,t){let n=Oe(e,t,"metadata");return Pe(e,n,"source")}function tn(e,t){return t?e.isIdentifier(t)?/^[A-Z]/.test(t.text):e.isPropertyAccessExpression(t)?tn(e,t.name):!1:!1}function ar(e,t){if(!e.isCallExpression(t))return!1;let n=t.expression;return e.isPropertyAccessExpression(n)?n.name.text==="publish":e.isIdentifier(n)&&n.text==="publish"}function or(e,t){if(!e.isCallExpression(t))return!1;let n=t.arguments[0],r=Te(e,n);return r!==void 0&&ie(r)||Pe(e,n,"intent")||tn(e,n)}function lr(e,t){if(!e.isCallExpression(t))return!1;let[n,r,s]=t.arguments;return ir(e,n)||Pe(e,r,"source")||Pe(e,s,"source")}function cr(e,t){if(!e.isCallExpression(t))return;let[n,r,s]=t.arguments,i=Oe(e,n,"metadata");return Te(e,Oe(e,i,"source"))??Te(e,Oe(e,r,"source"))??Te(e,Oe(e,s,"source"))}function dr(e,t,n,r){let s=e.createSourceFile("generated.ts",t,e.ScriptTarget.Latest,!0),i=n,a=i?.filePath,o=i?.layer,d=[],f=h=>s.getLineAndCharacterOfPosition(h.getStart(s)).line+1,g=h=>{if(ar(e,h)){let l=h.arguments[0],c=Te(e,l);for(let y of xe({publishCall:!0,rawIntentName:c,objectHasIntent:Pe(e,l,"intent"),arkPublishCandidate:or(e,h),hasSource:lr(e,h)}))d.push(O(y.ruleId,y.message,{line:f(h),filePath:a}));let p=cr(e,h);if(r&&o&&p&&ie(p)){let y=r.resolveLayer(p);y&&y!==o&&d.push(O("PUBLISH_SOURCE_LAYER_MISMATCH",`Publish source "${p}" resolves to ${y}, but the target file is classified as ${o}.`,{line:f(h),filePath:a,target:p,fromLayer:o,toLayer:y}))}}e.forEachChild(h,g)};return g(s),d}function nn(e={}){let t=new Set((e.intents||[]).map(i=>typeof i=="string"?i:i.name)),n=e.forbiddenPatterns||[],r=new Set(e.infrastructureLayers??[]),s=e.enforceIntentAllowlist??t.size>0;return{validate(i,a){let o=[],d=a,f=d?.filePath,g=d?.layer,h=e.typescript,l=h?h.createSourceFile(f??"generated.ts",i,h.ScriptTarget.Latest,!0):void 0,c=l?fe(e.typescript,l):void 0,p=c?c.filter(u=>u.specifier!==void 0).map(u=>({value:u.specifier,index:u.node.getStart(l),kind:u.kind,typeOnly:u.typeOnly})):Qn(i),y=e.typescript?er(e.typescript,i):Xn(i);if(e.typescript&&!e.allowNonLiteralDynamicImport?.(f))for(let u of c?.filter(({unresolved:m})=>m)??[]){let m=u.kind==="require";o.push(O(m?"DYNAMIC_REQUIRE_NOT_ALLOWLISTED":"DYNAMIC_IMPORT_NOT_ALLOWLISTED",`Non-literal ${m?"require call":"dynamic import"} cannot be resolved statically; add the reviewed file to dynamicImportAllowlist.`,{line:u.line,filePath:f}))}let b=g!==void 0&&(r.has(g)||rr(g)),I=g!==void 0?` If "${g}" is an infrastructure layer, mark it in ark.config.json with "mayImportInfrastructure": true (or name it with an infra token like Adapters/Persistence/Repository).`:"";for(let u of n)if(u instanceof RegExp){u.lastIndex=0;let m=u.exec(i);u.lastIndex=0,m&&o.push(O("FORBIDDEN_PATTERN",`Forbidden pattern matched: ${u}`,{line:m.index===void 0?void 0:me(i,m.index),filePath:f,suggestion:"Remove infrastructure imports from domain/application layers."+I}))}else i.includes(u)&&o.push(O("FORBIDDEN_SUBSTRING",`Forbidden substring: ${u}`,{line:me(i,i.indexOf(u)),filePath:f}));for(let u of p){let m=e.resolveImportTarget?.(u.value,f)??(e.resolveImportLayer?{layer:e.resolveImportLayer(u.value,f)}:void 0),R=typeof f=="string"?e.resolveImportTarget?.(f)??(e.resolveImportLayer?{layer:g,relPath:void 0}:void 0):void 0,S=m?.layer;if(S&&g){let T=Z(e.architectureProfile?.rules,g,S,{fromPath:R?.relPath,toPath:m?.relPath,layers:e.architectureLayers});if(T){if(u.typeOnly&&!T.peerIsolation)continue;let L=!!T.peerIsolation;o.push(O("LAYER_IMPORT_VIOLATION",T.message??(L?`Layer "${g}" must not import across slices into "${S}".`:`Layer "${g}" must not import "${S}".`),{line:me(i,u.index),source:u.value,target:u.value,filePath:f,fromLayer:g,toLayer:S,suggestion:L?"Extract shared code to a shared layer, or coordinate slices via events/ports \u2014 do not import across feature/context slices.":"Depend on a port/interface owned by an inner layer instead, or move this code to a layer allowed to make this import.",details:{importKind:u.kind,peerIsolation:L,...u.typeOnly?{typeOnly:!0}:{}}}));continue}continue}b||u.typeOnly||!tr(u.value)&&!nr(u.value)||o.push(O("FORBIDDEN_IMPORT",`Forbidden ${u.kind} target: "${u.value}".`,{line:me(i,u.index),source:u.value,target:u.value,filePath:f,suggestion:"Route infrastructure access through an allowed adapter or port boundary."+I,details:{importKind:u.kind}}))}if(e.policies)for(let u of e.policies){let m=u.check({source:i,context:a});if(m!==!0)if(Array.isArray(m))for(let R of m)o.push(O("POLICY_VIOLATION",R.message,{filePath:f,suggestion:`Fix violation of policy "${u.name}".`}));else m===!1?o.push(O("POLICY_VIOLATION",`Policy ${u.name} failed on generated code`)):o.push(O("POLICY_VIOLATION",m.message))}if(s&&t.size>0)for(let u of y)ie(u.value)&&!t.has(u.value)&&o.push(O("UNKNOWN_INTENT",`Unknown intent reference: "${u.value}"`,{line:me(i,u.index),filePath:f,target:u.value,suggestion:`Register intent "${u.value}" via defineIntent() or remove the reference.`}));if(e.architectureProfile&&g)for(let u of y){if(!ie(u.value))continue;let m=e.architectureProfile.resolveLayer(u.value);if(!m)continue;let R=Z(e.architectureProfile.rules,g,m);R&&o.push(O("LAYER_REFERENCE_VIOLATION",R.message??`Layer "${g}" must not reference "${m}" through "${u.value}".`,{line:me(i,u.index),filePath:f,target:u.value,fromLayer:g,toLayer:m,suggestion:"Route the dependency through an allowed intent, port, or event.",details:{rule:R}}))}if(e.extensions)for(let u of e.extensions)try{let m=u.analyze(i,a);o.push(...m)}catch(m){o.push(O("EXTENSION_ERROR",`Extension "${u.name}" failed: ${m instanceof Error?m.message:String(m)}`))}if(e.typescript&&l&&g&&e.forbiddenGlobals?.[g]?.length)try{let u=e.forbiddenGlobals[g];o.push(...ye(e.typescript,l,u).map(m=>O("FORBIDDEN_GLOBAL",`${g} must not use the ambient global "${m.name}".`,{line:m.line,filePath:f,target:m.name,fromLayer:g,suggestion:"Inject the capability through a port (e.g. a Clock, IdGenerator, or HttpPort) instead of reaching for the ambient global."})));for(let m of c??[]){if(m.typeOnly||!m.specifier)continue;let R=ee(m.specifier,u);R&&o.push(O("FORBIDDEN_GLOBAL",`${g} must not use module "${m.specifier}" because it is the import form of forbidden global "${R}".`,{line:m.line,filePath:f,source:m.specifier,target:m.specifier,fromLayer:g,details:{importKind:m.kind,forbiddenGlobal:R},suggestion:"Inject the capability through a port instead of importing the ambient global module form."}))}}catch(u){o.push(O("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${u instanceof Error?u.message:String(u)}`))}if(e.typescript&&l&&g&&e.capabilityWalls?.[g]?.length)try{let u=new Set(e.capabilityWalls[g]),m=e.forbiddenGlobals?.[g]??[];for(let R of bt(e.typescript,l))u.has(R.capability)&&(R.source==="ambient-global"&&ke(R.symbol,m)||R.source==="import-based"&&ee(R.symbol,m)||o.push(O("CAPABILITY_VIOLATION",R.source==="import-based"?`${g} denies the ${R.capability} capability; found import of "${R.symbol}".`:`${g} denies the ${R.capability} capability; found ambient "${R.symbol}".`,{line:R.line,filePath:f,target:R.symbol,capability:R.capability,fromLayer:g,suggestion:"Define a small port (ClockPort, HttpPort, StoragePort) and bind the implementation in an adapter layer."})))}catch(u){o.push(O("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${u instanceof Error?u.message:String(u)}`))}if(e.typescript)try{o.push(...dr(e.typescript,i,a,e.architectureProfile))}catch(u){o.push(O("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${u instanceof Error?u.message:String(u)}`))}return{mode:"lexical-compatibility",completeness:"partial",completenessReasons:["LEXICAL_EVIDENCE_INCOMPLETE"],valid:!1,lexicalValid:o.length===0,violations:o}}}}var pr="1.1",Ke="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",rn=["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 fr(){let e=[];for(let t of rn)for(let n of rn)t===n||ur.has(`${t}->${n}`)||e.push({from:t,to:n,allowed:!1});return e}var Ye=fr(),Et=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"}],te={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Ct={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Ke,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:Ke,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:"1.1",default:"1.1"},name:{type:"string",minLength:1},include:{...te,minItems:1,default:["src"]},exclude:{...te,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:Ye,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...te,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...te,minItems:1},exclude:te,intentPrefixes:te,description:{type:"string",minLength:1},forbiddenGlobals:te,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"}}},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:{...te,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}}}}},X=class extends Error{issues;source;constructor(t,n){super(`Invalid ArkGate config (${t}):
3
3
  ${n.map(r=>`- ${r.path}: ${r.message}`).join(`
4
4
  `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=n}};function sn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ze(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function ge(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function yr(e,t){let n="#/$defs/";if(e.startsWith(n))return t.$defs[e.slice(n.length)]}function we(e,t,n,r,s){if(t.$ref){let i=yr(t.$ref,r);if(!i){s.push({path:n,message:`schema reference ${t.$ref} cannot be resolved`});return}we(e,i,n,r,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:n,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(i=>Object.is(i,e))){s.push({path:n,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!sn(e)){s.push({path:n,message:`must be an object; received ${ge(e)}`});return}let i=t.properties??{};for(let a of t.required??[])e[a]===void 0&&s.push({path:ze(n,a),message:"is required"});if(t.additionalProperties===!1)for(let a of Object.keys(e))a in i||s.push({path:ze(n,a),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let a=t.additionalProperties;for(let o of Object.keys(e))o in i||we(e[o],a,ze(n,o),r,s)}for(let[a,o]of Object.entries(i))e[a]!==void 0&&we(e[a],o,ze(n,a),r,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:n,message:`must be an array; received ${ge(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:n,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let i=e.map(a=>JSON.stringify(a));new Set(i).size!==i.length&&s.push({path:n,message:"must not contain duplicate items"})}t.items&&e.forEach((i,a)=>we(i,t.items,`${n}[${a}]`,r,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:n,message:`must be a string; received ${ge(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:n,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:n,message:`must be a boolean; received ${ge(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:n,message:`must be an integer; received ${ge(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:n,message:`must be at least ${t.minimum}`})}}function mr(e){return{...e,$schema:e.$schema===void 0?Ke:e.$schema,schemaVersion:e.schemaVersion===void 0?"1.1":e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?Ye.map(t=>({...t})):e.rules}}function gr(){let e=new Set(["1.1"]);for(let t of Et)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}function hr(e,t="ark.config.json"){if(!sn(e))throw new X(t,[{path:"$",message:`must be an object; received ${ge(e)}`}]);let n=gr(),r=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(r===null)throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected 1.1`}]);if(r!=="unversioned"&&!n.has(r))throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected 1.1`}]);let s=r,i={...e},a=0;for(;s!=="1.1"&&a<Et.length+1;){a+=1;let d=Et.find(f=>f.from===s);if(!d)throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected 1.1`}]);s=d.to,i.schemaVersion=s}if(s!=="1.1")throw new X(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected 1.1`}]);let o=r==="unversioned"?"unversioned":r==="1.0"?"1.0":null;return{candidate:mr(i),migratedFrom:o}}function We(e,t="ark.config.json"){let{candidate:n,migratedFrom:r}=hr(e,t),s=[];if(we(n,Ct,"$",Ct,s),s.length>0)throw new X(t,s);return{config:n,migratedFrom:r}}function St(e,t="ark.config.json"){let n;try{n=JSON.parse(e)}catch(r){throw new X(t,[{path:"$",message:`invalid JSON: ${r instanceof Error?r.message:String(r)}`}])}return We(n,t)}function an(e){let t={$schema:typeof e.$schema=="string"&&e.$schema.length>0?e.$schema:Ke,schemaVersion:"1.1"};for(let[n,r]of Object.entries(e))n!=="$schema"&&n!=="schemaVersion"&&(t[n]=r);return t}function Ar(e){return e.endsWith(".")?e:`${e}.`}function br(e,t){let n=e.prefixes.length?Math.max(...e.prefixes.map(s=>s.length)):0;return(t.prefixes.length?Math.max(...t.prefixes.map(s=>s.length)):0)-n}function Ze(e){let t=e.layers.map(s=>({...s,prefixes:s.prefixes.map(Ar)})),n=[...t].sort(br),r=[...e.rules??[]];return{name:e.name,layers:t,rules:r,resolveLayer(s){return t.find(i=>i.match?.(s))?.name??n.find(i=>i.prefixes.some(a=>s.startsWith(a)))?.name}}}function on(e,t={}){return Ze({name:t.name??e.name??"ark.config.json",layers:e.layers.map((n,r)=>({name:n.name,prefixes:n.intentPrefixes??[],description:n.description,order:r+1})),rules:e.rules??[]})}var Rr=[{name:"DomainModel",prefixes:["Domain"],description:"Rich domain model, business rules, and domain events.",order:1},{name:"ApplicationOrchestration",prefixes:["Application"],description:"Use cases and command orchestration.",order:2},{name:"PersistenceAdapters",prefixes:["Adapter.Persistence","Adapter.Repository"],description:"Database, repository, and storage adapters.",order:3},{name:"IntegrationAdapters",prefixes:["Adapter.Integration","Adapter.External"],description:"External systems, APIs, and integration adapters.",order:4},{name:"WorkflowSagaEngine",prefixes:["Workflow"],description:"Sagas, workflows, and long-running processes.",order:5},{name:"BackgroundJobsScheduling",prefixes:["Job"],description:"Background jobs, scheduled work, and async processors.",order:6},{name:"PresentationAdapters",prefixes:["Presentation","Adapter.Presentation","Adapter.Api"],description:"API, UI, controller, and presentation adapters.",order:7},{name:"ReportingReadModels",prefixes:["Reporting"],description:"Read models, projections, and reporting surfaces.",order:8},{name:"ExtensibilityMetadata",prefixes:["Metadata"],description:"Metadata, extensions, and schema contracts.",order:9},{name:"SecurityAuditObservability",prefixes:["Security","Audit","Observability"],description:"Security, audit, and observability concerns.",order:10},{name:"Kernel",prefixes:["Kernel"],description:"Ark-owned governance and kernel signals.",order:11}],Je=Ze({name:"Ark 11-layer Hexagonal Event-Driven Profile",layers:Rr,rules:Ye.map(e=>({...e}))}),Ir={DomainModel:["domain"],ApplicationOrchestration:["application","app"],PersistenceAdapters:["adapters/persistence","adapters/repository","repositories","infra/persistence"],IntegrationAdapters:["adapters/integration","adapters/external","integrations"],WorkflowSagaEngine:["workflows","sagas"],BackgroundJobsScheduling:["jobs","schedules"],PresentationAdapters:["presentation","adapters/presentation","adapters/api"],ReportingReadModels:["reporting","read-models","projections"],ExtensibilityMetadata:["metadata","extensions"],SecurityAuditObservability:["security","audit","observability"],Kernel:["kernel"]};function ln(e={}){let t=e.rootDir??"src",n=e.optionalLayers??!0,r=t==="."?"":`${t}/`;return an({include:e.include??[t],layers:Je.layers.map(s=>({name:s.name,patterns:(Ir[s.name]??[s.name]).map(i=>`${r}${i}/**`),intentPrefixes:s.prefixes,optional:n})),rules:[...Je.rules]})}function w(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}function x(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(x).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${x(t[n])}`).join(",")}}`}var ae="1.1";var cn=["network","filesystem","clock","randomness","environment","process","persistence"];function Q(e,t){let n=x(e),r=x(t);return n<r?-1:n>r?1:0}function Y(e){return[...new Set(e)].sort((t,n)=>t<n?-1:t>n?1:0)}function $e(e){let t={schemaVersion:"1.1",include:Y(e.include??[]),exclude:Y(e.exclude??[]),excludeGenerated:e.excludeGenerated!==!1,dynamicImportAllowlist:Y(e.dynamicImportAllowlist??[]),layers:e.layers.map(n=>({name:n.name,patterns:Y(n.patterns??[]),exclude:Y(n.exclude??[]),forbiddenGlobals:Y(n.forbiddenGlobals??[]),intentPrefixes:Y(n.intentPrefixes??[]),capabilityDeny:Y(n.capabilities?.deny??[]),pure:n.pure===!0})).sort(Q),safety:{maxTsSuppressions:e.safety?.maxTsSuppressions??0,maxAnyCasts:e.safety?.maxAnyCasts??0,allowInMemory:e.safety?.allowInMemory===!0,allowDisabledPeerIsolation:e.safety?.allowDisabledPeerIsolation===!0}};return w(x(t))}function vr(e){let t=e.completenessReasons.map(l=>({code:l.code,message:l.message,...l.file?{file:l.file}:{}})).sort(Q),n=e.files.map(l=>({...l,typeOnlyExportNames:Y(l.typeOnlyExportNames)})).sort((l,c)=>l.path<c.path?-1:l.path>c.path?1:0),r=e.dependencies.map(l=>({...l,...l.namedBindings?{namedBindings:Y(l.namedBindings)}:{}})).sort(Q),s=e.capabilityUses.map(l=>({...l})).sort(Q),i=e.ambientUses.map(l=>({...l})).sort(Q),a=e.publishCalls.map(l=>({...l})).sort(Q),o=e.intentReferences.map(l=>({...l})).sort(Q),d=e.safetyUses.map(l=>({...l})).sort(Q),f=(e.classShapes??[]).map(l=>({...l,mutatingMethods:[...l.mutatingMethods??[]].map(c=>({...c}))})).sort(Q),g=e.files.map(({path:l,contentHash:c})=>({path:l,contentHash:c})).sort((l,c)=>l.path<c.path?-1:l.path>c.path?1:0),h=w(x(g));return{schemaVersion:"1.1",completeness:e.completeness,completenessReasons:t,resolverIdentity:e.resolverIdentity,compilerIdentity:e.compilerIdentity,compilerOptionsHash:e.compilerOptionsHash,tsconfigHash:e.tsconfigHash,candidateTreeHash:h,evidenceRequirementsHash:e.evidenceRequirementsHash,...e.projectPackageName?{projectPackageName:e.projectPackageName}:{},files:n,dependencies:r,capabilityUses:s,ambientUses:i,publishCalls:a,intentReferences:o,safetyUses:d,classShapes:f}}function pn(e){let t=vr(e);return{...t,factsHash:w(x(t))}}function kt(e){return pn(fn(V(e,"$"),!1))}function V(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object.`);return e}function G(e,t,n){let r=new Set(t),s=Object.keys(e).find(i=>!r.has(i));if(s)throw new Error(`${n}.${s} is not part of schema ${"1.1"}.`)}function _(e,t,n){let r=e[t];if(typeof r!="string"||r.length===0)throw new Error(`${n}.${t} must be a non-empty string.`);return r}function he(e,t,n){if(e[t]!==void 0)return _(e,t,n)}function z(e,t,n){let r=_(e,t,n),s=r.replace(/\\/g,"/");if(!s||s.startsWith("/")||/^[A-Za-z]:\//.test(s)||/[\u0000-\u001f\u007f]/.test(s))throw new Error(`${n}.${t} must be a canonical project-relative path.`);let i=[];for(let o of s.split("/"))if(!(!o||o==="."))if(o===".."){if(i.length===0)throw new Error(`${n}.${t} must be a canonical project-relative path.`);i.pop()}else i.push(o);let a=i.join("/");if(!a||a!==r)throw new Error(`${n}.${t} must be a canonical project-relative path.`);return a}function $(e,t,n){if(typeof e[t]!="boolean")throw new Error(`${n}.${t} must be a boolean.`);return e[t]}function un(e,t,n){let r=e[t];if(!Number.isInteger(r)||Number(r)<0)throw new Error(`${n}.${t} must be a non-negative integer.`);return Number(r)}function Ae(e,t,n){let r=un(e,t,n);if(r===0)throw new Error(`${n}.${t} must be a positive integer.`);return r}function K(e,t,n){let r=e[t];if(!Array.isArray(r))throw new Error(`${n}.${t} must be an array.`);return r}function ne(e,t,n,r){let s=e[t];if(typeof s!="string"||!n.includes(s))throw new Error(`${r}.${t} must be one of ${n.join(", ")}.`);return s}function dn(e,t){if(!Array.isArray(e)||e.some(n=>typeof n!="string"||!n))throw new Error(`${t} must be an array of non-empty strings.`);return[...e]}function Er(e,t,n){let r=new Set;for(let s of e){let i=t(s);if(r.has(i))throw new Error(`${n} must not contain duplicate facts (${i}).`);r.add(i)}}function fn(e,t){G(e,["schemaVersion","completeness","completenessReasons","resolverIdentity","compilerIdentity","compilerOptionsHash","tsconfigHash","evidenceRequirementsHash","projectPackageName","files","dependencies","capabilityUses","ambientUses","publishCalls","intentReferences","safetyUses","classShapes",...t?["candidateTreeHash","factsHash"]:[]],"$");let n=ne(e,"schemaVersion",["1.0","1.1"],"$"),r=ne(e,"completeness",["complete","partial","unavailable"],"$"),s=K(e,"completenessReasons","$").map((b,I)=>{let u=`$.completenessReasons[${I}]`,m=V(b,u);G(m,["code","message","file"],u);let R=m.file===void 0?void 0:z(m,"file",u);return{code:_(m,"code",u),message:_(m,"message",u),...R?{file:R}:{}}});if(r==="complete"&&s.length>0)throw new Error("$.completenessReasons must be empty when completeness is complete.");if(r!=="complete"&&s.length===0)throw new Error("$.completenessReasons must explain partial or unavailable facts.");let i=K(e,"files","$").map((b,I)=>{let u=`$.files[${I}]`,m=V(b,u);return G(m,["path","contentHash","parseStatus","parseDiagnosticCount","exportsOnlyTypes","typeOnlyExportNames","hasTopLevelSideEffects"],u),{path:z(m,"path",u),contentHash:_(m,"contentHash",u),parseStatus:ne(m,"parseStatus",["parsed","invalid"],u),parseDiagnosticCount:un(m,"parseDiagnosticCount",u),exportsOnlyTypes:$(m,"exportsOnlyTypes",u),typeOnlyExportNames:dn(m.typeOnlyExportNames,`${u}.typeOnlyExportNames`),hasTopLevelSideEffects:$(m,"hasTopLevelSideEffects",u)}}),a=K(e,"dependencies","$").map((b,I)=>{let u=`$.dependencies[${I}]`,m=V(b,u);G(m,["from","specifier","kind","typeOnly","line","resolution","target","namedBindings","targetTypeOnlyExports","sourcePureTypeModule","namedBindingsTypeOnly","portProofEligible"],u);let R=he(m,"specifier",u),S=he(m,"target",u),T=ne(m,"resolution",["resolved-project","resolved-external","unresolved","dynamic"],u);if(T==="resolved-project"&&!S)throw new Error(`${u}.target is required for resolved-project dependencies.`);if(T!=="resolved-project"&&S)throw new Error(`${u}.target is only allowed for resolved-project dependencies.`);if(T!=="dynamic"&&!R)throw new Error(`${u}.specifier is required unless resolution is dynamic.`);return{from:z(m,"from",u),...R?{specifier:R}:{},kind:ne(m,"kind",["import","export","dynamic-import","require"],u),typeOnly:$(m,"typeOnly",u),line:Ae(m,"line",u),resolution:T,...S?{target:z(m,"target",u)}:{},...m.namedBindings!==void 0?{namedBindings:dn(m.namedBindings,`${u}.namedBindings`)}:{},...m.targetTypeOnlyExports!==void 0?{targetTypeOnlyExports:$(m,"targetTypeOnlyExports",u)}:{},...m.sourcePureTypeModule!==void 0?{sourcePureTypeModule:$(m,"sourcePureTypeModule",u)}:{},...m.namedBindingsTypeOnly!==void 0?{namedBindingsTypeOnly:$(m,"namedBindingsTypeOnly",u)}:{},...m.portProofEligible!==void 0?{portProofEligible:$(m,"portProofEligible",u)}:{}}}),o=K(e,"capabilityUses","$").map((b,I)=>{let u=`$.capabilityUses[${I}]`,m=V(b,u);return G(m,["file","line","symbol","capability","source"],u),{file:z(m,"file",u),line:Ae(m,"line",u),symbol:_(m,"symbol",u),capability:ne(m,"capability",cn,u),source:ne(m,"source",["ambient-global","import-based"],u)}}),d=K(e,"ambientUses","$").map((b,I)=>{let u=`$.ambientUses[${I}]`,m=V(b,u);return G(m,["file","line","symbol"],u),{file:z(m,"file",u),line:Ae(m,"line",u),symbol:_(m,"symbol",u)}}),f=K(e,"publishCalls","$").map((b,I)=>{let u=`$.publishCalls[${I}]`,m=V(b,u);G(m,["file","line","rawIntentName","objectHasIntent","arkPublishCandidate","hasSource","sourceIntent"],u);let R=he(m,"rawIntentName",u),S=he(m,"sourceIntent",u);return{file:z(m,"file",u),line:Ae(m,"line",u),...R?{rawIntentName:R}:{},objectHasIntent:$(m,"objectHasIntent",u),arkPublishCandidate:$(m,"arkPublishCandidate",u),hasSource:$(m,"hasSource",u),...S?{sourceIntent:S}:{}}}),g=K(e,"intentReferences","$").map((b,I)=>{let u=`$.intentReferences[${I}]`,m=V(b,u);return G(m,["file","line","intent"],u),{file:z(m,"file",u),line:Ae(m,"line",u),intent:_(m,"intent",u)}}),h=K(e,"safetyUses","$").map((b,I)=>{let u=`$.safetyUses[${I}]`,m=V(b,u);G(m,["file","line","kind","symbol"],u);let R=he(m,"symbol",u),S=ne(m,"kind",["ts-suppression","any-cast","dynamic-import","dynamic-require","in-memory-store"],u);if(S==="in-memory-store"&&!R)throw new Error(`${u}.symbol is required for in-memory-store facts.`);if(S!=="in-memory-store"&&R)throw new Error(`${u}.symbol is only allowed for in-memory-store facts.`);return{file:z(m,"file",u),line:Ae(m,"line",u),kind:S,...R?{symbol:R}:{}}});Er(i,b=>b.path,"$.files");let l=new Set(i.map(b=>b.path));for(let b of i){if(b.parseStatus==="parsed"&&b.parseDiagnosticCount!==0)throw new Error(`$.files[${b.path}].parseDiagnosticCount must be 0 when parseStatus is parsed.`);if(b.parseStatus==="invalid"&&b.parseDiagnosticCount===0)throw new Error(`$.files[${b.path}].parseDiagnosticCount must be positive when parseStatus is invalid.`)}if(r==="complete"&&i.some(b=>b.parseStatus==="invalid"))throw new Error("$.completeness cannot be complete when a candidate file failed to parse.");for(let b of a)if(!l.has(b.from))throw new Error(`$.dependencies references missing source file ${b.from}.`);for(let[b,I]of[["$.capabilityUses",o],["$.ambientUses",d],["$.publishCalls",f],["$.intentReferences",g],["$.safetyUses",h]])for(let u of I)if(!l.has(u.file))throw new Error(`${b} references missing file ${u.file}.`);let c=he(e,"projectPackageName","$"),y=(e.classShapes===void 0?[]:K(e,"classShapes","$")).map((b,I)=>{let u=`$.classShapes[${I}]`,m=V(b,u);G(m,["file","className","exported","hasPublicMutableFields","hasPublicSetters","hasPublicConstructor","hasStaticFactory","mutatingMethods","dataOnly"],u);let R=K(m,"mutatingMethods",u).map((S,T)=>{let L=`${u}.mutatingMethods[${T}]`,v=V(S,L);return G(v,["name","referencesGuardOrPublish"],L),{name:_(v,"name",L),referencesGuardOrPublish:$(v,"referencesGuardOrPublish",L)}});return{file:z(m,"file",u),className:_(m,"className",u),exported:$(m,"exported",u),hasPublicMutableFields:$(m,"hasPublicMutableFields",u),hasPublicSetters:$(m,"hasPublicSetters",u),hasPublicConstructor:$(m,"hasPublicConstructor",u),hasStaticFactory:$(m,"hasStaticFactory",u),mutatingMethods:R,...m.dataOnly===void 0?{}:{dataOnly:$(m,"dataOnly",u)}}});return{schemaVersion:n,completeness:r,completenessReasons:s,resolverIdentity:_(e,"resolverIdentity","$"),compilerIdentity:_(e,"compilerIdentity","$"),compilerOptionsHash:_(e,"compilerOptionsHash","$"),tsconfigHash:_(e,"tsconfigHash","$"),evidenceRequirementsHash:_(e,"evidenceRequirementsHash","$"),...c?{projectPackageName:c}:{},files:i,dependencies:a,capabilityUses:o,ambientUses:d,publishCalls:f,intentReferences:g,safetyUses:h,classShapes:y}}function re(e){let t=V(e,"$"),n=_(t,"factsHash","$"),r=_(t,"candidateTreeHash","$"),s=pn(fn(t,!0));if(s.factsHash!==n)throw new Error(`$.factsHash does not match the canonical payload (${s.factsHash}).`);if(r!==s.candidateTreeHash)throw new Error(`$.candidateTreeHash does not match the canonical file tree (${s.candidateTreeHash}).`);return s}var Cr=["network","filesystem","clock","randomness","environment","process","persistence"],k={type:"string",minLength:1},be={type:"integer",minimum:1},W={type:"string",minLength:1,pattern:"^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$"},xt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://unpkg.com/arkgate@3/schemas/ark.resolved-candidate-facts.schema.json",title:"ArkGate resolved candidate facts",type:"object",additionalProperties:!1,required:["schemaVersion","completeness","completenessReasons","resolverIdentity","compilerIdentity","compilerOptionsHash","tsconfigHash","candidateTreeHash","evidenceRequirementsHash","files","dependencies","capabilityUses","ambientUses","publishCalls","intentReferences","safetyUses","factsHash"],properties:{schemaVersion:{enum:["1.0","1.1"]},completeness:{enum:["complete","partial","unavailable"]},completenessReasons:{type:"array",items:{type:"object",additionalProperties:!1,required:["code","message"],properties:{code:k,message:k,file:W}}},resolverIdentity:k,compilerIdentity:k,compilerOptionsHash:k,tsconfigHash:k,candidateTreeHash:k,evidenceRequirementsHash:k,projectPackageName:k,files:{type:"array",uniqueItems:!0,items:{type:"object",additionalProperties:!1,required:["path","contentHash","parseStatus","parseDiagnosticCount","exportsOnlyTypes","typeOnlyExportNames","hasTopLevelSideEffects"],properties:{path:W,contentHash:k,parseStatus:{enum:["parsed","invalid"]},parseDiagnosticCount:{type:"integer",minimum:0},exportsOnlyTypes:{type:"boolean"},typeOnlyExportNames:{type:"array",items:k},hasTopLevelSideEffects:{type:"boolean"}},allOf:[{if:{properties:{parseStatus:{const:"parsed"}}},then:{properties:{parseDiagnosticCount:{const:0}}}},{if:{properties:{parseStatus:{const:"invalid"}}},then:{properties:{parseDiagnosticCount:{minimum:1}}}}]}},dependencies:{type:"array",items:{type:"object",additionalProperties:!1,required:["from","kind","typeOnly","line","resolution"],properties:{from:W,specifier:k,kind:{enum:["import","export","dynamic-import","require"]},typeOnly:{type:"boolean"},line:be,resolution:{enum:["resolved-project","resolved-external","unresolved","dynamic"]},target:W,namedBindings:{type:"array",items:k},targetTypeOnlyExports:{type:"boolean"},sourcePureTypeModule:{type:"boolean"},namedBindingsTypeOnly:{type:"boolean"},portProofEligible:{type:"boolean"}},allOf:[{if:{properties:{resolution:{const:"resolved-project"}}},then:{required:["target"]},else:{not:{required:["target"]}}},{if:{properties:{resolution:{const:"dynamic"}}},else:{required:["specifier"]}}]}},capabilityUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","symbol","capability","source"],properties:{file:W,line:be,symbol:k,capability:{enum:Cr},source:{enum:["ambient-global","import-based"]}}}},ambientUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","symbol"],properties:{file:W,line:be,symbol:k}}},publishCalls:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","objectHasIntent","arkPublishCandidate","hasSource"],properties:{file:W,line:be,rawIntentName:k,objectHasIntent:{type:"boolean"},arkPublishCandidate:{type:"boolean"},hasSource:{type:"boolean"},sourceIntent:k}}},intentReferences:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","intent"],properties:{file:W,line:be,intent:k}}},safetyUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","kind"],properties:{file:W,line:be,kind:{enum:["ts-suppression","any-cast","dynamic-import","dynamic-require","in-memory-store"]},symbol:k},allOf:[{if:{properties:{kind:{const:"in-memory-store"}}},then:{required:["symbol"]},else:{not:{required:["symbol"]}}}]}},classShapes:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","className","exported","hasPublicMutableFields","hasPublicSetters","hasPublicConstructor","hasStaticFactory","mutatingMethods"],properties:{file:W,className:k,exported:{type:"boolean"},hasPublicMutableFields:{type:"boolean"},hasPublicSetters:{type:"boolean"},hasPublicConstructor:{type:"boolean"},hasStaticFactory:{type:"boolean"},dataOnly:{type:"boolean"},mutatingMethods:{type:"array",items:{type:"object",additionalProperties:!1,required:["name","referencesGuardOrPublish"],properties:{name:k,referencesGuardOrPublish:{type:"boolean"}}}}}}},factsHash:k},allOf:[{if:{properties:{completeness:{const:"complete"}}},then:{properties:{completenessReasons:{maxItems:0},files:{items:{properties:{parseStatus:{const:"parsed"}}}}}}},{if:{properties:{completeness:{enum:["partial","unavailable"]}}},then:{properties:{completenessReasons:{minItems:1}}}}]};var Ot="1.0";function D(e){return`${e.from}->${e.to}`}function _e(e,t,n,r="dependency"){return{id:`${e}:${r}:${D(t)}`,classification:e,subject:"dependency",from:t.from,to:t.to,message:n,...e==="missing"?{nextAction:`Add the planned dependency ${D(t)} to the candidate, then preflight again.`}:e==="contradictory"?{nextAction:`Replace the reverse dependency with ${D(t)}, then preflight again.`}:e==="unplanned"?{nextAction:r==="dependency-removed"?`Restore the removed dependency ${D(t)} in the candidate, then preflight again.`:`Remove the unplanned dependency ${D(t)} from the candidate, then preflight again.`}:{}}}function Re(e){let t=[],n=new Map(e.changeMap.map.files.map(l=>[l.path,l])),r=new Map(e.changes.map(l=>[l.path,l])),s=new Map(e.changeMap.map.dependencies.map(l=>[D(l),l])),i=new Map(e.baseDependencies.map(l=>[D(l),l])),a=new Map(e.candidateDependencies.map(l=>[D(l),l]));for(let l of[...n.values()].sort((c,p)=>c.path.localeCompare(p.path))){let c=r.get(l.path);c?c.operation!==l.operation?t.push({id:`contradictory:file:${l.path}`,classification:"contradictory",subject:"file",path:l.path,expectedOperation:l.operation,actualOperation:c.operation,message:`${l.path} was planned as ${l.operation} but the actual operation is ${c.operation}.`,nextAction:`Change ${l.path} to the planned ${l.operation} operation, then preflight again.`}):t.push({id:`satisfied:file:${l.path}`,classification:"satisfied",subject:"file",path:l.path,expectedOperation:l.operation,actualOperation:c.operation,message:`${l.path} matches the planned ${l.operation} operation.`}):t.push({id:`missing:file:${l.path}`,classification:"missing",subject:"file",path:l.path,expectedOperation:l.operation,message:`${l.path} was planned as ${l.operation} but is absent from the actual change.`,nextAction:`${l.operation[0].toUpperCase()}${l.operation.slice(1)} ${l.path} in the complete change set, then preflight again.`})}for(let l of[...r.values()].sort((c,p)=>c.path.localeCompare(p.path)))n.has(l.path)||t.push({id:`unplanned:file:${l.path}`,classification:"unplanned",subject:"file",path:l.path,actualOperation:l.operation,message:`${l.path} has an unplanned ${l.operation} operation.`,nextAction:`Remove ${l.path} from the change set, then preflight again.`});let o=new Set;for(let l of[...s.values()].sort((c,p)=>D(c).localeCompare(D(p)))){if(a.has(D(l))){t.push(_e("satisfied",l,`${l.from} -> ${l.to} exists in the candidate architecture.`));continue}let c={from:l.to,to:l.from};a.has(D(c))?(o.add(D(c)),t.push(_e("contradictory",l,`${l.from} -> ${l.to} was planned, but the candidate contains the reverse edge.`))):t.push(_e("missing",l,`${l.from} -> ${l.to} is absent from the candidate architecture.`))}let d=new Set([...n.keys(),...r.keys()]);for(let[l,c]of[...a].sort(([p],[y])=>p.localeCompare(y)))i.has(l)||s.has(l)||o.has(l)||!d.has(c.from)&&!d.has(c.to)||t.push({..._e("unplanned",c,`${c.from} -> ${c.to} was added without a matching planned dependency.`,"dependency-added"),actualOperation:"added"});let f=new Set(e.changeMap.map.files.filter(l=>l.operation==="delete").map(l=>l.path));for(let[l,c]of[...i].sort(([p],[y])=>p.localeCompare(y)))a.has(l)||f.has(c.from)||f.has(c.to)||!d.has(c.from)&&!d.has(c.to)||t.push({..._e("unplanned",c,`${c.from} -> ${c.to} was removed without a planned file deletion.`,"dependency-removed"),actualOperation:"removed"});let g={satisfied:0,missing:1,contradictory:2,unplanned:3};t.sort((l,c)=>g[l.classification]-g[c.classification]||(l.subject===c.subject?0:l.subject==="file"?-1:1)||l.id.localeCompare(c.id));let h={satisfied:t.filter(l=>l.classification==="satisfied").length,missing:t.filter(l=>l.classification==="missing").length,contradictory:t.filter(l=>l.classification==="contradictory").length,unplanned:t.filter(l=>l.classification==="unplanned").length};return{schemaVersion:"1.0",readOnly:!0,changeMapHash:e.changeMap.hash,structurallyConverged:h.missing===0&&h.contradictory===0&&h.unplanned===0,behavioralCompletion:"not-evaluated",summary:h,findings:t}}var Sr="1.0",Tt="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",gn=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","no-anemic-model","invariant-coverage"],kr=["no-anemic-model"],yn={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Pt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Tt,title:"ArkGate ArkRules (intra-layer contract)",description:"Per-layer structure sensors and invariant catalog consumed by the ArkGate Effective Contract.",type:"object",additionalProperties:!1,required:["schemaVersion","layer"],properties:{$schema:{type:"string",minLength:1,default:Tt},schemaVersion:{type:"string",const:"1.0",default:"1.0"},layer:{type:"string",minLength:1},structure:{type:"array",default:[],items:{$ref:"#/$defs/structureEntry"}},invariants:{type:"array",default:[],items:{$ref:"#/$defs/invariantEntry"}}},$defs:{structureEntry:{type:"object",additionalProperties:!1,required:["id","sensor"],properties:{id:{type:"string",minLength:1},sensor:{type:"string",enum:[...gn]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:yn,description:{type:"string",minLength:1}}},invariantEntry:{type:"object",additionalProperties:!1,required:["id","description"],properties:{id:{type:"string",minLength:1},description:{type:"string",minLength:1},aggregate:{type:"string",minLength:1},coverage:{type:"object",additionalProperties:!1,properties:{test:{type:"boolean"},symbol:{type:"string",minLength:1}}},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:yn}}}},oe=class extends Error{issues;source;constructor(t,n){super(`Invalid ArkRules (${t}):
package/docs/README.md CHANGED
@@ -52,15 +52,15 @@ These are **not** the day-to-day product path. They stay in the repo for evidenc
52
52
  | Area | Path |
53
53
  |------|------|
54
54
  | Release notes (by version) | [releases/](releases/) · [CHANGELOG.md](../CHANGELOG.md) |
55
- | Epic plans (seeded + shipped) | [plans/](plans/) · active: [workspace identity and activation truth](plans/workspace-identity-activation-truth/README.md) (`WI01`, 4.2.0 corrective minor) |
55
+ | Epic plans (seeded + shipped) | [plans/](plans/) · latest shipped: [workspace identity and activation truth](plans/workspace-identity-activation-truth/README.md) (Phase WI; **4.2.0 published**) |
56
56
  | Claims audit | [audit/claims-matrix.md](audit/claims-matrix.md) |
57
57
  | Field adoption kit (scaffolding, not closed) | [field/](field/) |
58
58
  | Runtime hardening (experimental) | [production-hardening.md](production-hardening.md) |
59
59
 
60
- Prepared candidate: [releases/4.2.0.md](releases/4.2.0.md) (`arkgate@4.2.0`, not published).
60
+ Prepared candidate: [releases/4.2.1.md](releases/4.2.1.md) (`arkgate@4.2.1`, not published).
61
61
 
62
- Current published: [releases/4.1.1.md](releases/4.1.1.md) (`arkgate@4.1.1` on npm `latest`).
63
- Previous: [releases/4.1.0.md](releases/4.1.0.md) (`arkgate@4.1.0`).
62
+ Current published: [releases/4.2.0.md](releases/4.2.0.md) (`arkgate@4.2.0` on npm `latest`).
63
+ Previous: [releases/4.1.1.md](releases/4.1.1.md) (`arkgate@4.1.1`) · [releases/4.1.0.md](releases/4.1.0.md) (`arkgate@4.1.0`).
64
64
  Previous major: [releases/4.0.0.md](releases/4.0.0.md) (`arkgate@4.0.0`).
65
65
  Config: [configuration.md](configuration.md) · Agent skills dual-plane: [agent-guide.md](agent-guide.md).
66
66
 
@@ -194,9 +194,10 @@ production deployment would need to satisfy; it is not a readiness certification
194
194
  ## Release notes (maintainers)
195
195
 
196
196
  Ship notes for a version live under [releases/](https://github.com/pedroknigge/arkgate/tree/main/docs/releases)
197
- (prepared: [4.2.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.2.0.md);
198
- current published: [4.1.1.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.1.1.md);
199
- previous: [4.1.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.1.0.md),
197
+ (prepared: [4.2.1.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.2.1.md);
198
+ current published: [4.2.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.2.0.md);
199
+ previous: [4.1.1.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.1.1.md),
200
+ [4.1.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.1.0.md),
200
201
  [4.0.1.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.0.1.md),
201
202
  [4.0.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.0.0.md)).
202
203
  Publish path: signed annotated tag → GitHub Release → `publish-npm.yml` (see [CONTRIBUTING.md](https://github.com/pedroknigge/arkgate/blob/main/CONTRIBUTING.md)).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkgate",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "ArkGate — architecture co-pilot for AI TypeScript (write gate, CI gate, plan/loop; optional ArkRules)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -160,6 +160,10 @@
160
160
  "qs": "6.15.3",
161
161
  "vite": "6.4.3",
162
162
  "postcss": "8.5.23",
163
+ "fast-uri": "3.1.5",
164
+ "nanoid": "3.3.18",
165
+ "brace-expansion@2": "2.1.4",
166
+ "brace-expansion@5": "5.0.9",
163
167
  "tsup": {
164
168
  "esbuild": "0.28.1"
165
169
  },
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/pedroknigge/arkgate",
7
7
  "source": "github"
8
8
  },
9
- "version": "4.2.0",
9
+ "version": "4.2.1",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "arkgate",
14
- "version": "4.2.0",
14
+ "version": "4.2.1",
15
15
  "runtimeHint": "npx",
16
16
  "transport": {
17
17
  "type": "stdio"