@unbrained/pm-cli 2026.10.13 → 2026.10.14
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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +19 -0
- package/dist/cli/extension-command-help.js +2 -2
- package/dist/cli/extension-command-options.js +1 -1
- package/dist/cli/main.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-AM2XOZKE.js → chunk-2UKKO45F.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-3S5SEMEB.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-LBDWFWPK.js → chunk-5LU6PWA4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RL45OYTL.js → chunk-66BZVFIK.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-IDEHMKYZ.js +235 -0
- package/dist/cli-bundle/chunks/{chunk-UBTYYZIE.js → chunk-JTF6VMXH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YH6H3UVE.js → chunk-LE4IEHDG.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-APWPC4ZZ.js → chunk-LKESCZEN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HXHFKXLV.js → chunk-LOSRTNNP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-N5EXRYCZ.js → chunk-MAT4AP7P.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PSNS537F.js → chunk-PP3BVMFL.js} +28 -28
- package/dist/cli-bundle/chunks/{chunk-IFPJDJUM.js → chunk-UNQZGMJL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WYZGZV2M.js → chunk-YXRAYL7H.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-BJ742QOR.js → register-list-query-GBLTOQQL.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-GGGBRIH2.js → register-mutation-TNRHNK4N.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-E6HXYHNM.js → register-operations-J3WXP3MA.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-4ZVTVEPY.js → register-setup-HLSKKU4V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-73UNAJHD.js → chunk-23ACMPGB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NNW5BS5L.js → chunk-4UA7KY4V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KGFRQ34R.js → chunk-AULVKHYX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3LQEBXU5.js → chunk-BUAGNTLG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DVK7VKZL.js → chunk-ELQNEJDA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SOB7X4FJ.js → chunk-ESOW6PH4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-HNRI2KBT.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IIKFTJVC.js → chunk-IGBSAHCA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-F5J3ATMV.js → chunk-JDVZF75H.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RU6GCFN3.js → chunk-KSMQEB3V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-LKWDWER4.js +20 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RAA7SVRA.js → chunk-QIU4Y3AB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-R23T7GFZ.js → chunk-RHQCQTZA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UPJA45K7.js → chunk-WIXZF5SS.js} +18 -18
- package/dist/cli-bundle/focused-chunks/{chunk-6BTUISKV.js → chunk-Y5A4XOSK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QMNAY25P.js → chunk-YJNKISEI.js} +6 -6
- package/dist/cli-bundle/main.js +22 -22
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +22 -22
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +46 -46
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +7 -7
- package/dist/core/extensions/flag-definition-validation.d.ts +13 -0
- package/dist/core/extensions/flag-definition-validation.js +1 -1
- package/dist/core/extensions/flag-value-types.js +1 -1
- package/dist/core/sentry/helpers.d.ts +2 -0
- package/dist/core/sentry/helpers.js +1 -1
- package/dist/core/sentry/instrument.d.ts +2 -0
- package/dist/core/sentry/instrument.js +1 -1
- package/dist/core/telemetry/runtime.d.ts +1 -1
- package/dist/core/telemetry/runtime.js +2 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/governance/defect-recurrence.js +2 -1
- package/dist/sdk/merge/install.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/runtime-primitives.d.ts +4 -2
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/testing.d.ts +4 -0
- package/dist/sdk/testing.js +2 -2
- package/docs/CONFIGURATION.md +43 -0
- package/docs/DEFECT_RECURRENCE.md +8 -0
- package/docs/EXTENSIONS.md +1 -1
- package/docs/EXTENSION_AUTHOR_CONTRACTS.md +19 -0
- package/docs/MERGE_SAFETY.md +8 -0
- package/docs/SDK.md +19 -0
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-DJDRHJBP.js +0 -234
- package/dist/cli-bundle/chunks/chunk-DUK5DHI6.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-IOTNG6CN.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-S6ITXQ5T.js +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as on,g as St,i as Tt,j as Ct,l as Ui,m as Bi,n as dn,o as Wi,p as Vi,q as qi}from"./chunk-NNW5BS5L.js";import{h as fn}from"./chunk-YLVHHWHN.js";import{$ as w,$a as Mi,$c as Or,$d as tt,A as ki,Ce as xr,De as Rr,F as nn,G as rn,H as vr,J as Ii,Ja as Ri,Me as ye,Nc as me,Ne as se,Oa as Ai,Oc as Sr,P as ve,Pa as Di,Pc as ln,Qc as _e,Ra as Ni,Rc as Tr,Sa as Li,Sc as ke,Tc as Cr,V as Pe,Va as sn,W as Si,Wc as Ot,Xa as Pi,Xd as Ji,Yd as Ie,Z as k,Zc as Gi,Zd as pe,_ as Me,_a as an,_d as Qi,aa as h,ae as he,cb as et,db as kr,de as Zi,eb as Ir,ed as $e,ee as es,fb as fe,fe as W,gd as Ki,hb as ji,hd as Xi,i as Qt,ib as D,jb as ie,ka as ue,kb as cn,lb as T,ld as Yi,pa as Ti,q as Zt,qb as Fi,r as bi,ra as Ci,s as wi,sa as je,t as vi,ta as Fe,u as Ei,ua as ne,ub as $i,va as Ee,vb as Hi,wa as Oi,xa as Er,xc as zi,y as en,ya as K,yd as un,z as tn,za as xi}from"./chunk-UPJA45K7.js";import{AsyncLocalStorage as Qc}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1fbb183b-c6d8-5834-b4cb-e4fb515572b9")}catch{}})();var Ar=new Qc,ts=/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,127})$/u;function mn(e,t){let n=typeof e=="string"?e.trim():"";return n.length>0?n.slice(0,t):void 0}function He(e,t){if(e===void 0)return;let n=typeof e=="object"&&e!==null?e:{},r=mn(n.id,128),o=mn(n.parent_id,128);if(r===void 0||!ts.test(r)||o!==void 0&&!ts.test(o)){if(t)throw new Error("Agent episode ids must be 1-128 letters, digits, dots, underscores, colons, or hyphens.");return}let i=mn(n.label,256);return{id:r,...i===void 0?{}:{label:i},...o===void 0?{}:{parent_id:o}}}function nt(e){let t={};for(let[n,r]of Object.entries(e??{}).slice(0,32)){let o=n.trim().toLowerCase().slice(0,64),i=mn(r,256);/^[a-z][a-z0-9_-]{0,63}$/u.test(o)&&i!==void 0&&(t[o]=i)}return t}function Zc(e,t,n){let r=Ar.getStore(),o=nt({role:t.PM_AGENT_SESSION_ROLE,topic:t.PM_AGENT_SESSION_TOPIC}),i=He(t.PM_AGENT_EPISODE_ID===void 0?void 0:{id:t.PM_AGENT_EPISODE_ID,label:t.PM_AGENT_EPISODE_LABEL,parent_id:t.PM_AGENT_EPISODE_PARENT_ID},!1),s={...nt(r?.provenance),...o,...nt(e?.provenance)},a=He(e?.episode,!1)??He(n,!1)??i??He(r?.episode,!1);return Object.keys(s).length===0&&a===void 0?void 0:{...Object.keys(s).length===0?{}:{provenance:s},...a===void 0?{}:{episode:a}}}function Dr(e,t){return Zc(e.session_context,t,e.client_info?.episode)??{}}function Jp(e,t){let n=Ar.getStore(),r=He(e.episode,!0),o=He(n?.episode,!1),i=r!==void 0&&r.parent_id===void 0&&o!==void 0?{...r,parent_id:o.id}:r,s={...nt(n?.provenance),...nt(e.provenance)};return Ar.run({...Object.keys(s).length===0?{}:{provenance:s},...i===void 0?o===void 0?{}:{episode:o}:{episode:i}},t)}function Qp(e){let t=nt(e.provenance),n=He(e.episode,!0);return{...n===void 0?{}:{PM_AGENT_EPISODE_ID:n.id,...n.label===void 0?{}:{PM_AGENT_EPISODE_LABEL:n.label},...n.parent_id===void 0?{}:{PM_AGENT_EPISODE_PARENT_ID:n.parent_id}},...t.role===void 0?{}:{PM_AGENT_SESSION_ROLE:t.role},...t.topic===void 0?{}:{PM_AGENT_SESSION_TOPIC:t.topic}}}import{AsyncLocalStorage as Vr}from"node:async_hooks";import{createHash as od}from"node:crypto";import V from"node:fs";import ls from"node:os";import Be from"node:path";import{createHash as ns}from"node:crypto";import{existsSync as Nr,promises as rs,readFileSync as ed}from"node:fs";import ae from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="06c9f6f4-c2f0-549c-9a0f-4f4269cc5f49")}catch{}})();var td="session.json";function Lr(e,t){return typeof e=="string"&&e.length>0&&e.length<=t}function os(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,n=["implementer","planner","release-operator"].includes(String(t.role)),r=["high","medium"].includes(String(t.confidence)),o=Lr(t.topic,256),i=Array.isArray(t.evidence)&&t.evidence.length<=32&&t.evidence.every(c=>typeof c=="string"&&c.length<=128),s=Array.isArray(t.active_item_ids)&&t.active_item_ids.length<=64&&t.active_item_ids.every(c=>Lr(c,128)),a=t.focused_item_id===void 0||Lr(t.focused_item_id,128);if([n,r,o,i,s,a,t.rule_version==="v2"].every(Boolean))return t}function nd(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=Object.entries(e).slice(0,128).flatMap(([n,r])=>{let o=os(r);return o&&n.length<=128?[[n,o]]:[]});return t.length>0?Object.fromEntries(t):void 0}function Pr(e){return ae.join(ji(e),td)}async function is(e){try{let t=await rs.readFile(Pr(e),"utf8"),n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return{};let r=n,o=r.focused_item,i=nd(r.semantic_attribution);return typeof o=="string"&&o.trim().length>0?{focused_item:o,...i?{semantic_attribution:i}:{}}:i?{semantic_attribution:i}:{}}catch{return{}}}async function Mr(e,t){let n=await W(e,"session-state",k.locks.ttl_seconds,"session-state",!1,!0,k.locks.wait_ms);try{let r=await is(e);t(r);let o=Pr(e);await rs.mkdir(ae.dirname(o),{recursive:!0}),await K(o,JSON.stringify(r))}finally{await n()}}function jr(e){return/#([a-f0-9]{24})$/u.exec(e.trim())?.[1]??`author-${ns("sha256").update(e).digest("hex").slice(0,24)}`}function Fr(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].slice(0,32).map(t=>t.slice(0,128))}function $r(e){let t=[...new Set(e)].sort((r,o)=>r.localeCompare(o));if(t.length===1)return t[0];let n=`workset:${t.join("+")}`;return n.length<=256?n:`workset:${t.join("+").slice(0,230)}+${ns("sha256").update(t.join("\0")).digest("hex").slice(0,12)}`}async function Hr(e,t,n){await Mr(e,r=>{let o={...r.semantic_attribution},i=n(o[t]);i===void 0?delete o[t]:o[t]=i,Object.keys(o).length===0?delete r.semantic_attribution:r.semantic_attribution=o})}async function ah(e){let t=jr(e.principal);await Hr(e.pmRoot,t,n=>{let r=[...new Set([...n?.active_item_ids??[],e.itemId])].slice(-64).sort((i,s)=>i.localeCompare(s)),o=n?.focused_item_id;return{role:"implementer",topic:o??$r(r),confidence:o?"high":"medium",rule_version:"v2",evidence:Fr([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:r,...o?{focused_item_id:o}:{}}})}async function ch(e){let t=jr(e.principal);await Hr(e.pmRoot,t,n=>{if(!n)return;let r=n.active_item_ids.filter(i=>i!==e.itemId);if(r.length===0&&!n.focused_item_id)return;let o=n.focused_item_id;return{...n,role:"release-operator",topic:o??$r(r),confidence:o?"high":"medium",evidence:Fr([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],`release:${e.itemId}`]),active_item_ids:r}})}async function dh(e){let t=jr(e.principal);await Hr(e.pmRoot,t,n=>{let r=n?.active_item_ids??[];if(!e.itemId&&r.length===0)return;let o=e.itemId;return{role:o?"planner":n.role,topic:o??$r(r),confidence:o?"high":"medium",rule_version:"v2",evidence:Fr([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:r,...o?{focused_item_id:o}:{}}})}function rd(e,t){let n=t.PM_PATH?.trim();if(n){let o=ae.resolve(e,n);if(Nr(ae.join(o,"settings.json")))return o;let i=ae.join(o,".agents","pm");if(Nr(ae.join(i,"settings.json")))return i}let r=ae.resolve(e);for(let o=0;o<32;o+=1){let i=ae.join(r,".agents","pm");if(Nr(ae.join(i,"settings.json")))return i;let s=ae.dirname(r);if(s===r)break;r=s}}function ss(e){if(!e.key)return;let t=rd(e.cwd,e.env);if(t)try{let n=JSON.parse(ed(Pr(t),"utf8"));return os(n.semantic_attribution?.[e.key])}catch{return}}async function lh(e){return(await is(e)).focused_item}async function uh(e,t){await Mr(e,n=>{n.focused_item=t})}async function fh(e){await Mr(e,t=>{delete t.focused_item})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a69b86e2-6633-5abc-81b7-6a54a592d36c")}catch{}})();var qr=["model","effort","role","topic","version"],hn=new Vr,us=new Vr,yn=new Vr,Gr=[{harness:"claude-code",environment_keys:["CLAUDE_CODE","CLAUDECODE"],model_environment_keys:["ANTHROPIC_MODEL","CLAUDE_MODEL"],session_environment_keys:["CLAUDE_CODE_SESSION_ID"],provenance_environment_keys:{effort:["CLAUDE_EFFORT"]},provenance_resolvers:{model:"claude_session_file",version:"claude_session_file"},provenance_unavailable_dimensions:["role","topic"],argv_markers:["claude","claude-code"],client_names:["claude","claude-code","claude code"]},{harness:"codex",environment_keys:["CODEX_HOME","CODEX_CI","CODEX_THREAD_ID"],model_environment_keys:["CODEX_MODEL"],session_environment_keys:["CODEX_THREAD_ID"],provenance_environment_keys:{effort:["CODEX_REASONING_EFFORT","CODEX_EFFORT"],role:["CODEX_SESSION_ROLE"]},provenance_resolvers:{model:"codex_session_file",effort:"codex_session_file",version:"ai_agent_version"},provenance_unavailable_dimensions:["topic"],argv_markers:["codex"],client_names:["codex"]},{harness:"pi",environment_keys:["PI_AGENT","PI_CODING_AGENT"],model_environment_keys:["PI_MODEL"],session_environment_keys:["PI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["pi"],client_names:["pi"]},{harness:"opencode",environment_keys:["OPENCODE","OPENCODE_SESSION_ID"],model_environment_keys:["OPENCODE_MODEL"],session_environment_keys:["OPENCODE_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["opencode"],client_names:["opencode"]},{harness:"cursor",environment_keys:["CURSOR_AGENT","CURSOR_TRACE_ID"],model_environment_keys:["CURSOR_MODEL"],session_environment_keys:["CURSOR_TRACE_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["cursor"],client_names:["cursor"]},{harness:"aider",environment_keys:["AIDER","AIDER_MODEL"],model_environment_keys:["AIDER_MODEL"],session_environment_keys:["AIDER_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["aider"],client_names:["aider"]},{harness:"gemini-cli",environment_keys:["GEMINI_CLI","GEMINI_CLI_HOME"],model_environment_keys:["GEMINI_MODEL"],session_environment_keys:["GEMINI_CLI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["gemini","gemini-cli"],client_names:["gemini","gemini-cli","gemini cli"]},{harness:"ci",environment_keys:["CI","GITHUB_ACTIONS","BUILDKITE","GITLAB_CI"],provenance_unavailable_dimensions:["model","effort","role","topic"],argv_markers:[],client_names:[]}],fs=Object.freeze({max_bytes:1048576,max_lines:4096,network_access:!1,subprocess_access:!1}),id=Object.freeze({...fs,max_bytes:4194304}),zr=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function sd(e){let t=Te(e).provenance_unavailable_dimensions,n=new Set(["model","version",...Object.keys(e.provenance_environment_keys??{}),...Object.keys(e.provenance_resolvers??{})]);return Object.freeze({contract_version:1,adapter_version:"v1",priority:0,harness:e.harness,descriptor:e,supported_dimensions:Object.freeze([...n].sort()),native_sources:Object.freeze(["environment","argv","mcp_client",...Object.values(e.provenance_resolvers??{}).some(r=>r?.endsWith("session_file"))?["session_file"]:[]]),probe_policy:e.harness==="codex"?id:fs,normalization:Object.freeze({model_family:"v1",effort:"v1",preserve_raw:!0}),confidence:"high",waivers:Object.freeze(Object.fromEntries(t.map(r=>[r,"Harness does not expose this dimension."])))})}var ms=Object.freeze(Gr.filter(e=>e.harness!=="ci").map(sd).sort((e,t)=>e.harness.localeCompare(t.harness))),Ue=new Map,rt=new Map;function P(e){let t=typeof e=="string"?e.trim():void 0;return t&&t.length>0?t:void 0}function Se(e){return[...new Set((e??[]).slice(0,64).map(t=>t.trim()).filter(t=>t.length>0).map(t=>t.slice(0,128)))]}function Te(e){let t=e.harness.trim().toLowerCase();if(!zr.test(t))throw new Error(`Invalid harness signal descriptor namespace: ${e.harness}`);return{harness:t,environment_keys:Se(e.environment_keys),model_environment_keys:Se(e.model_environment_keys),session_environment_keys:Se(e.session_environment_keys),provenance_environment_keys:Object.fromEntries(Object.entries(e.provenance_environment_keys??{}).slice(0,32).map(([n,r])=>[n.trim().toLowerCase().slice(0,64),Se(r)]).filter(([n])=>zr.test(n))),provenance_resolvers:Object.fromEntries(Object.entries(e.provenance_resolvers??{}).slice(0,32).map(([n,r])=>[n.trim().toLowerCase().slice(0,64),r]).filter(n=>typeof n[0]=="string"&&zr.test(n[0])&&(n[1]==="ai_agent_version"||n[1]==="claude_session_file"||n[1]==="codex_session_file"))),provenance_unavailable_dimensions:Se(e.provenance_unavailable_dimensions).map(n=>n.toLowerCase()),argv_markers:Se(e.argv_markers).map(n=>n.toLowerCase()),client_names:Se(e.client_names).map(n=>n.toLowerCase())}}var _s=Gr.map(Te);function ad(e,t){return JSON.stringify(e)===JSON.stringify(t)}function pn(e,t){return e.toLowerCase().slice(0,512).split(/[/\\\s:=]+/u).filter(n=>n.length>0).includes(t)||e.trim().toLowerCase()===t}function Kr(e=[]){let t=new Map(Gr.filter(o=>o.harness!=="ci").map(o=>[o.harness,Te(o)]));for(let{adapter:o}of Ue.values())t.set(o.harness,Te(o.descriptor));let n=[...t.values(),..._s.filter(o=>o.harness==="ci"),...[...rt.values()].map(o=>o.descriptor),...yn.getStore()?.descriptors??[],...e.map(Te)],r=new Set;for(let o of n){if(r.has(o.harness))throw new Error(`Harness signal descriptor collision for "${o.harness}"`);r.add(o.harness)}return n}function Xr(e,t){for(let n of t??[]){let r=P(e[n]);if(r)return r.slice(0,256)}}function cd(e,t){if(t==="role"){let n=e.slice(0,8).map(r=>r.trim().toLowerCase()).find(r=>["claim","create","update","close","release","review"].includes(r));if(n==="review")return"reviewer";if(n)return"implementer"}}function ps(e,t){let n=t==="model"?["--model","--agent-model"]:[`--agent-${t}`],r=e.slice(0,8);for(let o=0;o<r.length;o+=1){let i=r[o].slice(0,512);if(n.includes(i))return P(r[o+1])?.slice(0,256);let s=n.find(a=>i.startsWith(`${a}=`));if(s)return P(i.slice(s.length+1))?.slice(0,256)}}var dd=new Set(["implementation","implementer","investigator","orchestrator","planner","release-operator","reviewer"]);function ze(e,t){if(e!=="role"||t===void 0)return t;let n=t.trim().toLowerCase().replaceAll(/[_\s]+/gu,"-");return dd.has(n)?n:void 0}function Ur(e,t){return P(e?.[t])?.slice(0,256)}var ld=1048576,Wr=4194304,_n=new Map,as=Object.freeze({}),Br=new Map,cs=Object.freeze({});function ds(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function ud(e){let t;try{t=JSON.parse(e)}catch{return cs}let n=ds(t);if(!n)return cs;let r=[{value:n,depth:0}],o=0,i,s;for(;r.length>0&&o<64;){let a=r.shift();if(o+=1,i??=P(a.value.model)?.slice(0,256),s??=P(a.value.version)?.slice(0,256),i&&s)break;if(!(a.depth>=4))for(let c of Object.values(a.value)){let d=ds(c);d&&r.push({value:d,depth:a.depth+1})}}return Object.freeze({model:i,version:s})}function hs(e){try{return V.lstatSync(e).isFile()?"available":"missing"}catch(t){return Fe(t)?"missing":"failed"}}function fd(e,t){let n;try{n=V.readdirSync(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).sort((o,i)=>o.name.localeCompare(i.name)).slice(0,512).map(o=>{let i=Be.join(e,o.name,`${t}.jsonl`);return{candidate:i,status:hs(i)}})}catch(o){return{status:Fe(o)?"missing":"failed"}}let r=n.filter(({status:o})=>o==="available").map(({candidate:o})=>o);return r.length===0?{status:n.some(({status:o})=>o==="failed")?"failed":"missing"}:r.length>1?{status:"ambiguous"}:{status:"available",path:r[0]}}function ys(e,t){let n=P(t.CLAUDE_CODE_SESSION_ID);if(!n||!/^[A-Za-z0-9_-]{1,128}$/u.test(n))return{status:"unavailable"};let r=Be.resolve(e.cwd??process.cwd()).replaceAll(/[^A-Za-z0-9-]/gu,"-"),o=Be.join(e.home_dir??ls.homedir(),".claude","projects"),i=Be.join(o,r,`${n}.jsonl`),s=P(e.session_file),a=s&&Be.basename(s)===`${n}.jsonl`?s:void 0;for(let c of[a,i]){if(!c)continue;let d=hs(c);if(d==="available")return{status:d,path:c};if(d==="failed")return{status:d}}return fd(o,n)}function md(e,t,n){let r=ys(t,n);if(r.status==="available")try{let o=V.openSync(r.path,V.constants.O_RDONLY|V.constants.O_NOFOLLOW);try{let i=V.fstatSync(o),s=`${r.path}\0${i.size}\0${i.mtimeMs}`,a=Br.get(s);if(a)return a[e];let c=Math.min(i.size,ld),d=Math.min(c,Math.ceil(c/2)),l=Math.min(c-d,i.size-d),f=Buffer.alloc(d);V.readSync(o,f,0,d,0);let m=Buffer.alloc(l);l>0&&V.readSync(o,m,0,l,i.size-l);let p={},_=i.size<=c?Buffer.concat([f,m]).toString("utf8").split(`
|
|
1
|
+
import{b as on,g as St,i as Tt,j as Ct,l as Ui,m as Bi,n as dn,o as Wi,p as Vi,q as qi}from"./chunk-4UA7KY4V.js";import{h as fn}from"./chunk-YLVHHWHN.js";import{$ as w,$d as Ie,A as ki,Aa as K,Ac as zi,Ba as xi,Bd as un,F as nn,Fe as xr,G as rn,Ge as Rr,H as vr,J as Ii,La as Ri,P as ve,Pe as ye,Qa as Ai,Qc as me,Qe as se,Ra as Di,Rc as Sr,Sc as ln,Ta as Ni,Tc as _e,Ua as Li,Uc as Tr,V as Pe,Vc as ke,W as Si,Wc as Cr,Xa as sn,Z as k,Za as Pi,Zc as Ot,_ as Me,_d as Ji,aa as h,ab as an,ad as Gi,ae as pe,bb as Mi,be as Qi,cd as Or,ce as tt,de as he,eb as et,fb as kr,gb as Ir,ge as Zi,hb as fe,hd as $e,he as es,i as Qt,ie as W,jb as ji,jd as Ki,kb as D,kd as Xi,lb as ie,ma as ue,mb as cn,nb as T,od as Yi,q as Zt,r as bi,ra as Ti,s as wi,sb as Fi,t as vi,ta as Ci,u as Ei,ua as je,va as Fe,wa as ne,wb as $i,xa as Ee,xb as Hi,y as en,ya as Oi,z as tn,za as Er}from"./chunk-WIXZF5SS.js";import{AsyncLocalStorage as Qc}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1fbb183b-c6d8-5834-b4cb-e4fb515572b9")}catch{}})();var Ar=new Qc,ts=/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,127})$/u;function mn(e,t){let n=typeof e=="string"?e.trim():"";return n.length>0?n.slice(0,t):void 0}function He(e,t){if(e===void 0)return;let n=typeof e=="object"&&e!==null?e:{},r=mn(n.id,128),o=mn(n.parent_id,128);if(r===void 0||!ts.test(r)||o!==void 0&&!ts.test(o)){if(t)throw new Error("Agent episode ids must be 1-128 letters, digits, dots, underscores, colons, or hyphens.");return}let i=mn(n.label,256);return{id:r,...i===void 0?{}:{label:i},...o===void 0?{}:{parent_id:o}}}function nt(e){let t={};for(let[n,r]of Object.entries(e??{}).slice(0,32)){let o=n.trim().toLowerCase().slice(0,64),i=mn(r,256);/^[a-z][a-z0-9_-]{0,63}$/u.test(o)&&i!==void 0&&(t[o]=i)}return t}function Zc(e,t,n){let r=Ar.getStore(),o=nt({role:t.PM_AGENT_SESSION_ROLE,topic:t.PM_AGENT_SESSION_TOPIC}),i=He(t.PM_AGENT_EPISODE_ID===void 0?void 0:{id:t.PM_AGENT_EPISODE_ID,label:t.PM_AGENT_EPISODE_LABEL,parent_id:t.PM_AGENT_EPISODE_PARENT_ID},!1),s={...nt(r?.provenance),...o,...nt(e?.provenance)},a=He(e?.episode,!1)??He(n,!1)??i??He(r?.episode,!1);return Object.keys(s).length===0&&a===void 0?void 0:{...Object.keys(s).length===0?{}:{provenance:s},...a===void 0?{}:{episode:a}}}function Dr(e,t){return Zc(e.session_context,t,e.client_info?.episode)??{}}function Jp(e,t){let n=Ar.getStore(),r=He(e.episode,!0),o=He(n?.episode,!1),i=r!==void 0&&r.parent_id===void 0&&o!==void 0?{...r,parent_id:o.id}:r,s={...nt(n?.provenance),...nt(e.provenance)};return Ar.run({...Object.keys(s).length===0?{}:{provenance:s},...i===void 0?o===void 0?{}:{episode:o}:{episode:i}},t)}function Qp(e){let t=nt(e.provenance),n=He(e.episode,!0);return{...n===void 0?{}:{PM_AGENT_EPISODE_ID:n.id,...n.label===void 0?{}:{PM_AGENT_EPISODE_LABEL:n.label},...n.parent_id===void 0?{}:{PM_AGENT_EPISODE_PARENT_ID:n.parent_id}},...t.role===void 0?{}:{PM_AGENT_SESSION_ROLE:t.role},...t.topic===void 0?{}:{PM_AGENT_SESSION_TOPIC:t.topic}}}import{AsyncLocalStorage as Vr}from"node:async_hooks";import{createHash as od}from"node:crypto";import V from"node:fs";import ls from"node:os";import Be from"node:path";import{createHash as ns}from"node:crypto";import{existsSync as Nr,promises as rs,readFileSync as ed}from"node:fs";import ae from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="06c9f6f4-c2f0-549c-9a0f-4f4269cc5f49")}catch{}})();var td="session.json";function Lr(e,t){return typeof e=="string"&&e.length>0&&e.length<=t}function os(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,n=["implementer","planner","release-operator"].includes(String(t.role)),r=["high","medium"].includes(String(t.confidence)),o=Lr(t.topic,256),i=Array.isArray(t.evidence)&&t.evidence.length<=32&&t.evidence.every(c=>typeof c=="string"&&c.length<=128),s=Array.isArray(t.active_item_ids)&&t.active_item_ids.length<=64&&t.active_item_ids.every(c=>Lr(c,128)),a=t.focused_item_id===void 0||Lr(t.focused_item_id,128);if([n,r,o,i,s,a,t.rule_version==="v2"].every(Boolean))return t}function nd(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=Object.entries(e).slice(0,128).flatMap(([n,r])=>{let o=os(r);return o&&n.length<=128?[[n,o]]:[]});return t.length>0?Object.fromEntries(t):void 0}function Pr(e){return ae.join(ji(e),td)}async function is(e){try{let t=await rs.readFile(Pr(e),"utf8"),n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return{};let r=n,o=r.focused_item,i=nd(r.semantic_attribution);return typeof o=="string"&&o.trim().length>0?{focused_item:o,...i?{semantic_attribution:i}:{}}:i?{semantic_attribution:i}:{}}catch{return{}}}async function Mr(e,t){let n=await W(e,"session-state",k.locks.ttl_seconds,"session-state",!1,!0,k.locks.wait_ms);try{let r=await is(e);t(r);let o=Pr(e);await rs.mkdir(ae.dirname(o),{recursive:!0}),await K(o,JSON.stringify(r))}finally{await n()}}function jr(e){return/#([a-f0-9]{24})$/u.exec(e.trim())?.[1]??`author-${ns("sha256").update(e).digest("hex").slice(0,24)}`}function Fr(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].slice(0,32).map(t=>t.slice(0,128))}function $r(e){let t=[...new Set(e)].sort((r,o)=>r.localeCompare(o));if(t.length===1)return t[0];let n=`workset:${t.join("+")}`;return n.length<=256?n:`workset:${t.join("+").slice(0,230)}+${ns("sha256").update(t.join("\0")).digest("hex").slice(0,12)}`}async function Hr(e,t,n){await Mr(e,r=>{let o={...r.semantic_attribution},i=n(o[t]);i===void 0?delete o[t]:o[t]=i,Object.keys(o).length===0?delete r.semantic_attribution:r.semantic_attribution=o})}async function ah(e){let t=jr(e.principal);await Hr(e.pmRoot,t,n=>{let r=[...new Set([...n?.active_item_ids??[],e.itemId])].slice(-64).sort((i,s)=>i.localeCompare(s)),o=n?.focused_item_id;return{role:"implementer",topic:o??$r(r),confidence:o?"high":"medium",rule_version:"v2",evidence:Fr([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:r,...o?{focused_item_id:o}:{}}})}async function ch(e){let t=jr(e.principal);await Hr(e.pmRoot,t,n=>{if(!n)return;let r=n.active_item_ids.filter(i=>i!==e.itemId);if(r.length===0&&!n.focused_item_id)return;let o=n.focused_item_id;return{...n,role:"release-operator",topic:o??$r(r),confidence:o?"high":"medium",evidence:Fr([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],`release:${e.itemId}`]),active_item_ids:r}})}async function dh(e){let t=jr(e.principal);await Hr(e.pmRoot,t,n=>{let r=n?.active_item_ids??[];if(!e.itemId&&r.length===0)return;let o=e.itemId;return{role:o?"planner":n.role,topic:o??$r(r),confidence:o?"high":"medium",rule_version:"v2",evidence:Fr([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:r,...o?{focused_item_id:o}:{}}})}function rd(e,t){let n=t.PM_PATH?.trim();if(n){let o=ae.resolve(e,n);if(Nr(ae.join(o,"settings.json")))return o;let i=ae.join(o,".agents","pm");if(Nr(ae.join(i,"settings.json")))return i}let r=ae.resolve(e);for(let o=0;o<32;o+=1){let i=ae.join(r,".agents","pm");if(Nr(ae.join(i,"settings.json")))return i;let s=ae.dirname(r);if(s===r)break;r=s}}function ss(e){if(!e.key)return;let t=rd(e.cwd,e.env);if(t)try{let n=JSON.parse(ed(Pr(t),"utf8"));return os(n.semantic_attribution?.[e.key])}catch{return}}async function lh(e){return(await is(e)).focused_item}async function uh(e,t){await Mr(e,n=>{n.focused_item=t})}async function fh(e){await Mr(e,t=>{delete t.focused_item})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a69b86e2-6633-5abc-81b7-6a54a592d36c")}catch{}})();var qr=["model","effort","role","topic","version"],hn=new Vr,us=new Vr,yn=new Vr,Gr=[{harness:"claude-code",environment_keys:["CLAUDE_CODE","CLAUDECODE"],model_environment_keys:["ANTHROPIC_MODEL","CLAUDE_MODEL"],session_environment_keys:["CLAUDE_CODE_SESSION_ID"],provenance_environment_keys:{effort:["CLAUDE_EFFORT"]},provenance_resolvers:{model:"claude_session_file",version:"claude_session_file"},provenance_unavailable_dimensions:["role","topic"],argv_markers:["claude","claude-code"],client_names:["claude","claude-code","claude code"]},{harness:"codex",environment_keys:["CODEX_HOME","CODEX_CI","CODEX_THREAD_ID"],model_environment_keys:["CODEX_MODEL"],session_environment_keys:["CODEX_THREAD_ID"],provenance_environment_keys:{effort:["CODEX_REASONING_EFFORT","CODEX_EFFORT"],role:["CODEX_SESSION_ROLE"]},provenance_resolvers:{model:"codex_session_file",effort:"codex_session_file",version:"ai_agent_version"},provenance_unavailable_dimensions:["topic"],argv_markers:["codex"],client_names:["codex"]},{harness:"pi",environment_keys:["PI_AGENT","PI_CODING_AGENT"],model_environment_keys:["PI_MODEL"],session_environment_keys:["PI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["pi"],client_names:["pi"]},{harness:"opencode",environment_keys:["OPENCODE","OPENCODE_SESSION_ID"],model_environment_keys:["OPENCODE_MODEL"],session_environment_keys:["OPENCODE_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["opencode"],client_names:["opencode"]},{harness:"cursor",environment_keys:["CURSOR_AGENT","CURSOR_TRACE_ID"],model_environment_keys:["CURSOR_MODEL"],session_environment_keys:["CURSOR_TRACE_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["cursor"],client_names:["cursor"]},{harness:"aider",environment_keys:["AIDER","AIDER_MODEL"],model_environment_keys:["AIDER_MODEL"],session_environment_keys:["AIDER_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["aider"],client_names:["aider"]},{harness:"gemini-cli",environment_keys:["GEMINI_CLI","GEMINI_CLI_HOME"],model_environment_keys:["GEMINI_MODEL"],session_environment_keys:["GEMINI_CLI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["gemini","gemini-cli"],client_names:["gemini","gemini-cli","gemini cli"]},{harness:"ci",environment_keys:["CI","GITHUB_ACTIONS","BUILDKITE","GITLAB_CI"],provenance_unavailable_dimensions:["model","effort","role","topic"],argv_markers:[],client_names:[]}],fs=Object.freeze({max_bytes:1048576,max_lines:4096,network_access:!1,subprocess_access:!1}),id=Object.freeze({...fs,max_bytes:4194304}),zr=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function sd(e){let t=Te(e).provenance_unavailable_dimensions,n=new Set(["model","version",...Object.keys(e.provenance_environment_keys??{}),...Object.keys(e.provenance_resolvers??{})]);return Object.freeze({contract_version:1,adapter_version:"v1",priority:0,harness:e.harness,descriptor:e,supported_dimensions:Object.freeze([...n].sort()),native_sources:Object.freeze(["environment","argv","mcp_client",...Object.values(e.provenance_resolvers??{}).some(r=>r?.endsWith("session_file"))?["session_file"]:[]]),probe_policy:e.harness==="codex"?id:fs,normalization:Object.freeze({model_family:"v1",effort:"v1",preserve_raw:!0}),confidence:"high",waivers:Object.freeze(Object.fromEntries(t.map(r=>[r,"Harness does not expose this dimension."])))})}var ms=Object.freeze(Gr.filter(e=>e.harness!=="ci").map(sd).sort((e,t)=>e.harness.localeCompare(t.harness))),Ue=new Map,rt=new Map;function P(e){let t=typeof e=="string"?e.trim():void 0;return t&&t.length>0?t:void 0}function Se(e){return[...new Set((e??[]).slice(0,64).map(t=>t.trim()).filter(t=>t.length>0).map(t=>t.slice(0,128)))]}function Te(e){let t=e.harness.trim().toLowerCase();if(!zr.test(t))throw new Error(`Invalid harness signal descriptor namespace: ${e.harness}`);return{harness:t,environment_keys:Se(e.environment_keys),model_environment_keys:Se(e.model_environment_keys),session_environment_keys:Se(e.session_environment_keys),provenance_environment_keys:Object.fromEntries(Object.entries(e.provenance_environment_keys??{}).slice(0,32).map(([n,r])=>[n.trim().toLowerCase().slice(0,64),Se(r)]).filter(([n])=>zr.test(n))),provenance_resolvers:Object.fromEntries(Object.entries(e.provenance_resolvers??{}).slice(0,32).map(([n,r])=>[n.trim().toLowerCase().slice(0,64),r]).filter(n=>typeof n[0]=="string"&&zr.test(n[0])&&(n[1]==="ai_agent_version"||n[1]==="claude_session_file"||n[1]==="codex_session_file"))),provenance_unavailable_dimensions:Se(e.provenance_unavailable_dimensions).map(n=>n.toLowerCase()),argv_markers:Se(e.argv_markers).map(n=>n.toLowerCase()),client_names:Se(e.client_names).map(n=>n.toLowerCase())}}var _s=Gr.map(Te);function ad(e,t){return JSON.stringify(e)===JSON.stringify(t)}function pn(e,t){return e.toLowerCase().slice(0,512).split(/[/\\\s:=]+/u).filter(n=>n.length>0).includes(t)||e.trim().toLowerCase()===t}function Kr(e=[]){let t=new Map(Gr.filter(o=>o.harness!=="ci").map(o=>[o.harness,Te(o)]));for(let{adapter:o}of Ue.values())t.set(o.harness,Te(o.descriptor));let n=[...t.values(),..._s.filter(o=>o.harness==="ci"),...[...rt.values()].map(o=>o.descriptor),...yn.getStore()?.descriptors??[],...e.map(Te)],r=new Set;for(let o of n){if(r.has(o.harness))throw new Error(`Harness signal descriptor collision for "${o.harness}"`);r.add(o.harness)}return n}function Xr(e,t){for(let n of t??[]){let r=P(e[n]);if(r)return r.slice(0,256)}}function cd(e,t){if(t==="role"){let n=e.slice(0,8).map(r=>r.trim().toLowerCase()).find(r=>["claim","create","update","close","release","review"].includes(r));if(n==="review")return"reviewer";if(n)return"implementer"}}function ps(e,t){let n=t==="model"?["--model","--agent-model"]:[`--agent-${t}`],r=e.slice(0,8);for(let o=0;o<r.length;o+=1){let i=r[o].slice(0,512);if(n.includes(i))return P(r[o+1])?.slice(0,256);let s=n.find(a=>i.startsWith(`${a}=`));if(s)return P(i.slice(s.length+1))?.slice(0,256)}}var dd=new Set(["implementation","implementer","investigator","orchestrator","planner","release-operator","reviewer"]);function ze(e,t){if(e!=="role"||t===void 0)return t;let n=t.trim().toLowerCase().replaceAll(/[_\s]+/gu,"-");return dd.has(n)?n:void 0}function Ur(e,t){return P(e?.[t])?.slice(0,256)}var ld=1048576,Wr=4194304,_n=new Map,as=Object.freeze({}),Br=new Map,cs=Object.freeze({});function ds(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function ud(e){let t;try{t=JSON.parse(e)}catch{return cs}let n=ds(t);if(!n)return cs;let r=[{value:n,depth:0}],o=0,i,s;for(;r.length>0&&o<64;){let a=r.shift();if(o+=1,i??=P(a.value.model)?.slice(0,256),s??=P(a.value.version)?.slice(0,256),i&&s)break;if(!(a.depth>=4))for(let c of Object.values(a.value)){let d=ds(c);d&&r.push({value:d,depth:a.depth+1})}}return Object.freeze({model:i,version:s})}function hs(e){try{return V.lstatSync(e).isFile()?"available":"missing"}catch(t){return Fe(t)?"missing":"failed"}}function fd(e,t){let n;try{n=V.readdirSync(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).sort((o,i)=>o.name.localeCompare(i.name)).slice(0,512).map(o=>{let i=Be.join(e,o.name,`${t}.jsonl`);return{candidate:i,status:hs(i)}})}catch(o){return{status:Fe(o)?"missing":"failed"}}let r=n.filter(({status:o})=>o==="available").map(({candidate:o})=>o);return r.length===0?{status:n.some(({status:o})=>o==="failed")?"failed":"missing"}:r.length>1?{status:"ambiguous"}:{status:"available",path:r[0]}}function ys(e,t){let n=P(t.CLAUDE_CODE_SESSION_ID);if(!n||!/^[A-Za-z0-9_-]{1,128}$/u.test(n))return{status:"unavailable"};let r=Be.resolve(e.cwd??process.cwd()).replaceAll(/[^A-Za-z0-9-]/gu,"-"),o=Be.join(e.home_dir??ls.homedir(),".claude","projects"),i=Be.join(o,r,`${n}.jsonl`),s=P(e.session_file),a=s&&Be.basename(s)===`${n}.jsonl`?s:void 0;for(let c of[a,i]){if(!c)continue;let d=hs(c);if(d==="available")return{status:d,path:c};if(d==="failed")return{status:d}}return fd(o,n)}function md(e,t,n){let r=ys(t,n);if(r.status==="available")try{let o=V.openSync(r.path,V.constants.O_RDONLY|V.constants.O_NOFOLLOW);try{let i=V.fstatSync(o),s=`${r.path}\0${i.size}\0${i.mtimeMs}`,a=Br.get(s);if(a)return a[e];let c=Math.min(i.size,ld),d=Math.min(c,Math.ceil(c/2)),l=Math.min(c-d,i.size-d),f=Buffer.alloc(d);V.readSync(o,f,0,d,0);let m=Buffer.alloc(l);l>0&&V.readSync(o,m,0,l,i.size-l);let p={},_=i.size<=c?Buffer.concat([f,m]).toString("utf8").split(`
|
|
2
2
|
`):[...f.toString("utf8").split(`
|
|
3
3
|
`).slice(0,4096),...m.toString("utf8").split(`
|
|
4
4
|
`).slice(-4096)];for(let g of _){if(g.length===0||g.length>262144)continue;let S=ud(g);if(p.model??=S.model,p.version??=S.version,p.model&&p.version)break}let b=Object.freeze(p);return Br.clear(),Br.set(s,b),b[e]}finally{V.closeSync(o)}}catch{return}}function _d(e,t){let n=0,r=(o,i)=>{if(i>4||n>=512)return;let s;try{s=V.readdirSync(o,{withFileTypes:!0}).sort((a,c)=>c.name.localeCompare(a.name))}catch{return}for(let a of s){if(n+=1,n>512)return;let c=Be.join(o,a.name);if(a.isFile()&&a.name.endsWith(`-${t}.jsonl`))return c;if(a.isDirectory()){let d=r(c,i+1);if(d)return d}}};return r(e,0)}function pd(e){if(e<=Wr)return[{offset:0,length:e}];let t=Math.floor(Wr/2);return[{offset:e-t,length:t},{offset:0,length:t}]}function hd(e,t){if(t.length===0||t.length>262144)return;let n;try{n=JSON.parse(t)}catch{return}if(typeof n!="object"||n===null||Array.isArray(n))return;let r=n;if(r.type!=="turn_context")return;let o=typeof r.payload=="object"&&r.payload!==null?r.payload:void 0;e.model??=P(o?.model)?.slice(0,256),e.effort??=P(o?.effort)?.slice(0,256)}function yd(e,t){let n={},r=4096;for(let o of pd(t)){let i=Buffer.alloc(o.length);V.readSync(e,i,0,o.length,o.offset);let s=i.toString("utf8").split(`
|
|
@@ -162,4 +162,4 @@ ${i}
|
|
|
162
162
|
`}return`${JSON.stringify(r,null,2)}
|
|
163
163
|
`}async function Y_(e){let t;try{t=await _c(e)}catch(a){if(Fe(a))return le();throw a}let n=et(t),r;try{r=await y_(n)}catch(a){if(Fe(a))return le();throw a}if(!r.isFile())throw Er();let o;try{o=await Oi(n,Er())}catch(a){if(Fe(a))return le();throw a}let i;try{i=JSON.parse(o)}catch{return le("settings_read_invalid_json")}let s=Qo(i);return s.success?{settings:_r(s.data),metadata:{has_explicit_item_format:Oc(i)},warnings:s.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:le("settings_read_invalid_schema")}async function Pc(e){if(g_(e))return Y_(e);let t=et(e),n=[t];await ke({path:t,scope:"project"});let r=dc(e);if(r){let d=await Ae(r.tracked_paths);if(Xt(d,r.signatures))return mr(r.value)}let o=await Ae([t]),i;try{i=await Ee(t)}catch{return le("settings_read_fs_error")}if(i===null){let d=le();return await ri(e,[t],d,o,[t]),d}let s=await Ae([t]);if(!Xt(o,s))return De(e),Pc(e);let a;try{a=JSON.parse(i)}catch{let d=le("settings_read_invalid_json");return await ri(e,[t],d,s,[t]),d}let c=Qo(a);if(!c.success){let d=le("settings_read_invalid_schema");return await ri(e,[t],d,s,[t]),d}try{let d=_r(c.data),l=S_(e,d.schema,t);n=l;let f=await Ae(l),m=await Ui(e,d.schema),p=await Bi(e,d.schema),_=await Ae(l),b={...d,item_types:{definitions:wt([...d.item_types.definitions,...ai(p.type_definitions_from_file)])},schema:p.schema};ci(b,Tc(c.data,b));let g={settings:b,metadata:{has_explicit_item_format:Oc(a)},warnings:[...c.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...m.created_paths.map(S=>`runtime_schema_bootstrap_created:${S}`),...p.warnings]};return m.created_paths.length===0?Xt(f,_)?fr(e,{tracked_paths:l,signatures:_,value:mr(g)}):De(e):De(e),g}catch{let d=le("settings_read_merge_failed");return await C_(e,n,d),d}}async function Mc(e){return(await Pc(e)).settings}async function Uw(e,t,n=b_){let r=et(e),o=Cc(t),i=X_(t,{persist_source:o}),s=JSON.parse(i);try{await Ca({pmRoot:e,filePath:r,mutate:a=>{let c=null;if(a!==null)try{c=JSON.parse(a)}catch{throw new h("Existing settings.json is malformed; the settings write was refused.",w.USAGE,{code:"settings_write_invalid_existing_json",reason:"existing_settings_json_malformed",why:"Writing defaults over malformed settings could destroy intended project configuration.",nextSteps:["Repair the syntax in .agents/pm/settings.json, then retry the original command.","Run pm health to confirm the settings warning has cleared."]})}return{raw:o?`${JSON.stringify(T(Zo(o.persisted_settings,s,c),di),null,2)}
|
|
164
164
|
`:i,result:void 0}},op:n,author:Es(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),o&&ci(t,{...o,persisted_settings:structuredClone(s)}),await _e({path:r,scope:"project",op:n})}finally{De(e)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e23f9ca6-9fa6-566b-9bfb-7cbe6d449a59")}catch{}})();function J_(e,t){let n=e.trim().toLowerCase();if(n.length===0)return;let r=Math.floor(n.length/3);return t.map(o=>({candidate:o,distance:Qt(n,o.toLowerCase(),r)??Number.POSITIVE_INFINITY})).filter(({distance:o})=>Number.isFinite(o)).sort((o,i)=>o.distance!==i.distance?o.distance-i.distance:o.candidate.localeCompare(i.candidate))[0]?.candidate}function jc(e){return["pm",...e].map(t=>/^[A-Za-z0-9_./:@=-]+$/u.test(t)?t:JSON.stringify(t)).join(" ")}function Gw(e){let t=e.command_path.trim().replaceAll(/\s+/gu," "),n=e.token.trim(),r=n.length===0?"<empty>":n,o=[...new Set(e.allowed.map(m=>m.trim()))].filter(Boolean).sort((m,p)=>m.localeCompare(p));if(t.length===0||r.length===0||o.length===0)throw new TypeError("Unknown-subcommand contracts require a path, token, and allowed set");let i=t.split(" "),s=e.trailing_args??[],a=e.display_name??`pm ${t}`,c=e.token_kind??"subcommand",d=e.retry_command?void 0:J_(r,o),l=jc([...i,r,...s]),f=e.retry_command??(d?jc([...i,d,...s]):void 0);return new h(`Unknown ${a} ${c} "${r}". Allowed: ${o.join(", ")}${e.message_suffix??""}`,e.exit_code??w.USAGE,{code:"unknown_subcommand",reason:"unknown_positional_token",value:r,examples:[...f?[f]:[],...e.examples??[],`pm ${t} --help`],nextSteps:f?[`Retry with the suggested command: ${f}`]:["Choose one value from recovery.allowed_values."],recovery:{attempted_command:l,allowed_values:o,suggested_retry:f,fallback_candidates:e.fallback_candidates}})}import Q_ from"node:fs/promises";import Z_ from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1d746e4d-ff6c-54ec-a94f-4ec4cb8f77b5")}catch{}})();function ep(e){return[...new Set(e.filter(t=>t.trim().length>0))].sort((t,n)=>t.localeCompare(n))}function tp(e,t){return new h(`Missing history stream for ${e}. ${t} requires history streams when settings.history.missing_stream is strict_error.`,w.NOT_FOUND)}async function np(e,t){return await Ci(Z_.dirname(e)),await(await Q_.open(e,"a")).close(),_e({path:e,scope:"project",op:`${t}:history:auto_create`})}async function li(e){return rp({pmRoot:e.pmRoot,settings:e.settings,itemIds:[e.itemId],commandLabel:e.commandLabel})}async function rp(e){let t=ep(e.itemIds),n=[],r=[];for(let o of t){let i=fe(e.pmRoot,o);if(!await je(i)){if(e.settings.history.missing_stream==="strict_error")throw tp(o,e.commandLabel);r.push(...await np(i,e.commandLabel)),r.push(`history_stream_auto_created:${o}`),n.push(o)}}return{auto_created_ids:n,warnings:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5db05e2f-4742-526b-b1c8-b97ff302b40e")}catch{}})();function Yt(e,t=!1){let n=e[0];if(n?.op!=="history_compact_baseline")return 0;let r=n.context?.history_compaction,o=typeof r=="object"&&r!==null&&"version_offset"in r?r.version_offset:void 0;if(typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&Number.isSafeInteger(o+e.length))return o;if(t)return null;throw new h("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",w.USAGE,{code:"history_version_mapping_unavailable",required:"Use a retained timestamp or recover the pre-compaction stream from version control.",nextSteps:["Run pm history <id> --full to inspect the retained timestamps and checkpoint evidence."]})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ddc5bb8f-83bc-5121-a628-a501e7ed5a73")}catch{}})();function op(e,t){let n=-1;return e.forEach((r,o)=>{let i=Date.parse(r.ts);if(!Number.isFinite(i))throw new h(`History for this item contains invalid timestamp at entry ${o+1}.`,w.GENERIC_FAILURE);i<=t&&(n=o)}),n}function ip(e,t){let n=e[0]?.ts??null,r=e.at(-1)?.ts??null,o={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:n,last_timestamp:r}};return r!==null&&(o.examples=[r],t!==null&&(o.examples.unshift(String(t+1),String(t+e.length)),o.valid_range.first_version=t+1,o.valid_range.last_version=t+e.length)),{guidance:o,lastTimestamp:r}}function sp(e,t){let n={};if(t instanceof Error&&t.message.trim().length>0&&(n.reason=t.message.trim()),typeof t!="object"||t===null)return n;let r=t;if(typeof r.index=="number"&&Number.isInteger(r.index)&&r.index>=0&&(n.patchIndex=r.index),typeof r.operation=="object"&&r.operation!==null){let o=r.operation;Object.assign(n,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(n.patchIndex!==void 0){let o=e[n.patchIndex];o&&(n.op??=o.op,n.path??=o.path,n.from??=o.from)}return n}function Fc(e,t,n={}){let r=e.trim(),o=n.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=ip(t,Yt(t,!0));if(!r)throw new h(`Missing ${o} target. Use a timestamp or version number.`,w.USAGE,s);if(/^\d+$/.test(r)){let l=Yt(t),f=Number(r);if(f>=1&&f<=l)throw new h(`History version ${f} was pruned by compaction.`,w.USAGE,{...s,code:"history_version_pruned"});if(!Number.isSafeInteger(f)||f<1||f>l+t.length)throw new h(`${i} version must be between ${l+1} and ${l+t.length} for this item.`,w.USAGE,s);return{kind:"version",raw:r,historyIndex:f-l-1}}let c=Date.parse(r);if(!Number.isFinite(c))throw new h(`Invalid ${o} target "${e}". Use a positive version number or ISO timestamp.`,w.USAGE,s);let d=op(t,c);if(d<0||n.allowFutureTimestamp!==!0&&c>Date.parse(a))throw new h(o==="restore"?`No history entries exist at or before timestamp ${r}.`:`No history entry exists at timestamp ${r}.`,w.USAGE,s);return{kind:"timestamp",raw:r,historyIndex:d}}function ui(e,t,n,r){let o=Xe(e,t);if(o.ok)return o.document;let i=sp(t,o.error),s=[`history_op=${r}`,i.patchIndex===void 0?null:`patch_index=${i.patchIndex}`,i.op?`op=${i.op}`:null,i.path?`path=${i.path}`:null,i.from?`from=${i.from}`:null].filter(a=>a!==null);throw new h(`Failed to apply history patch at entry ${n} (${s.join(", ")}). ${i.reason??String(o.error)}`,w.GENERIC_FAILURE)}function $c(e,t){let n=e[0];if(n&&n.op!=="create"&&n.op!=="history_compact_baseline"){let s=Xe(mt,n.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new h("History starts without a reconstructable item baseline.",w.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the missing baseline."]})}let r=e.slice(0,t+1),o=we([...r]),i=structuredClone(mt);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new h(`History target entry ${s+1} does not exist.`,w.USAGE);i=ui(i,a.patch,s+1,a.op)}if(!o.ok)throw new h(`History cannot be replayed: ${o.errors.join(", ")}.`,w.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:o.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]});return i}function lv(e,t){if(Object.keys(e.metadata).length>0){if(typeof e.metadata.id!="string"||!Array.isArray(e.metadata.tags))throw new h("History has no complete item baseline for this target.",w.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the first recorded state."]});return e}throw new h(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,w.USAGE)}import mi from"node:fs/promises";import hr from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="658ab1c3-da92-5af6-a170-85ed7befaad6")}catch{}})();function Le(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function _i(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:$e(t),suggested_retry_args:t}}function yr(e){return new h(`Tracker root is not a directory at ${e}.`,w.USAGE,{code:"tracker_root_not_directory",reason:"not_a_directory",resolved_path:e,nextSteps:["Pass a tracker directory, usually <workspace>/.agents/pm, rather than a file path."]})}function fi(e){return new h(`Tracker root is not readable at ${e}.`,w.GENERIC_FAILURE,{code:"tracker_root_unreadable",reason:"unreadable",resolved_path:e,nextSteps:["Grant read and directory-search permission to the tracker root, then retry."]})}async function ap(e){let t=hr.resolve(e),n=hr.parse(t).root,r=hr.dirname(t);for(;r!==n;){let o;try{o=await mi.stat(r)}catch(i){if(Le(i,"ENOTDIR"))throw yr(e);if(!Le(i,"ENOENT"))throw i;r=hr.dirname(r);continue}if(!o.isDirectory())throw yr(e);return}}async function vt(e){let t;try{t=await mi.stat(e)}catch(n){throw Le(n,"ENOENT")?(await ap(e),new h(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,w.NOT_FOUND,{code:"tracker_root_missing",reason:"missing",resolved_path:e,nextSteps:["Confirm the tracker root path or initialize it with the emitted retry."],recovery:_i(e)})):Le(n,"ENOTDIR")?yr(e):Le(n,"EACCES")||Le(n,"EPERM")?fi(e):n}if(!t.isDirectory())throw yr(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw fi(e);try{await(await mi.opendir(e)).close()}catch(n){throw Le(n,"EACCES")||Le(n,"EPERM")?fi(e):n}}async function pi(e){if(await vt(e),!await je(et(e)))throw new h(`Tracker is not initialized at ${e}. Run pm init first.`,w.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:_i(e)})}import Et from"node:fs/promises";import{statSync as cp}from"node:fs";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be69f1e8-4543-5cf5-abb0-9d38ca1d0cc6")}catch{}})();function dp(e,t){let n=-1,r=structuredClone(mt);for(let[a,c]of e.entries()){if(r=ui(r,c.patch,a+1,c.op),r.metadata.id!==void 0&&r.metadata.id!==t)throw new h(`History belongs to item ${String(r.metadata.id)}, expected ${t}.`,w.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});r.metadata.id===t&&Array.isArray(r.metadata.tags)&&(n=a)}let o=Yt(e,!0),i=n<0||o===null?null:o+n+1,s=i===null?void 0:String(i);if(n>=0&&s===void 0){let a=e[n].ts;Fc(a,e).historyIndex===n&&(s=a)}return{version:i,target:s}}async function Hc(e,t,n){let r=new Set([Ye(t,n),jt(t)]);for(let o of r){let i=fe(e,o);if(!cp(i,{throwIfNoEntry:!1})?.isFile())continue;let s=await be(i,o),a=-1;if(s.forEach((p,_)=>{p.op==="delete"&&(a=_)}),a<0)continue;let c=$c(s,s.length-1);if(Object.keys(c.metadata).length!==0)continue;let{version:d,target:l}=dp(s,o),f=l===void 0?["history",o,"--verify"]:["get",o,"--at",l],m=$e(f);return new h(`Item ${o} was deleted at ${s[a].ts}; its history is retained.`,w.NOT_FOUND,{code:"item_deleted",required:"Read a retained materialized version, then restore it if the item should exist again.",item_id:o,tombstone:{deleted:!0,deleted_at:s[a].ts,recoverable:l!==void 0,last_materialized_version:d},nextSteps:[m,...l===void 0?["Recover the pre-compaction history from version control."]:[$e(["restore",o,l])]],recovery:{suggested_retry:m,suggested_retry_args:f}})}}import hi from"node:path";import{isUtf8 as lp}from"node:buffer";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ce5fc177-192a-5efe-a65f-59f0fc0bea42")}catch{}})();async function up(e){try{return await Et.access(e),!0}catch{return!1}}function fp(e,t){e&&(e.includes(t)||e.push(t))}function zc(e){return e??on(me())}function mp(e){return e==="toon"?["toon","json_markdown"]:e==="json_markdown"?["json_markdown","toon"]:["toon","json_markdown"]}async function gr(e,t,n="pm-",r,o=Pe){let i=t.trim(),s=i.startsWith("#")?i.slice(1):i;if(s.length===0)return null;let a=Ye(t,n),c=jt(t),d=[...new Set([s,a,c])].filter(m=>m.length>0),l=Object.entries(o),f=mp(r);for(let m of d){let p=new Map;for(let[_]of l)for(let b of f){let g=kr(e,_,m,b,o);await up(g)&&p.set(g,p.get(g)??{id:m,type:_,itemPath:g,item_format:b})}if(p.size>1){let _=[...p.keys()].map(b=>hi.relative(e,b).split(hi.sep).join("/")).sort();throw new h(`Item ${m} has ambiguous identity across ${_.join(", ")}. Preserve both documents and inspect pm ops validate --check-storage-integrity before resolving the collision.`,w.CONFLICT,{code:"item_identity_ambiguous",item_id:m,paths:_})}for(let _ of p.values())return _}return null}async function br(e,t={}){let n=await _p(e,t);if(n.error!==null)throw n.error;return{raw:n.raw,document:n.document}}async function _p(e,t={}){let n=await Et.readFile(e.itemPath);if(!lp(n))throw new h("Item contains invalid UTF-8; preserve a binary backup before recovering it.",w.CONFLICT,{code:"item_document_encoding_invalid",item_id:e.id,item_path:e.itemPath,byte_length:n.length,empty:!1});let r=n.toString("utf8");await ke({path:e.itemPath,scope:"project"});let o;try{o=In(r,{format:e.item_format,requireSupportedFormat:!0,schema:t.schema,extensionFieldNames:zc(t.extensionFieldNames),onWarning:i=>fp(t.warnings,i)})}catch(i){if(i instanceof h&&i.code==="item_format_version_unsupported")throw new h(`Item ${e.id}: ${i.message}`,i.exitCode,{...i.context,item_id:e.id,item_path:e.itemPath});if(i instanceof h&&i.code==="item_document_invalid")return{raw:r,document:null,error:new h(`Cannot read ${e.id} at ${e.itemPath}${n.length===0?" (zero-length file)":""}: ${i.message}`,i.exitCode,{...i.context,item_id:e.id,item_path:e.itemPath,byte_length:n.length,empty:n.length===0,nextSteps:[`Run pm history ${e.id} --full, then pm restore ${e.id} <version> to recover a recorded state.`]})};throw i}return{raw:r,document:o,error:null}}async function pp(e,t,n=Pe,r,o){await vt(e);let i=await Va(e,t,n,r,o);return Wn(i.length),i.map(s=>s.metadata)}async function Uc(e,t,n=Pe,r,o){await vt(e);let i=await qa(e,t,n,r,o);return Wn(i.length),i.map(s=>s.metadata)}async function nE(e,t,n=Pe,r,o,i={}){await vt(e);let s=await nr(e,t,n,r,o,{includeBody:!0,forceSourceScan:i.forceSourceScan});return Wn(s.length),s.map(a=>({...a.metadata,body:a.body}))}function Bc(e){return{async get(t){let n=await gr(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!n)return null;let{document:r}=await br(n,{schema:e.settings.schema});return{item:r.metadata,body:r.body}},list:()=>pp(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema)}}async function hp(e,t){let n=new Set(Object.values(t)),r=[];return await Promise.all([...n].map(async o=>{try{let i=await Et.readdir(hi.join(e,o));for(let s of i)for(let a of an)if(s.toLowerCase().endsWith(a)){r.push(s.slice(0,-a.length));break}}catch{}})),r}async function yp(e,t,n,r){let o=Ye(t,n),i=await hp(e,r);if(i.length===0)return[];let s=Math.max(3,Math.floor(o.length/2));return i.map(a=>({id:a,distance:Qt(a,o,s)})).filter(a=>a.distance!==null).sort((a,c)=>a.distance-c.distance).slice(0,3).map(a=>a.id)}async function gp(e,t,n,r){let o=await Hc(e,t,n);if(o)return o;let i=await yp(e,t,n,r),s=["Confirm the active --path/PM_PATH scope, then retry with a valid id."];return i.length>0&&s.unshift(`Did you mean one of: ${i.join(", ")}?`),new h(`Item ${t} not found`,w.NOT_FOUND,{nextSteps:s})}function bp(e,t){return e==="claim"||t===!0&&(e==="comment_add"||e==="comment_edit"||e==="comment_delete"||e==="note_add"||e==="learning_add"||e==="release"||e==="update"||e==="update_ownership_bypass"||e==="update_audit")}async function Wc(e){let t=e.typeToFolder??sn(e.settings,me()).type_to_folder,n=await gr(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,t);if(!n)throw await gp(e.pmRoot,e.id,e.settings.id_prefix,t);let r=await W(e.pmRoot,n.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms);try{let o=[],{raw:i,document:s}=await br(n,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames,warnings:o}),a=s.metadata.assignee?.trim(),c=s.metadata.claim_principal?.trim()||a,d=vs(e.author),l=pr(e.settings);if(a&&c!==d&&!e.force&&!bp(e.op,e.bypassAssigneeConflict)){if(l.ownership_enforcement==="strict")throw new h(`Item ${n.id} is assigned to ${a}. Use --force to override.`,w.CONFLICT);l.ownership_enforcement==="warn"&&o.push(`ownership_warning:assignee_conflict:${n.id}:${a}`)}return{typeToFolder:t,located:n,originalRaw:i,document:s,warnings:o,releaseLock:r}}catch(o){throw await r(),o}}function wp(e,t,n){if(!e.handled||typeof e.result!="object"||e.result===null)return{effectiveTargetItemPath:t,effectiveSerializedAfter:n,skipItemWrite:!1};let r=e.result;return{effectiveTargetItemPath:typeof r.target_item_path=="string"&&r.target_item_path.trim().length>0?r.target_item_path:t,effectiveSerializedAfter:typeof r.contents=="string"?r.contents:n,skipItemWrite:r.skip_write===!0}}async function vp(e){if(!e.skipItemWrite){if(e.effectiveTargetItemPath!==e.originalItemPath){await K(e.originalItemPath,e.originalRaw),await Et.rm(e.effectiveTargetItemPath,{force:!0});return}await K(e.originalItemPath,e.originalRaw)}}async function Vc(e){fn(e.op);let t=await Wc({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:e.op,author:e.author,force:e.force,bypassAssigneeConflict:e.bypassAssigneeConflict,extensionFieldNames:e.extensionFieldNames,typeToFolder:e.typeToFolder}),{typeToFolder:n,located:r,originalRaw:o,document:i,warnings:s,releaseLock:a}=t;try{let c=re(i,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),d=re(structuredClone(i),{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),l=await e.mutate(d);if(e.skipNoop===!0&&l.changedFields.length===0)return{item:c.metadata,body:c.body,changedFields:[],warnings:[...s,...l.warnings??[]]};let f=e.resolveHistoryContext?.();d.metadata.updated_at=Ie();let m=re(d,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),p=await Oo({pmRoot:e.pmRoot,settings:e.settings,operation:e.op,author:e.author,before:c,after:m});await Tr({pm_root:e.pmRoot,operation:e.op,before:c,after:m,changed_fields:l.changedFields,sdk:Bc({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:n})});let _=await li({pmRoot:e.pmRoot,settings:e.settings,itemId:r.id,commandLabel:e.op}),b="toon",g=Hs(m,{format:b,schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),S=kr(e.pmRoot,m.metadata.type,r.id,b,n),A=fe(e.pmRoot,r.id),L=await Ot("item_store_write",{op:e.op,pm_root:e.pmRoot,item_id:r.id,source_item_path:r.itemPath,target_item_path:S,history_path:A,item_format:b,before:c,after:m,contents:g}),{effectiveTargetItemPath:$,effectiveSerializedAfter:x,skipItemWrite:q}=wp(L,S,g),B=await Fo(e.pmRoot,e.author),Q=[];try{q||await K($,x),!q&&$!==r.itemPath&&await Et.rm(r.itemPath);let ee=ut({nowIso:m.metadata.updated_at,author:e.author,op:e.op,before:c,after:m,message:e.message,context:p.decisions.length===0?f:{...f,workflow_policies:p.decisions}});try{await ft(A,ee)}catch(te){throw await vp({skipItemWrite:q,effectiveTargetItemPath:$,originalItemPath:r.itemPath,originalRaw:o}),te}q||(Q=await $o({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:n,schema:e.settings.schema,itemPath:$,previousItemPath:r.itemPath,document:m}))}finally{await B()}let G=[...await _e({path:$,scope:"project",op:e.op,item_id:m.metadata.id,item_type:m.metadata.type,before:c,after:m,changed_fields:l.changedFields}),...await _e({path:A,scope:"project",op:`${e.op}:history`,item_id:m.metadata.id,item_type:m.metadata.type,before:c,after:m,changed_fields:l.changedFields})];return Sr({id:m.metadata.id,op:e.op,item_type:m.metadata.type,previous_status:c.metadata.status,status:m.metadata.status,previous:ln(c.metadata,l.changedFields),current:ln(m.metadata,l.changedFields),changed_fields:l.changedFields}),{item:m.metadata,body:m.body,changedFields:l.changedFields,warnings:[...s,...l.warnings??[],...p.warnings,..._.warnings,...L.warnings,...Q,...G]}}finally{await a()}}async function rE(e){return Vc(e)}async function oE(e){return Vc(e)}async function iE(e){let t=await Wc({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:"delete",author:e.author,force:e.force}),{located:n,originalRaw:r,document:o,warnings:i,releaseLock:s}=t;try{let a=zc(void 0),c=re(o,{schema:e.settings.schema,extensionFieldNames:a}),d=await Oo({pmRoot:e.pmRoot,settings:e.settings,operation:"delete",author:e.author,before:c,after:null,dryRun:e.dryRun});await Tr({pm_root:e.pmRoot,operation:"delete",before:c,after:null,changed_fields:["deleted"],sdk:Bc({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t.typeToFolder})});let l=await li({pmRoot:e.pmRoot,settings:e.settings,itemId:n.id,commandLabel:"delete"}),f=Ie(),m=Me,p=ut({nowIso:f,author:e.author,op:"delete",before:c,after:m,message:e.message,context:d.decisions.length===0?void 0:{workflow_policies:d.decisions}}),_=fe(e.pmRoot,n.id),b=await Ot("item_store_delete",{op:"delete",pm_root:e.pmRoot,item_id:n.id,item_path:n.itemPath,history_path:_,before:c}),g=n.itemPath,S=!1;if(b.handled&&typeof b.result=="object"&&b.result!==null){let x=b.result;typeof x.item_path=="string"&&x.item_path.trim().length>0&&(g=x.item_path),x.skip_delete===!0&&(S=!0)}if(e.dryRun===!0)return{item:c.metadata,changedFields:["deleted"],targetPath:g,warnings:[...i,...d.warnings,...l.warnings,...b.warnings]};let A=await Fo(e.pmRoot,e.author),L=[];try{S||await Et.rm(g);try{await ft(_,p)}catch(x){throw S||await K(g,r),x}S||(L=await $o({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:t.typeToFolder,schema:e.settings.schema,itemPath:g,document:null}))}finally{await A()}let $=[...await _e({path:g,scope:"project",op:"delete",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:m,changed_fields:["deleted"]}),...await _e({path:_,scope:"project",op:"delete:history",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:m,changed_fields:["deleted"]})];return Sr({id:c.metadata.id,op:"delete",item_type:c.metadata.type,previous_status:c.metadata.status,previous:ln(c.metadata,Object.keys(c.metadata)),changed_fields:["deleted"]}),{item:c.metadata,changedFields:["deleted"],warnings:[...i,...d.warnings,...l.warnings,...b.warnings,...L,...$]}}finally{await s()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c8194ff-d877-51b8-bd54-d206f85a979c")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="620bf4e4-e6d1-5520-89e4-0859f57c7afe")}catch{}})();var Ep=["tree","graph","context"],kp=["none","repeated"],Ip=["outgoing","incoming","both"],Sp=32,Tp=200,Cp=400,Op=16e3;function xp(e){let t=e?.trim().toLowerCase()??"tree";if(Ep.includes(t))return t;throw new h(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,w.USAGE)}function kt(e,t){if(e===void 0)return;let n=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(n)||n<1)throw new h(`Invalid --${t} value "${e}". Use a positive integer.`,w.USAGE);return n}function Gc(e){if(e===void 0)return;let t=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(t)||t<0)throw new h(`Invalid --max-depth value "${e}". Use a non-negative integer.`,w.USAGE);return t}function Rp(e){let t=e?.trim().toLowerCase()??"none";if(kp.includes(t))return t;throw new h(`Invalid --collapse value "${e}". Use "none" or "repeated".`,w.USAGE)}function Ap(e){let t=e?.trim().toLowerCase()??"both";if(Ip.includes(t))return t;throw new h(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,w.USAGE)}function Dp(e,t=ue()){if(e===void 0)return;let n=(Array.isArray(e)?e:[e]).flatMap(o=>o.split(",")).map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)return;let r=new Set;for(let o of n){let i=t.resolve(o);if(!i){let s=t.list().map(a=>a.kind).join(", ");throw new h(`Invalid --kind value "${o}". Registered kinds: ${s}.`,w.USAGE)}r.add(i.kind)}return[...r].sort()}function Np(e){if(!e||e.length===0)return[];let t=e.map(({id:r,kind:o})=>({id:r.trim(),kind:o.trim().toLowerCase()})).sort((r,o)=>{let i=r.kind.localeCompare(o.kind);return i!==0?i:r.id.localeCompare(o.id)}),n=new Map;for(let r of t){let o=`${r.kind.toLowerCase()}::${r.id.toLowerCase()}`;n.has(o)||n.set(o,{id:r.id,kind:r.kind})}return[...n.values()]}function Lp(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:Np(e.dependencies)}}function Pp(e){return un(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function Mp(e,t,n,r,o,i,s,a,c){for(let d of t.dependencies){let l=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:d.id,kind:d.kind}).length/3));if(a.nodes>=a.nodeLimit){e.truncated=!0,a.reasons.add("node_limit");break}if(a.edges>=a.edgeLimit){e.truncated=!0,a.reasons.add("edge_limit");break}if(a.estimatedTokens+l>=a.tokenBudget){e.truncated=!0,a.reasons.add("token_budget");break}a.edges+=1,a.estimatedTokens+=l,e.dependencies.push(Kc(d.id,n,r,o,i,s,a,c+1,d.kind))}}function jp(e,t,n,r,o,i,s,a){return s.estimatedTokens>=s.tokenBudget&&t?.dependencies.length?(e.truncated=!0,s.reasons.add("token_budget"),!0):!t||e.cycle?!0:r!==void 0&&a>=r?(t.dependencies.length>0&&(e.truncated=!0,s.reasons.add("max_depth")),!0):o==="repeated"&&i.has(n)?(e.collapsed=!0,!0):!1}function Kc(e,t,n,r,o,i,s,a=0,c){let d=e.trim().toLowerCase(),l=t.get(d),f={id:l?.id??e,title:l?.title,type:l?.type,status:l?.status,via:c,missing:!l,cycle:n.has(d),dependencies:[]};if(s.nodes+=1,s.estimatedTokens+=Pp(f),jp(f,l,d,r,o,i,s,a))return f;o==="repeated"&&i.add(d);let m=new Set(n);return m.add(d),Mp(f,l,t,m,r,o,i,s,a),f}function qc(e,t){return!e||e.missing&&!t.missing?t:{...e,title:e.title??t.title,type:e.type??t.type,status:e.status??t.status}}function Fp(e){let t=new Map,n=new Map,r=[e];for(;r.length>0;){let a=r.pop();t.set(a.id,qc(t.get(a.id),{id:a.id,title:a.title,type:a.type,status:a.status,missing:a.missing}));for(let c of a.dependencies){t.set(c.id,qc(t.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));let d=c.via??"related",l=`${a.id}::${c.id}::${d}`;n.has(l)||n.set(l,{from:a.id,to:c.id,kind:d}),c.cycle||r.push(c)}}let o=[...t.values()].sort((a,c)=>a.id.localeCompare(c.id)),i=[...n.values()].sort((a,c)=>{let d=a.from.localeCompare(c.from);if(d!==0)return d;let l=a.to.localeCompare(c.to);return l!==0?l:a.kind.localeCompare(c.kind)}),s=o.filter(a=>a.missing).map(a=>a.id);return{root_id:e.id,nodes:o,edges:i,missing_ids:s}}function Xc(e,t,n){let r=new Set,o=new Set,i=new Set,s=new Set,a=[{id:e,depth:0}],c=0;for(;c<a.length;){let d=a[c++],l=d.id.trim().toLowerCase();r.add(l);let f=t.get(l);if(!f){i.add(l);continue}if(!(n!==void 0&&d.depth>=n)&&!s.has(l)){s.add(l);for(let m of f.dependencies)o.add(`${l}::${m.id.trim().toLowerCase()}::${m.kind}`),a.push({id:m.id,depth:d.depth+1})}}return{node_count:r.size,edge_count:o.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function $p(e,t=ue()){let n=Gc(e.maxDepth),r=kt(e.nodeLimit,"node-limit"),o=kt(e.edgeLimit,"edge-limit"),i=kt(e.tokenBudget,"token-budget"),s=Dp(e.kind,t);return{direction:Ap(e.direction),...s===void 0?{}:{kinds:s},...n===void 0?{}:{maxDepth:n},...r===void 0?{}:{nodeLimit:r},...o===void 0?{}:{edgeLimit:o},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function Hp(e,t,n,r){return oc(e.graph,t,e.details.map(o=>o.id===t&&r.length>0?{...o,evidence:r}:o),n)}function yi(e,t,n,r){for(let o of n.slice(0,r)){let i=o?.trim();i&&e.push(`${t}:${i}`)}}async function zp(e,t,n,r){let o=await gr(e,t,n.id_prefix,n.item_format,r);if(!o)return[];let{document:i}=await br(o,{schema:n.schema}),s=i.metadata,a=s.files??[],c=s.tests??[],d=s.docs??[],l=[["files",a.length],["tests",c.length],["docs",d.length],["comments",(s.comments??[]).length],["notes",(s.notes??[]).length],["learnings",(s.learnings??[]).length]];if(l.every(([,m])=>m===0))return[];let f=[`linked:${l.map(([m,p])=>`${m}=${p}`).join(",")}`];return yi(f,"file",a.map(m=>m.path),3),yi(f,"test",c.map(m=>m.command??m.path),2),yi(f,"doc",d.map(m=>m.path),2),f}function Up(e){let{canonicalId:t,context:n,missingCount:r,missingReferences:o,referenceLimit:i,summaryOnly:s}=e;return{id:t,format:"context",node_count:n.nodes.length+1,edge_count:n.edges.length,edge_basis:"deduplicated_directed",missing_count:r,missing_scope:"traversal",missing_reference_count:o.length,...s?{}:{missing_references:o.slice(0,i),context:n}}}function Bp(e){let{row:t,missingReachableSet:n,packetIds:r,filteredKinds:o,registry:i}=e;if(t.no_active_blocker_sentinel||!n.has(t.target_id.trim().toLowerCase())||!r.has(t.holder_id))return!1;if(o===void 0)return!0;let s=i.resolve(t.kind);return s!==void 0&&(o.has(s.kind)||s.inverse!==void 0&&o.has(s.inverse))}function Yc(e,t,n){let r;for(;;){let o=un(new TextEncoder().encode(Rr(Or("deps",e),t)).byteLength);if(o===r)return o;n(o),r=o}}function Wp(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function Vp(e){try{return Hp(e.assembly,e.canonicalId,{...e.contextOptions,...e.internalTokenBudget===void 0?{}:{tokenBudget:e.internalTokenBudget}},e.rootEvidence)}catch(t){if(e.smallestResult!==void 0&&Wp(t))return e.smallestResult;throw t}}function qp(e){let{assembly:t,canonicalId:n,contextOptions:r,rootEvidence:o,summaryOnly:i,outputFormat:s,missingCount:a,missingReferences:c}=e,d=r.edgeLimit??40,l=r.tokenBudget,f,m;for(;;){let p=Vp({assembly:t,canonicalId:n,contextOptions:r,internalTokenBudget:l,rootEvidence:o,smallestResult:m});if("format"in p)return p;let _=p;f??=_.meta.tokenBudget,l??=f;let b=Up({canonicalId:n,context:_,missingCount:a,missingReferences:c,referenceLimit:d,summaryOnly:i});if(m=b,i||(_.meta.tokenBudget=f,_.meta.usedTokens=Yc(It(b,!1),s,A=>{_.meta.usedTokens=A}),_.meta.usedTokens<=f))return b;if(d>0){d-=1;continue}let g=l,S=g*f/_.meta.usedTokens;l=Math.min(g-1,Math.max(1,Math.floor(S*.9)))}}function Gp(e){let{assembly:t,canonicalId:n,options:r,rootEvidence:o,summaryOnly:i,outputFormat:s}=e,a=$p(r,t.graph.registry()),c=t.graph.closure(n,{direction:a.direction,...a.kinds===void 0?{}:{kinds:a.kinds},maxDepth:a.maxDepth??3}),d=c.value.filter(b=>t.missingIdSet.has(b.toLowerCase())),l=new Set(d.map(b=>b.toLowerCase())),f=t.graph.registry(),m=a.kinds?new Set(a.kinds.map(b=>f.require(b).kind)):void 0,p=new Set([n,...c.value]),_=[...t.dangling.active,...t.dangling.legacy_terminal].filter(b=>Bp({row:b,missingReachableSet:l,packetIds:p,filteredKinds:m,registry:f}));return qp({assembly:t,canonicalId:n,contextOptions:a,rootEvidence:o,summaryOnly:i,outputFormat:s,missingCount:d.length,missingReferences:_})}function Kp(e){let t=[e],n;for(;t.length>0;){let r=t.pop();r.dependencies.length>0&&(n=r,t.push(...r.dependencies))}return n?(n.dependencies.pop(),n.truncated=!0,!0):!1}function Xp(e,t,n,r,o,i,s){let a=o??Sp,c=kt(n.nodeLimit,"node-limit")??Tp,d=kt(n.edgeLimit,"edge-limit")??Cp,l=kt(n.tokenBudget,"token-budget")??Op,f={nodeLimit:c,edgeLimit:d,tokenBudget:l,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},m=Kc(e,r,new Set,a,t==="graph"?"repeated":i,new Set,f),p=Xc(e,r,void 0),_;for(;;){let b=Fp(m),g=f.reasons.size===0?void 0:{reasons:[...f.reasons].sort(),limits:{max_depth:a,node_limit:c,edge_limit:d,token_budget:l},estimated_tokens:0,total_node_count:p.node_count,total_edge_count:p.edge_count,omitted_node_count:Math.max(0,p.node_count-b.nodes.length),omitted_edge_count:Math.max(0,p.edge_count-b.edges.length)},S={id:e,format:t,node_count:b.nodes.length,edge_count:b.edges.length,edge_basis:"deduplicated_directed",missing_count:b.missing_ids.length,...g?{truncation:g}:{}};if(_=t==="tree"?{...S,tree:m}:{...S,graph:b},(_.truncation===void 0?un(new TextEncoder().encode(Rr(Or("deps",It(_,!1)),s)).byteLength):Yc(It(_,!1),s,A=>{_.truncation.estimated_tokens=A}))<=l)return _;if(!Kp(m))return f.reasons.add("token_budget"),_;f.reasons.add("token_budget")}}function It(e,t,n={}){let r={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"};return{...e,legacy_alias_counts:n,projection:{mode:t?"summary":"full",declared_field_groups:[r],included_field_groups:t?[]:[r.name]}}}async function TE(e,t,n){let r=Mi(process.cwd(),n.path);await pi(r);let o=xp(t.format),i=Gc(t.maxDepth),s=Rp(t.collapse);Gi(t.summary===!0,t.full===!0,"--summary");let a=t.summary===!0,c=await Mc(r),d=sn(c,me()),l=await Uc(r,c.item_format,d.type_to_folder,void 0,c.schema),f=dn(c.schema),m=new Map(l.map(_=>[_.id.trim().toLowerCase(),Lp(_)])),p=qo(l,_=>ge(_,f));for(let _ of[...p.active,...p.legacy_terminal]){let b=m.get(_.holder_id.trim().toLowerCase()),g=_.kind.trim().toLowerCase();b&&!b.dependencies.some(S=>S.id.trim().toLowerCase()===_.target_id.trim().toLowerCase()&&S.kind===g)&&b.dependencies.push({id:_.target_id,kind:g})}if(!m.has(e.trim().toLowerCase()))throw new h(`Item ${e} not found`,w.NOT_FOUND);if(o==="context"){let _=m.get(e.trim().toLowerCase()).id,b=a?[]:await zp(r,_,c,d.type_to_folder),g=L=>ge(L,f),S=de(),A=rc().lookup(r,tc(l,g,S),()=>ar(l,g,S));return It(Gp({assembly:A.assembly,canonicalId:_,options:t,rootEvidence:b,summaryOnly:a,outputFormat:n.json===!0?"json":"toon"}),a,A.assembly.legacyAliasCounts)}return a?It({id:e,format:o,...Xc(e,m,i)},!0,Object.fromEntries(Object.entries(ar(l,_=>ge(_,f)).legacyAliasCounts))):It(Xp(e,o,t,m,i,s,n.json===!0?"json":"toon"),!1,Object.fromEntries(Object.entries(ar(l,_=>ge(_,f)).legacyAliasCounts)))}export{Qo as a,He as b,Dr as c,Jp as d,Qp as e,is as f,jr as g,ah as h,ch as i,dh as j,lh as k,uh as l,fh as m,qr as n,Gr as o,ms as p,Eh as q,kh as r,Ih as s,Sh as t,Th as u,Ch as v,Jr as w,gs as x,Oh as y,xh as z,Rh as A,Rd as B,vs as C,Es as D,Nh as E,Dd as F,ks as G,We as H,Ce as I,Os as J,xt as K,Vh as L,qh as M,Qr as N,Zr as O,Is as P,Ss as Q,Nd as R,Ph as S,gn as T,ot as U,ge as V,wn as W,Pl as X,kn as Y,In as Z,Hs as _,re as $,su as aa,be as ba,ct as ca,Su as da,Ly as ea,Py as fa,My as ga,Nu as ha,Ln as ia,Ge as ja,Mt as ka,sg as la,ko as ma,jn as na,ca as oa,ag as pa,ua as qa,cg as ra,ut as sa,ft as ta,zs as ua,mt as va,Fn as wa,gg as xa,So as ya,$n as za,bg as Aa,wg as Ba,ha as Ca,Xe as Da,ba as Ea,we as Fa,sf as Ga,vg as Ha,Eg as Ia,pt as Ja,zn as Ka,Ug as La,Bg as Ma,Sa as Na,Ca as Oa,Wg as Pa,ww as Qa,De as Ra,zw as Sa,g_ as Ta,pr as Ua,_r as Va,X_ as Wa,Pc as Xa,Mc as Ya,Uw as Za,Gw as _a,li as $a,rp as ab,va as bb,jt as cb,Ye as db,xg as eb,Yt as fb,Fc as gb,ui as hb,$c as ib,lv as jb,hf as kb,gf as lb,bf as mb,wf as nb,vf as ob,Oo as pb,ab as qb,_b as rb,pb as sb,hb as tb,Ha as ub,Mf as vb,Fo as wb,xb,$o as yb,nr as zb,vt as Ab,pi as Bb,gr as Cb,br as Db,_p as Eb,pp as Fb,Uc as Gb,nE as Hb,Bc as Ib,gp as Jb,rE as Kb,oE as Lb,iE as Mb,zo as Nb,_m as Ob,Vt as Pb,or as Qb,Ka as Rb,pm as Sb,hm as Tb,ym as Ub,wm as Vb,Yb as Wb,Jb as Xb,Am as Yb,de as Zb,Bb as _b,sr as $b,Wb as ac,xm as bc,Vb as cc,Gt as dc,Nm as ec,Pm as fc,qo as gc,Mm as hc,ow as ic,ar as jc,tc as kc,Go as lc,rc as mc,dw as nc,oc,kt as pc,Gc as qc,Ap as rc,Dp as sc,TE as tc};
|
|
165
|
-
//# sourceMappingURL=chunk-
|
|
165
|
+
//# sourceMappingURL=chunk-JDVZF75H.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Bb as Pe,Gb as Le,V as Oe,Ya as je,Zb as Fe,_a as Me,ic as G,jc as Ge,kc as $e,mc as qe,pc as $,qc as Ue,rc as Be,sc as ze}from"./chunk-F5J3ATMV.js";import{n as Se}from"./chunk-NNW5BS5L.js";import{$ as w,$a as Ee,Aa as Ie,Nc as Ce,Qb as ie,Va as xe,Yd as Ae,Zc as De,aa as k,fe as Re,gd as Te,hd as oe,ka as we,kd as Ne,pa as ke,va as j,wc as I,ya as re}from"./chunk-UPJA45K7.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="403706c5-987d-5db1-95d2-b0eaded98e92")}catch{}})();function Ut(e,t,n,r,i,o){if(e.seen.has(t))return"skip";if(e.cursorFound&&e.affected.length>=o)return"truncate";e.seen.add(t),e.parents.set(t,n.id);let s=n.depth+1;return e.queue.push({id:t,depth:s}),e.cursorFound?(e.affected.push({id:t,distance:s,path:Yt(r,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function Ke(e,t,n,r){let i=Te("graph impact",{root:e,direction:n,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(r)?r:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:Ne(t.after,i)}}function C(e,t,n){e.get(t).add(n)}function M(e){return new Map(e.map(t=>[t,new Set]))}function Ve(e){for(let t of e)t.sort();return e.sort((t,n)=>n.length-t.length||t[0].localeCompare(n[0]))}function q(e){if(Array.isArray(e))return e.map(n=>q(n));if(e===null||typeof e!="object")return e;let t=e.toJSON;return typeof t=="function"?q(t.call(e)):Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,q(r)]))}function He(e){return JSON.stringify(q(e))}function Bt(e,t,n,r){let i=[{id:e,expanded:!1}];for(;i.length>0;){let o=i.pop();if(o.expanded){r.push(o.id);continue}if(n.has(o.id))continue;n.add(o.id),i.push({id:o.id,expanded:!0});let s=[...t.get(o.id)].sort().reverse();for(let a of s)n.has(a)||i.push({id:a,expanded:!1})}}function zt(e,t){let n=new Set,r=[];for(let i of e)n.has(i)||Bt(i,t,n,r);return r}function Ht(e,t){let n=new Set,r=[];for(let i of[...e].reverse()){if(n.has(i))continue;let o=[],s=[i];for(n.add(i);s.length>0;){let a=s.pop();o.push(a);for(let c of t.get(a))n.has(c)||(n.add(c),s.push(c))}r.push(o)}return Ve(r)}function We(e,t){let n=M(e);for(let[r,i]of t)for(let o of i)C(n,o,r);return Ht(zt(e,t),n)}function Kt(e,t){let n=M(e.nodes());for(let r of e.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let o=(i.precedence??"source_before_target")==="source_before_target";C(n,o?r.source:r.target,o?r.target:r.source)}return n}function Vt(e,t){let n=new Map(e.map(o=>[o,0]));for(let o of t.values())for(let s of o)n.set(s,n.get(s)+1);let r=e.filter(o=>n.get(o)===0).sort(),i=[];for(;r.length>0;){i.push(r);let o=[];for(let s of r)for(let a of t.get(s)){let c=n.get(a)-1;n.set(a,c),c===0&&o.push(a)}r=o.sort()}return i}function Wt(e,t){let n=new Map(e.map(s=>[s,0])),r=new Map;for(let s of e)for(let a of t.get(s)){if(!n.has(a))continue;let c=n.get(s)+1,d=r.get(a);(c>n.get(a)||c===n.get(a)&&(d===void 0||s.localeCompare(d)<0))&&(n.set(a,c),r.set(a,s))}let i=[...e].sort((s,a)=>n.get(a)-n.get(s)||s.localeCompare(a))[0],o=i===void 0?[]:[i];for(;o[0]!==void 0&&r.has(o[0]);)o.unshift(r.get(o[0]));return{depth:Object.fromEntries(n),path:o}}function Yt(e,t,n){let r=[t],i=t;for(;i!==e;)i=n.get(i),r.push(i);return r.reverse()}function B(e,t={}){let n=t.registry??we(),r=[...e.nodes()],i=Kt(e,n),o=Vt(r,i),s=o.flat(),a=s.length===r.length,c=a?[]:We(r,i).filter(l=>l.length>1||i.get(l[0]).has(l[0])),d=Wt(s,i);return{exact:!0,acyclic:a,order:s,layers:o,frontier:o[0]??[],depth:d.depth,criticalPath:d.path,criticalPathLength:Math.max(0,d.path.length-1),cycles:c,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function Xt(e,t,n){let r=M(e.nodes()),i=n===void 0?void 0:new Set(n.map(s=>e.registry().require(s).kind)),o=e.edges();for(let s of o){let a=e.registry().require(s.kind);i!==void 0&&!i.has(s.kind)&&(a.inverse===void 0||!i.has(a.inverse))||C(r,t==="incoming"?s.target:s.source,t==="incoming"?s.source:s.target)}return{adjacency:r,inspectedEdges:o.length}}function Jt(e,t,n,r,i,o){let s=U(e,t,{...n,after:void 0,direction:"incoming",limit:void 0}),a=U(e,t,{...n,after:void 0,direction:"outgoing",limit:void 0}),c=new Map,d=[...s.affected,...a.affected].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)||p.path.join("\0").localeCompare(m.path.join("\0")));for(let p of d)c.has(p.id)||c.set(p.id,p);let l=[...c.values()].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)),g=r===void 0||r===t?-1:l.findIndex(p=>p.id===r);if(r!==void 0&&r!==t&&g<0)throw new TypeError(`Unknown impact cursor item: ${r}`);let u=l.slice(g+1,g+1+i),f=g+1+u.length<l.length;return{root:t,affected:u,exact:!0,truncated:s.truncated||a.truncated||f,...f?{nextCursor:oe(o,u.at(-1)?.id??t)}:{},cost:{visitedNodes:s.cost.visitedNodes+a.cost.visitedNodes,inspectedEdges:s.cost.inspectedEdges+a.cost.inspectedEdges}}}function Qt(e,t,n){let r=n.direction,i=n.maxDepth??Number.POSITIVE_INFINITY,o=n.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,n,r,i),{adjacency:c,inspectedEdges:d}=Xt(e,r,n.kinds),l={queue:[{id:t,depth:0}],seen:new Set([t]),parents:new Map,affected:[],cursorFound:a===void 0||a===t},g=0,u=!1,f=!1;e:for(let p=0;p<l.queue.length;p+=1){n.signal?.throwIfAborted();let m=l.queue[p];g+=1;let b=[...c.get(m.id)].sort();if(m.depth>=i){b.some(v=>!l.seen.has(v))&&(u=!0);continue}for(let v of b)if(Ut(l,v,m,t,a,o)==="truncate"){u=!0,f=!0;break e}}if(!l.cursorFound)throw new TypeError(`Unknown impact cursor item: ${a}`);return{root:t,affected:l.affected,exact:!0,truncated:u,...f?{nextCursor:oe(s,l.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:g,inspectedEdges:d}}}function U(e,t,n={}){let r=n.direction??"outgoing";if(r!=="both")return Qt(e,t,{...n,direction:r});let i=n.maxDepth??Number.POSITIVE_INFINITY,o=n.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,n,r,i);return Jt(e,t,n,a,o,s)}function Ye(e){let t=[...e.nodes()],n=M(t),r=M(t);for(let c of e.edges())C(n,c.source,c.target),C(n,c.target,c.source),C(r,c.source,c.target);let i=[],o=new Set;for(let c of t){if(o.has(c))continue;let d=[],l=[c];for(o.add(c);l.length>0;){let g=l.pop();d.push(g);for(let u of n.get(g))o.has(u)||(o.add(u),l.push(u))}i.push(d)}let s=t.map(c=>({id:c,degree:n.get(c).size})),a=Math.max(0,...s.map(({degree:c})=>c));return{components:Ve(i),stronglyConnected:We(t,r),orphans:s.filter(({degree:c})=>c===0).map(({id:c})=>c),hubs:s.filter(({degree:c})=>c>0&&c===a),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function Xr(e,t){let n=new Map(e.edges.map(i=>[He(i),i])),r=new Map(t.edges.map(i=>[He(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),removed:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),unchangedCount:[...n.keys()].filter(i=>r.has(i)).length,exact:!0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f60c628a-2e42-5770-a001-39cce5f92595")}catch{}})();var Zt=I.paths,en=I.visited_paths,tn=I.path_depth;function se(e,t){if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new TypeError(`Invalid path ${e} bound: ${String(t)}`)}function z(e,t){return t.hierarchyDirection==="target_parent"?e.target:e.source}function P(e,t){return(t.precedence??"source_before_target")==="target_before_source"?e.target:e.source}function D(e,t){let n=P(e,t);return{predecessor:n,successor:n===e.source?e.target:e.source}}function nn(e,t,n){if(t===void 0)return;let r=e.registry(),i=new Set;for(let o of t){let s=r.require(o),a=s.traversal;if(a==="association")throw new TypeError(`Relationship kind ${s.kind} uses association traversal; use graph impact --direction both`);if(a!==n&&a!=="semantic"){let c=a==="hierarchy"?"graph ancestors or graph descendants":"graph predecessors or graph successors";throw new TypeError(`Relationship kind ${s.kind} uses ${a} traversal; use ${c}`)}i.add(s.kind)}return i}function rn(e,t,n,r,i){let o=e.registry(),s=e.neighborEdges(t,{direction:"both",...n===void 0?{}:{kinds:[...n]}}),a=[],c=new Set;for(let d of s.value){let l=o.require(d.edge.kind);n===void 0&&!l[r]||i(d,l,t)&&(c.has(d.id)||(c.add(d.id),a.push(d.id)))}return{neighbors:a,inspectedEdges:s.meta.inspectedEdges}}function on(e,t,n,r,i,o){if(t>=n)return e.neighbors.some(s=>!o.seen.has(s))&&(o.truncated=!0),!1;for(let s of e.neighbors)if(!o.seen.has(s)){if(o.seen.add(s),o.queue.push({id:s,depth:t+1}),!o.resumed){s===i&&(o.resumed=!0);continue}if(o.value.length>=r)return o.truncated=!0,!0;o.value.push(s)}return!1}function H(e,t,n,r,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let o=nn(e,n.kinds,r),s=n.limit??Number.POSITIVE_INFINITY,a=n.maxDepth??Number.POSITIVE_INFINITY,c=n.after,d={seen:new Set([t]),value:[],queue:[{id:t,depth:0}],resumed:c===void 0,truncated:!1},l=0,g=0;for(let u=0;u<d.queue.length;u+=1){n.signal?.throwIfAborted();let f=d.queue[u];l+=1;let p=rn(e,f.id,o,r,i);if(g+=p.inspectedEdges,on(p,f.depth,a,s,c,d))break}if(!d.resumed)throw new TypeError(`Traversal cursor not found in sequence: ${c}`);return{value:d.value,meta:{visitedNodes:l,inspectedEdges:g,truncated:d.truncated,nextCursor:d.value.at(-1)}}}function Xe(e,t){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`)}function Je(e,t,n,r,i){let o=e.neighborEdges(t.nodes.at(-1),{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});return i.inspectedEdges+=o.meta.inspectedEdges,o.value.filter(s=>!t.nodeSet.has(s.id))}function sn(e,t,n,r,i,o,s){for(let a of Je(e,t,r,i,s)){let c=[...t.nodes,a.id],d=new Set(t.nodeSet).add(a.id),l=[...t.edges,a.edge];if(a.id===n){if(s.value.push({nodes:c,edges:l,length:l.length}),s.value.length>=o)return!0}else s.queue.push({nodes:c,nodeSet:d,edges:l})}return!1}function Qe(e,t,n={}){return H(e,t,n,"hierarchy",(r,i)=>z(r.edge,i)===r.id)}function Ze(e,t,n={}){return H(e,t,n,"hierarchy",(r,i,o)=>z(r.edge,i)===o)}function et(e,t,n={}){return H(e,t,n,"ordering",(r,i)=>P(r.edge,i)===r.id)}function tt(e,t,n={}){return H(e,t,n,"ordering",(r,i,o)=>P(r.edge,i)===o)}function an(e,t,n,r,i,o,s,a){let c={value:[],queue:[{nodes:[t],nodeSet:new Set([t]),edges:[]}],inspectedEdges:0},d=0,l=!1,g=i+1;for(let u=0;u<c.queue.length;u+=1){if(r.signal?.throwIfAborted(),c.value.length>=g||d>=o){l=!0;break}let f=c.queue[u];if(d+=1,f.edges.length>=s){Je(e,f,r,a,c).length>0&&(l=!0);continue}if(sn(e,f,n,r,a,g,c)){l=!0;break}}return{value:c.value.slice(0,i),meta:{visitedNodes:d,inspectedEdges:c.inspectedEdges,truncated:l}}}function nt(e,t,n,r={}){Xe(e,t),Xe(e,n);let i=r.maxPaths??Zt,o=r.maxVisitedPaths??en,s=r.maxDepth??tn;se("maxPaths",i),se("maxVisitedPaths",o),se("maxDepth",s);let a=r.direction??"outgoing";r.signal?.throwIfAborted();for(let c of r.kinds??[])e.registry().require(c);return t===n?i===0?{value:[],meta:{visitedNodes:1,inspectedEdges:0,truncated:!0}}:{value:[{nodes:[t],edges:[],length:0}],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}}:an(e,t,n,r,i,o,s,a)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="789f7451-ceb1-5e5c-b2b6-45eec49580ce")}catch{}})();var cn=16,dn=2,ln=8;function K(e,t){if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`)}function V(e,t,n){let r=e.registry(),i=t===void 0?void 0:new Set(t.map(o=>r.require(o).kind));for(let o of e.edges()){if(o.source===o.target)continue;let s=r.require(o.kind);i!==void 0&&!(i.has(s.kind)||s.inverse!==void 0&&i.has(s.inverse))||n(o,s)}}function un(e,t){let n=new Map;V(e,t,r=>{rt(n,r.source,r.target),rt(n,r.target,r.source)});for(let r of n.values())r.sort();return n}function rt(e,t,n){let r=e.get(t);r===void 0?e.set(t,[n]):r.push(n)}function gn(e,t){let n=new Map;for(let o of e){let s=t.get(o);n.set(s,(n.get(s)??0)+1)}let r,i=0;for(let[o,s]of n)(s>i||s===i&&o<r)&&(r=o,i=s);return r}function fn(e,t){let n=new Map;for(let[i,o]of e){let s=n.get(o);s===void 0?n.set(o,[i]):s.push(i)}let r=[];for(let i of n.values())i.length<t||(i.sort(),r.push({representative:i[0],size:i.length,members:i}));return r.sort((i,o)=>o.size-i.size||i.representative.localeCompare(o.representative))}function it(e,t={}){let n=t.maxIterations??cn,r=t.minSize??dn;K("maxIterations",n),K("minSize",r);let i=un(e,t.kinds),o=e.nodes(),s=new Map(o.map(g=>[g,g])),a=0,c=!1,d=0,l=0;for(;a<n&&!c;){t.signal?.throwIfAborted(),a+=1,c=!0;for(let g of o){d+=1;let u=i.get(g);if(u===void 0)continue;l+=u.length;let f=gn(u,s);f!==s.get(g)&&(s.set(g,f),c=!1)}}return{value:{communities:fn(s,r),iterations:a,converged:c},meta:{visitedNodes:d,inspectedEdges:l,truncated:!c}}}function W(e){return e.direction==="directed"&&(e.ordering||e.hierarchy)}function Y(e){return e.inverse!==void 0&&e.inverse<e.kind?e.inverse:e.kind}function ae(e,t){return(t.hierarchy?z(e,t):e.source===P(e,t)?e.target:e.source)===e.target?{from:e.source,to:e.target}:{from:e.target,to:e.source}}function pn(e,t){if(t===void 0)return;let n=e.registry(),r=new Set;for(let i of t){let o=n.require(i);if(!W(o))throw new TypeError(`Relationship kind ${o.kind} is not a directed ordering or hierarchy kind`);r.add(Y(o))}return r}function hn(e,t){let n=e.registry(),r=new Map;for(let i of e.edges()){let o=n.require(i.kind);if(!W(o))continue;let s=Y(o);if(t!==void 0&&!t.has(s))continue;let a=ae(i,o);if(a.from===a.to)continue;let c=r.get(s);c===void 0&&(c={adjacency:new Map,records:[]},r.set(s,c));let d=c.adjacency.get(a.from);d===void 0?c.adjacency.set(a.from,new Set([a.to])):d.add(a.to),c.records.push({...a,edge:i})}return r}function mn(e){let t=new Map;for(let[n,r]of e.adjacency)t.set(n,[...r].sort());return t}function _n(e,t,n,r){let i=[r];for(let o=n;o!==t;o=e.get(o))i.push(o);return i.push(t),i.reverse()}function yn(e,t,n,r,i,o){for(let s of e.get(n.id)??[])if(o.inspectedEdges+=1,!(n.depth===0&&s===t.to)&&!r.has(s)){if(r.set(s,n.id),s===t.to)return _n(r,t.from,n.id,s);i.push({id:s,depth:n.depth+1})}}function bn(e,t,n,r){let i=new Map([[t.from,t.from]]),o=[{id:t.from,depth:0}];for(let s=0;s<o.length;s+=1){let a=o[s];if(r.visitedNodes+=1,a.depth>=n)continue;let c=yn(e,t,a,i,o,r);if(c!==void 0)return c}}function T(e,t={}){let n=t.maxDepth??ln;K("maxDepth",n),t.limit!==void 0&&K("limit",t.limit);let r=t.limit??Number.POSITIVE_INFINITY,i=pn(e,t.kinds),o=hn(e,i),s=[],a={visitedNodes:0,inspectedEdges:0},c=!1;e:for(let d of[...o.keys()].sort()){let l=o.get(d),g=mn(l);for(let u of l.records){t.signal?.throwIfAborted();let f=bn(g,u,n,a);if(f!==void 0){if(s.length>=r){c=!0;break e}s.push({edge:u.edge,witness:f})}}}return{value:s,meta:{visitedNodes:a.visitedNodes,inspectedEdges:a.inspectedEdges,truncated:c}}}function vn(e,t,n,r,i){let o=new Set,s=[];for(let a of n){if(a.id===e||o.has(a.id))continue;if(!i.seen.has(a.id)){if(t>=r){i.truncated=!0;continue}i.seen.add(a.id),i.queue.push({id:a.id,depth:t+1})}o.add(a.id),s.push(a.id);let c=i.predecessors.get(a.id);c===void 0&&(c=new Set,i.predecessors.set(a.id,c)),c.add(e)}return s}function wn(e,t,n){let r=n.direction??"outgoing",i=n.maxDepth??Number.POSITIVE_INFINITY,o=[],s=new Map,a={seen:new Set([t]),queue:[{id:t,depth:0}],predecessors:new Map,truncated:!1},c=0;for(let d=0;d<a.queue.length;d+=1){n.signal?.throwIfAborted();let{id:l,depth:g}=a.queue[d];o.push(l);let u=e.neighborEdges(l,{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});c+=u.meta.inspectedEdges,s.set(l,vn(l,g,u.value,i,a))}return{order:o,successors:s,predecessors:a.predecessors,inspectedEdges:c,truncated:a.truncated}}function kn(e,t){let n=[],r=new Set([t]),i=[{id:t,index:0}];for(;i.length>0;){let o=i.at(-1),s=e.successors.get(o.id);if(o.index<s.length){let a=s[o.index];o.index+=1,r.has(a)||(r.add(a),i.push({id:a,index:0}))}else n.push(o.id),i.pop()}return n.reverse()}function In(e,t,n,r){let i=e,o=t;for(;i!==o;){for(;r.get(i)>r.get(o);)i=n.get(i);for(;r.get(o)>r.get(i);)o=n.get(o)}return i}function xn(e,t,n){let r;for(let i of[...e].sort())t.has(i)&&(r=r===void 0?i:In(r,i,t,n));return r}function En(e,t,n,r,i){let o=new Map([[t,t]]),s=!0;for(;s;){s=!1;for(let a of n){if(i?.throwIfAborted(),a===t)continue;let c=xn(e.predecessors.get(a),o,r);c!==void 0&&o.get(a)!==c&&(o.set(a,c),s=!0)}}return o}function ot(e,t,n={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(n.maxDepth!==void 0&&(!Number.isInteger(n.maxDepth)||n.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(n.maxDepth)}`);let r=wn(e,t,n),i=kn(r,t),o=new Map(i.map((d,l)=>[d,l])),s=En(r,t,i,o,n.signal),a=new Map(i.map(d=>[d,1]));for(let d=i.length-1;d>=0;d-=1){let l=i[d];if(l===t)continue;let g=s.get(l);a.set(g,a.get(g)+a.get(l))}let c=i.filter(d=>d!==t).map(d=>({id:d,idom:s.get(d),dominatedCount:a.get(d)-1})).sort((d,l)=>l.dominatedCount-d.dominatedCount||d.id.localeCompare(l.id));return{value:{root:t,reachableCount:r.order.length,rows:c},meta:{visitedNodes:r.order.length,inspectedEdges:r.inspectedEdges,truncated:r.truncated}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3cef3a97-fda4-5811-9e69-04ff722e40a1")}catch{}})();function st(e){return Math.round(e*1e6)/1e6}function at(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function ct(e,t){let n=new Map(e.nodes().map(i=>[i,new Set]));V(e,t,i=>{n.get(i.source).add(i.target),n.get(i.target).add(i.source)});let r=new Map;for(let[i,o]of n)r.set(i,[...o].sort());return r}function Sn(e,t){let n=new Map,r=new Map;return V(e,t,(i,o)=>{if(!o.ordering)return;let{predecessor:s,successor:a}=D(i,o);at(r,s,a),at(n,a,s)}),{incoming:n,outgoing:r}}function Cn(e,t,n){let r=new Map([[e,0]]),i=new Map([[e,1]]),o=new Map,s=[],a=[e],c=0,d=0;for(let l=0;l<a.length;l+=1){let g=a[l];n.visitedNodes+=1,s.push(g);let u=r.get(g);g!==e&&(c+=1,d+=u);for(let f of t.get(g))if(n.inspectedEdges+=1,r.has(f)||(r.set(f,u+1),a.push(f)),r.get(f)===u+1){i.set(f,(i.get(f)??0)+i.get(g));let p=o.get(f);p===void 0?o.set(f,[g]):p.push(g)}}return{stack:s,sigma:i,predecessors:o,reachableCount:c,distanceSum:d}}function Dn(e,t,n){let r=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let o=e.stack[i],s=(1+(r.get(o)??0))/e.sigma.get(o);for(let a of e.predecessors.get(o)??[])r.set(a,(r.get(a)??0)+e.sigma.get(a)*s);o!==t&&n.set(o,(n.get(o)??0)+(r.get(o)??0))}}function Tn(e,t){return t<=1||e.reachableCount===0?0:e.reachableCount/(t-1)*(e.reachableCount/e.distanceSum)}function Nn(e,t,n,r,i){return{id:e,degree:t.get(e).length,inDegree:n.incoming.get(e)?.size??0,outDegree:n.outgoing.get(e)?.size??0,betweenness:st((r.get(e)??0)/2),closeness:st(i.get(e))}}function dt(e,t={}){let n=ct(e,t.kinds),r=Sn(e,t.kinds),i=e.nodes(),o=new Map,s=new Map,a={visitedNodes:0,inspectedEdges:0};for(let l of i){t.signal?.throwIfAborted();let g=Cn(l,n,a);s.set(l,Tn(g,i.length)),Dn(g,l,o)}let c=0;for(let l of n.values())c+=l.length;let d=i.map(l=>Nn(l,n,r,o,s)).sort((l,g)=>g.betweenness-l.betweenness||g.degree-l.degree||l.id.localeCompare(g.id));return{value:{nodeCount:i.length,edgeCount:c/2,rows:d},meta:{visitedNodes:a.visitedNodes,inspectedEdges:a.inspectedEdges,truncated:!1}}}function An(e,t){return e<=t?{source:e,target:t}:{source:t,target:e}}function Rn(e,t,n){let r=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,n.inspectedEdges+=1,r!==e.parent){if(n.discovery.has(r)){n.low.set(e.node,Math.min(n.low.get(e.node),n.discovery.get(r)));return}return e.children+=1,n.discovery.set(r,n.timer),n.low.set(r,n.timer),n.timer+=1,{node:r,parent:e.node,neighborIndex:0,children:0}}}function On(e,t,n){if(e.parent===null){e.children>1&&n.articulation.add(e.node);return}let r=e.parent,i=n.low.get(e.node);n.low.set(r,Math.min(n.low.get(r),i)),r!==t&&i>=n.discovery.get(r)&&n.articulation.add(r),i>n.discovery.get(r)&&n.bridges.push(An(r,e.node))}function jn(e,t,n,r){n.discovery.set(e,n.timer),n.low.set(e,n.timer),n.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){r?.throwIfAborted();let o=i.at(-1);if(o.neighborIndex<t.get(o.node).length){let s=Rn(o,t,n);s!==void 0&&i.push(s)}else On(o,e,n),i.pop()}}function X(e,t={}){let n=ct(e,t.kinds),r={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())r.discovery.has(i)||jn(i,n,r,t.signal);return{value:{articulationPoints:[...r.articulation].sort(),bridges:r.bridges.sort((i,o)=>i.source.localeCompare(o.source)||i.target.localeCompare(o.target))},meta:{visitedNodes:r.discovery.size,inspectedEdges:r.inspectedEdges,truncated:!1}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="32f3ce0d-64ac-5ad4-b27a-2a279718de22")}catch{}})();function Mn(e){let t=e.registry(),n=new Map,r=new Set;for(let i of e.edges()){let o=t.require(i.kind);if(!o.ordering)continue;let{predecessor:s,successor:a}=D(i,o);if(r.add(s),r.add(a),s===a)continue;let c=n.get(s);c===void 0?n.set(s,new Set([a])):c.add(a)}return{forward:n,participants:r}}function Pn(e,t,n,r){if(e===void 0)return r;let i=r;for(let o of e)t.has(o)&&(i=Math.min(i,n.get(o)));return i}function Ln(e,t,n){let r=n-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:n,latestFinish:n+1,slack:r,critical:r===0}}function Fn(e,t,n,r,i){let o=new Map;for(let s=e.length-1;s>=0;s-=1){let a=e[s],c=Pn(t.forward.get(a),r,o,i);o.set(a,c-1)}return e.map(s=>Ln(s,n[s],o.get(s))).sort((s,a)=>s.slack-a.slack||s.earliestStart-a.earliestStart||s.id.localeCompare(a.id))}function lt(e,t={}){t.signal?.throwIfAborted();let n=B(e,{registry:e.registry()}),r=Mn(e),i=new Set(n.order),o=n.order.filter(d=>r.participants.has(d)),s=o.reduce((d,l)=>Math.max(d,n.depth[l]+1),0),a=Fn(o,r,n.depth,i,s),c=a.length>0;return{exact:!0,acyclic:n.acyclic,makespan:s,scheduledCount:a.length,criticalPath:c?n.criticalPath:[],criticalPathLength:c?n.criticalPathLength:0,cycles:n.cycles,rows:a,provenance:{algorithm:"critical-path-method",edgeFamily:"ordering",weighting:"unit"}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fa17672a-97a2-5f94-bdfe-9df970cc038b")}catch{}})();function Gn(e,t,n){for(let r=e.length-1;r>=0;r-=1){n?.throwIfAborted();let i=t.get(e[r]);for(let o of i.successors){n?.throwIfAborted();let s=t.get(o);if(s.latest===void 0||s.duration===void 0)continue;let a=s.latest-s.duration;(i.latest===void 0||a<i.latest)&&(i.latest=a,i.anchor=s.anchor)}}}function $n(e,t,n,r){let i=[],o=e;for(;o!==void 0&&i.length<n;)r?.throwIfAborted(),i.push(o),o=t.get(o).predecessor;return i.reverse(),{path:i,path_truncated:o!==void 0}}function qn(e,t,n,r,i){let o=new Map(t.map(a=>[a.id,a])),s=new Map;for(let a of e){i?.throwIfAborted();let c=o.get(a),d=c?.estimated_minutes,l=typeof d=="number"&&Number.isFinite(d)&&d>=0?d:void 0,g={item:c,duration:l,pending:0,successors:new Set,earliest:0};if(c?.deadline!==void 0){let u=Date.parse(c.deadline);Number.isFinite(u)?(g.deadline=(u-n)/6e4,g.latest=g.deadline,g.anchor=a):r(a,"invalid_deadline")}s.set(a,g)}return s}function Un(e,t,n){for(let r of e.edges()){n?.throwIfAborted();let i=e.registry().require(r.kind);if(!i.ordering)continue;let{predecessor:o,successor:s}=D(r,i),a=t.get(o);a.successors.has(s)||(a.successors.add(s),t.get(s).pending+=1)}}function Bn(e,t,n){let r=e.filter(i=>t.get(i).pending===0);for(let i=0;i<r.length;i+=1){n?.throwIfAborted();let o=r[i],s=t.get(o),a=s.earliest===null||s.duration===void 0?null:s.earliest+s.duration;for(let c of s.successors){n?.throwIfAborted();let d=t.get(c);a===null?d.earliest=null:d.earliest!==null&&(a>d.earliest||a===d.earliest&&(d.predecessor===void 0||o<d.predecessor))&&(d.earliest=a,d.predecessor=o),d.pending-=1,d.pending===0&&r.push(c)}}return r}function zn(e,t,n,r,i,o,s,a){let c=t.duration;if(t.latest!==void 0){r.scheduled_count+=1;let d=t.latest-c;r.rows.length<o?r.rows.push({id:e,deadline_id:t.anchor,latest_start:new Date(i+d*6e4).toISOString(),slack_minutes:t.earliest===null?null:d-t.earliest}):r.truncated=!0}if(t.deadline!==void 0&&t.earliest!==null&&t.earliest+c>t.deadline)if(r.overcommitted_count+=1,r.overcommitted.length<o){let d=$n(e,n,Math.min(o,s.remaining),a);s.remaining-=d.path.length,d.path_truncated&&(r.truncated=!0),r.overcommitted.push({deadline_id:e,deadline:t.item.deadline,shortfall_minutes:t.earliest+c-t.deadline,...d})}else r.truncated=!0}function Hn(e,t,n,r,i,o,s,a){let c={remaining:o};for(let d of e){a?.throwIfAborted();let l=t.get(d);if(l.pending>0){s(d,"cycle_or_gated_by_cycle");continue}if(l.duration===void 0){s(d,"unknown_estimate");continue}if(l.latest!==void 0&&!Number.isFinite(new Date(r+(l.latest-l.duration)*6e4).getTime())){s(d,"date_range_exceeded");continue}l.earliest===null&&s(d,"unknown_predecessor_estimate"),zn(d,l,t,n,r,i,c,a)}}function ut(e,t,n={}){n.signal?.throwIfAborted();let r=Date.parse(n.now??new Date().toISOString());if(!Number.isFinite(r))throw new TypeError("Invalid scheduling clock");let i=n.maxWork??1e5,o=n.limit??10;for(let[u,f]of[["maxWork",i],["limit",o]])if(!Number.isSafeInteger(f)||f<1)throw new TypeError(`Invalid scheduling ${u}`);let s={as_of:new Date(r).toISOString(),basis:"derived_elapsed_minutes",complete:!0,truncated:!1,work_limit_exceeded:!1,scheduled_count:0,residual_count:0,overcommitted_count:0,rows:[],residuals:[],overcommitted:[]},a=e.nodes(),c=e.edges();if(a.length+c.length+t.length>i)return{...s,complete:!1,work_limit_exceeded:!0};let d=(u,f)=>{s.complete=!1,s.residual_count+=1,s.residuals.length<o?s.residuals.push({id:u,reason:f}):s.truncated=!0},l=qn(a,t,r,d,n.signal);Un(e,l,n.signal);let g=Bn(a,l,n.signal);return Gn(g,l,n.signal),Hn(a,l,s,r,o,i,d,n.signal),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ccb7d865-8baa-5379-a810-7be494eadcb1")}catch{}})();function N(){return{nodes:0,isolated:0,degree_leq_one:0,semantic_nodes:0,without_semantic_edges:0,degree_histogram:{}}}function pt(e,t,n,r){let i={all:N(),active:N(),terminal:N()},o=new Map;for(let s of e.details){if(r?.throwIfAborted(),e.missingIdSet.has(s.id.toLowerCase())||s.status==="external")continue;let a=o.get(s.status)??N();o.set(s.status,a);let c=e.graph.incidentEdges(s.id),d=c.some(l=>n(l.kind));for(let l of[i.all,i[t(s.status)?"terminal":"active"],a]){l.nodes+=1,l.isolated+=+(c.length===0),c.length<=1&&(l.degree_leq_one+=1),d?l.semantic_nodes+=1:l.without_semantic_edges+=1;let g=String(c.length);l.degree_histogram[g]=(l.degree_histogram[g]??0)+1}}return{coverage_by_lifecycle:i,coverage_by_status:Object.fromEntries([...o].sort(([s],[a])=>s.localeCompare(a)))}}function gt(e){if(!J(e))return!1;let t=e;if(!["nodes","isolated","degree_leq_one","semantic_nodes","without_semantic_edges"].every(r=>Number.isSafeInteger(t[r])&&Number(t[r])>=0)||!J(t.degree_histogram))return!1;let n=Object.entries(t.degree_histogram);return n.every(([r,i])=>/^(0|[1-9]\d*)$/.test(r)&&Number.isSafeInteger(i)&&Number(i)>=0)&&n.reduce((r,[,i])=>r+Number(i),0)===t.nodes&&Number(t.isolated)<=Number(t.degree_leq_one)&&Number(t.degree_leq_one)<=Number(t.nodes)&&Number(t.semantic_nodes)+Number(t.without_semantic_edges)===t.nodes}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ht(e){for(let r of["ordering_acyclic","active_ordering_acyclic"])if(e[r]!==void 0&&typeof e[r]!="boolean")return!1;let t=e.coverage_by_lifecycle,n=e.coverage_by_status;return t===void 0&&n===void 0?!0:!J(t)||!J(n)?!1:["all","active","terminal"].every(r=>gt(t[r]))&&Object.values(n).every(gt)}function ft(e,t){return Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].sort().map(n=>{let r=Object.hasOwn(e,n)?e[n]:N(),i=Object.hasOwn(t,n)?t[n]:N(),o=Object.fromEntries([...new Set([...Object.keys(r.degree_histogram),...Object.keys(i.degree_histogram)])].sort().map(s=>[s,(i.degree_histogram[s]??0)-(r.degree_histogram[s]??0)]));return[n,{nodes:i.nodes-r.nodes,isolated:i.isolated-r.isolated,degree_leq_one:i.degree_leq_one-r.degree_leq_one,semantic_nodes:i.semantic_nodes-r.semantic_nodes,without_semantic_edges:i.without_semantic_edges-r.without_semantic_edges,degree_histogram:o}]}))}function mt(e,t){return!e.coverage_by_lifecycle||!t.coverage_by_lifecycle||!e.coverage_by_status||!t.coverage_by_status?{lifecycle_comparable:!1}:{lifecycle_comparable:!0,coverage_by_lifecycle:ft(e.coverage_by_lifecycle,t.coverage_by_lifecycle),coverage_by_status:ft(e.coverage_by_status,t.coverage_by_status)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="896e1553-b127-532f-ac39-e0d47f29eebc")}catch{}})();var A=["missing_reference_active","missing_reference_terminal","legacy_no_blocker_sentinel","ordering_cycle","legacy_ordering_cycle","ordering_storage_contradiction","legacy_ordering_storage_contradiction","hierarchy_cycle","legacy_hierarchy_cycle","hierarchy_cardinality_violation","legacy_hierarchy_cardinality_violation","hierarchy_direction_violation","legacy_hierarchy_direction_violation","duplicate_edge","legacy_duplicate_edge","duplicate_dependency_row","legacy_duplicate_dependency_row","stale_lifecycle_block","isolated_active_node","sparse_active_node"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34b2e83e-f6a1-57e7-84ee-4ad83acb2e19")}catch{}})();var Kn=25,Vn="milestone",Wn="outcome milestone:",Yn=new Set(["discovered_from","incident_from","recurs_from","supersedes","verifies"]);function Q(e){return Yn.has(e)}var _t={error:0,warning:1,info:2};function yt(e){return new Set((e??[]).filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()))}function R(e,t,n,r,i,o,s,a){let c=[...i].sort((d,l)=>d.localeCompare(l));return{code:e,severity:t,policy:n,message:r(c.length),count:c.length,sample:c.slice(0,o),sample_truncated:c.length>o,remediation:s,...a===void 0?{}:{evidence:[...a].sort((d,l)=>d.localeCompare(l)).slice(0,o)}}}function Xn(e,t){return e.cycles.map(n=>R(n.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",n.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",r=>`${r} items participate in one hierarchy cycle.`,n.item_ids,t,n.legacy_terminal?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove or retype one exact hierarchy relation before continuing mutation."))}function bt(e,t,n){let r=e.cardinality_violations.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[R(n?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",n?"info":"error","Every structural child must resolve to at most one logical parent across all hierarchy spellings.",i=>`${i} child item${i===1?"":"s"} resolve to multiple hierarchy parents.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",r.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function vt(e,t,n){let r=e.divergences.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[R(n?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",n?"info":"error","Scalar parent metadata and dependency-backed hierarchy rows must resolve to the same logical parent.",i=>`${i} child item${i===1?"":"s"} have divergent hierarchy storage surfaces.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",r.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function Jn(e,t){let n=G(e);return n?[...Xn(n,t),...bt(n,t,!1),...bt(n,t,!0),...vt(n,t,!1),...vt(n,t,!0)]:[]}function Qn(e){let t=e.graph.registry(),n=new Map;for(let r of e.graph.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let[o,s]=(i.precedence??"source_before_target")==="target_before_source"?[r.target,r.source]:[r.source,r.target],a=n.get(o);a?a.push(s):n.set(o,[s])}for(let r of n.values())r.sort((i,o)=>i.localeCompare(o));return n}function kt(e,t){t.indexes.set(e,t.nextIndex),t.lowLinks.set(e,t.nextIndex),t.nextIndex+=1,t.stack.push(e),t.onStack.add(e)}function Zn(e,t,n,r){let i=n.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let o=i[e.neighborIndex];return e.neighborIndex+=1,r.indexes.has(o)?r.onStack.has(o)&&r.lowLinks.set(e.node,Math.min(r.lowLinks.get(e.node),r.indexes.get(o))):(kt(o,r),t.push({node:o,neighborIndex:0})),!0}function er(e,t,n,r){t.pop();let i=t.at(-1);if(i&&r.lowLinks.set(i.node,Math.min(r.lowLinks.get(i.node),r.lowLinks.get(e.node))),r.lowLinks.get(e.node)!==r.indexes.get(e.node))return;let o=[];for(;;){let s=r.stack.pop();if(r.onStack.delete(s),o.push(s),s===e.node)break}(o.length>1||o.length===1&&n.get(o[0])?.includes(o[0]))&&r.components.push(o.sort((s,a)=>s.localeCompare(a)))}function tr(e){let t={indexes:new Map,lowLinks:new Map,onStack:new Set,stack:[],components:[],nextIndex:0},n=[...e.keys()].sort((r,i)=>r.localeCompare(i));for(let r of n){if(t.indexes.has(r))continue;let i=[{node:r,neighborIndex:0}];for(kt(r,t);i.length>0;){let o=i.at(-1);Zn(o,i,e,t)||er(o,i,e,t)}}return t.components.sort((r,i)=>r[0].localeCompare(i[0]))}function ce(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function y(e,t,n,r,i,o,s,a){t.length!==0&&e.push(R(r,i,o,s,t,n,a))}function nr(e,t,n){let r=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(o=>!o.no_active_blocker_sentinel);return y(r,i.filter(o=>!t(o.holder_status)).map(ce),n,"missing_reference_active","error","Active items must not reference absent targets; missing prerequisites distort scheduling.",o=>`${o} active dangling reference(s) to absent items`,"Restore or re-create the referenced item, or remove/retype the reference on the holder."),y(r,i.filter(o=>t(o.holder_status)).map(ce),n,"missing_reference_terminal","info","Terminal items may retain historical references, but absent targets remain unexplainable context.",o=>`${o} terminal dangling reference(s) to absent items`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),y(r,e.dangling.no_active_blocker_sentinels.map(ce),n,"legacy_no_blocker_sentinel","info","The pre-structured-dependency no-active-blocker sentinel is retired; real edges carry blocker state.",o=>`${o} legacy no-active-blocker sentinel reference(s)`,"Delete the sentinel reference; blocker state is derived from blocked_by edges."),r}function le(e,t){let n=t.get(e);return n?!n.terminal:!0}function It(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function rr(e,t){let n=[],r=[];for(let o of e.orderingContradictions??[])(o.legacy_terminal?r:n).push(It(o));let i=[];return y(i,n,t,"ordering_storage_contradiction","error","A scalar blocker and same-target structured ordering row must not assert opposite precedence.",o=>`${o} active scalar-versus-structured ordering contradiction(s)`,"Remove the structured dependency row that points the holder before its scalar blocker, or replace both representations with one unambiguous ordering edge."),y(i,r,t,"legacy_ordering_storage_contradiction","info","Terminal scalar-versus-structured ordering contradictions are exact historical storage defects with no live scheduling effect.",o=>`${o} terminal scalar-versus-structured ordering contradiction(s)`,"Remove the contradictory blocks dependency row in a dedicated changelog-safe closed-item batch; preserve the scalar blocker as the historical precedence record."),i}function ir(e,t,n,r){let i=[],o=Qn(e);for(let c of tr(o)){let d=c.some(u=>le(u,t)),l=new Set(c.map(u=>u.toLowerCase())),g=(e.orderingContradictions??[]).filter(u=>l.has(u.holder_id.toLowerCase())&&l.has(u.target_id.toLowerCase())).map(It);i.push(d?R("ordering_cycle","error","Order-bearing relationship kinds must stay acyclic; a cycle makes every member unschedulable.",u=>`execution-order cycle across ${u} item(s)`,c,r,"Remove or retype one ordering edge inside the cycle, or split the work so precedence is linear.",g.length===0?void 0:g):R("legacy_ordering_cycle","info","Ordering cycles between exclusively terminal items are historical contradictions with no scheduling effect.",u=>`terminal-only execution-order cycle across ${u} item(s)`,c,r,"Leave as history debt, or clean up in a dedicated changelog-safe closed-item batch; never repair closed items ad hoc.",g.length===0?void 0:g))}let s=new Map;for(let[c,d]of o)for(let l of d){let g=s.get(l);g?g.push(c):s.set(l,[c])}let a=[...t.values()].filter(c=>!c.missing&&!c.terminal&&n(c.status)&&!(s.get(c.id)??[]).some(d=>{let l=t.get(d);return l===void 0||!l.terminal})).map(c=>c.id);return y(i,a,r,"stale_lifecycle_block","warning","A blocked lifecycle status must be backed by at least one open ordering predecessor.",c=>`${c} status-blocked item(s) with no open blocker edge`,'Add a local blocker edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status.'),i}function Z(e){let t=e.edges.map(n=>n.kind).sort((n,r)=>n.localeCompare(r));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function ue(e){let t=e.graph.registry(),n=new Map;for(let i of e.graph.edges()){let o=t.require(i.kind);if(!W(o))continue;let s=ae(i,o);if(s.from===s.to)continue;let a=`${Y(o)}::${s.from}::${s.to}`,c=n.get(a);c?c.edges.push(i):n.set(a,{...s,edges:[i]})}let r=[...n.values()].filter(i=>i.edges.length>=2);for(let i of r)i.edges.sort((o,s)=>o.kind.localeCompare(s.kind));return r.sort((i,o)=>i.from.localeCompare(o.from)||i.to.localeCompare(o.to))}function or(e,t,n){let r=[],i=[];for(let s of ue(e))(le(s.from,t)||le(s.to,t)?r:i).push(Z(s));let o=[];return y(o,r,n,"duplicate_edge","info","One semantic relationship should be stored once; parallel same-family spellings (reciprocal inverse pairs included) add no information and skew degree metrics.",s=>`${s} duplicated relationship(s) between active endpoints`,"Remove all but one stored spelling of the relationship; keep the canonical direction the holder declared first."),y(o,i,n,"legacy_duplicate_edge","info","Duplicated spellings between exclusively terminal items are historical noise with no scheduling effect.",s=>`${s} duplicated relationship(s) between terminal endpoints`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),o}function sr(e,t){let n=[],r=[];for(let o of e.duplicateRows??[])(o.legacy_terminal?r:n).push(`${o.holder_id} -> ${o.target_id} (${o.kind} x${o.occurrences})`);let i=[];return y(i,n,t,"duplicate_dependency_row","warning","One dependency row must be stored once per holder; identical repeated rows are a storage-layer defect invisible to the assembled graph.",o=>`${o} exactly duplicated stored dependency row(s) on active holder(s)`,"Remove the repeated rows so the dependency is stored exactly once; graph semantics are unchanged."),y(i,r,t,"legacy_duplicate_dependency_row","info","Identical repeated dependency rows on terminal holders are historical storage noise with no scheduling effect.",o=>`${o} exactly duplicated stored dependency row(s) on terminal holder(s)`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),i}function ar(e,t){let n=new Map,r={source_to_target:[],target_to_source:[],both:[]};for(let s of e.graph.registry().list())s.outcomeTraversal!==void 0&&r[s.outcomeTraversal].push(s.kind);let i={source_to_target:r.source_to_target.join(","),target_to_source:r.target_to_source.join(","),both:r.both.join(",")},o=(s,a)=>{let c=n.get(a)??new Set;c.add(s),n.set(a,c)};for(let s of e.graph.edges()){t?.throwIfAborted();let a=e.graph.registry().require(s.kind);(a.outcomeTraversal==="source_to_target"||a.outcomeTraversal==="both")&&o(s.source,s.target),(a.outcomeTraversal==="target_to_source"||a.outcomeTraversal==="both")&&o(s.target,s.source)}return{basis:i,reverse:n}}function cr(e,t,n){let r=new Set(e),i=[...e].sort();for(let o=0;o<i.length;o+=1){n?.throwIfAborted();for(let s of[...t.get(i[o])??[]].sort())r.has(s)||(r.add(s),i.push(s))}return r}function dr(e,t,n,r){let i=0,o=0,s=0,a=0;for(let f of e.values())if(r?.throwIfAborted(),!t.has(f.id)&&!(f.missing||f.status==="external")){if(f.terminal){s+=1,n.has(f.id)&&(a+=1);continue}n.has(f.id)?i+=1:o+=1}let c=i+o,d=s-a,l=i+a,g=o+d,u=l+g;return{active_outcome_reachable_nodes:i,active_outcome_unreachable_nodes:o,active_outcome_reachability_basis_points:c===0?0:Math.floor(i*1e4/c),terminal_nodes:s,terminal_outcome_reachable_nodes:a,terminal_outcome_unreachable_nodes:d,terminal_outcome_reachability_basis_points:s===0?0:Math.floor(a*1e4/s),outcome_reachable_nodes:l,outcome_unreachable_nodes:g,outcome_reachability_basis_points:u===0?0:Math.floor(l*1e4/u)}}function lr(e,t,n){let r=new Set(e.details.filter(a=>a.type?.toLowerCase()===Vn&&a.title.trim().toLowerCase().startsWith(Wn)).map(a=>a.id)),{basis:i,reverse:o}=ar(e,n),s=cr(r,o,n);return{outcome_nodes:r.size,outcome_reachability_basis:i,...dr(t,r,s,n)}}function ur(e,t,n,r,i){e.active+=1;let o=t.type??"(untyped)",s=e.byType.get(o);s||(s={active:0,isolated:0,degree_leq_one:0},e.byType.set(o,s)),s.active+=1,!(n>1)&&(e.degreeLeqOne+=1,s.degree_leq_one+=1,n===0&&(e.isolated+=1,s.isolated+=1),!(r.has(t.id.toLowerCase())||i.has(o.toLowerCase()))&&(n===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function gr(e,t,n,r,i,o,s){let a={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let h of e.graph.nodes()){s?.throwIfAborted();let _=t.get(h);if(_){if(_.missing){a.missing+=1;continue}_.terminal||ur(a,_,e.graph.incidentEdges(h).length,n,r)}}let{isolates:c,sparse:d}=a,l=[];y(l,c,i,"isolated_active_node","warning","Active work should be reachable from the graph unless explicitly declared a valid isolate.",h=>`${h} active item(s) with no relationships`,"Link the item to its parent, prerequisite, or origin \u2014 or register it as an exempt isolate."),y(l,d,i,"sparse_active_node","info","Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.",h=>`${h} active item(s) with exactly one relationship`,"Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");let g=e.graph.edges().length,u=T(e.graph,{signal:s}).value,f=new Set(u.map(({edge:h})=>`${h.source.toLowerCase()}\0${h.target.toLowerCase()}\0${h.kind}`));for(let h of e.orderingContradictions??[])f.add(`${h.holder_id.toLowerCase()}\0${h.target_id.toLowerCase()}\0${h.dependency_kind}`);let p=Object.fromEntries(Object.entries(o).sort(([h],[_])=>h.localeCompare(_))),m=Object.entries(p).reduce((h,[_,E])=>h+(Q(_)?E:0),0),b=X(e.graph,{signal:s}).value,v=lr(e,t,s);return{findings:l,profile:{nodes:e.graph.nodes().length,recorded_nodes:e.details.filter(h=>h.status!=="missing"&&h.status!=="external").length,edges:g,informative_edges:g-f.size,redundant_edges:u.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:p,edge_share_by_kind:Object.fromEntries(Object.entries(p).map(([h,_])=>[h,_/g])),semantic_edges:m,semantic_edge_share:g===0?0:m/g,active_nodes:a.active,missing_nodes:a.missing,isolated_active_nodes:a.isolated,degree_leq_one_active_nodes:a.degreeLeqOne,coverage_by_type:Object.fromEntries([...a.byType.entries()].sort(([h],[_])=>h<_?-1:1)),articulation_points:b.articulationPoints.length,bridge_edges:b.bridges.length,...v,finding_subjects_by_code:Object.fromEntries(A.map(h=>[h,0]))}}}function ee(e,t={}){let n=t.isTerminal??(u=>u==="closed"||u==="canceled"),r=t.isBlocked??(u=>u==="blocked"),i=t.maxSampleSize??Kn;if(!Number.isInteger(i)||i<1)throw new TypeError(`Invalid audit sample bound: ${String(t.maxSampleSize)}`);let o=yt(t.exemptIsolates),s=yt(t.isolateExemptTypes),a=new Map(e.details.map(u=>[u.id,{id:u.id,status:u.status,missing:e.missingIdSet.has(u.id.toLowerCase()),terminal:n(u.status),...u.type===void 0?{}:{type:u.type}}]));t.signal?.throwIfAborted();let c={};for(let u of e.graph.edges())c[u.kind]=(c[u.kind]??0)+1;let d=nr(e,n,i);d.push(...Jn(e,i)),t.signal?.throwIfAborted(),d.push(...rr(e,i)),t.signal?.throwIfAborted(),d.push(...ir(e,a,r,i)),t.signal?.throwIfAborted(),d.push(...or(e,a,i),...sr(e,i)),t.signal?.throwIfAborted();let l=gr(e,a,o,s,i,c,t.signal);d.push(...l.findings),d.sort((u,f)=>_t[u.severity]-_t[f.severity]||u.code.localeCompare(f.code)||u.sample[0].localeCompare(f.sample[0]));let g=l.profile.finding_subjects_by_code;for(let u of d)g[u.code]+=u.count;return{findings:d,profile:{...l.profile,...pt(e,n,Q,t.signal),ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"||u.code==="legacy_ordering_cycle"),active_ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"),finding_subjects_by_code:g}}}function de(e,t){let n=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),r={};for(let i of n){let o=(t[i]??0)-(e[i]??0);o!==0&&(r[i]=o)}return r}function wt(e){return e.profile.coverage_by_type??{}}function fr(e,t){let n={},r=wt(e),i=wt(t),o=[...new Set([...Object.keys(r),...Object.keys(i)])].sort();for(let s of o){let a=Object.assign({active:0,isolated:0,degree_leq_one:0},r[s]),c=Object.assign({active:0,isolated:0,degree_leq_one:0},i[s]),d={active:c.active-a.active,isolated:c.isolated-a.isolated,degree_leq_one:c.degree_leq_one-a.degree_leq_one};Object.values(d).some(l=>l!==0)&&(n[s]=d)}return n}function xt(e,t){let n=fr(e,t),{edge_share_by_kind:r={},semantic_edges:i=0,semantic_edge_share:o=0}=e.profile,{edge_share_by_kind:s={},semantic_edges:a=0,semantic_edge_share:c=0}=t.profile,d=e.profile.recorded_nodes??e.profile.nodes,l=t.profile.recorded_nodes??t.profile.nodes,g=e.profile.informative_edges??e.profile.edges,u=t.profile.informative_edges??t.profile.edges,f=e.profile.redundant_edges??0,p=t.profile.redundant_edges??0,m=e.profile.ordering_contradiction_edges??0,b=t.profile.ordering_contradiction_edges??0;return{baseline_saved_at:e.saved_at,same_snapshot:e.fingerprint===t.fingerprint,affected_subjects_by_code:de(e.affected_subjects_by_code,t.affected_subjects_by_code),profile:{nodes:t.profile.nodes-e.profile.nodes,recorded_nodes:l-d,edges:t.profile.edges-e.profile.edges,informative_edges:u-g,redundant_edges:p-f,ordering_contradiction_edges:b-m,active_nodes:t.profile.active_nodes-e.profile.active_nodes,missing_nodes:t.profile.missing_nodes-e.profile.missing_nodes,isolated_active_nodes:t.profile.isolated_active_nodes-e.profile.isolated_active_nodes,degree_leq_one_active_nodes:t.profile.degree_leq_one_active_nodes-e.profile.degree_leq_one_active_nodes,edges_by_kind:de(e.profile.edges_by_kind,t.profile.edges_by_kind),edge_share_by_kind:de(r,s),semantic_edges:a-i,semantic_edge_share:c-o,coverage_by_type:n,...mt(e.profile,t.profile)}}}import Et from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e5089f2d-3fc5-5843-95ab-ba3dd2ab9582")}catch{}})();var St=2,ge=500,pr=64,hr="graph-durable-cache";function Ct(e){return Re(e,hr,30,`graph-cache:${process.pid}`,!1,!1,3e3)}function F(e){return Et.join(e,"runtime","graph-cache.json")}function Dt(e){return Et.join(e,"runtime","graph-audit-baseline.json")}function fe(e){if(e!==null)try{let t=JSON.parse(e);return typeof t!="object"||t===null||t.version!==St||typeof t.fingerprint!="string"||typeof t.saved_at!="string"||typeof t.results!="object"||t.results===null||Array.isArray(t.results)?void 0:t}catch{return}}async function pe(e,t){let n=await j(F(e)),r=fe(n),i=r?.fingerprint===t;return{exists:n!==null,fresh:i,results:i?r.results:{}}}async function he(e,t,n,r,i){let o=await Ct(e);try{let s=fe(await j(F(e))),a=s?.fingerprint===t?s.results:{};delete a[r],a[r]=i;let c=Object.keys(a);for(let d of c.slice(0,Math.max(0,c.length-pr)))delete a[d];await re(F(e),JSON.stringify({version:St,fingerprint:t,saved_at:new Date().toISOString(),results:a})),n.results=a}finally{await o()}}async function me(e){let t=await Ct(e);try{await Ie(F(e))}finally{await t()}}async function Tt(e,t){let n=F(e),r=await j(n),i=fe(r);return i===void 0?{exists:r!==null,fresh:!1,entry_count:0}:{exists:!0,fresh:i.fingerprint===t,entry_count:Object.keys(i.results).length,fingerprint:i.fingerprint.slice(0,12),saved_at:i.saved_at,bytes:Buffer.byteLength(r,"utf8")}}function _e(e,t){return t||e>=ge}function te(e){return O(e)&&Object.values(e).every(x)}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function x(e){return Number.isInteger(e)&&Number(e)>=0}function Nt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function L(e,t){return e===void 0||t(e)}function mr(e){return O(e)&&Object.values(e).every(Nt)}function _r(e){return O(e)?Object.values(e).every(t=>O(t)&&[t.active,t.isolated,t.degree_leq_one].every(x)):!1}function yr(e,t,n){let r=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=r.filter(s=>e[s]!==void 0).length;if(i!==0&&i!==r.length||!r.every(s=>L(e[s],x)))return;let o={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??n,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return o.recorded_nodes<=t&&o.informative_edges<=n&&o.redundant_edges<=n&&o.ordering_contradiction_edges<=n?o:void 0}function br(e,t,n){let r=[...t,...n,"finding_subjects_by_code"],i=r.filter(o=>e[o]!==void 0).length;return i!==0&&i!==r.length?!1:t.every(o=>L(e[o],x))&&n.every(o=>L(e[o],x)&&(e[o]===void 0||Number(e[o])<=1e4))&&L(e.finding_subjects_by_code,te)}function vr(e,t,n,r){let i=yr(e,n,r);if(i===void 0)return;let o=["articulation_points","bridge_edges","outcome_nodes","active_outcome_reachable_nodes","active_outcome_unreachable_nodes","terminal_nodes","terminal_outcome_reachable_nodes","terminal_outcome_unreachable_nodes","outcome_reachable_nodes","outcome_unreachable_nodes"],s=["active_outcome_reachability_basis_points","terminal_outcome_reachability_basis_points","outcome_reachability_basis_points"];if(!br(e,o,s)||e.edge_basis!==void 0&&e.edge_basis!=="deduplicated_directed")return;let a=te(e.finding_subjects_by_code)?e.finding_subjects_by_code:{};return{edge_basis:"deduplicated_directed",...i,...Object.fromEntries(o.map(c=>[c,e[c]??0])),...Object.fromEntries(s.map(c=>[c,e[c]??0])),finding_subjects_by_code:Object.fromEntries(A.map(c=>[c,a[c]??t[c]??0]))}}function wr(e,t,n,r,i){let o=[n,r,i],s=o.filter(d=>d!==void 0).length;if(s===0)return{edge_share_by_kind:{},semantic_edges:0,semantic_edge_share:0};if(s!==o.length||!mr(n)||!x(r)||!Nt(i))return;let a=Object.entries(t);if(a.reduce((d,[,l])=>d+l,0)!==e||Object.keys(n).length!==a.length||a.some(([d,l])=>n[d]!==(e===0?0:l/e)))return;let c=a.reduce((d,[l,g])=>d+(Q(l)?g:0),0);if(!(r!==c||i!==(e===0?0:c/e)))return{edge_share_by_kind:n,semantic_edges:r,semantic_edge_share:i}}function kr(e){if(e!==null)try{let t=JSON.parse(e);if(!O(t))return;let n=t,r=n.profile;if(typeof n.saved_at!="string"||typeof n.fingerprint!="string")return;let i=n.affected_subjects_by_code;if(!te(i)||!O(r)||!ht(r)||![r.nodes,r.edges,r.active_nodes,r.missing_nodes,r.isolated_active_nodes,r.degree_leq_one_active_nodes].every(x)||!te(r.edges_by_kind)||!L(r.coverage_by_type,_r))return;let o=wr(r.edges,r.edges_by_kind,r.edge_share_by_kind,r.semantic_edges,r.semantic_edge_share);if(o===void 0)return;let s=vr(r,i,r.nodes,r.edges);if(s===void 0)return;let{coverage_by_type:a={}}=r;return{...n,profile:{...r,...o,...s,coverage_by_type:a}}}catch{return}}async function At(e){return kr(await j(Dt(e)))}async function Rt(e,t){await re(Dt(e),JSON.stringify(t))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="253f392d-4e91-57ec-b656-6134583d57e5")}catch{}})();var Ir={missing_reference_active:{op:"investigate",confidence:"medium",rationale:"Restore or re-create the referenced item, or remove/retype the reference on the active holder; the correct fix depends on why the target is absent."},missing_reference_terminal:{op:"waive",confidence:"high",rationale:"Terminal-holder reference to an absent item is historical debt; waive it or clean it up only in a dedicated changelog-safe closed-item batch."},legacy_no_blocker_sentinel:{op:"remove",confidence:"high",rationale:"The pre-structured-dependency no-active-blocker sentinel is retired and carries no information; blocker state derives from blocked_by edges."},ordering_cycle:{op:"investigate",confidence:"low",rationale:"Every cycle member is unschedulable until one ordering edge is removed or retyped; the planner never chooses which edge to cut."},legacy_ordering_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only ordering cycles have no scheduling effect; repairing them would mutate closed history (changelog drag)."},ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The structured ordering row asserts the opposite precedence from the same-target scalar blocker; remove that exact dependency row or replace both representations with one unambiguous edge."},legacy_ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The terminal holder contains a proven contradictory structured ordering row; remove it in a dedicated changelog-safe batch while preserving the scalar blocker as history."},hierarchy_cycle:{op:"investigate",confidence:"low",rationale:"Cut or retype one exact structural relation in the cycle; the planner preserves every evidence row because intent determines the correct parent."},legacy_hierarchy_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only hierarchy cycles are historical debt; waive them unless an explicit closed-history repair is approved."},hierarchy_cardinality_violation:{op:"investigate",confidence:"medium",rationale:"Choose the canonical parent and remove or retype the exact surplus hierarchy rows; the planner cannot infer ownership intent."},legacy_hierarchy_cardinality_violation:{op:"waive",confidence:"high",rationale:"Multiple parents confined to terminal items are historical debt; waive them unless a dedicated history repair is approved."},hierarchy_direction_violation:{op:"investigate",confidence:"medium",rationale:"Align the scalar parent and dependency-backed hierarchy rows to the intended canonical parent."},legacy_hierarchy_direction_violation:{op:"waive",confidence:"high",rationale:"Divergent hierarchy storage confined to terminal items is historical debt; waive it unless a dedicated history repair is approved."},duplicate_edge:{op:"remove",confidence:"high",rationale:"Parallel same-family spellings state one relationship twice; remove all but one stored spelling, keeping the holder's canonical direction."},legacy_duplicate_edge:{op:"waive",confidence:"high",rationale:"Duplicated spellings between terminal items are historical noise; waive or batch changelog-safe cleanup."},duplicate_dependency_row:{op:"remove",confidence:"high",rationale:"The identical dependency row is stored more than once on the holder; drop the repeats so the row exists exactly once \u2014 graph semantics are unchanged."},legacy_duplicate_dependency_row:{op:"waive",confidence:"high",rationale:"Repeated identical rows on terminal holders are storage noise; waive or clean up only in a changelog-safe closed-item batch."},stale_lifecycle_block:{op:"investigate",confidence:"medium",rationale:`Add a local ordering edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status; only the holder's owner knows which is true.`},isolated_active_node:{op:"investigate",confidence:"medium",rationale:"Link the item to its parent, prerequisite, or origin \u2014 or register it as an explicitly exempt isolate; the audit never fabricates an edge."},sparse_active_node:{op:"investigate",confidence:"low",rationale:"Investigate for an honest second edge (story-to-task, defect family, cross-epic complement); sparse is not automatically defective."}};function Ot(e){return`${e.source} -${e.kind}-> ${e.target}`}function xr(e){let[t,...n]=e.edges;return n.map(r=>({op:"remove",code:"duplicate_edge",subject:Ot(r),rationale:"This stored spelling restates the kept canonical edge of the same semantic family; removing it leaves the relationship stated exactly once.",evidence:[`keep: ${Ot(t)}`,`group: ${Z(e)}`],confidence:"high"}))}function Er(e,t){if(e.code==="duplicate_edge")return e.sample.flatMap(r=>xr(t.get(r)));let n=Ir[e.code];return e.sample.map(r=>({op:n.op,code:e.code,subject:r,rationale:n.rationale,evidence:[e.policy],confidence:n.confidence}))}function jt(e,t={}){let{redundancyLimit:n,...r}=t,i=ee(e,r),o=new Map(ue(e).map(d=>[Z(d),d])),s=i.findings.flatMap(d=>Er(d,o)),a=i.findings.some(d=>d.sample_truncated);t.signal?.throwIfAborted();let c=T(e.graph,{limit:n??t.maxSampleSize??25,...t.signal===void 0?{}:{signal:t.signal}});for(let d of c.value)s.push({op:"remove",code:"redundant_edge",subject:`${d.edge.source} -> ${d.edge.target} (${d.edge.kind})`,rationale:"The stored edge is implied by a longer same-family witness path; shortcut edges are sometimes deliberate emphasis, so confirm intent before removing.",evidence:[`witness: ${d.witness.join(" -> ")}`],confidence:"medium"});return a=a||c.meta.truncated,{steps:s,report:i,truncated:a,cost:{visitedNodes:c.meta.visitedNodes,inspectedEdges:c.meta.inspectedEdges}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="66df3949-0caf-5f01-8cec-3bba3d1e6111")}catch{}})();var Ft=new Set(["ancestors","descendants","predecessors","successors","paths","impact","dominators"]);function Mt(e,t,n){let r=e;if(t&&e.subcommand==="audit"){let{nodes:i,recorded_nodes:o,edges:s,active_nodes:a,terminal_nodes:c,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:g,coverage_by_lifecycle:u}=e.profile,f=Object.fromEntries(Object.entries(u).map(([p,m])=>{let{degree_histogram:b,...v}=m;return[p,v]}));r={...e,profile:{nodes:i,recorded_nodes:o,edges:s,active_nodes:a,terminal_nodes:c,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:g,coverage_by_lifecycle:f}}}return{...r,projection:{mode:t?"summary":"full",declared_field_groups:n===void 0?[]:[{name:n,restore_with:"--full"}],included_field_groups:n===void 0||t?[]:[n]}}}function Sr(e,t,n,r){return{assembly:t,...n===void 0?{}:{kinds:n},maxDepth:Ue(r.maxDepth),limit:e==="impact"&&Number(r.limit)===0?0:$(r.limit,"limit")??(r.full===!0?Number.MAX_SAFE_INTEGER:I.rows),after:r.after?.trim()||void 0,direction:Be(r.direction),maxPaths:$(r.maxPaths,"max-paths"),sample:$(r.sample,"sample")??I.samples,exemptIsolates:Pt(r.exemptIsolate),exemptIsolateTypes:Pt(r.exemptIsolateType),saveBaseline:r.saveBaseline===!0,summary:r.summary===!0,unbounded:r.full===!0}}function Pt(e){return e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",")).map(t=>t.trim()).filter(t=>t.length>0)}function Cr(e,t,n){let r=e.trim().toLowerCase();if(!ie.includes(r))throw Me({command_path:"graph",token:r||"<empty>",allowed:ie});let i=r;if(Ft.has(i)&&!t?.trim())throw new k(`graph ${i} requires an item id.`,w.USAGE);if(i==="paths"&&!n?.trim())throw new k("graph paths requires a source and a target item id.",w.USAGE);return i}function ye(e){throw e instanceof TypeError?new k(e.message,w.USAGE):e}function be(e){return{truncated:e.truncated,cost:{visited_nodes:e.visitedNodes,inspected_edges:e.inspectedEdges}}}function Lt(e,t){let n=t.trim().toLowerCase();for(let r of e.details)if(r.id.trim().toLowerCase()===n&&!e.missingIdSet.has(r.id.toLowerCase()))return r.id;throw new k(`Item ${t} not found`,w.NOT_FOUND)}function Dr(e,t,n){let r={ancestors:Qe,descendants:Ze,predecessors:et,successors:tt}[e],i;try{i=r(n.assembly.graph,t,{...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},limit:n.limit,...n.after===void 0?{}:{after:n.after}})}catch(s){ye(s)}let o=be(i.meta);return{subcommand:e,root:t,count:i.value.length,...o,...i.meta.nextCursor===void 0?{}:{next_cursor:i.meta.nextCursor},...n.summary?{}:{ids:i.value}}}function Tr(e,t,n){let r=nt(n.assembly.graph,e,t,{direction:n.direction,...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},...n.maxPaths===void 0?{}:{maxPaths:n.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:n.direction,count:r.value.length,...be(r.meta),...n.summary?{}:{paths:r.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(o=>o.kind),length:i.length}))}}}function Nr(e,t){let n;try{n=U(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth},...t.unbounded?{}:{limit:t.limit},...t.after===void 0?{}:{after:t.after}})}catch(r){ye(r)}return{subcommand:"impact",root:e,direction:t.direction,count:n.affected.length,truncated:n.truncated,...n.nextCursor===void 0?{}:{next_cursor:n.nextCursor},cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...t.summary?{}:{affected:n.affected}}}function Ar(e,t,n){return{acyclic:e.acyclic,ordered_node_count:e.order.length,layer_count:e.layers.length,frontier_count:e.frontier.length,critical_path_length:e.criticalPathLength,cycle_count:e.cycles.length,...t?{}:{frontier:e.frontier.slice(0,n),critical_path:e.criticalPath.slice(0,n),cycles:e.cycles.slice(0,n)}}}function Rr(e,t,n){return{component_count:e.components.length,largest_component_size:e.components[0]?.length??0,orphan_count:e.orphans.length,...t?{}:{orphans:e.orphans.slice(0,n),hubs:e.hubs.slice(0,n)}}}function Or(e,t,n){let r=0,i=0,o=0;for(let s of e.cycles)r+=Number(s.legacy_terminal);for(let s of e.cardinality_violations)i+=Number(s.legacy_terminal);for(let s of e.divergences)o+=Number(s.legacy_terminal);return{acyclic:e.cycles.length===0,relation_count:e.relations.length,cycle_count:e.cycles.length,active_cycle_count:e.cycles.length-r,legacy_cycle_count:r,cardinality_violation_count:e.cardinality_violations.length,active_cardinality_violation_count:e.cardinality_violations.length-i,legacy_cardinality_violation_count:i,parent_divergence_count:e.divergences.length,active_parent_divergence_count:e.divergences.length-o,legacy_parent_divergence_count:o,...t?{}:{cycles:e.cycles.slice(0,n).map(s=>s.item_ids)}}}function jr(e){let t=e.assembly.graph,n=e.limit,r=B(t,{registry:t.registry()}),i=Ye(t);return{subcommand:"analyze",node_count:t.nodes().length,edge_count:t.edges().length,edge_basis:"deduplicated_directed",sample_limit:n,execution:Ar(r,e.summary,n),knowledge:Rr(i,e.summary,n),hierarchy:Or(G(e.assembly),e.summary,n)}}function Mr(e,t){let n=ee(e.assembly,{isTerminal:t,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),r={},i={},o={},s={};for(let d of n.findings)r[d.severity]=(r[d.severity]??0)+1,i[d.code]=(i[d.code]??0)+1,o[d.severity]=(o[d.severity]??0)+d.count,s[d.code]=(s[d.code]??0)+d.count;let{finding_subjects_by_code:a,...c}=n.profile;return{subcommand:"audit",truncated:n.findings.length>e.limit,finding_count:n.findings.length,findings_by_severity:r,findings_by_code:i,affected_subjects_by_severity:o,affected_subjects_by_code:s,profile:e.summary?c:n.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:n.findings.slice(0,e.limit)}}}function Pr(e){let t=e.limit,n={};e.kinds!==void 0&&(n.kinds=e.kinds);let r=it(e.assembly.graph,n),i=r.value;return{subcommand:"communities",community_count:i.communities.length,largest_community_size:i.communities[0]?.size??0,iterations:i.iterations,converged:i.converged,truncated:!i.converged||i.communities.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{communities:i.communities.slice(0,t).map(o=>({representative:o.representative,size:o.size,members:o.members.slice(0,t)}))}}}function Lr(e){let t;try{t=T(e.assembly.graph,{...e.kinds===void 0?{}:{kinds:e.kinds},...e.maxDepth===void 0?{}:{maxDepth:e.maxDepth},limit:e.limit})}catch(n){ye(n)}return{subcommand:"redundancy",redundant_count:t.value.length,...be(t.meta),...e.summary?{}:{redundant:t.value.map(n=>({source:n.edge.source,target:n.edge.target,kind:n.edge.kind,witness:n.witness}))}}}function Fr(e,t){let n=t.limit,r=ot(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=r.value.rows.filter(o=>o.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:r.value.reachableCount,bottleneck_count:i.length,truncated:r.meta.truncated||i.length>n,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,n).map(o=>({id:o.id,idom:o.idom,dominated_count:o.dominatedCount}))}}}function Gr(e){let t=e.limit,n=lt(e.assembly.graph),r=n.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:n.acyclic,makespan:n.makespan,scheduled_count:n.scheduledCount,critical_count:r,critical_path_length:n.criticalPathLength,cycle_count:n.cycles.length,truncated:n.rows.length>t,...e.summary?{}:{critical_path:n.criticalPath.slice(0,t),rows:n.rows.slice(0,t).map(i=>({id:i.id,earliest_start:i.earliestStart,latest_start:i.latestStart,slack:i.slack,critical:i.critical}))}}}function $r(e){let t=e.limit,n=dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),r=n.value;return{subcommand:"centrality",node_count:r.nodeCount,edge_count:r.edgeCount,edge_basis:"simple_undirected",truncated:r.rows.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{rows:r.rows.slice(0,t).map(i=>({id:i.id,degree:i.degree,in_degree:i.inDegree,out_degree:i.outDegree,betweenness:i.betweenness,closeness:i.closeness}))}}}function qr(e){let t=e.limit,n=X(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:r,bridges:i}=n.value;return{subcommand:"articulation",articulation_count:r.length,bridge_count:i.length,truncated:r.length>t||i.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{articulation_points:r.slice(0,t),bridges:i.slice(0,t)}}}function Ur(e,t){let n=e.limit,r=jt(e.assembly,{isTerminal:t,redundancyLimit:n,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},o={};for(let s of r.steps)i[s.op]=(i[s.op]??0)+1,o[s.code]=(o[s.code]??0)+1;return{subcommand:"plan",step_count:r.steps.length,steps_by_op:i,steps_by_code:o,finding_count:r.report.findings.length,truncated:r.truncated||r.steps.length>n,cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...e.summary?{}:{steps:r.steps.slice(0,n)}}}function Gt(e,t,n,r){return JSON.stringify({projection_version:2,subcommand:e,root:t??null,target:n??null,kinds:r.kinds??null,maxDepth:r.maxDepth??null,limit:r.limit,after:r.after??null,direction:r.direction,maxPaths:r.maxPaths??null,sample:r.sample,exemptIsolates:[...new Set(r.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(r.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:r.summary,unbounded:r.unbounded})}function $t(e,t,n,r,i){return e==="analyze"?jr(r):e==="audit"?Mr(r,i):e==="plan"?Ur(r,i):e==="communities"?Pr(r):e==="redundancy"?Lr(r):e==="dominators"?Fr(t,r):e==="slack"?Gr(r):e==="centrality"?$r(r):e==="articulation"?qr(r):e==="paths"?Tr(t,n,r):e==="impact"?Nr(t,r):Dr(e,t,r)}function Br(e,t){if(e!=="index"&&(t.rebuild===!0||t.clear===!0))throw new k("--rebuild and --clear apply only to graph index.",w.USAGE);if(e!=="audit"&&t.saveBaseline===!0)throw new k("--save-baseline applies only to graph audit.",w.USAGE);if(e==="slack"&&t.kind!==void 0)throw new k("graph slack analyzes every ordering kind; --kind is not supported.",w.USAGE);if(t.rebuild===!0&&t.clear===!0)throw new k("graph index accepts either --rebuild or --clear, not both.",w.USAGE);if(t.full===!0&&t.limit!==void 0)throw new k(`graph ${e} accepts either --full or --limit, not both.`,w.USAGE)}async function zr(e,t,n,r,i,o){let s="status";if(o.clear===!0&&(await me(e),s="cleared"),o.rebuild===!0){await me(e);let c=await pe(e,t),d={assembly:n.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,limit:I.rows,sample:I.samples,unbounded:!1};for(let l of["analyze","audit"])await he(e,t,c,Gt(l,void 0,void 0,d),$t(l,void 0,void 0,d,i));s="rebuilt"}let a=await Tt(e,t);return{subcommand:"index",action:s,state:a.exists?a.fresh?"fresh":"stale":"absent",entry_count:a.entry_count,item_count:r,min_items_threshold:ge,persist_enabled:_e(r,a.exists),current_fingerprint:t.slice(0,12),...a.saved_at===void 0?{}:{saved_at:a.saved_at},...a.bytes===void 0?{}:{bytes:a.bytes}}}async function Hr(e,t,n,r){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:n.affected_subjects_by_code,profile:{...n.profile,finding_subjects_by_code:Object.fromEntries(A.map(s=>[s,n.affected_subjects_by_code[s]??0]))}},o=await At(e);return r&&await Rt(e,i),o===void 0?n:{...n,baseline:xt(o,i)}}async function Kr(e,t,n,r,i){try{await he(e,t,n,r,i)}catch{}}function Vr(e,t,n,r){if(e.subcommand!=="slack")return;let i=new Set(t.assembly.details.filter(u=>r(u.status)).map(u=>u.id)),o=t.assembly.graph,s=new ke(o.nodes().filter(u=>!i.has(u)),o.edges().filter(u=>!i.has(u.source)&&!i.has(u.target)),o.registry()),a=ut(s,n.filter(u=>!i.has(u.id)),{now:Ae(),limit:t.limit}),{rows:c,residuals:d,overcommitted:l,...g}=a;e.deadline_schedule={population:"active",...g,...t.summary?{}:{rows:c,residuals:d,overcommitted:l}}}async function ro(e,t,n,r,i){let o=Cr(e,t,n);De(r.summary===!0,r.full===!0,"--summary");let s=Ee(process.cwd(),i.path);await Pe(s);let a=await je(s),c=xe(a,Ce()),d=await Le(s,a.item_format,c.type_to_folder,void 0,a.schema),l=Se(a.schema),g=qt=>Oe(qt,l);Br(o,r);let u=Fe(),f=ze(r.kind,u),p=qe().lookup(s,$e(d,g,u),()=>Ge(d,g,u)),m=Sr(o,p.assembly,f,r);if(o==="index")return Mt(await zr(s,p.fingerprint,m,d.length,g,r),!1);let b=Ft.has(o)?Lt(m.assembly,t):void 0,v=o==="paths"?Lt(m.assembly,n):void 0,h=Gt(o,b,v,m),_=await pe(s,p.fingerprint),E=_.results[h],S=p.memoize(h,()=>E!==void 0?structuredClone(E):$t(o,b,v,m,g)),ve=_e(d.length,_.exists);!S.reused&&E===void 0&&ve&&await Kr(s,p.fingerprint,_,h,S.value);let ne=S.value.subcommand==="audit"?await Hr(s,p.fingerprint,S.value,m.saveBaseline):S.value;return ne.cache={fingerprint:p.fingerprint.slice(0,12),assembly:p.assemblyReused?"hit":"miss",result:S.reused?"hit":"miss",durable:E!==void 0?"hit":ve?"miss":"off"},Vr(ne,m,d,g),Mt(ne,m.summary,"result_rows")}export{B as a,U as b,Ye as c,Xr as d,Qe as e,Ze as f,et as g,tt as h,nt as i,V as j,it as k,T as l,ot as m,dt as n,X as o,lt as p,ut as q,tr as r,It as s,Z as t,ue as u,ee as v,xt as w,St as x,ge as y,F as z,Dt as A,pe as B,he as C,me as D,Tt as E,_e as F,At as G,Rt as H,jt as I,Cr as J,ro as K};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{Bb as Pe,Gb as Le,V as Oe,Ya as je,Zb as Fe,_a as Me,ic as G,jc as Ge,kc as $e,mc as qe,pc as $,qc as Ue,rc as Be,sc as ze}from"./chunk-JDVZF75H.js";import{n as Se}from"./chunk-4UA7KY4V.js";import{$ as w,$d as Ae,Aa as re,Ca as Ie,Qc as Ce,Sb as ie,Xa as xe,aa as k,ad as De,bb as Ee,ie as Re,jd as Te,kd as oe,ma as we,nd as Ne,ra as ke,xa as j,zc as I}from"./chunk-WIXZF5SS.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="403706c5-987d-5db1-95d2-b0eaded98e92")}catch{}})();function Ut(e,t,n,r,i,o){if(e.seen.has(t))return"skip";if(e.cursorFound&&e.affected.length>=o)return"truncate";e.seen.add(t),e.parents.set(t,n.id);let s=n.depth+1;return e.queue.push({id:t,depth:s}),e.cursorFound?(e.affected.push({id:t,distance:s,path:Yt(r,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function Ke(e,t,n,r){let i=Te("graph impact",{root:e,direction:n,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(r)?r:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:Ne(t.after,i)}}function C(e,t,n){e.get(t).add(n)}function M(e){return new Map(e.map(t=>[t,new Set]))}function Ve(e){for(let t of e)t.sort();return e.sort((t,n)=>n.length-t.length||t[0].localeCompare(n[0]))}function q(e){if(Array.isArray(e))return e.map(n=>q(n));if(e===null||typeof e!="object")return e;let t=e.toJSON;return typeof t=="function"?q(t.call(e)):Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,q(r)]))}function He(e){return JSON.stringify(q(e))}function Bt(e,t,n,r){let i=[{id:e,expanded:!1}];for(;i.length>0;){let o=i.pop();if(o.expanded){r.push(o.id);continue}if(n.has(o.id))continue;n.add(o.id),i.push({id:o.id,expanded:!0});let s=[...t.get(o.id)].sort().reverse();for(let a of s)n.has(a)||i.push({id:a,expanded:!1})}}function zt(e,t){let n=new Set,r=[];for(let i of e)n.has(i)||Bt(i,t,n,r);return r}function Ht(e,t){let n=new Set,r=[];for(let i of[...e].reverse()){if(n.has(i))continue;let o=[],s=[i];for(n.add(i);s.length>0;){let a=s.pop();o.push(a);for(let c of t.get(a))n.has(c)||(n.add(c),s.push(c))}r.push(o)}return Ve(r)}function We(e,t){let n=M(e);for(let[r,i]of t)for(let o of i)C(n,o,r);return Ht(zt(e,t),n)}function Kt(e,t){let n=M(e.nodes());for(let r of e.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let o=(i.precedence??"source_before_target")==="source_before_target";C(n,o?r.source:r.target,o?r.target:r.source)}return n}function Vt(e,t){let n=new Map(e.map(o=>[o,0]));for(let o of t.values())for(let s of o)n.set(s,n.get(s)+1);let r=e.filter(o=>n.get(o)===0).sort(),i=[];for(;r.length>0;){i.push(r);let o=[];for(let s of r)for(let a of t.get(s)){let c=n.get(a)-1;n.set(a,c),c===0&&o.push(a)}r=o.sort()}return i}function Wt(e,t){let n=new Map(e.map(s=>[s,0])),r=new Map;for(let s of e)for(let a of t.get(s)){if(!n.has(a))continue;let c=n.get(s)+1,d=r.get(a);(c>n.get(a)||c===n.get(a)&&(d===void 0||s.localeCompare(d)<0))&&(n.set(a,c),r.set(a,s))}let i=[...e].sort((s,a)=>n.get(a)-n.get(s)||s.localeCompare(a))[0],o=i===void 0?[]:[i];for(;o[0]!==void 0&&r.has(o[0]);)o.unshift(r.get(o[0]));return{depth:Object.fromEntries(n),path:o}}function Yt(e,t,n){let r=[t],i=t;for(;i!==e;)i=n.get(i),r.push(i);return r.reverse()}function B(e,t={}){let n=t.registry??we(),r=[...e.nodes()],i=Kt(e,n),o=Vt(r,i),s=o.flat(),a=s.length===r.length,c=a?[]:We(r,i).filter(l=>l.length>1||i.get(l[0]).has(l[0])),d=Wt(s,i);return{exact:!0,acyclic:a,order:s,layers:o,frontier:o[0]??[],depth:d.depth,criticalPath:d.path,criticalPathLength:Math.max(0,d.path.length-1),cycles:c,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function Xt(e,t,n){let r=M(e.nodes()),i=n===void 0?void 0:new Set(n.map(s=>e.registry().require(s).kind)),o=e.edges();for(let s of o){let a=e.registry().require(s.kind);i!==void 0&&!i.has(s.kind)&&(a.inverse===void 0||!i.has(a.inverse))||C(r,t==="incoming"?s.target:s.source,t==="incoming"?s.source:s.target)}return{adjacency:r,inspectedEdges:o.length}}function Jt(e,t,n,r,i,o){let s=U(e,t,{...n,after:void 0,direction:"incoming",limit:void 0}),a=U(e,t,{...n,after:void 0,direction:"outgoing",limit:void 0}),c=new Map,d=[...s.affected,...a.affected].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)||p.path.join("\0").localeCompare(m.path.join("\0")));for(let p of d)c.has(p.id)||c.set(p.id,p);let l=[...c.values()].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)),g=r===void 0||r===t?-1:l.findIndex(p=>p.id===r);if(r!==void 0&&r!==t&&g<0)throw new TypeError(`Unknown impact cursor item: ${r}`);let u=l.slice(g+1,g+1+i),f=g+1+u.length<l.length;return{root:t,affected:u,exact:!0,truncated:s.truncated||a.truncated||f,...f?{nextCursor:oe(o,u.at(-1)?.id??t)}:{},cost:{visitedNodes:s.cost.visitedNodes+a.cost.visitedNodes,inspectedEdges:s.cost.inspectedEdges+a.cost.inspectedEdges}}}function Qt(e,t,n){let r=n.direction,i=n.maxDepth??Number.POSITIVE_INFINITY,o=n.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,n,r,i),{adjacency:c,inspectedEdges:d}=Xt(e,r,n.kinds),l={queue:[{id:t,depth:0}],seen:new Set([t]),parents:new Map,affected:[],cursorFound:a===void 0||a===t},g=0,u=!1,f=!1;e:for(let p=0;p<l.queue.length;p+=1){n.signal?.throwIfAborted();let m=l.queue[p];g+=1;let b=[...c.get(m.id)].sort();if(m.depth>=i){b.some(v=>!l.seen.has(v))&&(u=!0);continue}for(let v of b)if(Ut(l,v,m,t,a,o)==="truncate"){u=!0,f=!0;break e}}if(!l.cursorFound)throw new TypeError(`Unknown impact cursor item: ${a}`);return{root:t,affected:l.affected,exact:!0,truncated:u,...f?{nextCursor:oe(s,l.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:g,inspectedEdges:d}}}function U(e,t,n={}){let r=n.direction??"outgoing";if(r!=="both")return Qt(e,t,{...n,direction:r});let i=n.maxDepth??Number.POSITIVE_INFINITY,o=n.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,n,r,i);return Jt(e,t,n,a,o,s)}function Ye(e){let t=[...e.nodes()],n=M(t),r=M(t);for(let c of e.edges())C(n,c.source,c.target),C(n,c.target,c.source),C(r,c.source,c.target);let i=[],o=new Set;for(let c of t){if(o.has(c))continue;let d=[],l=[c];for(o.add(c);l.length>0;){let g=l.pop();d.push(g);for(let u of n.get(g))o.has(u)||(o.add(u),l.push(u))}i.push(d)}let s=t.map(c=>({id:c,degree:n.get(c).size})),a=Math.max(0,...s.map(({degree:c})=>c));return{components:Ve(i),stronglyConnected:We(t,r),orphans:s.filter(({degree:c})=>c===0).map(({id:c})=>c),hubs:s.filter(({degree:c})=>c>0&&c===a),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function Xr(e,t){let n=new Map(e.edges.map(i=>[He(i),i])),r=new Map(t.edges.map(i=>[He(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),removed:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),unchangedCount:[...n.keys()].filter(i=>r.has(i)).length,exact:!0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f60c628a-2e42-5770-a001-39cce5f92595")}catch{}})();var Zt=I.paths,en=I.visited_paths,tn=I.path_depth;function se(e,t){if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new TypeError(`Invalid path ${e} bound: ${String(t)}`)}function z(e,t){return t.hierarchyDirection==="target_parent"?e.target:e.source}function P(e,t){return(t.precedence??"source_before_target")==="target_before_source"?e.target:e.source}function D(e,t){let n=P(e,t);return{predecessor:n,successor:n===e.source?e.target:e.source}}function nn(e,t,n){if(t===void 0)return;let r=e.registry(),i=new Set;for(let o of t){let s=r.require(o),a=s.traversal;if(a==="association")throw new TypeError(`Relationship kind ${s.kind} uses association traversal; use graph impact --direction both`);if(a!==n&&a!=="semantic"){let c=a==="hierarchy"?"graph ancestors or graph descendants":"graph predecessors or graph successors";throw new TypeError(`Relationship kind ${s.kind} uses ${a} traversal; use ${c}`)}i.add(s.kind)}return i}function rn(e,t,n,r,i){let o=e.registry(),s=e.neighborEdges(t,{direction:"both",...n===void 0?{}:{kinds:[...n]}}),a=[],c=new Set;for(let d of s.value){let l=o.require(d.edge.kind);n===void 0&&!l[r]||i(d,l,t)&&(c.has(d.id)||(c.add(d.id),a.push(d.id)))}return{neighbors:a,inspectedEdges:s.meta.inspectedEdges}}function on(e,t,n,r,i,o){if(t>=n)return e.neighbors.some(s=>!o.seen.has(s))&&(o.truncated=!0),!1;for(let s of e.neighbors)if(!o.seen.has(s)){if(o.seen.add(s),o.queue.push({id:s,depth:t+1}),!o.resumed){s===i&&(o.resumed=!0);continue}if(o.value.length>=r)return o.truncated=!0,!0;o.value.push(s)}return!1}function H(e,t,n,r,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let o=nn(e,n.kinds,r),s=n.limit??Number.POSITIVE_INFINITY,a=n.maxDepth??Number.POSITIVE_INFINITY,c=n.after,d={seen:new Set([t]),value:[],queue:[{id:t,depth:0}],resumed:c===void 0,truncated:!1},l=0,g=0;for(let u=0;u<d.queue.length;u+=1){n.signal?.throwIfAborted();let f=d.queue[u];l+=1;let p=rn(e,f.id,o,r,i);if(g+=p.inspectedEdges,on(p,f.depth,a,s,c,d))break}if(!d.resumed)throw new TypeError(`Traversal cursor not found in sequence: ${c}`);return{value:d.value,meta:{visitedNodes:l,inspectedEdges:g,truncated:d.truncated,nextCursor:d.value.at(-1)}}}function Xe(e,t){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`)}function Je(e,t,n,r,i){let o=e.neighborEdges(t.nodes.at(-1),{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});return i.inspectedEdges+=o.meta.inspectedEdges,o.value.filter(s=>!t.nodeSet.has(s.id))}function sn(e,t,n,r,i,o,s){for(let a of Je(e,t,r,i,s)){let c=[...t.nodes,a.id],d=new Set(t.nodeSet).add(a.id),l=[...t.edges,a.edge];if(a.id===n){if(s.value.push({nodes:c,edges:l,length:l.length}),s.value.length>=o)return!0}else s.queue.push({nodes:c,nodeSet:d,edges:l})}return!1}function Qe(e,t,n={}){return H(e,t,n,"hierarchy",(r,i)=>z(r.edge,i)===r.id)}function Ze(e,t,n={}){return H(e,t,n,"hierarchy",(r,i,o)=>z(r.edge,i)===o)}function et(e,t,n={}){return H(e,t,n,"ordering",(r,i)=>P(r.edge,i)===r.id)}function tt(e,t,n={}){return H(e,t,n,"ordering",(r,i,o)=>P(r.edge,i)===o)}function an(e,t,n,r,i,o,s,a){let c={value:[],queue:[{nodes:[t],nodeSet:new Set([t]),edges:[]}],inspectedEdges:0},d=0,l=!1,g=i+1;for(let u=0;u<c.queue.length;u+=1){if(r.signal?.throwIfAborted(),c.value.length>=g||d>=o){l=!0;break}let f=c.queue[u];if(d+=1,f.edges.length>=s){Je(e,f,r,a,c).length>0&&(l=!0);continue}if(sn(e,f,n,r,a,g,c)){l=!0;break}}return{value:c.value.slice(0,i),meta:{visitedNodes:d,inspectedEdges:c.inspectedEdges,truncated:l}}}function nt(e,t,n,r={}){Xe(e,t),Xe(e,n);let i=r.maxPaths??Zt,o=r.maxVisitedPaths??en,s=r.maxDepth??tn;se("maxPaths",i),se("maxVisitedPaths",o),se("maxDepth",s);let a=r.direction??"outgoing";r.signal?.throwIfAborted();for(let c of r.kinds??[])e.registry().require(c);return t===n?i===0?{value:[],meta:{visitedNodes:1,inspectedEdges:0,truncated:!0}}:{value:[{nodes:[t],edges:[],length:0}],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}}:an(e,t,n,r,i,o,s,a)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="789f7451-ceb1-5e5c-b2b6-45eec49580ce")}catch{}})();var cn=16,dn=2,ln=8;function K(e,t){if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`)}function V(e,t,n){let r=e.registry(),i=t===void 0?void 0:new Set(t.map(o=>r.require(o).kind));for(let o of e.edges()){if(o.source===o.target)continue;let s=r.require(o.kind);i!==void 0&&!(i.has(s.kind)||s.inverse!==void 0&&i.has(s.inverse))||n(o,s)}}function un(e,t){let n=new Map;V(e,t,r=>{rt(n,r.source,r.target),rt(n,r.target,r.source)});for(let r of n.values())r.sort();return n}function rt(e,t,n){let r=e.get(t);r===void 0?e.set(t,[n]):r.push(n)}function gn(e,t){let n=new Map;for(let o of e){let s=t.get(o);n.set(s,(n.get(s)??0)+1)}let r,i=0;for(let[o,s]of n)(s>i||s===i&&o<r)&&(r=o,i=s);return r}function fn(e,t){let n=new Map;for(let[i,o]of e){let s=n.get(o);s===void 0?n.set(o,[i]):s.push(i)}let r=[];for(let i of n.values())i.length<t||(i.sort(),r.push({representative:i[0],size:i.length,members:i}));return r.sort((i,o)=>o.size-i.size||i.representative.localeCompare(o.representative))}function it(e,t={}){let n=t.maxIterations??cn,r=t.minSize??dn;K("maxIterations",n),K("minSize",r);let i=un(e,t.kinds),o=e.nodes(),s=new Map(o.map(g=>[g,g])),a=0,c=!1,d=0,l=0;for(;a<n&&!c;){t.signal?.throwIfAborted(),a+=1,c=!0;for(let g of o){d+=1;let u=i.get(g);if(u===void 0)continue;l+=u.length;let f=gn(u,s);f!==s.get(g)&&(s.set(g,f),c=!1)}}return{value:{communities:fn(s,r),iterations:a,converged:c},meta:{visitedNodes:d,inspectedEdges:l,truncated:!c}}}function W(e){return e.direction==="directed"&&(e.ordering||e.hierarchy)}function Y(e){return e.inverse!==void 0&&e.inverse<e.kind?e.inverse:e.kind}function ae(e,t){return(t.hierarchy?z(e,t):e.source===P(e,t)?e.target:e.source)===e.target?{from:e.source,to:e.target}:{from:e.target,to:e.source}}function pn(e,t){if(t===void 0)return;let n=e.registry(),r=new Set;for(let i of t){let o=n.require(i);if(!W(o))throw new TypeError(`Relationship kind ${o.kind} is not a directed ordering or hierarchy kind`);r.add(Y(o))}return r}function hn(e,t){let n=e.registry(),r=new Map;for(let i of e.edges()){let o=n.require(i.kind);if(!W(o))continue;let s=Y(o);if(t!==void 0&&!t.has(s))continue;let a=ae(i,o);if(a.from===a.to)continue;let c=r.get(s);c===void 0&&(c={adjacency:new Map,records:[]},r.set(s,c));let d=c.adjacency.get(a.from);d===void 0?c.adjacency.set(a.from,new Set([a.to])):d.add(a.to),c.records.push({...a,edge:i})}return r}function mn(e){let t=new Map;for(let[n,r]of e.adjacency)t.set(n,[...r].sort());return t}function _n(e,t,n,r){let i=[r];for(let o=n;o!==t;o=e.get(o))i.push(o);return i.push(t),i.reverse()}function yn(e,t,n,r,i,o){for(let s of e.get(n.id)??[])if(o.inspectedEdges+=1,!(n.depth===0&&s===t.to)&&!r.has(s)){if(r.set(s,n.id),s===t.to)return _n(r,t.from,n.id,s);i.push({id:s,depth:n.depth+1})}}function bn(e,t,n,r){let i=new Map([[t.from,t.from]]),o=[{id:t.from,depth:0}];for(let s=0;s<o.length;s+=1){let a=o[s];if(r.visitedNodes+=1,a.depth>=n)continue;let c=yn(e,t,a,i,o,r);if(c!==void 0)return c}}function T(e,t={}){let n=t.maxDepth??ln;K("maxDepth",n),t.limit!==void 0&&K("limit",t.limit);let r=t.limit??Number.POSITIVE_INFINITY,i=pn(e,t.kinds),o=hn(e,i),s=[],a={visitedNodes:0,inspectedEdges:0},c=!1;e:for(let d of[...o.keys()].sort()){let l=o.get(d),g=mn(l);for(let u of l.records){t.signal?.throwIfAborted();let f=bn(g,u,n,a);if(f!==void 0){if(s.length>=r){c=!0;break e}s.push({edge:u.edge,witness:f})}}}return{value:s,meta:{visitedNodes:a.visitedNodes,inspectedEdges:a.inspectedEdges,truncated:c}}}function vn(e,t,n,r,i){let o=new Set,s=[];for(let a of n){if(a.id===e||o.has(a.id))continue;if(!i.seen.has(a.id)){if(t>=r){i.truncated=!0;continue}i.seen.add(a.id),i.queue.push({id:a.id,depth:t+1})}o.add(a.id),s.push(a.id);let c=i.predecessors.get(a.id);c===void 0&&(c=new Set,i.predecessors.set(a.id,c)),c.add(e)}return s}function wn(e,t,n){let r=n.direction??"outgoing",i=n.maxDepth??Number.POSITIVE_INFINITY,o=[],s=new Map,a={seen:new Set([t]),queue:[{id:t,depth:0}],predecessors:new Map,truncated:!1},c=0;for(let d=0;d<a.queue.length;d+=1){n.signal?.throwIfAborted();let{id:l,depth:g}=a.queue[d];o.push(l);let u=e.neighborEdges(l,{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});c+=u.meta.inspectedEdges,s.set(l,vn(l,g,u.value,i,a))}return{order:o,successors:s,predecessors:a.predecessors,inspectedEdges:c,truncated:a.truncated}}function kn(e,t){let n=[],r=new Set([t]),i=[{id:t,index:0}];for(;i.length>0;){let o=i.at(-1),s=e.successors.get(o.id);if(o.index<s.length){let a=s[o.index];o.index+=1,r.has(a)||(r.add(a),i.push({id:a,index:0}))}else n.push(o.id),i.pop()}return n.reverse()}function In(e,t,n,r){let i=e,o=t;for(;i!==o;){for(;r.get(i)>r.get(o);)i=n.get(i);for(;r.get(o)>r.get(i);)o=n.get(o)}return i}function xn(e,t,n){let r;for(let i of[...e].sort())t.has(i)&&(r=r===void 0?i:In(r,i,t,n));return r}function En(e,t,n,r,i){let o=new Map([[t,t]]),s=!0;for(;s;){s=!1;for(let a of n){if(i?.throwIfAborted(),a===t)continue;let c=xn(e.predecessors.get(a),o,r);c!==void 0&&o.get(a)!==c&&(o.set(a,c),s=!0)}}return o}function ot(e,t,n={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(n.maxDepth!==void 0&&(!Number.isInteger(n.maxDepth)||n.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(n.maxDepth)}`);let r=wn(e,t,n),i=kn(r,t),o=new Map(i.map((d,l)=>[d,l])),s=En(r,t,i,o,n.signal),a=new Map(i.map(d=>[d,1]));for(let d=i.length-1;d>=0;d-=1){let l=i[d];if(l===t)continue;let g=s.get(l);a.set(g,a.get(g)+a.get(l))}let c=i.filter(d=>d!==t).map(d=>({id:d,idom:s.get(d),dominatedCount:a.get(d)-1})).sort((d,l)=>l.dominatedCount-d.dominatedCount||d.id.localeCompare(l.id));return{value:{root:t,reachableCount:r.order.length,rows:c},meta:{visitedNodes:r.order.length,inspectedEdges:r.inspectedEdges,truncated:r.truncated}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3cef3a97-fda4-5811-9e69-04ff722e40a1")}catch{}})();function st(e){return Math.round(e*1e6)/1e6}function at(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function ct(e,t){let n=new Map(e.nodes().map(i=>[i,new Set]));V(e,t,i=>{n.get(i.source).add(i.target),n.get(i.target).add(i.source)});let r=new Map;for(let[i,o]of n)r.set(i,[...o].sort());return r}function Sn(e,t){let n=new Map,r=new Map;return V(e,t,(i,o)=>{if(!o.ordering)return;let{predecessor:s,successor:a}=D(i,o);at(r,s,a),at(n,a,s)}),{incoming:n,outgoing:r}}function Cn(e,t,n){let r=new Map([[e,0]]),i=new Map([[e,1]]),o=new Map,s=[],a=[e],c=0,d=0;for(let l=0;l<a.length;l+=1){let g=a[l];n.visitedNodes+=1,s.push(g);let u=r.get(g);g!==e&&(c+=1,d+=u);for(let f of t.get(g))if(n.inspectedEdges+=1,r.has(f)||(r.set(f,u+1),a.push(f)),r.get(f)===u+1){i.set(f,(i.get(f)??0)+i.get(g));let p=o.get(f);p===void 0?o.set(f,[g]):p.push(g)}}return{stack:s,sigma:i,predecessors:o,reachableCount:c,distanceSum:d}}function Dn(e,t,n){let r=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let o=e.stack[i],s=(1+(r.get(o)??0))/e.sigma.get(o);for(let a of e.predecessors.get(o)??[])r.set(a,(r.get(a)??0)+e.sigma.get(a)*s);o!==t&&n.set(o,(n.get(o)??0)+(r.get(o)??0))}}function Tn(e,t){return t<=1||e.reachableCount===0?0:e.reachableCount/(t-1)*(e.reachableCount/e.distanceSum)}function Nn(e,t,n,r,i){return{id:e,degree:t.get(e).length,inDegree:n.incoming.get(e)?.size??0,outDegree:n.outgoing.get(e)?.size??0,betweenness:st((r.get(e)??0)/2),closeness:st(i.get(e))}}function dt(e,t={}){let n=ct(e,t.kinds),r=Sn(e,t.kinds),i=e.nodes(),o=new Map,s=new Map,a={visitedNodes:0,inspectedEdges:0};for(let l of i){t.signal?.throwIfAborted();let g=Cn(l,n,a);s.set(l,Tn(g,i.length)),Dn(g,l,o)}let c=0;for(let l of n.values())c+=l.length;let d=i.map(l=>Nn(l,n,r,o,s)).sort((l,g)=>g.betweenness-l.betweenness||g.degree-l.degree||l.id.localeCompare(g.id));return{value:{nodeCount:i.length,edgeCount:c/2,rows:d},meta:{visitedNodes:a.visitedNodes,inspectedEdges:a.inspectedEdges,truncated:!1}}}function An(e,t){return e<=t?{source:e,target:t}:{source:t,target:e}}function Rn(e,t,n){let r=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,n.inspectedEdges+=1,r!==e.parent){if(n.discovery.has(r)){n.low.set(e.node,Math.min(n.low.get(e.node),n.discovery.get(r)));return}return e.children+=1,n.discovery.set(r,n.timer),n.low.set(r,n.timer),n.timer+=1,{node:r,parent:e.node,neighborIndex:0,children:0}}}function On(e,t,n){if(e.parent===null){e.children>1&&n.articulation.add(e.node);return}let r=e.parent,i=n.low.get(e.node);n.low.set(r,Math.min(n.low.get(r),i)),r!==t&&i>=n.discovery.get(r)&&n.articulation.add(r),i>n.discovery.get(r)&&n.bridges.push(An(r,e.node))}function jn(e,t,n,r){n.discovery.set(e,n.timer),n.low.set(e,n.timer),n.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){r?.throwIfAborted();let o=i.at(-1);if(o.neighborIndex<t.get(o.node).length){let s=Rn(o,t,n);s!==void 0&&i.push(s)}else On(o,e,n),i.pop()}}function X(e,t={}){let n=ct(e,t.kinds),r={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())r.discovery.has(i)||jn(i,n,r,t.signal);return{value:{articulationPoints:[...r.articulation].sort(),bridges:r.bridges.sort((i,o)=>i.source.localeCompare(o.source)||i.target.localeCompare(o.target))},meta:{visitedNodes:r.discovery.size,inspectedEdges:r.inspectedEdges,truncated:!1}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="32f3ce0d-64ac-5ad4-b27a-2a279718de22")}catch{}})();function Mn(e){let t=e.registry(),n=new Map,r=new Set;for(let i of e.edges()){let o=t.require(i.kind);if(!o.ordering)continue;let{predecessor:s,successor:a}=D(i,o);if(r.add(s),r.add(a),s===a)continue;let c=n.get(s);c===void 0?n.set(s,new Set([a])):c.add(a)}return{forward:n,participants:r}}function Pn(e,t,n,r){if(e===void 0)return r;let i=r;for(let o of e)t.has(o)&&(i=Math.min(i,n.get(o)));return i}function Ln(e,t,n){let r=n-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:n,latestFinish:n+1,slack:r,critical:r===0}}function Fn(e,t,n,r,i){let o=new Map;for(let s=e.length-1;s>=0;s-=1){let a=e[s],c=Pn(t.forward.get(a),r,o,i);o.set(a,c-1)}return e.map(s=>Ln(s,n[s],o.get(s))).sort((s,a)=>s.slack-a.slack||s.earliestStart-a.earliestStart||s.id.localeCompare(a.id))}function lt(e,t={}){t.signal?.throwIfAborted();let n=B(e,{registry:e.registry()}),r=Mn(e),i=new Set(n.order),o=n.order.filter(d=>r.participants.has(d)),s=o.reduce((d,l)=>Math.max(d,n.depth[l]+1),0),a=Fn(o,r,n.depth,i,s),c=a.length>0;return{exact:!0,acyclic:n.acyclic,makespan:s,scheduledCount:a.length,criticalPath:c?n.criticalPath:[],criticalPathLength:c?n.criticalPathLength:0,cycles:n.cycles,rows:a,provenance:{algorithm:"critical-path-method",edgeFamily:"ordering",weighting:"unit"}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fa17672a-97a2-5f94-bdfe-9df970cc038b")}catch{}})();function Gn(e,t,n){for(let r=e.length-1;r>=0;r-=1){n?.throwIfAborted();let i=t.get(e[r]);for(let o of i.successors){n?.throwIfAborted();let s=t.get(o);if(s.latest===void 0||s.duration===void 0)continue;let a=s.latest-s.duration;(i.latest===void 0||a<i.latest)&&(i.latest=a,i.anchor=s.anchor)}}}function $n(e,t,n,r){let i=[],o=e;for(;o!==void 0&&i.length<n;)r?.throwIfAborted(),i.push(o),o=t.get(o).predecessor;return i.reverse(),{path:i,path_truncated:o!==void 0}}function qn(e,t,n,r,i){let o=new Map(t.map(a=>[a.id,a])),s=new Map;for(let a of e){i?.throwIfAborted();let c=o.get(a),d=c?.estimated_minutes,l=typeof d=="number"&&Number.isFinite(d)&&d>=0?d:void 0,g={item:c,duration:l,pending:0,successors:new Set,earliest:0};if(c?.deadline!==void 0){let u=Date.parse(c.deadline);Number.isFinite(u)?(g.deadline=(u-n)/6e4,g.latest=g.deadline,g.anchor=a):r(a,"invalid_deadline")}s.set(a,g)}return s}function Un(e,t,n){for(let r of e.edges()){n?.throwIfAborted();let i=e.registry().require(r.kind);if(!i.ordering)continue;let{predecessor:o,successor:s}=D(r,i),a=t.get(o);a.successors.has(s)||(a.successors.add(s),t.get(s).pending+=1)}}function Bn(e,t,n){let r=e.filter(i=>t.get(i).pending===0);for(let i=0;i<r.length;i+=1){n?.throwIfAborted();let o=r[i],s=t.get(o),a=s.earliest===null||s.duration===void 0?null:s.earliest+s.duration;for(let c of s.successors){n?.throwIfAborted();let d=t.get(c);a===null?d.earliest=null:d.earliest!==null&&(a>d.earliest||a===d.earliest&&(d.predecessor===void 0||o<d.predecessor))&&(d.earliest=a,d.predecessor=o),d.pending-=1,d.pending===0&&r.push(c)}}return r}function zn(e,t,n,r,i,o,s,a){let c=t.duration;if(t.latest!==void 0){r.scheduled_count+=1;let d=t.latest-c;r.rows.length<o?r.rows.push({id:e,deadline_id:t.anchor,latest_start:new Date(i+d*6e4).toISOString(),slack_minutes:t.earliest===null?null:d-t.earliest}):r.truncated=!0}if(t.deadline!==void 0&&t.earliest!==null&&t.earliest+c>t.deadline)if(r.overcommitted_count+=1,r.overcommitted.length<o){let d=$n(e,n,Math.min(o,s.remaining),a);s.remaining-=d.path.length,d.path_truncated&&(r.truncated=!0),r.overcommitted.push({deadline_id:e,deadline:t.item.deadline,shortfall_minutes:t.earliest+c-t.deadline,...d})}else r.truncated=!0}function Hn(e,t,n,r,i,o,s,a){let c={remaining:o};for(let d of e){a?.throwIfAborted();let l=t.get(d);if(l.pending>0){s(d,"cycle_or_gated_by_cycle");continue}if(l.duration===void 0){s(d,"unknown_estimate");continue}if(l.latest!==void 0&&!Number.isFinite(new Date(r+(l.latest-l.duration)*6e4).getTime())){s(d,"date_range_exceeded");continue}l.earliest===null&&s(d,"unknown_predecessor_estimate"),zn(d,l,t,n,r,i,c,a)}}function ut(e,t,n={}){n.signal?.throwIfAborted();let r=Date.parse(n.now??new Date().toISOString());if(!Number.isFinite(r))throw new TypeError("Invalid scheduling clock");let i=n.maxWork??1e5,o=n.limit??10;for(let[u,f]of[["maxWork",i],["limit",o]])if(!Number.isSafeInteger(f)||f<1)throw new TypeError(`Invalid scheduling ${u}`);let s={as_of:new Date(r).toISOString(),basis:"derived_elapsed_minutes",complete:!0,truncated:!1,work_limit_exceeded:!1,scheduled_count:0,residual_count:0,overcommitted_count:0,rows:[],residuals:[],overcommitted:[]},a=e.nodes(),c=e.edges();if(a.length+c.length+t.length>i)return{...s,complete:!1,work_limit_exceeded:!0};let d=(u,f)=>{s.complete=!1,s.residual_count+=1,s.residuals.length<o?s.residuals.push({id:u,reason:f}):s.truncated=!0},l=qn(a,t,r,d,n.signal);Un(e,l,n.signal);let g=Bn(a,l,n.signal);return Gn(g,l,n.signal),Hn(a,l,s,r,o,i,d,n.signal),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ccb7d865-8baa-5379-a810-7be494eadcb1")}catch{}})();function N(){return{nodes:0,isolated:0,degree_leq_one:0,semantic_nodes:0,without_semantic_edges:0,degree_histogram:{}}}function pt(e,t,n,r){let i={all:N(),active:N(),terminal:N()},o=new Map;for(let s of e.details){if(r?.throwIfAborted(),e.missingIdSet.has(s.id.toLowerCase())||s.status==="external")continue;let a=o.get(s.status)??N();o.set(s.status,a);let c=e.graph.incidentEdges(s.id),d=c.some(l=>n(l.kind));for(let l of[i.all,i[t(s.status)?"terminal":"active"],a]){l.nodes+=1,l.isolated+=+(c.length===0),c.length<=1&&(l.degree_leq_one+=1),d?l.semantic_nodes+=1:l.without_semantic_edges+=1;let g=String(c.length);l.degree_histogram[g]=(l.degree_histogram[g]??0)+1}}return{coverage_by_lifecycle:i,coverage_by_status:Object.fromEntries([...o].sort(([s],[a])=>s.localeCompare(a)))}}function gt(e){if(!J(e))return!1;let t=e;if(!["nodes","isolated","degree_leq_one","semantic_nodes","without_semantic_edges"].every(r=>Number.isSafeInteger(t[r])&&Number(t[r])>=0)||!J(t.degree_histogram))return!1;let n=Object.entries(t.degree_histogram);return n.every(([r,i])=>/^(0|[1-9]\d*)$/.test(r)&&Number.isSafeInteger(i)&&Number(i)>=0)&&n.reduce((r,[,i])=>r+Number(i),0)===t.nodes&&Number(t.isolated)<=Number(t.degree_leq_one)&&Number(t.degree_leq_one)<=Number(t.nodes)&&Number(t.semantic_nodes)+Number(t.without_semantic_edges)===t.nodes}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ht(e){for(let r of["ordering_acyclic","active_ordering_acyclic"])if(e[r]!==void 0&&typeof e[r]!="boolean")return!1;let t=e.coverage_by_lifecycle,n=e.coverage_by_status;return t===void 0&&n===void 0?!0:!J(t)||!J(n)?!1:["all","active","terminal"].every(r=>gt(t[r]))&&Object.values(n).every(gt)}function ft(e,t){return Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].sort().map(n=>{let r=Object.hasOwn(e,n)?e[n]:N(),i=Object.hasOwn(t,n)?t[n]:N(),o=Object.fromEntries([...new Set([...Object.keys(r.degree_histogram),...Object.keys(i.degree_histogram)])].sort().map(s=>[s,(i.degree_histogram[s]??0)-(r.degree_histogram[s]??0)]));return[n,{nodes:i.nodes-r.nodes,isolated:i.isolated-r.isolated,degree_leq_one:i.degree_leq_one-r.degree_leq_one,semantic_nodes:i.semantic_nodes-r.semantic_nodes,without_semantic_edges:i.without_semantic_edges-r.without_semantic_edges,degree_histogram:o}]}))}function mt(e,t){return!e.coverage_by_lifecycle||!t.coverage_by_lifecycle||!e.coverage_by_status||!t.coverage_by_status?{lifecycle_comparable:!1}:{lifecycle_comparable:!0,coverage_by_lifecycle:ft(e.coverage_by_lifecycle,t.coverage_by_lifecycle),coverage_by_status:ft(e.coverage_by_status,t.coverage_by_status)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="896e1553-b127-532f-ac39-e0d47f29eebc")}catch{}})();var A=["missing_reference_active","missing_reference_terminal","legacy_no_blocker_sentinel","ordering_cycle","legacy_ordering_cycle","ordering_storage_contradiction","legacy_ordering_storage_contradiction","hierarchy_cycle","legacy_hierarchy_cycle","hierarchy_cardinality_violation","legacy_hierarchy_cardinality_violation","hierarchy_direction_violation","legacy_hierarchy_direction_violation","duplicate_edge","legacy_duplicate_edge","duplicate_dependency_row","legacy_duplicate_dependency_row","stale_lifecycle_block","isolated_active_node","sparse_active_node"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34b2e83e-f6a1-57e7-84ee-4ad83acb2e19")}catch{}})();var Kn=25,Vn="milestone",Wn="outcome milestone:",Yn=new Set(["discovered_from","incident_from","recurs_from","supersedes","verifies"]);function Q(e){return Yn.has(e)}var _t={error:0,warning:1,info:2};function yt(e){return new Set((e??[]).filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()))}function R(e,t,n,r,i,o,s,a){let c=[...i].sort((d,l)=>d.localeCompare(l));return{code:e,severity:t,policy:n,message:r(c.length),count:c.length,sample:c.slice(0,o),sample_truncated:c.length>o,remediation:s,...a===void 0?{}:{evidence:[...a].sort((d,l)=>d.localeCompare(l)).slice(0,o)}}}function Xn(e,t){return e.cycles.map(n=>R(n.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",n.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",r=>`${r} items participate in one hierarchy cycle.`,n.item_ids,t,n.legacy_terminal?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove or retype one exact hierarchy relation before continuing mutation."))}function bt(e,t,n){let r=e.cardinality_violations.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[R(n?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",n?"info":"error","Every structural child must resolve to at most one logical parent across all hierarchy spellings.",i=>`${i} child item${i===1?"":"s"} resolve to multiple hierarchy parents.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",r.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function vt(e,t,n){let r=e.divergences.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[R(n?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",n?"info":"error","Scalar parent metadata and dependency-backed hierarchy rows must resolve to the same logical parent.",i=>`${i} child item${i===1?"":"s"} have divergent hierarchy storage surfaces.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",r.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function Jn(e,t){let n=G(e);return n?[...Xn(n,t),...bt(n,t,!1),...bt(n,t,!0),...vt(n,t,!1),...vt(n,t,!0)]:[]}function Qn(e){let t=e.graph.registry(),n=new Map;for(let r of e.graph.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let[o,s]=(i.precedence??"source_before_target")==="target_before_source"?[r.target,r.source]:[r.source,r.target],a=n.get(o);a?a.push(s):n.set(o,[s])}for(let r of n.values())r.sort((i,o)=>i.localeCompare(o));return n}function kt(e,t){t.indexes.set(e,t.nextIndex),t.lowLinks.set(e,t.nextIndex),t.nextIndex+=1,t.stack.push(e),t.onStack.add(e)}function Zn(e,t,n,r){let i=n.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let o=i[e.neighborIndex];return e.neighborIndex+=1,r.indexes.has(o)?r.onStack.has(o)&&r.lowLinks.set(e.node,Math.min(r.lowLinks.get(e.node),r.indexes.get(o))):(kt(o,r),t.push({node:o,neighborIndex:0})),!0}function er(e,t,n,r){t.pop();let i=t.at(-1);if(i&&r.lowLinks.set(i.node,Math.min(r.lowLinks.get(i.node),r.lowLinks.get(e.node))),r.lowLinks.get(e.node)!==r.indexes.get(e.node))return;let o=[];for(;;){let s=r.stack.pop();if(r.onStack.delete(s),o.push(s),s===e.node)break}(o.length>1||o.length===1&&n.get(o[0])?.includes(o[0]))&&r.components.push(o.sort((s,a)=>s.localeCompare(a)))}function tr(e){let t={indexes:new Map,lowLinks:new Map,onStack:new Set,stack:[],components:[],nextIndex:0},n=[...e.keys()].sort((r,i)=>r.localeCompare(i));for(let r of n){if(t.indexes.has(r))continue;let i=[{node:r,neighborIndex:0}];for(kt(r,t);i.length>0;){let o=i.at(-1);Zn(o,i,e,t)||er(o,i,e,t)}}return t.components.sort((r,i)=>r[0].localeCompare(i[0]))}function ce(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function y(e,t,n,r,i,o,s,a){t.length!==0&&e.push(R(r,i,o,s,t,n,a))}function nr(e,t,n){let r=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(o=>!o.no_active_blocker_sentinel);return y(r,i.filter(o=>!t(o.holder_status)).map(ce),n,"missing_reference_active","error","Active items must not reference absent targets; missing prerequisites distort scheduling.",o=>`${o} active dangling reference(s) to absent items`,"Restore or re-create the referenced item, or remove/retype the reference on the holder."),y(r,i.filter(o=>t(o.holder_status)).map(ce),n,"missing_reference_terminal","info","Terminal items may retain historical references, but absent targets remain unexplainable context.",o=>`${o} terminal dangling reference(s) to absent items`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),y(r,e.dangling.no_active_blocker_sentinels.map(ce),n,"legacy_no_blocker_sentinel","info","The pre-structured-dependency no-active-blocker sentinel is retired; real edges carry blocker state.",o=>`${o} legacy no-active-blocker sentinel reference(s)`,"Delete the sentinel reference; blocker state is derived from blocked_by edges."),r}function le(e,t){let n=t.get(e);return n?!n.terminal:!0}function It(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function rr(e,t){let n=[],r=[];for(let o of e.orderingContradictions??[])(o.legacy_terminal?r:n).push(It(o));let i=[];return y(i,n,t,"ordering_storage_contradiction","error","A scalar blocker and same-target structured ordering row must not assert opposite precedence.",o=>`${o} active scalar-versus-structured ordering contradiction(s)`,"Remove the structured dependency row that points the holder before its scalar blocker, or replace both representations with one unambiguous ordering edge."),y(i,r,t,"legacy_ordering_storage_contradiction","info","Terminal scalar-versus-structured ordering contradictions are exact historical storage defects with no live scheduling effect.",o=>`${o} terminal scalar-versus-structured ordering contradiction(s)`,"Remove the contradictory blocks dependency row in a dedicated changelog-safe closed-item batch; preserve the scalar blocker as the historical precedence record."),i}function ir(e,t,n,r){let i=[],o=Qn(e);for(let c of tr(o)){let d=c.some(u=>le(u,t)),l=new Set(c.map(u=>u.toLowerCase())),g=(e.orderingContradictions??[]).filter(u=>l.has(u.holder_id.toLowerCase())&&l.has(u.target_id.toLowerCase())).map(It);i.push(d?R("ordering_cycle","error","Order-bearing relationship kinds must stay acyclic; a cycle makes every member unschedulable.",u=>`execution-order cycle across ${u} item(s)`,c,r,"Remove or retype one ordering edge inside the cycle, or split the work so precedence is linear.",g.length===0?void 0:g):R("legacy_ordering_cycle","info","Ordering cycles between exclusively terminal items are historical contradictions with no scheduling effect.",u=>`terminal-only execution-order cycle across ${u} item(s)`,c,r,"Leave as history debt, or clean up in a dedicated changelog-safe closed-item batch; never repair closed items ad hoc.",g.length===0?void 0:g))}let s=new Map;for(let[c,d]of o)for(let l of d){let g=s.get(l);g?g.push(c):s.set(l,[c])}let a=[...t.values()].filter(c=>!c.missing&&!c.terminal&&n(c.status)&&!(s.get(c.id)??[]).some(d=>{let l=t.get(d);return l===void 0||!l.terminal})).map(c=>c.id);return y(i,a,r,"stale_lifecycle_block","warning","A blocked lifecycle status must be backed by at least one open ordering predecessor.",c=>`${c} status-blocked item(s) with no open blocker edge`,'Add a local blocker edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status.'),i}function Z(e){let t=e.edges.map(n=>n.kind).sort((n,r)=>n.localeCompare(r));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function ue(e){let t=e.graph.registry(),n=new Map;for(let i of e.graph.edges()){let o=t.require(i.kind);if(!W(o))continue;let s=ae(i,o);if(s.from===s.to)continue;let a=`${Y(o)}::${s.from}::${s.to}`,c=n.get(a);c?c.edges.push(i):n.set(a,{...s,edges:[i]})}let r=[...n.values()].filter(i=>i.edges.length>=2);for(let i of r)i.edges.sort((o,s)=>o.kind.localeCompare(s.kind));return r.sort((i,o)=>i.from.localeCompare(o.from)||i.to.localeCompare(o.to))}function or(e,t,n){let r=[],i=[];for(let s of ue(e))(le(s.from,t)||le(s.to,t)?r:i).push(Z(s));let o=[];return y(o,r,n,"duplicate_edge","info","One semantic relationship should be stored once; parallel same-family spellings (reciprocal inverse pairs included) add no information and skew degree metrics.",s=>`${s} duplicated relationship(s) between active endpoints`,"Remove all but one stored spelling of the relationship; keep the canonical direction the holder declared first."),y(o,i,n,"legacy_duplicate_edge","info","Duplicated spellings between exclusively terminal items are historical noise with no scheduling effect.",s=>`${s} duplicated relationship(s) between terminal endpoints`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),o}function sr(e,t){let n=[],r=[];for(let o of e.duplicateRows??[])(o.legacy_terminal?r:n).push(`${o.holder_id} -> ${o.target_id} (${o.kind} x${o.occurrences})`);let i=[];return y(i,n,t,"duplicate_dependency_row","warning","One dependency row must be stored once per holder; identical repeated rows are a storage-layer defect invisible to the assembled graph.",o=>`${o} exactly duplicated stored dependency row(s) on active holder(s)`,"Remove the repeated rows so the dependency is stored exactly once; graph semantics are unchanged."),y(i,r,t,"legacy_duplicate_dependency_row","info","Identical repeated dependency rows on terminal holders are historical storage noise with no scheduling effect.",o=>`${o} exactly duplicated stored dependency row(s) on terminal holder(s)`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),i}function ar(e,t){let n=new Map,r={source_to_target:[],target_to_source:[],both:[]};for(let s of e.graph.registry().list())s.outcomeTraversal!==void 0&&r[s.outcomeTraversal].push(s.kind);let i={source_to_target:r.source_to_target.join(","),target_to_source:r.target_to_source.join(","),both:r.both.join(",")},o=(s,a)=>{let c=n.get(a)??new Set;c.add(s),n.set(a,c)};for(let s of e.graph.edges()){t?.throwIfAborted();let a=e.graph.registry().require(s.kind);(a.outcomeTraversal==="source_to_target"||a.outcomeTraversal==="both")&&o(s.source,s.target),(a.outcomeTraversal==="target_to_source"||a.outcomeTraversal==="both")&&o(s.target,s.source)}return{basis:i,reverse:n}}function cr(e,t,n){let r=new Set(e),i=[...e].sort();for(let o=0;o<i.length;o+=1){n?.throwIfAborted();for(let s of[...t.get(i[o])??[]].sort())r.has(s)||(r.add(s),i.push(s))}return r}function dr(e,t,n,r){let i=0,o=0,s=0,a=0;for(let f of e.values())if(r?.throwIfAborted(),!t.has(f.id)&&!(f.missing||f.status==="external")){if(f.terminal){s+=1,n.has(f.id)&&(a+=1);continue}n.has(f.id)?i+=1:o+=1}let c=i+o,d=s-a,l=i+a,g=o+d,u=l+g;return{active_outcome_reachable_nodes:i,active_outcome_unreachable_nodes:o,active_outcome_reachability_basis_points:c===0?0:Math.floor(i*1e4/c),terminal_nodes:s,terminal_outcome_reachable_nodes:a,terminal_outcome_unreachable_nodes:d,terminal_outcome_reachability_basis_points:s===0?0:Math.floor(a*1e4/s),outcome_reachable_nodes:l,outcome_unreachable_nodes:g,outcome_reachability_basis_points:u===0?0:Math.floor(l*1e4/u)}}function lr(e,t,n){let r=new Set(e.details.filter(a=>a.type?.toLowerCase()===Vn&&a.title.trim().toLowerCase().startsWith(Wn)).map(a=>a.id)),{basis:i,reverse:o}=ar(e,n),s=cr(r,o,n);return{outcome_nodes:r.size,outcome_reachability_basis:i,...dr(t,r,s,n)}}function ur(e,t,n,r,i){e.active+=1;let o=t.type??"(untyped)",s=e.byType.get(o);s||(s={active:0,isolated:0,degree_leq_one:0},e.byType.set(o,s)),s.active+=1,!(n>1)&&(e.degreeLeqOne+=1,s.degree_leq_one+=1,n===0&&(e.isolated+=1,s.isolated+=1),!(r.has(t.id.toLowerCase())||i.has(o.toLowerCase()))&&(n===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function gr(e,t,n,r,i,o,s){let a={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let h of e.graph.nodes()){s?.throwIfAborted();let _=t.get(h);if(_){if(_.missing){a.missing+=1;continue}_.terminal||ur(a,_,e.graph.incidentEdges(h).length,n,r)}}let{isolates:c,sparse:d}=a,l=[];y(l,c,i,"isolated_active_node","warning","Active work should be reachable from the graph unless explicitly declared a valid isolate.",h=>`${h} active item(s) with no relationships`,"Link the item to its parent, prerequisite, or origin \u2014 or register it as an exempt isolate."),y(l,d,i,"sparse_active_node","info","Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.",h=>`${h} active item(s) with exactly one relationship`,"Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");let g=e.graph.edges().length,u=T(e.graph,{signal:s}).value,f=new Set(u.map(({edge:h})=>`${h.source.toLowerCase()}\0${h.target.toLowerCase()}\0${h.kind}`));for(let h of e.orderingContradictions??[])f.add(`${h.holder_id.toLowerCase()}\0${h.target_id.toLowerCase()}\0${h.dependency_kind}`);let p=Object.fromEntries(Object.entries(o).sort(([h],[_])=>h.localeCompare(_))),m=Object.entries(p).reduce((h,[_,E])=>h+(Q(_)?E:0),0),b=X(e.graph,{signal:s}).value,v=lr(e,t,s);return{findings:l,profile:{nodes:e.graph.nodes().length,recorded_nodes:e.details.filter(h=>h.status!=="missing"&&h.status!=="external").length,edges:g,informative_edges:g-f.size,redundant_edges:u.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:p,edge_share_by_kind:Object.fromEntries(Object.entries(p).map(([h,_])=>[h,_/g])),semantic_edges:m,semantic_edge_share:g===0?0:m/g,active_nodes:a.active,missing_nodes:a.missing,isolated_active_nodes:a.isolated,degree_leq_one_active_nodes:a.degreeLeqOne,coverage_by_type:Object.fromEntries([...a.byType.entries()].sort(([h],[_])=>h<_?-1:1)),articulation_points:b.articulationPoints.length,bridge_edges:b.bridges.length,...v,finding_subjects_by_code:Object.fromEntries(A.map(h=>[h,0]))}}}function ee(e,t={}){let n=t.isTerminal??(u=>u==="closed"||u==="canceled"),r=t.isBlocked??(u=>u==="blocked"),i=t.maxSampleSize??Kn;if(!Number.isInteger(i)||i<1)throw new TypeError(`Invalid audit sample bound: ${String(t.maxSampleSize)}`);let o=yt(t.exemptIsolates),s=yt(t.isolateExemptTypes),a=new Map(e.details.map(u=>[u.id,{id:u.id,status:u.status,missing:e.missingIdSet.has(u.id.toLowerCase()),terminal:n(u.status),...u.type===void 0?{}:{type:u.type}}]));t.signal?.throwIfAborted();let c={};for(let u of e.graph.edges())c[u.kind]=(c[u.kind]??0)+1;let d=nr(e,n,i);d.push(...Jn(e,i)),t.signal?.throwIfAborted(),d.push(...rr(e,i)),t.signal?.throwIfAborted(),d.push(...ir(e,a,r,i)),t.signal?.throwIfAborted(),d.push(...or(e,a,i),...sr(e,i)),t.signal?.throwIfAborted();let l=gr(e,a,o,s,i,c,t.signal);d.push(...l.findings),d.sort((u,f)=>_t[u.severity]-_t[f.severity]||u.code.localeCompare(f.code)||u.sample[0].localeCompare(f.sample[0]));let g=l.profile.finding_subjects_by_code;for(let u of d)g[u.code]+=u.count;return{findings:d,profile:{...l.profile,...pt(e,n,Q,t.signal),ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"||u.code==="legacy_ordering_cycle"),active_ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"),finding_subjects_by_code:g}}}function de(e,t){let n=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),r={};for(let i of n){let o=(t[i]??0)-(e[i]??0);o!==0&&(r[i]=o)}return r}function wt(e){return e.profile.coverage_by_type??{}}function fr(e,t){let n={},r=wt(e),i=wt(t),o=[...new Set([...Object.keys(r),...Object.keys(i)])].sort();for(let s of o){let a=Object.assign({active:0,isolated:0,degree_leq_one:0},r[s]),c=Object.assign({active:0,isolated:0,degree_leq_one:0},i[s]),d={active:c.active-a.active,isolated:c.isolated-a.isolated,degree_leq_one:c.degree_leq_one-a.degree_leq_one};Object.values(d).some(l=>l!==0)&&(n[s]=d)}return n}function xt(e,t){let n=fr(e,t),{edge_share_by_kind:r={},semantic_edges:i=0,semantic_edge_share:o=0}=e.profile,{edge_share_by_kind:s={},semantic_edges:a=0,semantic_edge_share:c=0}=t.profile,d=e.profile.recorded_nodes??e.profile.nodes,l=t.profile.recorded_nodes??t.profile.nodes,g=e.profile.informative_edges??e.profile.edges,u=t.profile.informative_edges??t.profile.edges,f=e.profile.redundant_edges??0,p=t.profile.redundant_edges??0,m=e.profile.ordering_contradiction_edges??0,b=t.profile.ordering_contradiction_edges??0;return{baseline_saved_at:e.saved_at,same_snapshot:e.fingerprint===t.fingerprint,affected_subjects_by_code:de(e.affected_subjects_by_code,t.affected_subjects_by_code),profile:{nodes:t.profile.nodes-e.profile.nodes,recorded_nodes:l-d,edges:t.profile.edges-e.profile.edges,informative_edges:u-g,redundant_edges:p-f,ordering_contradiction_edges:b-m,active_nodes:t.profile.active_nodes-e.profile.active_nodes,missing_nodes:t.profile.missing_nodes-e.profile.missing_nodes,isolated_active_nodes:t.profile.isolated_active_nodes-e.profile.isolated_active_nodes,degree_leq_one_active_nodes:t.profile.degree_leq_one_active_nodes-e.profile.degree_leq_one_active_nodes,edges_by_kind:de(e.profile.edges_by_kind,t.profile.edges_by_kind),edge_share_by_kind:de(r,s),semantic_edges:a-i,semantic_edge_share:c-o,coverage_by_type:n,...mt(e.profile,t.profile)}}}import Et from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e5089f2d-3fc5-5843-95ab-ba3dd2ab9582")}catch{}})();var St=2,ge=500,pr=64,hr="graph-durable-cache";function Ct(e){return Re(e,hr,30,`graph-cache:${process.pid}`,!1,!1,3e3)}function F(e){return Et.join(e,"runtime","graph-cache.json")}function Dt(e){return Et.join(e,"runtime","graph-audit-baseline.json")}function fe(e){if(e!==null)try{let t=JSON.parse(e);return typeof t!="object"||t===null||t.version!==St||typeof t.fingerprint!="string"||typeof t.saved_at!="string"||typeof t.results!="object"||t.results===null||Array.isArray(t.results)?void 0:t}catch{return}}async function pe(e,t){let n=await j(F(e)),r=fe(n),i=r?.fingerprint===t;return{exists:n!==null,fresh:i,results:i?r.results:{}}}async function he(e,t,n,r,i){let o=await Ct(e);try{let s=fe(await j(F(e))),a=s?.fingerprint===t?s.results:{};delete a[r],a[r]=i;let c=Object.keys(a);for(let d of c.slice(0,Math.max(0,c.length-pr)))delete a[d];await re(F(e),JSON.stringify({version:St,fingerprint:t,saved_at:new Date().toISOString(),results:a})),n.results=a}finally{await o()}}async function me(e){let t=await Ct(e);try{await Ie(F(e))}finally{await t()}}async function Tt(e,t){let n=F(e),r=await j(n),i=fe(r);return i===void 0?{exists:r!==null,fresh:!1,entry_count:0}:{exists:!0,fresh:i.fingerprint===t,entry_count:Object.keys(i.results).length,fingerprint:i.fingerprint.slice(0,12),saved_at:i.saved_at,bytes:Buffer.byteLength(r,"utf8")}}function _e(e,t){return t||e>=ge}function te(e){return O(e)&&Object.values(e).every(x)}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function x(e){return Number.isInteger(e)&&Number(e)>=0}function Nt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function L(e,t){return e===void 0||t(e)}function mr(e){return O(e)&&Object.values(e).every(Nt)}function _r(e){return O(e)?Object.values(e).every(t=>O(t)&&[t.active,t.isolated,t.degree_leq_one].every(x)):!1}function yr(e,t,n){let r=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=r.filter(s=>e[s]!==void 0).length;if(i!==0&&i!==r.length||!r.every(s=>L(e[s],x)))return;let o={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??n,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return o.recorded_nodes<=t&&o.informative_edges<=n&&o.redundant_edges<=n&&o.ordering_contradiction_edges<=n?o:void 0}function br(e,t,n){let r=[...t,...n,"finding_subjects_by_code"],i=r.filter(o=>e[o]!==void 0).length;return i!==0&&i!==r.length?!1:t.every(o=>L(e[o],x))&&n.every(o=>L(e[o],x)&&(e[o]===void 0||Number(e[o])<=1e4))&&L(e.finding_subjects_by_code,te)}function vr(e,t,n,r){let i=yr(e,n,r);if(i===void 0)return;let o=["articulation_points","bridge_edges","outcome_nodes","active_outcome_reachable_nodes","active_outcome_unreachable_nodes","terminal_nodes","terminal_outcome_reachable_nodes","terminal_outcome_unreachable_nodes","outcome_reachable_nodes","outcome_unreachable_nodes"],s=["active_outcome_reachability_basis_points","terminal_outcome_reachability_basis_points","outcome_reachability_basis_points"];if(!br(e,o,s)||e.edge_basis!==void 0&&e.edge_basis!=="deduplicated_directed")return;let a=te(e.finding_subjects_by_code)?e.finding_subjects_by_code:{};return{edge_basis:"deduplicated_directed",...i,...Object.fromEntries(o.map(c=>[c,e[c]??0])),...Object.fromEntries(s.map(c=>[c,e[c]??0])),finding_subjects_by_code:Object.fromEntries(A.map(c=>[c,a[c]??t[c]??0]))}}function wr(e,t,n,r,i){let o=[n,r,i],s=o.filter(d=>d!==void 0).length;if(s===0)return{edge_share_by_kind:{},semantic_edges:0,semantic_edge_share:0};if(s!==o.length||!mr(n)||!x(r)||!Nt(i))return;let a=Object.entries(t);if(a.reduce((d,[,l])=>d+l,0)!==e||Object.keys(n).length!==a.length||a.some(([d,l])=>n[d]!==(e===0?0:l/e)))return;let c=a.reduce((d,[l,g])=>d+(Q(l)?g:0),0);if(!(r!==c||i!==(e===0?0:c/e)))return{edge_share_by_kind:n,semantic_edges:r,semantic_edge_share:i}}function kr(e){if(e!==null)try{let t=JSON.parse(e);if(!O(t))return;let n=t,r=n.profile;if(typeof n.saved_at!="string"||typeof n.fingerprint!="string")return;let i=n.affected_subjects_by_code;if(!te(i)||!O(r)||!ht(r)||![r.nodes,r.edges,r.active_nodes,r.missing_nodes,r.isolated_active_nodes,r.degree_leq_one_active_nodes].every(x)||!te(r.edges_by_kind)||!L(r.coverage_by_type,_r))return;let o=wr(r.edges,r.edges_by_kind,r.edge_share_by_kind,r.semantic_edges,r.semantic_edge_share);if(o===void 0)return;let s=vr(r,i,r.nodes,r.edges);if(s===void 0)return;let{coverage_by_type:a={}}=r;return{...n,profile:{...r,...o,...s,coverage_by_type:a}}}catch{return}}async function At(e){return kr(await j(Dt(e)))}async function Rt(e,t){await re(Dt(e),JSON.stringify(t))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="253f392d-4e91-57ec-b656-6134583d57e5")}catch{}})();var Ir={missing_reference_active:{op:"investigate",confidence:"medium",rationale:"Restore or re-create the referenced item, or remove/retype the reference on the active holder; the correct fix depends on why the target is absent."},missing_reference_terminal:{op:"waive",confidence:"high",rationale:"Terminal-holder reference to an absent item is historical debt; waive it or clean it up only in a dedicated changelog-safe closed-item batch."},legacy_no_blocker_sentinel:{op:"remove",confidence:"high",rationale:"The pre-structured-dependency no-active-blocker sentinel is retired and carries no information; blocker state derives from blocked_by edges."},ordering_cycle:{op:"investigate",confidence:"low",rationale:"Every cycle member is unschedulable until one ordering edge is removed or retyped; the planner never chooses which edge to cut."},legacy_ordering_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only ordering cycles have no scheduling effect; repairing them would mutate closed history (changelog drag)."},ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The structured ordering row asserts the opposite precedence from the same-target scalar blocker; remove that exact dependency row or replace both representations with one unambiguous edge."},legacy_ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The terminal holder contains a proven contradictory structured ordering row; remove it in a dedicated changelog-safe batch while preserving the scalar blocker as history."},hierarchy_cycle:{op:"investigate",confidence:"low",rationale:"Cut or retype one exact structural relation in the cycle; the planner preserves every evidence row because intent determines the correct parent."},legacy_hierarchy_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only hierarchy cycles are historical debt; waive them unless an explicit closed-history repair is approved."},hierarchy_cardinality_violation:{op:"investigate",confidence:"medium",rationale:"Choose the canonical parent and remove or retype the exact surplus hierarchy rows; the planner cannot infer ownership intent."},legacy_hierarchy_cardinality_violation:{op:"waive",confidence:"high",rationale:"Multiple parents confined to terminal items are historical debt; waive them unless a dedicated history repair is approved."},hierarchy_direction_violation:{op:"investigate",confidence:"medium",rationale:"Align the scalar parent and dependency-backed hierarchy rows to the intended canonical parent."},legacy_hierarchy_direction_violation:{op:"waive",confidence:"high",rationale:"Divergent hierarchy storage confined to terminal items is historical debt; waive it unless a dedicated history repair is approved."},duplicate_edge:{op:"remove",confidence:"high",rationale:"Parallel same-family spellings state one relationship twice; remove all but one stored spelling, keeping the holder's canonical direction."},legacy_duplicate_edge:{op:"waive",confidence:"high",rationale:"Duplicated spellings between terminal items are historical noise; waive or batch changelog-safe cleanup."},duplicate_dependency_row:{op:"remove",confidence:"high",rationale:"The identical dependency row is stored more than once on the holder; drop the repeats so the row exists exactly once \u2014 graph semantics are unchanged."},legacy_duplicate_dependency_row:{op:"waive",confidence:"high",rationale:"Repeated identical rows on terminal holders are storage noise; waive or clean up only in a changelog-safe closed-item batch."},stale_lifecycle_block:{op:"investigate",confidence:"medium",rationale:`Add a local ordering edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status; only the holder's owner knows which is true.`},isolated_active_node:{op:"investigate",confidence:"medium",rationale:"Link the item to its parent, prerequisite, or origin \u2014 or register it as an explicitly exempt isolate; the audit never fabricates an edge."},sparse_active_node:{op:"investigate",confidence:"low",rationale:"Investigate for an honest second edge (story-to-task, defect family, cross-epic complement); sparse is not automatically defective."}};function Ot(e){return`${e.source} -${e.kind}-> ${e.target}`}function xr(e){let[t,...n]=e.edges;return n.map(r=>({op:"remove",code:"duplicate_edge",subject:Ot(r),rationale:"This stored spelling restates the kept canonical edge of the same semantic family; removing it leaves the relationship stated exactly once.",evidence:[`keep: ${Ot(t)}`,`group: ${Z(e)}`],confidence:"high"}))}function Er(e,t){if(e.code==="duplicate_edge")return e.sample.flatMap(r=>xr(t.get(r)));let n=Ir[e.code];return e.sample.map(r=>({op:n.op,code:e.code,subject:r,rationale:n.rationale,evidence:[e.policy],confidence:n.confidence}))}function jt(e,t={}){let{redundancyLimit:n,...r}=t,i=ee(e,r),o=new Map(ue(e).map(d=>[Z(d),d])),s=i.findings.flatMap(d=>Er(d,o)),a=i.findings.some(d=>d.sample_truncated);t.signal?.throwIfAborted();let c=T(e.graph,{limit:n??t.maxSampleSize??25,...t.signal===void 0?{}:{signal:t.signal}});for(let d of c.value)s.push({op:"remove",code:"redundant_edge",subject:`${d.edge.source} -> ${d.edge.target} (${d.edge.kind})`,rationale:"The stored edge is implied by a longer same-family witness path; shortcut edges are sometimes deliberate emphasis, so confirm intent before removing.",evidence:[`witness: ${d.witness.join(" -> ")}`],confidence:"medium"});return a=a||c.meta.truncated,{steps:s,report:i,truncated:a,cost:{visitedNodes:c.meta.visitedNodes,inspectedEdges:c.meta.inspectedEdges}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="66df3949-0caf-5f01-8cec-3bba3d1e6111")}catch{}})();var Ft=new Set(["ancestors","descendants","predecessors","successors","paths","impact","dominators"]);function Mt(e,t,n){let r=e;if(t&&e.subcommand==="audit"){let{nodes:i,recorded_nodes:o,edges:s,active_nodes:a,terminal_nodes:c,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:g,coverage_by_lifecycle:u}=e.profile,f=Object.fromEntries(Object.entries(u).map(([p,m])=>{let{degree_histogram:b,...v}=m;return[p,v]}));r={...e,profile:{nodes:i,recorded_nodes:o,edges:s,active_nodes:a,terminal_nodes:c,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:g,coverage_by_lifecycle:f}}}return{...r,projection:{mode:t?"summary":"full",declared_field_groups:n===void 0?[]:[{name:n,restore_with:"--full"}],included_field_groups:n===void 0||t?[]:[n]}}}function Sr(e,t,n,r){return{assembly:t,...n===void 0?{}:{kinds:n},maxDepth:Ue(r.maxDepth),limit:e==="impact"&&Number(r.limit)===0?0:$(r.limit,"limit")??(r.full===!0?Number.MAX_SAFE_INTEGER:I.rows),after:r.after?.trim()||void 0,direction:Be(r.direction),maxPaths:$(r.maxPaths,"max-paths"),sample:$(r.sample,"sample")??I.samples,exemptIsolates:Pt(r.exemptIsolate),exemptIsolateTypes:Pt(r.exemptIsolateType),saveBaseline:r.saveBaseline===!0,summary:r.summary===!0,unbounded:r.full===!0}}function Pt(e){return e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",")).map(t=>t.trim()).filter(t=>t.length>0)}function Cr(e,t,n){let r=e.trim().toLowerCase();if(!ie.includes(r))throw Me({command_path:"graph",token:r||"<empty>",allowed:ie});let i=r;if(Ft.has(i)&&!t?.trim())throw new k(`graph ${i} requires an item id.`,w.USAGE);if(i==="paths"&&!n?.trim())throw new k("graph paths requires a source and a target item id.",w.USAGE);return i}function ye(e){throw e instanceof TypeError?new k(e.message,w.USAGE):e}function be(e){return{truncated:e.truncated,cost:{visited_nodes:e.visitedNodes,inspected_edges:e.inspectedEdges}}}function Lt(e,t){let n=t.trim().toLowerCase();for(let r of e.details)if(r.id.trim().toLowerCase()===n&&!e.missingIdSet.has(r.id.toLowerCase()))return r.id;throw new k(`Item ${t} not found`,w.NOT_FOUND)}function Dr(e,t,n){let r={ancestors:Qe,descendants:Ze,predecessors:et,successors:tt}[e],i;try{i=r(n.assembly.graph,t,{...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},limit:n.limit,...n.after===void 0?{}:{after:n.after}})}catch(s){ye(s)}let o=be(i.meta);return{subcommand:e,root:t,count:i.value.length,...o,...i.meta.nextCursor===void 0?{}:{next_cursor:i.meta.nextCursor},...n.summary?{}:{ids:i.value}}}function Tr(e,t,n){let r=nt(n.assembly.graph,e,t,{direction:n.direction,...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},...n.maxPaths===void 0?{}:{maxPaths:n.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:n.direction,count:r.value.length,...be(r.meta),...n.summary?{}:{paths:r.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(o=>o.kind),length:i.length}))}}}function Nr(e,t){let n;try{n=U(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth},...t.unbounded?{}:{limit:t.limit},...t.after===void 0?{}:{after:t.after}})}catch(r){ye(r)}return{subcommand:"impact",root:e,direction:t.direction,count:n.affected.length,truncated:n.truncated,...n.nextCursor===void 0?{}:{next_cursor:n.nextCursor},cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...t.summary?{}:{affected:n.affected}}}function Ar(e,t,n){return{acyclic:e.acyclic,ordered_node_count:e.order.length,layer_count:e.layers.length,frontier_count:e.frontier.length,critical_path_length:e.criticalPathLength,cycle_count:e.cycles.length,...t?{}:{frontier:e.frontier.slice(0,n),critical_path:e.criticalPath.slice(0,n),cycles:e.cycles.slice(0,n)}}}function Rr(e,t,n){return{component_count:e.components.length,largest_component_size:e.components[0]?.length??0,orphan_count:e.orphans.length,...t?{}:{orphans:e.orphans.slice(0,n),hubs:e.hubs.slice(0,n)}}}function Or(e,t,n){let r=0,i=0,o=0;for(let s of e.cycles)r+=Number(s.legacy_terminal);for(let s of e.cardinality_violations)i+=Number(s.legacy_terminal);for(let s of e.divergences)o+=Number(s.legacy_terminal);return{acyclic:e.cycles.length===0,relation_count:e.relations.length,cycle_count:e.cycles.length,active_cycle_count:e.cycles.length-r,legacy_cycle_count:r,cardinality_violation_count:e.cardinality_violations.length,active_cardinality_violation_count:e.cardinality_violations.length-i,legacy_cardinality_violation_count:i,parent_divergence_count:e.divergences.length,active_parent_divergence_count:e.divergences.length-o,legacy_parent_divergence_count:o,...t?{}:{cycles:e.cycles.slice(0,n).map(s=>s.item_ids)}}}function jr(e){let t=e.assembly.graph,n=e.limit,r=B(t,{registry:t.registry()}),i=Ye(t);return{subcommand:"analyze",node_count:t.nodes().length,edge_count:t.edges().length,edge_basis:"deduplicated_directed",sample_limit:n,execution:Ar(r,e.summary,n),knowledge:Rr(i,e.summary,n),hierarchy:Or(G(e.assembly),e.summary,n)}}function Mr(e,t){let n=ee(e.assembly,{isTerminal:t,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),r={},i={},o={},s={};for(let d of n.findings)r[d.severity]=(r[d.severity]??0)+1,i[d.code]=(i[d.code]??0)+1,o[d.severity]=(o[d.severity]??0)+d.count,s[d.code]=(s[d.code]??0)+d.count;let{finding_subjects_by_code:a,...c}=n.profile;return{subcommand:"audit",truncated:n.findings.length>e.limit,finding_count:n.findings.length,findings_by_severity:r,findings_by_code:i,affected_subjects_by_severity:o,affected_subjects_by_code:s,profile:e.summary?c:n.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:n.findings.slice(0,e.limit)}}}function Pr(e){let t=e.limit,n={};e.kinds!==void 0&&(n.kinds=e.kinds);let r=it(e.assembly.graph,n),i=r.value;return{subcommand:"communities",community_count:i.communities.length,largest_community_size:i.communities[0]?.size??0,iterations:i.iterations,converged:i.converged,truncated:!i.converged||i.communities.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{communities:i.communities.slice(0,t).map(o=>({representative:o.representative,size:o.size,members:o.members.slice(0,t)}))}}}function Lr(e){let t;try{t=T(e.assembly.graph,{...e.kinds===void 0?{}:{kinds:e.kinds},...e.maxDepth===void 0?{}:{maxDepth:e.maxDepth},limit:e.limit})}catch(n){ye(n)}return{subcommand:"redundancy",redundant_count:t.value.length,...be(t.meta),...e.summary?{}:{redundant:t.value.map(n=>({source:n.edge.source,target:n.edge.target,kind:n.edge.kind,witness:n.witness}))}}}function Fr(e,t){let n=t.limit,r=ot(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=r.value.rows.filter(o=>o.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:r.value.reachableCount,bottleneck_count:i.length,truncated:r.meta.truncated||i.length>n,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,n).map(o=>({id:o.id,idom:o.idom,dominated_count:o.dominatedCount}))}}}function Gr(e){let t=e.limit,n=lt(e.assembly.graph),r=n.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:n.acyclic,makespan:n.makespan,scheduled_count:n.scheduledCount,critical_count:r,critical_path_length:n.criticalPathLength,cycle_count:n.cycles.length,truncated:n.rows.length>t,...e.summary?{}:{critical_path:n.criticalPath.slice(0,t),rows:n.rows.slice(0,t).map(i=>({id:i.id,earliest_start:i.earliestStart,latest_start:i.latestStart,slack:i.slack,critical:i.critical}))}}}function $r(e){let t=e.limit,n=dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),r=n.value;return{subcommand:"centrality",node_count:r.nodeCount,edge_count:r.edgeCount,edge_basis:"simple_undirected",truncated:r.rows.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{rows:r.rows.slice(0,t).map(i=>({id:i.id,degree:i.degree,in_degree:i.inDegree,out_degree:i.outDegree,betweenness:i.betweenness,closeness:i.closeness}))}}}function qr(e){let t=e.limit,n=X(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:r,bridges:i}=n.value;return{subcommand:"articulation",articulation_count:r.length,bridge_count:i.length,truncated:r.length>t||i.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{articulation_points:r.slice(0,t),bridges:i.slice(0,t)}}}function Ur(e,t){let n=e.limit,r=jt(e.assembly,{isTerminal:t,redundancyLimit:n,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},o={};for(let s of r.steps)i[s.op]=(i[s.op]??0)+1,o[s.code]=(o[s.code]??0)+1;return{subcommand:"plan",step_count:r.steps.length,steps_by_op:i,steps_by_code:o,finding_count:r.report.findings.length,truncated:r.truncated||r.steps.length>n,cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...e.summary?{}:{steps:r.steps.slice(0,n)}}}function Gt(e,t,n,r){return JSON.stringify({projection_version:2,subcommand:e,root:t??null,target:n??null,kinds:r.kinds??null,maxDepth:r.maxDepth??null,limit:r.limit,after:r.after??null,direction:r.direction,maxPaths:r.maxPaths??null,sample:r.sample,exemptIsolates:[...new Set(r.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(r.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:r.summary,unbounded:r.unbounded})}function $t(e,t,n,r,i){return e==="analyze"?jr(r):e==="audit"?Mr(r,i):e==="plan"?Ur(r,i):e==="communities"?Pr(r):e==="redundancy"?Lr(r):e==="dominators"?Fr(t,r):e==="slack"?Gr(r):e==="centrality"?$r(r):e==="articulation"?qr(r):e==="paths"?Tr(t,n,r):e==="impact"?Nr(t,r):Dr(e,t,r)}function Br(e,t){if(e!=="index"&&(t.rebuild===!0||t.clear===!0))throw new k("--rebuild and --clear apply only to graph index.",w.USAGE);if(e!=="audit"&&t.saveBaseline===!0)throw new k("--save-baseline applies only to graph audit.",w.USAGE);if(e==="slack"&&t.kind!==void 0)throw new k("graph slack analyzes every ordering kind; --kind is not supported.",w.USAGE);if(t.rebuild===!0&&t.clear===!0)throw new k("graph index accepts either --rebuild or --clear, not both.",w.USAGE);if(t.full===!0&&t.limit!==void 0)throw new k(`graph ${e} accepts either --full or --limit, not both.`,w.USAGE)}async function zr(e,t,n,r,i,o){let s="status";if(o.clear===!0&&(await me(e),s="cleared"),o.rebuild===!0){await me(e);let c=await pe(e,t),d={assembly:n.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,limit:I.rows,sample:I.samples,unbounded:!1};for(let l of["analyze","audit"])await he(e,t,c,Gt(l,void 0,void 0,d),$t(l,void 0,void 0,d,i));s="rebuilt"}let a=await Tt(e,t);return{subcommand:"index",action:s,state:a.exists?a.fresh?"fresh":"stale":"absent",entry_count:a.entry_count,item_count:r,min_items_threshold:ge,persist_enabled:_e(r,a.exists),current_fingerprint:t.slice(0,12),...a.saved_at===void 0?{}:{saved_at:a.saved_at},...a.bytes===void 0?{}:{bytes:a.bytes}}}async function Hr(e,t,n,r){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:n.affected_subjects_by_code,profile:{...n.profile,finding_subjects_by_code:Object.fromEntries(A.map(s=>[s,n.affected_subjects_by_code[s]??0]))}},o=await At(e);return r&&await Rt(e,i),o===void 0?n:{...n,baseline:xt(o,i)}}async function Kr(e,t,n,r,i){try{await he(e,t,n,r,i)}catch{}}function Vr(e,t,n,r){if(e.subcommand!=="slack")return;let i=new Set(t.assembly.details.filter(u=>r(u.status)).map(u=>u.id)),o=t.assembly.graph,s=new ke(o.nodes().filter(u=>!i.has(u)),o.edges().filter(u=>!i.has(u.source)&&!i.has(u.target)),o.registry()),a=ut(s,n.filter(u=>!i.has(u.id)),{now:Ae(),limit:t.limit}),{rows:c,residuals:d,overcommitted:l,...g}=a;e.deadline_schedule={population:"active",...g,...t.summary?{}:{rows:c,residuals:d,overcommitted:l}}}async function ro(e,t,n,r,i){let o=Cr(e,t,n);De(r.summary===!0,r.full===!0,"--summary");let s=Ee(process.cwd(),i.path);await Pe(s);let a=await je(s),c=xe(a,Ce()),d=await Le(s,a.item_format,c.type_to_folder,void 0,a.schema),l=Se(a.schema),g=qt=>Oe(qt,l);Br(o,r);let u=Fe(),f=ze(r.kind,u),p=qe().lookup(s,$e(d,g,u),()=>Ge(d,g,u)),m=Sr(o,p.assembly,f,r);if(o==="index")return Mt(await zr(s,p.fingerprint,m,d.length,g,r),!1);let b=Ft.has(o)?Lt(m.assembly,t):void 0,v=o==="paths"?Lt(m.assembly,n):void 0,h=Gt(o,b,v,m),_=await pe(s,p.fingerprint),E=_.results[h],S=p.memoize(h,()=>E!==void 0?structuredClone(E):$t(o,b,v,m,g)),ve=_e(d.length,_.exists);!S.reused&&E===void 0&&ve&&await Kr(s,p.fingerprint,_,h,S.value);let ne=S.value.subcommand==="audit"?await Hr(s,p.fingerprint,S.value,m.saveBaseline):S.value;return ne.cache={fingerprint:p.fingerprint.slice(0,12),assembly:p.assemblyReused?"hit":"miss",result:S.reused?"hit":"miss",durable:E!==void 0?"hit":ve?"miss":"off"},Vr(ne,m,d,g),Mt(ne,m.summary,"result_rows")}export{B as a,U as b,Ye as c,Xr as d,Qe as e,Ze as f,et as g,tt as h,nt as i,V as j,it as k,T as l,ot as m,dt as n,X as o,lt as p,ut as q,tr as r,It as s,Z as t,ue as u,ee as v,xt as w,St as x,ge as y,F as z,Dt as A,pe as B,he as C,me as D,Tt as E,_e as F,At as G,Rt as H,jt as I,Cr as J,ro as K};
|
|
2
|
+
//# sourceMappingURL=chunk-KSMQEB3V.js.map
|