arkgate 4.8.7 → 4.8.8
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 +31 -3
- package/README.md +36 -4
- package/bin/ark-dashboard.mjs +423 -0
- package/bin/ark.mjs +51 -3
- package/dist/{diagnosticCatalog-wDAH08gH.d.ts → diagnosticCatalog-DxKCTBbp.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/nestjs/index.cjs +5 -5
- package/dist/nestjs/index.d.ts +1 -1
- package/dist/nestjs/index.js +5 -5
- package/dist/runtime/index.cjs +15 -15
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/index.js +15 -15
- package/dist/{types-CwZ_oz1N.d.ts → types-DxvmJO-D.d.ts} +105 -1
- package/docs/README.md +12 -4
- package/docs/agent-guide.md +36 -1
- package/docs/ai-gates.md +13 -1
- package/docs/arkorder.md +11 -1
- package/docs/configuration.md +2 -1
- package/docs/develop.md +13 -6
- package/docs/enthusiast/README.md +13 -2
- package/docs/package-surface.md +17 -4
- package/docs/product-voice.md +25 -2
- package/docs/use.md +11 -3
- package/package.json +3 -1
- package/server.json +2 -2
- package/templates/agent-skills/ark-adopt/SKILL.md +1 -0
- package/templates/agent-skills/ark-autopilot/SKILL.md +1 -1
- package/templates/agent-skills/ark-contract/SKILL.md +1 -1
- package/templates/agent-skills/ark-place/SKILL.md +1 -0
- package/templates/skills/ark-adopt.md +1 -0
- package/templates/skills/ark-autopilot.md +1 -1
- package/templates/skills/ark-contract.md +1 -1
- package/templates/skills/ark-place.md +1 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var bo=Object.defineProperty;var i=(e,t)=>bo(e,"name",{value:t,configurable:!0});var Co="4.8.7";var Oo=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,_o=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,xo=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function To(e,t){let n=String(e??"").replace(/\\/g,"/").trim(),r=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Oo.test(n)?"pure-shared":r==="PersistenceAdapters"&&(_o.test(n)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${n}`))?"kernel-emit":xo.test(n)||(r==="DomainModel"||r==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}i(To,"classifyLayerImportKind");function No(e){if(e.typeOnly||e.targetTypeOnlyExports||e.namedBindingsTypeOnly)return"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.";if(e.peerIsolation)return"Extract the shared dependency to a shared layer, test at the public interface, then preflight again.";let t=To(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}i(No,"layerImportNextAction");function Lo(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}i(Lo,"arkRunCallSiteName");function Po(e){let t=Lo(e),n=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${n??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}i(Po,"arkRunNextAction");function fe(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return No(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return Po(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Use release() for the first freeze of \u03BE. Later pattern change is proposeRelease then apply(ProposeResult). Never update/patch/set. Never mechanical-safe.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Do not persist slow key ${e.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again.`:"Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again. Never mechanical-safe.";case"ARKORDER_UNVALVED_RELEASE":return"Change \u03BE with proposeRelease then apply(ProposeResult). release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}i(fe,"deterministicNextAction");var nn="1.5",kr="docs/diagnostics.md";function O(e){return typeof e=="string"&&e.length>0?e:void 0}i(O,"text");function Rr(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}i(Rr,"positiveInteger");function rn(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,n=typeof e.file=="string"?e.file:void 0,r=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,n,r??"",s??"",o??""].join("|")}i(rn,"adapterFindingTargetKey");function en(e){let t=new Map;return e.map(n=>{let r=rn(n),s=(t.get(r)??0)+1;return t.set(r,s),s===1?r:`${r}#${s}`})}i(en,"adapterFindingOccurrenceTargetKeys");function Er(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")}`}i(Er,"adapterFindingRefFromTargetKey");function Ir(e){return`${kr}#${e}`}i(Ir,"adapterDocsCodePath");function wo(e,t,n){return fe({ruleId:e,target:O(t.target)??O(n.target)??void 0,fromLayer:O(t.fromLayer)??void 0,toLayer:O(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:O(t.edgeKind)??void 0,capability:O(t.capability)??O(n.capability)??void 0,arkruleId:O(t.arkruleId)??void 0,arkruleSource:O(t.arkruleSource)??void 0})}i(wo,"nextActionForDiagnostic");function tn(e,t="error",n){let r=O(e.ruleId)??O(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...O(e.target)?{target:O(e.target)}:{},...O(e.fromLayer)?{fromLayer:O(e.fromLayer)}:{},...O(e.toLayer)?{toLayer:O(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}:{},...O(e.capability)?{capability:O(e.capability)}:{},...O(e.edgeKind)?{edgeKind:O(e.edgeKind)}:{},...O(e.arkruleId)?{arkruleId:O(e.arkruleId)}:{},...O(e.arkruleSource)?{arkruleSource:O(e.arkruleSource)}:{}},a=n??rn(e),l=Er(a);return{ruleId:r,severity:s,message:O(e.message)??r,location:{file:O(e.file)??"<unknown>",line:Rr(e.line,1),column:Rr(e.column,1)},evidence:o,nextAction:O(e.nextAction)??wo(r,o,e),findingRef:l,targetKey:a,docsCodePath:Ir(r)}}i(tn,"toAdapterDiagnostic");function Do(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(y=>({code:O(y.code)??"ANALYSIS_EVIDENCE_INCOMPLETE",message:O(y.message)??`Analysis ${t}: required evidence is incomplete.`,...O(y.file)?{file:O(y.file)}:{}})):[{code:t==="unavailable"?"ANALYSIS_UNAVAILABLE":"ANALYSIS_EVIDENCE_INCOMPLETE",message:`Analysis ${t}: required evidence is incomplete.`}],s={...O(e.policyHash)?{policyHash:O(e.policyHash)}:{},...O(e.resolverIdentity)?{resolverIdentity:O(e.resolverIdentity)}:{},...O(e.factsHash)?{factsHash:O(e.factsHash)}:{},...O(e.candidateTreeHash)?{candidateTreeHash:O(e.candidateTreeHash)}:{}};if(n==="resolved-candidate-facts"&&t!=="unavailable"){for(let y of["policyHash","resolverIdentity","factsHash","candidateTreeHash"])if(!s[y])throw new Error(`${y} is required for resolved ${t} adapter evidence.`)}let o=e.violations??[],a=e.warnings??[],l=en(o),c=en(a),p=[...o.map((y,m)=>tn(y,"error",l[m])),...a.map((y,m)=>tn(y,"warning",c[m]))],g={schemaVersion:nn,completenessReasons:r,diagnostics:p};if(n==="resolved-candidate-facts"){if(t==="unavailable")return{...g,mode:n,valid:!1,completeness:t,...s};let y={policyHash:s.policyHash,resolverIdentity:s.resolverIdentity,factsHash:s.factsHash,candidateTreeHash:s.candidateTreeHash};return t==="complete"?{...g,mode:n,valid:e.valid,completeness:t,...y}:{...g,mode:n,valid:!1,completeness:t,...y}}return t==="complete"?{...g,mode:n,valid:e.valid,completeness:t,...s}:{...g,mode:n,valid:!1,completeness:t,...s}}i(Do,"createAdapterResult");var Mo={$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:nn},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},findingRef:{type:"string",minLength:1,pattern:"^fnv1a-[0-9a-f]{8}$"},targetKey:{type:"string",minLength:1},docsCodePath:{type:"string",minLength:1}}}}}};var Fo="1.0",vr="https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json",Rt="^sha256:[a-f0-9]{64}$",Sr={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:Rt,description:"Project id previously returned by ark_identity or ark_manifest."}}},br={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:Rt},code:{enum:["PROJECT_ROOT_MISMATCH","PROJECT_ID_MISMATCH","INVALID_PROJECT_EXPECTATION"]},message:{type:"string",minLength:1}}},$o={$schema:"https://json-schema.org/draft/2020-12/schema",$id:vr,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:Rt},resolvedRoot:{type:"string",minLength:1},resolvedConfigPath:{type:"string",minLength:1},arkgateVersion:{type:"string",minLength:1},contractHash:{type:"string",pattern:Rt},contractSource:{enum:["project","default-profile","manifest"]},runtimeId:{type:"string",minLength:1},processStartedAt:{type:"string",format:"date-time"}},$defs:{expectation:Sr,binding:br}};function Ho(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}`}i(Ho,"createProjectId");function jo(e){return{schemaVersion:"1.0",...e}}i(jo,"createProjectIdentity");var on=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),ln=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),cn=Object.freeze(Object.keys(ln).sort()),sn=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"}),an=Object.freeze({process:Object.freeze(["process","node:process"])});function Ye(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=sn[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=sn[r];if(s)return s;let o=e.indexOf("/",n+1);return o<0?null:sn[e.slice(0,o)]??null}i(Ye,"capabilityForModuleSpecifier");function Ie(e,t){for(let n of t)if(an[n]?.includes(e))return n;return null}i(Ie,"forbiddenGlobalForModuleSpecifier");function kt(e){let t=e.split(".");for(let n=t.length;n>=1;n-=1){let r=t.slice(0,n).join("."),s=ln[r];if(s)return s}return null}i(kt,"capabilityForAmbientName");function we(e){if(e?.pure===!0)return[...on].sort();let n=(e?.capabilities?.deny??[]).filter(r=>on.includes(r));return[...new Set(n)].sort()}i(we,"effectiveCapabilityDeny");function Xe(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}i(Xe,"ambientCoveredByForbiddenGlobals");function Et(e){let t=new Set,n=new Set,r=Object.keys(ln);for(let s of e?.forbiddenGlobals??[]){let o=r.filter(a=>a===s||a.startsWith(`${s}.`));if(o.length===0)n.add(s);else for(let a of o)t.add(`ambient:${a}`);for(let a of an[s]??[])t.add(`import-exact:${a}`)}for(let s of we(e)){if(t.add(`import:${s}`),s==="process")for(let o of an.process)t.add(`import-exact:${o}`);for(let o of r)kt(o)===s&&t.add(`ambient:${o}`)}return{atoms:[...t].sort(),rawGlobals:[...n].sort()}}i(Et,"loweredLayerCoverage");var Cr=new Map;function Or(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}i(Or,"escapeLiteral");function It(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}i(It,"normalizeGlobSeparators");function Vo(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}i(Vo,"bracesBalanced");function me(e){let t=Cr.get(e);if(t)return t;let n=It(e),r=Vo(n),s="",o=0;for(let l=0;l<n.length;l+=1){let c=n[l];c==="\\"&&l+1<n.length?(s+=Or(n[l+1]),l+=1):c==="*"?n[l+1]==="*"?n[l+2]==="/"?(s+="(?:.*/)?",l+=2):(s+=".*",l+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&r?(s+="(?:",o+=1):c==="}"&&r&&o>0?(s+=")",o-=1):c===","&&r&&o>0?s+="|":s+=Or(c)}let a=new RegExp(`^${s}$`);return Cr.set(e,a),a}i(me,"globToRegExp");function Uo(e){return It(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}i(Uo,"concreteGlobSegments");function dn(e,t){let n=It(String(e)),r=Uo(n),s=n.replace(/\*/g,"").length,o=r.length*1e4+s;if(t==null||t==="")return o;let a=String(t).split(/[/\\]/).filter(Boolean);if(r.length===0)return s;let l=0,c=-1;for(let p of r){let g=-1;for(let y=l;y<a.length;y+=1)if(a[y]===p){g=y;break}if(g<0)return o;c=g,l=g+1}return(c+1)*1e6+r.length*1e4+s}i(dn,"patternSpecificity");function de(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(a=>me(a).test(n))){for(let a of o.patterns??[])if(me(a).test(n)){let l=dn(a,n);l>s&&(s=l,r=o.name)}}return r}i(de,"layerForRelativePath");function _r(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()}`}i(_r,"sliceIdForPath");function Ko(e){let t=new Set;for(let n of e??[]){let s=It(String(n)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let a=s[o];if((a==="**"||a==="*")&&o>0){let l=s[o-1];l&&!l.includes("*")&&!l.includes("{")&&!l.includes("}")&&t.add(l)}}}return[...t]}i(Ko,"inferSliceFoldersFromPatterns");function Go(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 Ko(r?.patterns)}i(Go,"resolveSliceFolders");function xr(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}i(xr,"normalizeSegments");function Lr(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}i(Lr,"trimTrailingSlashes");var Bo=["src","app"];function zo(e){let t=Lr(e.replace(/^[./]+/,""));return t==="*"||t==="**"}i(zo,"isBlanketRoot");function Tr(e,t){if(!e||!t?.length)return!1;let n=String(e).split(/[/\\]/).join("/"),r=n.toLowerCase(),s=xr(n);for(let o of t){if(typeof o!="string"||o.length===0||zo(o))continue;if(o.includes("*")){let c=Lr(o.toLowerCase());if(me(c).test(r)||me(`${c}/**`).test(r))return!0;continue}let a=xr(o);if(a.length===0)continue;let l=Bo.includes(s[0])&&a[0]!==s[0]?[0,1]:[0];for(let c of l){if(c+a.length>s.length)continue;let p=!0;for(let g=0;g<a.length;g+=1)if(s[c+g]!==a[g]){p=!1;break}if(p)return!0}}return!1}i(Tr,"pathUnderSharedRoot");function Nr(e,t){let n=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!n)return!1;let r=t.toLowerCase();return n===r?!0:!n.includes("/")&&r.endsWith(`/${n}`)}i(Nr,"sliceMatchesDeclaration");function qo(e,t,n){return!e?.length||!t||!n?!1:e.some(r=>r&&typeof r.from=="string"&&typeof r.to=="string"&&Nr(r.from,t)&&Nr(r.to,n))}i(qo,"crossSliceEdgeAllowed");function Wo(e){if(!e.fromPath||!e.toPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0,n=!!e.toSlice||e.toShared===!0;return!t||!n?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}i(Wo,"peerIsolationDecision");function Pr(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"unclassifiable-path":{let n=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${n.length>0?` (${n.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}i(Pr,"peerIsolationDenyExplanation");function be(e,t,n,r){return un(e,t,n,r)?.rule}i(be,"findDeniedEdgeRule");function un(e,t,n,r){for(let s of e??[])if(!(s.from!==t||s.to!==n)&&s.allowed===!1){if(s.peerIsolation){let o=r?.fromPath,a=r?.toPath,l=Go(s,t,r?.layers),c=o&&a?_r(o,l):void 0,p=o&&a?_r(a,l):void 0,g=Wo({fromPath:o,toPath:a,folderCount:l.length,fromSlice:c,toSlice:p,fromShared:!c&&Tr(o,s.sharedRoots),toShared:!p&&Tr(a,s.sharedRoots),crossSliceAllowed:qo(s.allowedCrossSlice,c,p)});if(g.denied)return{rule:s,peerIsolationReason:g.reason,fromSlice:c,toSlice:p};continue}if(t!==n)return{rule:s}}}i(un,"findDeniedEdgeDecision");function De(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}i(De,"literalText");function Mr(e,t){return e.getLineAndCharacterOfPosition(t.getStart(e)).line+1}i(Mr,"lineOf");function wr(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(o=>o.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))}i(wr,"isTypeOnlyReference");function Fr(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()}i(Fr,"singleFileChecker");function pn(e,t){try{return e.getSymbolAtLocation(t)}catch{return}}i(pn,"symbolAt");function fn(e,t,n,r){let s=r.parent&&e.isShorthandPropertyAssignment(r.parent)&&r.parent.name===r,o;try{o=s?t.getShorthandAssignmentValueSymbol(r.parent):pn(t,r)}catch{o=void 0}return!!o?.declarations?.some(a=>a.getSourceFile().fileName===n.fileName)}i(fn,"localDeclaration");function Me(e,t){let n,r=[],s=i((a,l,c,p=!1)=>r.push({specifier:c,kind:l,line:Mr(t,a),typeOnly:p,unresolved:c===void 0,node:a}),"add"),o=i(a=>{if(e.isImportDeclaration(a))s(a,"import",De(e,a.moduleSpecifier),wr(e,a));else if(e.isExportDeclaration(a)&&a.moduleSpecifier)s(a,"export",De(e,a.moduleSpecifier),wr(e,a));else if(e.isImportEqualsDeclaration(a)&&e.isExternalModuleReference(a.moduleReference))s(a,"require",De(e,a.moduleReference.expression),a.isTypeOnly===!0);else if(e.isCallExpression(a)){let l=a.expression.kind===e.SyntaxKind.ImportKeyword,p=e.isIdentifier(a.expression)&&a.expression.text==="require"&&!fn(e,n??(n=Fr(e,t)),t,a.expression);(l||p)&&s(a,p?"require":"dynamic-import",De(e,a.arguments[0]))}e.forEachChild(a,o)},"visit");return o(t),r}i(Me,"extractSemanticDependencies");function Yo(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=De(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}}i(Yo,"staticAccessPath");function Xo(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}i(Xo,"runtimeIdentifierReference");function Dr(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}}i(Dr,"bestForbiddenMatch");function Fe(e,t,n){if(n.length===0)return[];let r=new Set(n),s=Fr(e,t),o=new Map,a=new Set;for(let m of t.statements)if(e.isVariableStatement(m))for(let u of m.declarationList.declarations)e.isIdentifier(u.name)&&a.add(u.name.text);let l=i(m=>{let u=Yo(e,m);if(!u)return;let f=pn(s,u.root),A=f?o.get(f):void 0;return A?[...A,...u.segments.slice(1)]:fn(e,s,t,u.root)||a.has(u.root.text)?void 0:u.segments},"resolvePath");for(let m of t.statements)if(e.isVariableStatement(m))for(let u of m.declarationList.declarations){if(!u.initializer||!e.isIdentifier(u.name))continue;let f=l(u.initializer),A=pn(s,u.name);!f||!A||o.set(A,f)}let c=[],p=new Set,g=i((m,u)=>{let f=Mr(t,u),A=`${m}:${u.getStart(t)}`;p.has(A)||(p.add(A),c.push({name:m,line:f,node:u}))},"flag"),y=i(m=>{let u=m.parent&&(e.isPropertyAccessExpression(m.parent)||e.isElementAccessExpression(m.parent))&&m.parent.expression===m;if((e.isPropertyAccessExpression(m)||e.isElementAccessExpression(m))&&!u){let f=l(m),A=f?Dr(r,f):void 0;A&&g(A,m)}else e.isIdentifier(m)&&r.has(m.text)&&Xo(e,m)&&!fn(e,s,t,m)&&g(m.text,m);if(e.isVariableDeclaration(m)&&e.isObjectBindingPattern(m.name)&&m.initializer){let f=l(m.initializer);if(f)for(let A of m.name.elements){if(!e.isIdentifier(A.name))continue;let v=A.propertyName?De(e,A.propertyName)??A.propertyName.text:A.name.text,_=Dr(r,[...f,v]);_&&g(_,m.initializer)}}e.forEachChild(m,y)},"visit");return y(t),c}i(Fe,"collectForbiddenCapabilityUses");function mn(e,t,n){let r=[];for(let s of n?.dependencies??Me(e,t)){if(s.typeOnly||!s.specifier)continue;let o=Ye(s.specifier);o&&r.push({capability:o,symbol:s.specifier,line:s.line,source:"import-based"})}for(let s of n?.ambientUses??Fe(e,t,cn)){let o=kt(s.name);o&&r.push({capability:o,symbol:s.name,line:s.line,source:"ambient-global"})}return r.sort((s,o)=>s.line-o.line||s.capability.localeCompare(o.capability)||s.symbol.localeCompare(o.symbol))}i(mn,"collectCapabilityUses");var gn={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."},yn=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 hn(e,t){return t.flatMap((r,s)=>(r.prefixes??r.intentPrefixes??[]).map(o=>({layer:r.name,layerIndex:s,prefix:o.endsWith(".")?o:`${o}.`}))).filter(({prefix:r})=>e.startsWith(r)).sort((r,s)=>s.prefix.length-r.prefix.length||r.layerIndex-s.layerIndex)[0]?.layer}i(hn,"resolveIntentLayer");function Ce(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}i(Ce,"looksLikeArkIntent");function Je(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Ce(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:gn.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:gn.PUBLISH_MISSING_SOURCE}),t}i(Je,"classifyPublishFacts");function W(e,t,n){return{ruleId:e,code:e,message:t,...n}}i(W,"violation");function $e(e,t){return e.slice(0,t).split(`
|
|
1
|
+
var bo=Object.defineProperty;var i=(e,t)=>bo(e,"name",{value:t,configurable:!0});var Co="4.8.8";var Oo=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,_o=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,xo=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function To(e,t){let n=String(e??"").replace(/\\/g,"/").trim(),r=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Oo.test(n)?"pure-shared":r==="PersistenceAdapters"&&(_o.test(n)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${n}`))?"kernel-emit":xo.test(n)||(r==="DomainModel"||r==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}i(To,"classifyLayerImportKind");function No(e){if(e.typeOnly||e.targetTypeOnlyExports||e.namedBindingsTypeOnly)return"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.";if(e.peerIsolation)return"Extract the shared dependency to a shared layer, test at the public interface, then preflight again.";let t=To(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}i(No,"layerImportNextAction");function Lo(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}i(Lo,"arkRunCallSiteName");function Po(e){let t=Lo(e),n=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${n??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}i(Po,"arkRunNextAction");function fe(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return No(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return Po(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Use release() for the first freeze of \u03BE. Later pattern change is proposeRelease then apply(ProposeResult). Never update/patch/set. Never mechanical-safe.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Do not persist slow key ${e.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again.`:"Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again. Never mechanical-safe.";case"ARKORDER_UNVALVED_RELEASE":return"Change \u03BE with proposeRelease then apply(ProposeResult). release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}i(fe,"deterministicNextAction");var nn="1.5",kr="docs/diagnostics.md";function O(e){return typeof e=="string"&&e.length>0?e:void 0}i(O,"text");function Rr(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}i(Rr,"positiveInteger");function rn(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,n=typeof e.file=="string"?e.file:void 0,r=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,n,r??"",s??"",o??""].join("|")}i(rn,"adapterFindingTargetKey");function en(e){let t=new Map;return e.map(n=>{let r=rn(n),s=(t.get(r)??0)+1;return t.set(r,s),s===1?r:`${r}#${s}`})}i(en,"adapterFindingOccurrenceTargetKeys");function Er(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")}`}i(Er,"adapterFindingRefFromTargetKey");function Ir(e){return`${kr}#${e}`}i(Ir,"adapterDocsCodePath");function wo(e,t,n){return fe({ruleId:e,target:O(t.target)??O(n.target)??void 0,fromLayer:O(t.fromLayer)??void 0,toLayer:O(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:O(t.edgeKind)??void 0,capability:O(t.capability)??O(n.capability)??void 0,arkruleId:O(t.arkruleId)??void 0,arkruleSource:O(t.arkruleSource)??void 0})}i(wo,"nextActionForDiagnostic");function tn(e,t="error",n){let r=O(e.ruleId)??O(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...O(e.target)?{target:O(e.target)}:{},...O(e.fromLayer)?{fromLayer:O(e.fromLayer)}:{},...O(e.toLayer)?{toLayer:O(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}:{},...O(e.capability)?{capability:O(e.capability)}:{},...O(e.edgeKind)?{edgeKind:O(e.edgeKind)}:{},...O(e.arkruleId)?{arkruleId:O(e.arkruleId)}:{},...O(e.arkruleSource)?{arkruleSource:O(e.arkruleSource)}:{}},a=n??rn(e),l=Er(a);return{ruleId:r,severity:s,message:O(e.message)??r,location:{file:O(e.file)??"<unknown>",line:Rr(e.line,1),column:Rr(e.column,1)},evidence:o,nextAction:O(e.nextAction)??wo(r,o,e),findingRef:l,targetKey:a,docsCodePath:Ir(r)}}i(tn,"toAdapterDiagnostic");function Do(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(y=>({code:O(y.code)??"ANALYSIS_EVIDENCE_INCOMPLETE",message:O(y.message)??`Analysis ${t}: required evidence is incomplete.`,...O(y.file)?{file:O(y.file)}:{}})):[{code:t==="unavailable"?"ANALYSIS_UNAVAILABLE":"ANALYSIS_EVIDENCE_INCOMPLETE",message:`Analysis ${t}: required evidence is incomplete.`}],s={...O(e.policyHash)?{policyHash:O(e.policyHash)}:{},...O(e.resolverIdentity)?{resolverIdentity:O(e.resolverIdentity)}:{},...O(e.factsHash)?{factsHash:O(e.factsHash)}:{},...O(e.candidateTreeHash)?{candidateTreeHash:O(e.candidateTreeHash)}:{}};if(n==="resolved-candidate-facts"&&t!=="unavailable"){for(let y of["policyHash","resolverIdentity","factsHash","candidateTreeHash"])if(!s[y])throw new Error(`${y} is required for resolved ${t} adapter evidence.`)}let o=e.violations??[],a=e.warnings??[],l=en(o),c=en(a),p=[...o.map((y,m)=>tn(y,"error",l[m])),...a.map((y,m)=>tn(y,"warning",c[m]))],g={schemaVersion:nn,completenessReasons:r,diagnostics:p};if(n==="resolved-candidate-facts"){if(t==="unavailable")return{...g,mode:n,valid:!1,completeness:t,...s};let y={policyHash:s.policyHash,resolverIdentity:s.resolverIdentity,factsHash:s.factsHash,candidateTreeHash:s.candidateTreeHash};return t==="complete"?{...g,mode:n,valid:e.valid,completeness:t,...y}:{...g,mode:n,valid:!1,completeness:t,...y}}return t==="complete"?{...g,mode:n,valid:e.valid,completeness:t,...s}:{...g,mode:n,valid:!1,completeness:t,...s}}i(Do,"createAdapterResult");var Mo={$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:nn},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},findingRef:{type:"string",minLength:1,pattern:"^fnv1a-[0-9a-f]{8}$"},targetKey:{type:"string",minLength:1},docsCodePath:{type:"string",minLength:1}}}}}};var Fo="1.0",vr="https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json",Rt="^sha256:[a-f0-9]{64}$",Sr={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:Rt,description:"Project id previously returned by ark_identity or ark_manifest."}}},br={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:Rt},code:{enum:["PROJECT_ROOT_MISMATCH","PROJECT_ID_MISMATCH","INVALID_PROJECT_EXPECTATION"]},message:{type:"string",minLength:1}}},$o={$schema:"https://json-schema.org/draft/2020-12/schema",$id:vr,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:Rt},resolvedRoot:{type:"string",minLength:1},resolvedConfigPath:{type:"string",minLength:1},arkgateVersion:{type:"string",minLength:1},contractHash:{type:"string",pattern:Rt},contractSource:{enum:["project","default-profile","manifest"]},runtimeId:{type:"string",minLength:1},processStartedAt:{type:"string",format:"date-time"}},$defs:{expectation:Sr,binding:br}};function Ho(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}`}i(Ho,"createProjectId");function jo(e){return{schemaVersion:"1.0",...e}}i(jo,"createProjectIdentity");var on=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),ln=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),cn=Object.freeze(Object.keys(ln).sort()),sn=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"}),an=Object.freeze({process:Object.freeze(["process","node:process"])});function Ye(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=sn[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=sn[r];if(s)return s;let o=e.indexOf("/",n+1);return o<0?null:sn[e.slice(0,o)]??null}i(Ye,"capabilityForModuleSpecifier");function Ie(e,t){for(let n of t)if(an[n]?.includes(e))return n;return null}i(Ie,"forbiddenGlobalForModuleSpecifier");function kt(e){let t=e.split(".");for(let n=t.length;n>=1;n-=1){let r=t.slice(0,n).join("."),s=ln[r];if(s)return s}return null}i(kt,"capabilityForAmbientName");function we(e){if(e?.pure===!0)return[...on].sort();let n=(e?.capabilities?.deny??[]).filter(r=>on.includes(r));return[...new Set(n)].sort()}i(we,"effectiveCapabilityDeny");function Xe(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}i(Xe,"ambientCoveredByForbiddenGlobals");function Et(e){let t=new Set,n=new Set,r=Object.keys(ln);for(let s of e?.forbiddenGlobals??[]){let o=r.filter(a=>a===s||a.startsWith(`${s}.`));if(o.length===0)n.add(s);else for(let a of o)t.add(`ambient:${a}`);for(let a of an[s]??[])t.add(`import-exact:${a}`)}for(let s of we(e)){if(t.add(`import:${s}`),s==="process")for(let o of an.process)t.add(`import-exact:${o}`);for(let o of r)kt(o)===s&&t.add(`ambient:${o}`)}return{atoms:[...t].sort(),rawGlobals:[...n].sort()}}i(Et,"loweredLayerCoverage");var Cr=new Map;function Or(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}i(Or,"escapeLiteral");function It(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}i(It,"normalizeGlobSeparators");function Vo(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}i(Vo,"bracesBalanced");function me(e){let t=Cr.get(e);if(t)return t;let n=It(e),r=Vo(n),s="",o=0;for(let l=0;l<n.length;l+=1){let c=n[l];c==="\\"&&l+1<n.length?(s+=Or(n[l+1]),l+=1):c==="*"?n[l+1]==="*"?n[l+2]==="/"?(s+="(?:.*/)?",l+=2):(s+=".*",l+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&r?(s+="(?:",o+=1):c==="}"&&r&&o>0?(s+=")",o-=1):c===","&&r&&o>0?s+="|":s+=Or(c)}let a=new RegExp(`^${s}$`);return Cr.set(e,a),a}i(me,"globToRegExp");function Uo(e){return It(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}i(Uo,"concreteGlobSegments");function dn(e,t){let n=It(String(e)),r=Uo(n),s=n.replace(/\*/g,"").length,o=r.length*1e4+s;if(t==null||t==="")return o;let a=String(t).split(/[/\\]/).filter(Boolean);if(r.length===0)return s;let l=0,c=-1;for(let p of r){let g=-1;for(let y=l;y<a.length;y+=1)if(a[y]===p){g=y;break}if(g<0)return o;c=g,l=g+1}return(c+1)*1e6+r.length*1e4+s}i(dn,"patternSpecificity");function de(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(a=>me(a).test(n))){for(let a of o.patterns??[])if(me(a).test(n)){let l=dn(a,n);l>s&&(s=l,r=o.name)}}return r}i(de,"layerForRelativePath");function _r(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()}`}i(_r,"sliceIdForPath");function Ko(e){let t=new Set;for(let n of e??[]){let s=It(String(n)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let a=s[o];if((a==="**"||a==="*")&&o>0){let l=s[o-1];l&&!l.includes("*")&&!l.includes("{")&&!l.includes("}")&&t.add(l)}}}return[...t]}i(Ko,"inferSliceFoldersFromPatterns");function Go(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 Ko(r?.patterns)}i(Go,"resolveSliceFolders");function xr(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}i(xr,"normalizeSegments");function Lr(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}i(Lr,"trimTrailingSlashes");var Bo=["src","app"];function zo(e){let t=Lr(e.replace(/^[./]+/,""));return t==="*"||t==="**"}i(zo,"isBlanketRoot");function Tr(e,t){if(!e||!t?.length)return!1;let n=String(e).split(/[/\\]/).join("/"),r=n.toLowerCase(),s=xr(n);for(let o of t){if(typeof o!="string"||o.length===0||zo(o))continue;if(o.includes("*")){let c=Lr(o.toLowerCase());if(me(c).test(r)||me(`${c}/**`).test(r))return!0;continue}let a=xr(o);if(a.length===0)continue;let l=Bo.includes(s[0])&&a[0]!==s[0]?[0,1]:[0];for(let c of l){if(c+a.length>s.length)continue;let p=!0;for(let g=0;g<a.length;g+=1)if(s[c+g]!==a[g]){p=!1;break}if(p)return!0}}return!1}i(Tr,"pathUnderSharedRoot");function Nr(e,t){let n=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!n)return!1;let r=t.toLowerCase();return n===r?!0:!n.includes("/")&&r.endsWith(`/${n}`)}i(Nr,"sliceMatchesDeclaration");function qo(e,t,n){return!e?.length||!t||!n?!1:e.some(r=>r&&typeof r.from=="string"&&typeof r.to=="string"&&Nr(r.from,t)&&Nr(r.to,n))}i(qo,"crossSliceEdgeAllowed");function Wo(e){if(!e.fromPath||!e.toPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0,n=!!e.toSlice||e.toShared===!0;return!t||!n?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}i(Wo,"peerIsolationDecision");function Pr(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"unclassifiable-path":{let n=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${n.length>0?` (${n.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}i(Pr,"peerIsolationDenyExplanation");function be(e,t,n,r){return un(e,t,n,r)?.rule}i(be,"findDeniedEdgeRule");function un(e,t,n,r){for(let s of e??[])if(!(s.from!==t||s.to!==n)&&s.allowed===!1){if(s.peerIsolation){let o=r?.fromPath,a=r?.toPath,l=Go(s,t,r?.layers),c=o&&a?_r(o,l):void 0,p=o&&a?_r(a,l):void 0,g=Wo({fromPath:o,toPath:a,folderCount:l.length,fromSlice:c,toSlice:p,fromShared:!c&&Tr(o,s.sharedRoots),toShared:!p&&Tr(a,s.sharedRoots),crossSliceAllowed:qo(s.allowedCrossSlice,c,p)});if(g.denied)return{rule:s,peerIsolationReason:g.reason,fromSlice:c,toSlice:p};continue}if(t!==n)return{rule:s}}}i(un,"findDeniedEdgeDecision");function De(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}i(De,"literalText");function Mr(e,t){return e.getLineAndCharacterOfPosition(t.getStart(e)).line+1}i(Mr,"lineOf");function wr(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(o=>o.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))}i(wr,"isTypeOnlyReference");function Fr(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()}i(Fr,"singleFileChecker");function pn(e,t){try{return e.getSymbolAtLocation(t)}catch{return}}i(pn,"symbolAt");function fn(e,t,n,r){let s=r.parent&&e.isShorthandPropertyAssignment(r.parent)&&r.parent.name===r,o;try{o=s?t.getShorthandAssignmentValueSymbol(r.parent):pn(t,r)}catch{o=void 0}return!!o?.declarations?.some(a=>a.getSourceFile().fileName===n.fileName)}i(fn,"localDeclaration");function Me(e,t){let n,r=[],s=i((a,l,c,p=!1)=>r.push({specifier:c,kind:l,line:Mr(t,a),typeOnly:p,unresolved:c===void 0,node:a}),"add"),o=i(a=>{if(e.isImportDeclaration(a))s(a,"import",De(e,a.moduleSpecifier),wr(e,a));else if(e.isExportDeclaration(a)&&a.moduleSpecifier)s(a,"export",De(e,a.moduleSpecifier),wr(e,a));else if(e.isImportEqualsDeclaration(a)&&e.isExternalModuleReference(a.moduleReference))s(a,"require",De(e,a.moduleReference.expression),a.isTypeOnly===!0);else if(e.isCallExpression(a)){let l=a.expression.kind===e.SyntaxKind.ImportKeyword,p=e.isIdentifier(a.expression)&&a.expression.text==="require"&&!fn(e,n??(n=Fr(e,t)),t,a.expression);(l||p)&&s(a,p?"require":"dynamic-import",De(e,a.arguments[0]))}e.forEachChild(a,o)},"visit");return o(t),r}i(Me,"extractSemanticDependencies");function Yo(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=De(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}}i(Yo,"staticAccessPath");function Xo(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}i(Xo,"runtimeIdentifierReference");function Dr(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}}i(Dr,"bestForbiddenMatch");function Fe(e,t,n){if(n.length===0)return[];let r=new Set(n),s=Fr(e,t),o=new Map,a=new Set;for(let m of t.statements)if(e.isVariableStatement(m))for(let u of m.declarationList.declarations)e.isIdentifier(u.name)&&a.add(u.name.text);let l=i(m=>{let u=Yo(e,m);if(!u)return;let f=pn(s,u.root),A=f?o.get(f):void 0;return A?[...A,...u.segments.slice(1)]:fn(e,s,t,u.root)||a.has(u.root.text)?void 0:u.segments},"resolvePath");for(let m of t.statements)if(e.isVariableStatement(m))for(let u of m.declarationList.declarations){if(!u.initializer||!e.isIdentifier(u.name))continue;let f=l(u.initializer),A=pn(s,u.name);!f||!A||o.set(A,f)}let c=[],p=new Set,g=i((m,u)=>{let f=Mr(t,u),A=`${m}:${u.getStart(t)}`;p.has(A)||(p.add(A),c.push({name:m,line:f,node:u}))},"flag"),y=i(m=>{let u=m.parent&&(e.isPropertyAccessExpression(m.parent)||e.isElementAccessExpression(m.parent))&&m.parent.expression===m;if((e.isPropertyAccessExpression(m)||e.isElementAccessExpression(m))&&!u){let f=l(m),A=f?Dr(r,f):void 0;A&&g(A,m)}else e.isIdentifier(m)&&r.has(m.text)&&Xo(e,m)&&!fn(e,s,t,m)&&g(m.text,m);if(e.isVariableDeclaration(m)&&e.isObjectBindingPattern(m.name)&&m.initializer){let f=l(m.initializer);if(f)for(let A of m.name.elements){if(!e.isIdentifier(A.name))continue;let v=A.propertyName?De(e,A.propertyName)??A.propertyName.text:A.name.text,_=Dr(r,[...f,v]);_&&g(_,m.initializer)}}e.forEachChild(m,y)},"visit");return y(t),c}i(Fe,"collectForbiddenCapabilityUses");function mn(e,t,n){let r=[];for(let s of n?.dependencies??Me(e,t)){if(s.typeOnly||!s.specifier)continue;let o=Ye(s.specifier);o&&r.push({capability:o,symbol:s.specifier,line:s.line,source:"import-based"})}for(let s of n?.ambientUses??Fe(e,t,cn)){let o=kt(s.name);o&&r.push({capability:o,symbol:s.name,line:s.line,source:"ambient-global"})}return r.sort((s,o)=>s.line-o.line||s.capability.localeCompare(o.capability)||s.symbol.localeCompare(o.symbol))}i(mn,"collectCapabilityUses");var gn={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."},yn=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 hn(e,t){return t.flatMap((r,s)=>(r.prefixes??r.intentPrefixes??[]).map(o=>({layer:r.name,layerIndex:s,prefix:o.endsWith(".")?o:`${o}.`}))).filter(({prefix:r})=>e.startsWith(r)).sort((r,s)=>s.prefix.length-r.prefix.length||r.layerIndex-s.layerIndex)[0]?.layer}i(hn,"resolveIntentLayer");function Ce(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}i(Ce,"looksLikeArkIntent");function Je(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Ce(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:gn.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:gn.PUBLISH_MISSING_SOURCE}),t}i(Je,"classifyPublishFacts");function W(e,t,n){return{ruleId:e,code:e,message:t,...n}}i(W,"violation");function $e(e,t){return e.slice(0,t).split(`
|
|
2
2
|
`).length}i($e,"lineOf");function Jo(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}i(Jo,"extractQuotedStrings");function Zo(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 o=s.index+s[0].indexOf(s[1]),a=s[0],l=r.kind==="import"&&/\bimport\s+type\b/.test(a)||r.kind==="export"&&/\bexport\s+type\b/.test(a);t.push({value:s[1],index:o,kind:r.kind,typeOnly:l})}}return t.sort((r,s)=>r.index-s.index)}i(Zo,"extractModuleSpecifiers");function Qo(e,t){let n=e.createSourceFile("generated.ts",t,e.ScriptTarget.Latest,!0),r=[],s=i(o=>{e.isStringLiteralLike(o)&&r.push({value:o.text,index:o.getStart(n)}),e.forEachChild(o,s)},"visit");return s(n),r}i(Qo,"extractQuotedStringsAst");function ea(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))}i(ea,"hasInfrastructureToken");function ta(e){let t=e.toLowerCase();return["sequelize","prisma","typeorm","mongoose","knex"].some(n=>t===n||t.startsWith(`${n}/`))}i(ta,"isKnownInfrastructurePackage");function na(e){let t=e.toLowerCase();return["adapter","infra","persistence","repository","repositories","integration","database"].some(n=>t.includes(n))}i(na,"layerHasInfrastructureRole");function Qe(e,t){return t&&e.isStringLiteralLike(t)?t.text:void 0}i(Qe,"tsStringLiteralText");function ra(e,t){if(t&&(e.isIdentifier(t)||e.isStringLiteralLike(t)))return t.text}i(ra,"tsPropertyName");function $r(e,t,n){if(!(!t||!e.isObjectLiteralExpression(t)))return t.properties.find(r=>!e.isPropertyAssignment(r)&&!e.isShorthandPropertyAssignment(r)?!1:ra(e,r.name)===n)}i($r,"tsObjectProperty");function et(e,t,n){return $r(e,t,n)!==void 0}i(et,"tsObjectHasProperty");function Ze(e,t,n){let r=$r(e,t,n);return r&&e.isPropertyAssignment(r)?r.initializer:void 0}i(Ze,"tsObjectPropertyValue");function sa(e,t){let n=Ze(e,t,"metadata");return et(e,n,"source")}i(sa,"tsObjectHasMetadataSource");function Hr(e,t){return t?e.isIdentifier(t)?/^[A-Z]/.test(t.text):e.isPropertyAccessExpression(t)?Hr(e,t.name):!1:!1}i(Hr,"tsLooksLikeIntentCreatorExpression");function oa(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"}i(oa,"tsIsPublishCall");function aa(e,t){if(!e.isCallExpression(t))return!1;let n=t.arguments[0],r=Qe(e,n);return r!==void 0&&Ce(r)||et(e,n,"intent")||Hr(e,n)}i(aa,"tsIsArkPublishCandidate");function ia(e,t){if(!e.isCallExpression(t))return!1;let[n,r,s]=t.arguments;return sa(e,n)||et(e,r,"source")||et(e,s,"source")}i(ia,"tsPublishHasSource");function la(e,t){if(!e.isCallExpression(t))return;let[n,r,s]=t.arguments,o=Ze(e,n,"metadata");return Qe(e,Ze(e,o,"source"))??Qe(e,Ze(e,r,"source"))??Qe(e,Ze(e,s,"source"))}i(la,"tsPublishSourceLiteral");function ca(e,t,n,r){let s=e.createSourceFile("generated.ts",t,e.ScriptTarget.Latest,!0),o=n,a=o?.filePath,l=o?.layer,c=[],p=i(y=>s.getLineAndCharacterOfPosition(y.getStart(s)).line+1,"lineForNode"),g=i(y=>{if(oa(e,y)){let m=y.arguments[0],u=Qe(e,m);for(let A of Je({publishCall:!0,rawIntentName:u,objectHasIntent:et(e,m,"intent"),arkPublishCandidate:aa(e,y),hasSource:ia(e,y)}))c.push(W(A.ruleId,A.message,{line:p(y),filePath:a}));let f=la(e,y);if(r&&l&&f&&Ce(f)){let A=r.resolveLayer(f);A&&A!==l&&c.push(W("PUBLISH_SOURCE_LAYER_MISMATCH",`Publish source "${f}" resolves to ${A}, but the target file is classified as ${l}.`,{line:p(y),filePath:a,target:f,fromLayer:l,toLayer:A}))}}e.forEachChild(y,g)},"visit");return g(s),c}i(ca,"analyzePublishAst");function jr(e={}){let t=new Set((e.intents||[]).map(o=>typeof o=="string"?o:o.name)),n=e.forbiddenPatterns||[],r=new Set(e.infrastructureLayers??[]),s=e.enforceIntentAllowlist??t.size>0;return{validate(o,a){let l=[],c=a,p=c?.filePath,g=c?.layer,y=e.typescript,m=y?y.createSourceFile(p??"generated.ts",o,y.ScriptTarget.Latest,!0):void 0,u=m?Me(e.typescript,m):void 0,f=u?u.filter(R=>R.specifier!==void 0).map(R=>({value:R.specifier,index:R.node.getStart(m),kind:R.kind,typeOnly:R.typeOnly})):Zo(o),A=e.typescript?Qo(e.typescript,o):Jo(o);if(e.typescript&&!e.allowNonLiteralDynamicImport?.(p))for(let R of u?.filter(({unresolved:I})=>I)??[]){let I=R.kind==="require";l.push(W(I?"DYNAMIC_REQUIRE_NOT_ALLOWLISTED":"DYNAMIC_IMPORT_NOT_ALLOWLISTED",`Non-literal ${I?"require call":"dynamic import"} cannot be resolved statically; add the reviewed file to dynamicImportAllowlist.`,{line:R.line,filePath:p}))}let v=g!==void 0&&(r.has(g)||na(g)),_=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 R of n)if(R instanceof RegExp){R.lastIndex=0;let I=R.exec(o);R.lastIndex=0,I&&l.push(W("FORBIDDEN_PATTERN",`Forbidden pattern matched: ${R}`,{line:I.index===void 0?void 0:$e(o,I.index),filePath:p,suggestion:"Remove infrastructure imports from domain/application layers."+_}))}else o.includes(R)&&l.push(W("FORBIDDEN_SUBSTRING",`Forbidden substring: ${R}`,{line:$e(o,o.indexOf(R)),filePath:p}));for(let R of f){let I=e.resolveImportTarget?.(R.value,p)??(e.resolveImportLayer?{layer:e.resolveImportLayer(R.value,p)}:void 0),C=typeof p=="string"?e.resolveImportTarget?.(p)??(e.resolveImportLayer?{layer:g,relPath:void 0}:void 0):void 0,$=I?.layer;if($&&g){let k=be(e.architectureProfile?.rules,g,$,{fromPath:C?.relPath,toPath:I?.relPath,layers:e.architectureLayers});if(k){if(R.typeOnly&&!k.peerIsolation)continue;let L=!!k.peerIsolation;l.push(W("LAYER_IMPORT_VIOLATION",k.message??(L?`Layer "${g}" must not import across slices into "${$}".`:`Layer "${g}" must not import "${$}".`),{line:$e(o,R.index),source:R.value,target:R.value,filePath:p,fromLayer:g,toLayer:$,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:R.kind,peerIsolation:L,...R.typeOnly?{typeOnly:!0}:{}}}));continue}continue}v||R.typeOnly||!ea(R.value)&&!ta(R.value)||l.push(W("FORBIDDEN_IMPORT",`Forbidden ${R.kind} target: "${R.value}".`,{line:$e(o,R.index),source:R.value,target:R.value,filePath:p,suggestion:"Route infrastructure access through an allowed adapter or port boundary."+_,details:{importKind:R.kind}}))}if(e.policies)for(let R of e.policies){let I=R.check({source:o,context:a});if(I!==!0)if(Array.isArray(I))for(let C of I)l.push(W("POLICY_VIOLATION",C.message,{filePath:p,suggestion:`Fix violation of policy "${R.name}".`}));else I===!1?l.push(W("POLICY_VIOLATION",`Policy ${R.name} failed on generated code`)):l.push(W("POLICY_VIOLATION",I.message))}if(s&&t.size>0)for(let R of A)Ce(R.value)&&!t.has(R.value)&&l.push(W("UNKNOWN_INTENT",`Unknown intent reference: "${R.value}"`,{line:$e(o,R.index),filePath:p,target:R.value,suggestion:`Register intent "${R.value}" via defineIntent() or remove the reference.`}));if(e.architectureProfile&&g)for(let R of A){if(!Ce(R.value))continue;let I=e.architectureProfile.resolveLayer(R.value);if(!I)continue;let C=be(e.architectureProfile.rules,g,I);C&&l.push(W("LAYER_REFERENCE_VIOLATION",C.message??`Layer "${g}" must not reference "${I}" through "${R.value}".`,{line:$e(o,R.index),filePath:p,target:R.value,fromLayer:g,toLayer:I,suggestion:"Route the dependency through an allowed intent, port, or event.",details:{rule:C}}))}if(e.extensions)for(let R of e.extensions)try{let I=R.analyze(o,a);l.push(...I)}catch(I){l.push(W("EXTENSION_ERROR",`Extension "${R.name}" failed: ${I instanceof Error?I.message:String(I)}`))}if(e.typescript&&m&&g&&e.forbiddenGlobals?.[g]?.length)try{let R=e.forbiddenGlobals[g];l.push(...Fe(e.typescript,m,R).map(I=>W("FORBIDDEN_GLOBAL",`${g} must not use the ambient global "${I.name}".`,{line:I.line,filePath:p,target:I.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 I of u??[]){if(I.typeOnly||!I.specifier)continue;let C=Ie(I.specifier,R);C&&l.push(W("FORBIDDEN_GLOBAL",`${g} must not use module "${I.specifier}" because it is the import form of forbidden global "${C}".`,{line:I.line,filePath:p,source:I.specifier,target:I.specifier,fromLayer:g,details:{importKind:I.kind,forbiddenGlobal:C},suggestion:"Inject the capability through a port instead of importing the ambient global module form."}))}}catch(R){l.push(W("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${R instanceof Error?R.message:String(R)}`))}if(e.typescript&&m&&g&&e.capabilityWalls?.[g]?.length)try{let R=new Set(e.capabilityWalls[g]),I=e.forbiddenGlobals?.[g]??[];for(let C of mn(e.typescript,m))R.has(C.capability)&&(C.source==="ambient-global"&&Xe(C.symbol,I)||C.source==="import-based"&&Ie(C.symbol,I)||l.push(W("CAPABILITY_VIOLATION",C.source==="import-based"?`${g} denies the ${C.capability} capability; found import of "${C.symbol}".`:`${g} denies the ${C.capability} capability; found ambient "${C.symbol}".`,{line:C.line,filePath:p,target:C.symbol,capability:C.capability,fromLayer:g,suggestion:"Define a small port (ClockPort, HttpPort, StoragePort) and bind the implementation in an adapter layer."})))}catch(R){l.push(W("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${R instanceof Error?R.message:String(R)}`))}if(e.typescript)try{l.push(...ca(e.typescript,o,a,e.architectureProfile))}catch(R){l.push(W("AST_ANALYZER_ERROR",`TypeScript AST analyzer failed: ${R instanceof Error?R.message:String(R)}`))}return{mode:"lexical-compatibility",completeness:"partial",completenessReasons:["LEXICAL_EVIDENCE_INCOMPLETE"],valid:!1,lexicalValid:l.length===0,violations:l}}}}i(jr,"createAICodeGate");var He={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Vr={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...He,default:[]},kernelRoots:{...He},managedLayers:{...He,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},Ur={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...He,default:[]},managedLayers:{...He,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...He,default:[]}}};function tt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(tt,"isObject");function Kr(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let n of e.layers)tt(n)&&typeof n.name=="string"&&n.name.length>0&&t.add(n.name);return t}i(Kr,"declaredLayerNames");function Gr(e){if(!tt(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}i(Gr,"defaultedArkRun");function Br(e){if(!tt(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}i(Br,"defaultedArkOrder");function zr(e,t){let n=e.arkRun;if(n===void 0||!tt(n))return;let r=Kr(e),s=n.managedLayers;if(Array.isArray(s)&&s.forEach((o,a)=>{typeof o=="string"&&o.length>0&&!r.has(o)&&t.push({path:`$.arkRun.managedLayers[${a}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),n.mode==="enforced"){let o=n.kernelRoots??n.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:n.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}i(zr,"validateArkRunExtra");function qr(e,t){let n=e.arkOrder;if(n===void 0||!tt(n))return;let r=Kr(e),s=n.managedLayers;if(Array.isArray(s)&&s.forEach((o,a)=>{typeof o=="string"&&o.length>0&&!r.has(o)&&t.push({path:`$.arkOrder.managedLayers[${a}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),n.mode==="enforced"){let o=n.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}i(qr,"validateArkOrderExtra");var se="1.3",St="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",Wr=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],da=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function ua(){let e=[];for(let t of Wr)for(let n of Wr)t===n||da.has(`${t}->${n}`)||e.push({from:t,to:n,allowed:!1});return e}i(ua,"createDefaultRules");var bt=ua(),An=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],le={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Rn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:St,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:St,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:se,default:se},name:{type:"string",minLength:1},include:{...le,minItems:1,default:["src"]},exclude:{...le,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:bt,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...le,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...le,default:[]}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...le,minItems:1},exclude:le,intentPrefixes:le,description:{type:"string",minLength:1},forbiddenGlobals:le,capabilities:{type:"object",additionalProperties:!1,properties:{deny:{type:"array",uniqueItems:!0,items:{type:"string",enum:["network","filesystem","clock","randomness","environment","process","persistence"]}}}},pure:{type:"boolean"},mayImportInfrastructure:{type:"boolean"},optional:{type:"boolean"},reserved:{type:"boolean"},allowEmpty:{type:"boolean"}}},rule:{type:"object",additionalProperties:!1,required:["from","to","allowed"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},allowed:{type:"boolean"},message:{type:"string",minLength:1},peerIsolation:{type:"boolean"},sliceFolders:{...le,minItems:1},sharedRoots:{...le,minItems:1},allowedCrossSlice:{type:"array",minItems:1,items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}}}},safety:{type:"object",additionalProperties:!1,properties:{maxTsSuppressions:{type:"integer",minimum:0,default:0},maxAnyCasts:{type:"integer",minimum:0,default:0},allowInMemory:{type:"boolean",default:!1},allowDisabledPeerIsolation:{type:"boolean",default:!1}}},coverage:{type:"object",additionalProperties:!1,description:"Invariant coverage scan controls. testGlobs replaces the built-in test-name heuristic; maxFiles raises or lowers the evidence file budget; coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant.",properties:{testGlobs:{...le,minItems:1},maxFiles:{type:"integer",minimum:1},coverageRoots:{...le,minItems:1}}},arkRun:Vr,arkOrder:Ur}},ge=class extends Error{static{i(this,"ArkConfigValidationError")}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 Yr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(Yr,"isObject");function vt(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}i(vt,"propertyPath");function je(e){return e===null?"null":Array.isArray(e)?"array":typeof e}i(je,"valueType");function pa(e,t){let n="#/$defs/";if(e.startsWith(n))return t.$defs[e.slice(n.length)]}i(pa,"resolveSchemaRef");function nt(e,t,n,r,s){if(t.$ref){let o=pa(t.$ref,r);if(!o){s.push({path:n,message:`schema reference ${t.$ref} cannot be resolved`});return}nt(e,o,n,r,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:n,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(o=>Object.is(o,e))){s.push({path:n,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!Yr(e)){s.push({path:n,message:`must be an object; received ${je(e)}`});return}let o=t.properties??{};for(let a of t.required??[])e[a]===void 0&&s.push({path:vt(n,a),message:"is required"});if(t.additionalProperties===!1)for(let a of Object.keys(e))a in o||s.push({path:vt(n,a),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let a=t.additionalProperties;for(let l of Object.keys(e))l in o||nt(e[l],a,vt(n,l),r,s)}for(let[a,l]of Object.entries(o))e[a]!==void 0&&nt(e[a],l,vt(n,a),r,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:n,message:`must be an array; received ${je(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:n,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let o=e.map(a=>JSON.stringify(a));new Set(o).size!==o.length&&s.push({path:n,message:"must not contain duplicate items"})}t.items&&e.forEach((o,a)=>nt(o,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 ${je(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 ${je(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:n,message:`must be an integer; received ${je(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:n,message:`must be at least ${t.minimum}`})}}i(nt,"validateNode");function fa(e){let t={...e,$schema:e.$schema===void 0?St:e.$schema,schemaVersion:e.schemaVersion===void 0?se:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?bt.map(n=>({...n})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Gr(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Br(e.arkOrder)),t}i(fa,"defaultedConfig");function ma(e){return e===se?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}i(ma,"migratedFromOf");function ga(){let e=new Set([se]);for(let t of An)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}i(ga,"knownInputVersions");function ya(e,t="ark.config.json"){if(!Yr(e))throw new ge(t,[{path:"$",message:`must be an object; received ${je(e)}`}]);let n=ga(),r=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(r===null)throw new ge(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${se}`}]);if(r!=="unversioned"&&!n.has(r))throw new ge(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected ${se}`}]);let s=r,o={...e},a=0;for(;s!==se&&a<An.length+1;){a+=1;let l=An.find(c=>c.from===s);if(!l)throw new ge(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${se}`}]);s=l.to,o.schemaVersion=s}if(s!==se)throw new ge(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected ${se}`}]);return{candidate:fa(o),migratedFrom:ma(r)}}i(ya,"migrateArkConfig");function Ct(e,t="ark.config.json"){let{candidate:n,migratedFrom:r}=ya(e,t),s=[];if(nt(n,Rn,"$",Rn,s),zr(n,s),qr(n,s),s.length>0)throw new ge(t,s);return{config:n,migratedFrom:r}}i(Ct,"loadArkConfigContract");function kn(e,t="ark.config.json"){let n;try{n=JSON.parse(e)}catch(r){throw new ge(t,[{path:"$",message:`invalid JSON: ${r instanceof Error?r.message:String(r)}`}])}return Ct(n,t)}i(kn,"parseArkConfigJson");function Xr(e){let t={$schema:typeof e.$schema=="string"&&e.$schema.length>0?e.$schema:St,schemaVersion:se};for(let[n,r]of Object.entries(e))n!=="$schema"&&n!=="schemaVersion"&&(t[n]=r);return t}i(Xr,"withArkConfigMetadata");function ha(e){return e.endsWith(".")?e:`${e}.`}i(ha,"normalizePrefix");function Aa(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}i(Aa,"byLongestPrefix");function _t(e){let t=e.layers.map(s=>({...s,prefixes:s.prefixes.map(ha)})),n=[...t].sort(Aa),r=[...e.rules??[]];return{name:e.name,layers:t,rules:r,resolveLayer(s){return t.find(o=>o.match?.(s))?.name??n.find(o=>o.prefixes.some(a=>s.startsWith(a)))?.name}}}i(_t,"createArchitectureProfile");function Jr(e,t={}){return _t({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??[]})}i(Jr,"createArchitectureProfileFromArkConfig");var Ra=[{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}],Ot=_t({name:"Ark 11-layer Hexagonal Event-Driven Profile",layers:Ra,rules:bt.map(e=>({...e}))}),ka={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 Zr(e={}){let t=e.rootDir??"src",n=e.optionalLayers??!0,r=t==="."?"":`${t}/`;return Xr({include:e.include??[t],layers:Ot.layers.map(s=>({name:s.name,patterns:(ka[s.name]??[s.name]).map(o=>`${r}${o}/**`),intentPrefixes:s.prefixes,optional:n})),rules:[...Ot.rules]})}i(Zr,"createElevenLayerArkConfig");function X(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")}`}i(X,"deterministicHash");function V(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(V).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${V(t[n])}`).join(",")}}`}i(V,"stableSerialize");var Oe="1.2";var Qr=["network","filesystem","clock","randomness","environment","process","persistence"];function Y(e,t){let n=V(e),r=V(t);return n<r?-1:n>r?1:0}i(Y,"compareCanonical");function J(e){return[...new Set(e)].sort((t,n)=>t<n?-1:t>n?1:0)}i(J,"sortedUnique");function rt(e){let t={schemaVersion:"1.2",include:J(e.include??[]),exclude:J(e.exclude??[]),excludeGenerated:e.excludeGenerated!==!1,dynamicImportAllowlist:J(e.dynamicImportAllowlist??[]),layers:e.layers.map(n=>({name:n.name,patterns:J(n.patterns??[]),exclude:J(n.exclude??[]),forbiddenGlobals:J(n.forbiddenGlobals??[]),intentPrefixes:J(n.intentPrefixes??[]),capabilityDeny:J(n.capabilities?.deny??[]),pure:n.pure===!0})).sort(Y),safety:{maxTsSuppressions:e.safety?.maxTsSuppressions??0,maxAnyCasts:e.safety?.maxAnyCasts??0,allowInMemory:e.safety?.allowInMemory===!0,allowDisabledPeerIsolation:e.safety?.allowDisabledPeerIsolation===!0},...e.arkRun?{arkRun:{mode:e.arkRun.mode,compositionRoots:J(e.arkRun.compositionRoots),managedLayers:J(e.arkRun.managedLayers),requireDeclarations:e.arkRun.requireDeclarations===!0}}:{}};return X(V(t))}i(rt,"resolvedFactsEvidenceRequirementsHash");function Ea(e){let t=e.completenessReasons.map(k=>({code:k.code,message:k.message,...k.file?{file:k.file}:{}})).sort(Y),n=e.files.map(k=>({...k,typeOnlyExportNames:J(k.typeOnlyExportNames)})).sort((k,L)=>k.path<L.path?-1:k.path>L.path?1:0),r=e.dependencies.map(k=>({...k,...k.namedBindings?{namedBindings:J(k.namedBindings)}:{}})).sort(Y),s=e.capabilityUses.map(k=>({...k})).sort(Y),o=e.ambientUses.map(k=>({...k})).sort(Y),a=e.publishCalls.map(k=>({...k})).sort(Y),l=e.intentReferences.map(k=>({...k})).sort(Y),c=e.safetyUses.map(k=>({...k})).sort(Y),p=(e.classShapes??[]).map(k=>({...k,mutatingMethods:[...k.mutatingMethods??[]].map(L=>({...L}))})).sort(Y),g=(e.arkRunKernelCalls??[]).map(k=>({...k})).sort(Y),y=(e.arkRunManagedNews??[]).map(k=>({...k})).sort(Y),m=(e.arkRunCompositionRootHits??[]).map(k=>({...k})).sort(Y),u=(e.arkRunDeclarations??[]).map(k=>({...k,uses:J(k.uses),reactsTo:J(k.reactsTo),raises:J(k.raises),sends:J(k.sends)})).sort(Y),f=(e.arkOrderPlaneCalls??[]).map(k=>({...k})).sort(Y),A=(e.arkOrderGenericUpdates??[]).map(k=>({...k})).sort(Y),v=(e.arkOrderRootHits??[]).map(k=>({...k})).sort(Y),_=(e.arkOrderXiFieldWrites??[]).map(k=>({...k})).sort(Y),R=(e.arkOrderIngestWritesXi??[]).map(k=>({...k})).sort(Y),I=(e.arkOrderReleaseKeyCounts??[]).map(k=>({...k})).sort(Y),C=e.files.map(({path:k,contentHash:L})=>({path:k,contentHash:L})).sort((k,L)=>k.path<L.path?-1:k.path>L.path?1:0),$=X(V(C));return{schemaVersion:"1.2",completeness:e.completeness,completenessReasons:t,resolverIdentity:e.resolverIdentity,compilerIdentity:e.compilerIdentity,compilerOptionsHash:e.compilerOptionsHash,tsconfigHash:e.tsconfigHash,candidateTreeHash:$,evidenceRequirementsHash:e.evidenceRequirementsHash,...e.projectPackageName?{projectPackageName:e.projectPackageName}:{},files:n,dependencies:r,capabilityUses:s,ambientUses:o,publishCalls:a,intentReferences:l,safetyUses:c,classShapes:p,arkRunKernelCalls:g,arkRunManagedNews:y,arkRunCompositionRootHits:m,arkRunDeclarations:u,arkOrderPlaneCalls:f,arkOrderGenericUpdates:A,arkOrderRootHits:v,arkOrderXiFieldWrites:_,arkOrderIngestWritesXi:R,arkOrderReleaseKeyCounts:I}}i(Ea,"canonicalResolvedFactsInput");function es(e){let t=Ea(e);return{...t,factsHash:X(V(t))}}i(es,"createCanonicalResolvedCandidateFacts");function En(e){return es(ns(F(e,"$"),!1))}i(En,"createResolvedCandidateFacts");function F(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object.`);return e}i(F,"asRecord");function U(e,t,n){let r=new Set(t),s=Object.keys(e).find(o=>!r.has(o));if(s)throw new Error(`${n}.${s} is not part of schema ${"1.2"}.`)}i(U,"assertOnlyKeys");function M(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}i(M,"requiredText");function ye(e,t,n){if(e[t]!==void 0)return M(e,t,n)}i(ye,"optionalText");function G(e,t,n){let r=M(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 o=[];for(let l of s.split("/"))if(!(!l||l==="."))if(l===".."){if(o.length===0)throw new Error(`${n}.${t} must be a canonical project-relative path.`);o.pop()}else o.push(l);let a=o.join("/");if(!a||a!==r)throw new Error(`${n}.${t} must be a canonical project-relative path.`);return a}i(G,"requiredProjectPath");function B(e,t,n){if(typeof e[t]!="boolean")throw new Error(`${n}.${t} must be a boolean.`);return e[t]}i(B,"requiredBoolean");function ts(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)}i(ts,"requiredInteger");function Q(e,t,n){let r=ts(e,t,n);if(r===0)throw new Error(`${n}.${t} must be a positive integer.`);return r}i(Q,"requiredPositiveInteger");function z(e,t,n){let r=e[t];if(!Array.isArray(r))throw new Error(`${n}.${t} must be an array.`);return r}i(z,"requiredArray");function he(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}i(he,"enumValue");function Ve(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]}i(Ve,"parseStringArray");function Ia(e,t,n){let r=new Set;for(let s of e){let o=t(s);if(r.has(o))throw new Error(`${n} must not contain duplicate facts (${o}).`);r.add(o)}}i(Ia,"assertUnique");function ns(e,t){U(e,["schemaVersion","completeness","completenessReasons","resolverIdentity","compilerIdentity","compilerOptionsHash","tsconfigHash","evidenceRequirementsHash","projectPackageName","files","dependencies","capabilityUses","ambientUses","publishCalls","intentReferences","safetyUses","classShapes","arkRunKernelCalls","arkRunManagedNews","arkRunCompositionRootHits","arkRunDeclarations","arkOrderPlaneCalls","arkOrderGenericUpdates","arkOrderRootHits","arkOrderXiFieldWrites","arkOrderIngestWritesXi","arkOrderReleaseKeyCounts",...t?["candidateTreeHash","factsHash"]:[]],"$");let n=he(e,"schemaVersion",["1.0","1.1","1.2"],"$"),r=he(e,"completeness",["complete","partial","unavailable"],"$"),s=z(e,"completenessReasons","$").map((S,b)=>{let h=`$.completenessReasons[${b}]`,d=F(S,h);U(d,["code","message","file"],h);let P=d.file===void 0?void 0:G(d,"file",h);return{code:M(d,"code",h),message:M(d,"message",h),...P?{file:P}:{}}});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 o=z(e,"files","$").map((S,b)=>{let h=`$.files[${b}]`,d=F(S,h);return U(d,["path","contentHash","parseStatus","parseDiagnosticCount","exportsOnlyTypes","typeOnlyExportNames","hasTopLevelSideEffects"],h),{path:G(d,"path",h),contentHash:M(d,"contentHash",h),parseStatus:he(d,"parseStatus",["parsed","invalid"],h),parseDiagnosticCount:ts(d,"parseDiagnosticCount",h),exportsOnlyTypes:B(d,"exportsOnlyTypes",h),typeOnlyExportNames:Ve(d.typeOnlyExportNames,`${h}.typeOnlyExportNames`),hasTopLevelSideEffects:B(d,"hasTopLevelSideEffects",h)}}),a=z(e,"dependencies","$").map((S,b)=>{let h=`$.dependencies[${b}]`,d=F(S,h);U(d,["from","specifier","kind","typeOnly","line","resolution","target","namedBindings","targetTypeOnlyExports","sourcePureTypeModule","namedBindingsTypeOnly","portProofEligible"],h);let P=ye(d,"specifier",h),j=ye(d,"target",h),ie=he(d,"resolution",["resolved-project","resolved-external","unresolved","dynamic"],h);if(ie==="resolved-project"&&!j)throw new Error(`${h}.target is required for resolved-project dependencies.`);if(ie!=="resolved-project"&&j)throw new Error(`${h}.target is only allowed for resolved-project dependencies.`);if(ie!=="dynamic"&&!P)throw new Error(`${h}.specifier is required unless resolution is dynamic.`);return{from:G(d,"from",h),...P?{specifier:P}:{},kind:he(d,"kind",["import","export","dynamic-import","require"],h),typeOnly:B(d,"typeOnly",h),line:Q(d,"line",h),resolution:ie,...j?{target:G(d,"target",h)}:{},...d.namedBindings!==void 0?{namedBindings:Ve(d.namedBindings,`${h}.namedBindings`)}:{},...d.targetTypeOnlyExports!==void 0?{targetTypeOnlyExports:B(d,"targetTypeOnlyExports",h)}:{},...d.sourcePureTypeModule!==void 0?{sourcePureTypeModule:B(d,"sourcePureTypeModule",h)}:{},...d.namedBindingsTypeOnly!==void 0?{namedBindingsTypeOnly:B(d,"namedBindingsTypeOnly",h)}:{},...d.portProofEligible!==void 0?{portProofEligible:B(d,"portProofEligible",h)}:{}}}),l=z(e,"capabilityUses","$").map((S,b)=>{let h=`$.capabilityUses[${b}]`,d=F(S,h);return U(d,["file","line","symbol","capability","source"],h),{file:G(d,"file",h),line:Q(d,"line",h),symbol:M(d,"symbol",h),capability:he(d,"capability",Qr,h),source:he(d,"source",["ambient-global","import-based"],h)}}),c=z(e,"ambientUses","$").map((S,b)=>{let h=`$.ambientUses[${b}]`,d=F(S,h);return U(d,["file","line","symbol"],h),{file:G(d,"file",h),line:Q(d,"line",h),symbol:M(d,"symbol",h)}}),p=z(e,"publishCalls","$").map((S,b)=>{let h=`$.publishCalls[${b}]`,d=F(S,h);U(d,["file","line","rawIntentName","objectHasIntent","arkPublishCandidate","hasSource","sourceIntent"],h);let P=ye(d,"rawIntentName",h),j=ye(d,"sourceIntent",h);return{file:G(d,"file",h),line:Q(d,"line",h),...P?{rawIntentName:P}:{},objectHasIntent:B(d,"objectHasIntent",h),arkPublishCandidate:B(d,"arkPublishCandidate",h),hasSource:B(d,"hasSource",h),...j?{sourceIntent:j}:{}}}),g=z(e,"intentReferences","$").map((S,b)=>{let h=`$.intentReferences[${b}]`,d=F(S,h);return U(d,["file","line","intent"],h),{file:G(d,"file",h),line:Q(d,"line",h),intent:M(d,"intent",h)}}),y=z(e,"safetyUses","$").map((S,b)=>{let h=`$.safetyUses[${b}]`,d=F(S,h);U(d,["file","line","kind","symbol"],h);let P=ye(d,"symbol",h),j=he(d,"kind",["ts-suppression","any-cast","dynamic-import","dynamic-require","in-memory-store"],h);if(j==="in-memory-store"&&!P)throw new Error(`${h}.symbol is required for in-memory-store facts.`);if(j!=="in-memory-store"&&P)throw new Error(`${h}.symbol is only allowed for in-memory-store facts.`);return{file:G(d,"file",h),line:Q(d,"line",h),kind:j,...P?{symbol:P}:{}}});Ia(o,S=>S.path,"$.files");let m=new Set(o.map(S=>S.path));for(let S of o){if(S.parseStatus==="parsed"&&S.parseDiagnosticCount!==0)throw new Error(`$.files[${S.path}].parseDiagnosticCount must be 0 when parseStatus is parsed.`);if(S.parseStatus==="invalid"&&S.parseDiagnosticCount===0)throw new Error(`$.files[${S.path}].parseDiagnosticCount must be positive when parseStatus is invalid.`)}if(r==="complete"&&o.some(S=>S.parseStatus==="invalid"))throw new Error("$.completeness cannot be complete when a candidate file failed to parse.");for(let S of a)if(!m.has(S.from))throw new Error(`$.dependencies references missing source file ${S.from}.`);let f=(e.arkRunKernelCalls===void 0?[]:z(e,"arkRunKernelCalls","$")).map((S,b)=>{let h=`$.arkRunKernelCalls[${b}]`,d=F(S,h);U(d,["file","line","kind","callee","viaImport","receiver","nameLiteral"],h);let P=ye(d,"receiver",h),j=ye(d,"nameLiteral",h);return{file:G(d,"file",h),line:Q(d,"line",h),kind:he(d,"kind",["factory","publisher","publish","raise","send","subscribe","register-handler","resolve","resolve-singleton"],h),callee:M(d,"callee",h),viaImport:B(d,"viaImport",h),...P?{receiver:P}:{},...j?{nameLiteral:j}:{}}}),v=(e.arkRunManagedNews===void 0?[]:z(e,"arkRunManagedNews","$")).map((S,b)=>{let h=`$.arkRunManagedNews[${b}]`,d=F(S,h);U(d,["file","line","typeName","importedFrom"],h);let P=ye(d,"importedFrom",h);return{file:G(d,"file",h),line:Q(d,"line",h),typeName:M(d,"typeName",h),...P?{importedFrom:P}:{}}}),R=(e.arkRunCompositionRootHits===void 0?[]:z(e,"arkRunCompositionRootHits","$")).map((S,b)=>{let h=`$.arkRunCompositionRootHits[${b}]`,d=F(S,h);return U(d,["file","matchedRoot","hasKernelFactory"],h),{file:G(d,"file",h),matchedRoot:M(d,"matchedRoot",h),hasKernelFactory:B(d,"hasKernelFactory",h)}}),I=e.arkRunDeclarations===void 0?[]:z(e,"arkRunDeclarations","$"),$=(e.arkOrderPlaneCalls===void 0?[]:z(e,"arkOrderPlaneCalls","$")).map((S,b)=>{let h=`$.arkOrderPlaneCalls[${b}]`,d=F(S,h);return U(d,["file","line","callee"],h),{file:G(d,"file",h),line:Q(d,"line",h),callee:M(d,"callee",h)}}),L=(e.arkOrderGenericUpdates===void 0?[]:z(e,"arkOrderGenericUpdates","$")).map((S,b)=>{let h=`$.arkOrderGenericUpdates[${b}]`,d=F(S,h);return U(d,["file","line","method"],h),{file:G(d,"file",h),line:Q(d,"line",h),method:M(d,"method",h)}}),x=(e.arkOrderRootHits===void 0?[]:z(e,"arkOrderRootHits","$")).map((S,b)=>{let h=`$.arkOrderRootHits[${b}]`,d=F(S,h);return U(d,["file","matchedRoot","hasPlaneFactory"],h),{file:G(d,"file",h),matchedRoot:M(d,"matchedRoot",h),hasPlaneFactory:B(d,"hasPlaneFactory",h)}}),D=(e.arkOrderXiFieldWrites===void 0?[]:z(e,"arkOrderXiFieldWrites","$")).map((S,b)=>{let h=`$.arkOrderXiFieldWrites[${b}]`,d=F(S,h);return U(d,["file","line","key"],h),{file:G(d,"file",h),line:Q(d,"line",h),key:M(d,"key",h)}}),pe=(e.arkOrderIngestWritesXi===void 0?[]:z(e,"arkOrderIngestWritesXi","$")).map((S,b)=>{let h=`$.arkOrderIngestWritesXi[${b}]`,d=F(S,h);return U(d,["file","line"],h),{file:G(d,"file",h),line:Q(d,"line",h)}}),qe=(e.arkOrderReleaseKeyCounts===void 0?[]:z(e,"arkOrderReleaseKeyCounts","$")).map((S,b)=>{let h=`$.arkOrderReleaseKeyCounts[${b}]`,d=F(S,h);return U(d,["file","line","keyCount"],h),{file:G(d,"file",h),line:Q(d,"line",h),keyCount:Q(d,"keyCount",h)}}),We=I.map((S,b)=>{let h=`$.arkRunDeclarations[${b}]`,d=F(S,h);return U(d,["file","line","uses","reactsTo","raises","sends"],h),{file:G(d,"file",h),line:Q(d,"line",h),uses:Ve(d.uses,`${h}.uses`),reactsTo:Ve(d.reactsTo,`${h}.reactsTo`),raises:Ve(d.raises,`${h}.raises`),sends:Ve(d.sends,`${h}.sends`)}});for(let[S,b]of[["$.capabilityUses",l],["$.ambientUses",c],["$.publishCalls",p],["$.intentReferences",g],["$.safetyUses",y],["$.arkRunKernelCalls",f],["$.arkRunManagedNews",v],["$.arkRunCompositionRootHits",R],["$.arkRunDeclarations",We],["$.arkOrderPlaneCalls",$],["$.arkOrderGenericUpdates",L],["$.arkOrderRootHits",x],["$.arkOrderXiFieldWrites",D],["$.arkOrderIngestWritesXi",pe],["$.arkOrderReleaseKeyCounts",qe]])for(let h of b)if(!m.has(h.file))throw new Error(`${S} references missing file ${h.file}.`);let Se=ye(e,"projectPackageName","$"),Zt=(e.classShapes===void 0?[]:z(e,"classShapes","$")).map((S,b)=>{let h=`$.classShapes[${b}]`,d=F(S,h);U(d,["file","className","exported","hasPublicMutableFields","hasPublicSetters","hasPublicConstructor","hasStaticFactory","mutatingMethods","dataOnly"],h);let P=z(d,"mutatingMethods",h).map((j,ie)=>{let At=`${h}.mutatingMethods[${ie}]`,Qt=F(j,At);return U(Qt,["name","referencesGuardOrPublish"],At),{name:M(Qt,"name",At),referencesGuardOrPublish:B(Qt,"referencesGuardOrPublish",At)}});return{file:G(d,"file",h),className:M(d,"className",h),exported:B(d,"exported",h),hasPublicMutableFields:B(d,"hasPublicMutableFields",h),hasPublicSetters:B(d,"hasPublicSetters",h),hasPublicConstructor:B(d,"hasPublicConstructor",h),hasStaticFactory:B(d,"hasStaticFactory",h),mutatingMethods:P,...d.dataOnly===void 0?{}:{dataOnly:B(d,"dataOnly",h)}}});return{schemaVersion:n,completeness:r,completenessReasons:s,resolverIdentity:M(e,"resolverIdentity","$"),compilerIdentity:M(e,"compilerIdentity","$"),compilerOptionsHash:M(e,"compilerOptionsHash","$"),tsconfigHash:M(e,"tsconfigHash","$"),evidenceRequirementsHash:M(e,"evidenceRequirementsHash","$"),...Se?{projectPackageName:Se}:{},files:o,dependencies:a,capabilityUses:l,ambientUses:c,publishCalls:p,intentReferences:g,safetyUses:y,classShapes:Zt,arkRunKernelCalls:f,arkRunManagedNews:v,arkRunCompositionRootHits:R,arkRunDeclarations:We,arkOrderPlaneCalls:$,arkOrderGenericUpdates:L,arkOrderRootHits:x,arkOrderXiFieldWrites:D,arkOrderIngestWritesXi:pe,arkOrderReleaseKeyCounts:qe}}i(ns,"parseResolvedFactsInput");function ve(e){let t=F(e,"$"),n=M(t,"factsHash","$"),r=M(t,"candidateTreeHash","$"),s=es(ns(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}i(ve,"loadResolvedCandidateFacts");var va=["network","filesystem","clock","randomness","environment","process","persistence"],T={type:"string",minLength:1},ne={type:"integer",minimum:1},q={type:"string",minLength:1,pattern:"^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$"},In={$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","1.2"]},completeness:{enum:["complete","partial","unavailable"]},completenessReasons:{type:"array",items:{type:"object",additionalProperties:!1,required:["code","message"],properties:{code:T,message:T,file:q}}},resolverIdentity:T,compilerIdentity:T,compilerOptionsHash:T,tsconfigHash:T,candidateTreeHash:T,evidenceRequirementsHash:T,projectPackageName:T,files:{type:"array",uniqueItems:!0,items:{type:"object",additionalProperties:!1,required:["path","contentHash","parseStatus","parseDiagnosticCount","exportsOnlyTypes","typeOnlyExportNames","hasTopLevelSideEffects"],properties:{path:q,contentHash:T,parseStatus:{enum:["parsed","invalid"]},parseDiagnosticCount:{type:"integer",minimum:0},exportsOnlyTypes:{type:"boolean"},typeOnlyExportNames:{type:"array",items:T},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:q,specifier:T,kind:{enum:["import","export","dynamic-import","require"]},typeOnly:{type:"boolean"},line:ne,resolution:{enum:["resolved-project","resolved-external","unresolved","dynamic"]},target:q,namedBindings:{type:"array",items:T},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:q,line:ne,symbol:T,capability:{enum:va},source:{enum:["ambient-global","import-based"]}}}},ambientUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","symbol"],properties:{file:q,line:ne,symbol:T}}},publishCalls:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","objectHasIntent","arkPublishCandidate","hasSource"],properties:{file:q,line:ne,rawIntentName:T,objectHasIntent:{type:"boolean"},arkPublishCandidate:{type:"boolean"},hasSource:{type:"boolean"},sourceIntent:T}}},intentReferences:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","intent"],properties:{file:q,line:ne,intent:T}}},safetyUses:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","kind"],properties:{file:q,line:ne,kind:{enum:["ts-suppression","any-cast","dynamic-import","dynamic-require","in-memory-store"]},symbol:T},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:q,className:T,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:T,referencesGuardOrPublish:{type:"boolean"}}}}}}},arkRunKernelCalls:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","kind","callee","viaImport"],properties:{file:q,line:ne,kind:{enum:["factory","publisher","publish","raise","send","subscribe","register-handler","resolve","resolve-singleton"]},callee:T,viaImport:{type:"boolean"},receiver:T,nameLiteral:T}}},arkRunManagedNews:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","typeName"],properties:{file:q,line:ne,typeName:T,importedFrom:T}}},arkRunCompositionRootHits:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","matchedRoot","hasKernelFactory"],properties:{file:q,matchedRoot:T,hasKernelFactory:{type:"boolean"}}}},arkRunDeclarations:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","uses","reactsTo","raises","sends"],properties:{file:q,line:ne,uses:{type:"array",items:T},reactsTo:{type:"array",items:T},raises:{type:"array",items:T},sends:{type:"array",items:T}}}},arkOrderPlaneCalls:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","callee"],properties:{file:q,line:ne,callee:T}}},arkOrderGenericUpdates:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","method"],properties:{file:q,line:ne,method:T}}},arkOrderRootHits:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","matchedRoot","hasPlaneFactory"],properties:{file:q,matchedRoot:T,hasPlaneFactory:{type:"boolean"}}}},arkOrderXiFieldWrites:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","key"],properties:{file:q,line:ne,key:T}}},arkOrderIngestWritesXi:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line"],properties:{file:q,line:ne}}},arkOrderReleaseKeyCounts:{type:"array",items:{type:"object",additionalProperties:!1,required:["file","line","keyCount"],properties:{file:q,line:ne,keyCount:{type:"integer",minimum:1}}}},factsHash:T},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 vn="1.0";function oe(e){return`${e.from}->${e.to}`}i(oe,"dependencyKey");function st(e,t,n,r="dependency"){return{id:`${e}:${r}:${oe(t)}`,classification:e,subject:"dependency",from:t.from,to:t.to,message:n,...e==="missing"?{nextAction:`Add the planned dependency ${oe(t)} to the candidate, then preflight again.`}:e==="contradictory"?{nextAction:`Replace the reverse dependency with ${oe(t)}, then preflight again.`}:e==="unplanned"?{nextAction:r==="dependency-removed"?`Restore the removed dependency ${oe(t)} in the candidate, then preflight again.`:`Remove the unplanned dependency ${oe(t)} from the candidate, then preflight again.`}:{}}}i(st,"dependencyFinding");function Ue(e){let t=[],n=new Map(e.changeMap.map.files.map(m=>[m.path,m])),r=new Map(e.changes.map(m=>[m.path,m])),s=new Map(e.changeMap.map.dependencies.map(m=>[oe(m),m])),o=new Map(e.baseDependencies.map(m=>[oe(m),m])),a=new Map(e.candidateDependencies.map(m=>[oe(m),m]));for(let m of[...n.values()].sort((u,f)=>u.path.localeCompare(f.path))){let u=r.get(m.path);u?u.operation!==m.operation?t.push({id:`contradictory:file:${m.path}`,classification:"contradictory",subject:"file",path:m.path,expectedOperation:m.operation,actualOperation:u.operation,message:`${m.path} was planned as ${m.operation} but the actual operation is ${u.operation}.`,nextAction:`Change ${m.path} to the planned ${m.operation} operation, then preflight again.`}):t.push({id:`satisfied:file:${m.path}`,classification:"satisfied",subject:"file",path:m.path,expectedOperation:m.operation,actualOperation:u.operation,message:`${m.path} matches the planned ${m.operation} operation.`}):t.push({id:`missing:file:${m.path}`,classification:"missing",subject:"file",path:m.path,expectedOperation:m.operation,message:`${m.path} was planned as ${m.operation} but is absent from the actual change.`,nextAction:`${m.operation[0].toUpperCase()}${m.operation.slice(1)} ${m.path} in the complete change set, then preflight again.`})}for(let m of[...r.values()].sort((u,f)=>u.path.localeCompare(f.path)))n.has(m.path)||t.push({id:`unplanned:file:${m.path}`,classification:"unplanned",subject:"file",path:m.path,actualOperation:m.operation,message:`${m.path} has an unplanned ${m.operation} operation.`,nextAction:`Remove ${m.path} from the change set, then preflight again.`});let l=new Set;for(let m of[...s.values()].sort((u,f)=>oe(u).localeCompare(oe(f)))){if(a.has(oe(m))){t.push(st("satisfied",m,`${m.from} -> ${m.to} exists in the candidate architecture.`));continue}let u={from:m.to,to:m.from};a.has(oe(u))?(l.add(oe(u)),t.push(st("contradictory",m,`${m.from} -> ${m.to} was planned, but the candidate contains the reverse edge.`))):t.push(st("missing",m,`${m.from} -> ${m.to} is absent from the candidate architecture.`))}let c=new Set([...n.keys(),...r.keys()]);for(let[m,u]of[...a].sort(([f],[A])=>f.localeCompare(A)))o.has(m)||s.has(m)||l.has(m)||!c.has(u.from)&&!c.has(u.to)||t.push({...st("unplanned",u,`${u.from} -> ${u.to} was added without a matching planned dependency.`,"dependency-added"),actualOperation:"added"});let p=new Set(e.changeMap.map.files.filter(m=>m.operation==="delete").map(m=>m.path));for(let[m,u]of[...o].sort(([f],[A])=>f.localeCompare(A)))a.has(m)||p.has(u.from)||p.has(u.to)||!c.has(u.from)&&!c.has(u.to)||t.push({...st("unplanned",u,`${u.from} -> ${u.to} was removed without a planned file deletion.`,"dependency-removed"),actualOperation:"removed"});let g={satisfied:0,missing:1,contradictory:2,unplanned:3};t.sort((m,u)=>g[m.classification]-g[u.classification]||(m.subject===u.subject?0:m.subject==="file"?-1:1)||m.id.localeCompare(u.id));let y={satisfied:t.filter(m=>m.classification==="satisfied").length,missing:t.filter(m=>m.classification==="missing").length,contradictory:t.filter(m=>m.classification==="contradictory").length,unplanned:t.filter(m=>m.classification==="unplanned").length};return{schemaVersion:"1.0",readOnly:!0,changeMapHash:e.changeMap.hash,structurallyConverged:y.missing===0&&y.contradictory===0&&y.unplanned===0,behavioralCompletion:"not-evaluated",summary:y,findings:t}}i(Ue,"analyzeArchitectureConvergence");var Sa="1.0",Sn="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",os=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","writes-via-aggregate","no-anemic-model","invariant-coverage"],ba=["no-anemic-model"],rs={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},bn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Sn,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:Sn},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:[...os]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:rs,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:rs}}}},_e=class extends Error{static{i(this,"ArkRulesValidationError")}issues;source;constructor(t,n){super(`Invalid ArkRules (${t}):
|