@unbrained/pm-cli 2026.10.5 → 2026.10.6
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 +2 -2
- package/CHANGELOG.md +26 -1
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/runtime/projection-retry.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +158 -158
- package/dist/cli-bundle/chunks/{chunk-Z66DWDAU.js → chunk-25EW53VO.js} +39 -38
- package/dist/cli-bundle/chunks/{chunk-YVBRASXO.js → chunk-3CCVTV6Q.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5MNOWZPN.js → chunk-3REXBTST.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-4WB55TBC.js +80 -0
- package/dist/cli-bundle/chunks/{chunk-OOLYASYJ.js → chunk-6STTPXOC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AJ7H6XUF.js → chunk-ATB4ZZBQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-N4YGSG6F.js → chunk-D4G43LBV.js} +38 -38
- package/dist/cli-bundle/chunks/{chunk-HRJ6G6ZG.js → chunk-K6D6DMRT.js} +28 -28
- package/dist/cli-bundle/chunks/chunk-KIRHWPZB.js +2 -0
- package/dist/cli-bundle/chunks/chunk-O67BH435.js +6 -0
- package/dist/cli-bundle/chunks/{chunk-3CYOBJUK.js → chunk-RJHLD64E.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WFZ4UEOB.js → chunk-TUKO5NF7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VZ63DEVJ.js → chunk-XJD47LUH.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-75QXHIFH.js → register-list-query-53WYLNZT.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-YS54SCHG.js → register-mutation-34XXUBVI.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-6KHZQSYJ.js → register-operations-WANO6EIM.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-WT37UPBQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-GITOYRUW.js → chunk-6KFKQD2D.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UDYRVBOZ.js → chunk-FOHRPFIT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DDRN42PB.js → chunk-GRQXL5G5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ABV67XCC.js → chunk-JZ4WGUVH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-B5RSLVE6.js → chunk-NM3PM6O6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-OT7HK7SG.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2CVX3KR3.js → chunk-PCLU34KB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5C3IDDW7.js → chunk-QQIE4L42.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RPUNVKXK.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-LE4JUCRR.js → chunk-RXSVJPZ7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SPN5QTZ3.js +30 -0
- package/dist/cli-bundle/focused-chunks/{chunk-CLDPTMQY.js → chunk-SUZJNPGB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YMU42COG.js → chunk-W4BG5HHS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-C224METM.js → chunk-Y5HXFDTZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ECBOPEJE.js → chunk-ZK5SOOPC.js} +61 -61
- package/dist/cli-bundle/focused-chunks/chunk-ZQK2XUSS.js +12 -0
- package/dist/cli-bundle/main.js +21 -21
- 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 +31 -30
- 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 +42 -42
- 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 +2 -2
- package/dist/core/extensions/extension-types.d.ts +2 -0
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/sdk/cli-bootstrap.d.ts +5 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/extension/managed-state.d.ts +2 -0
- package/dist/sdk/extension/managed-state.js +1 -1
- package/dist/sdk/extension/managed-update-status.d.ts +3 -0
- package/dist/sdk/extension/managed-update-status.js +2 -0
- package/dist/sdk/extension/source-resolution.d.ts +2 -6
- package/dist/sdk/extension/source-resolution.js +1 -1
- package/dist/sdk/extension/update-check.d.ts +10 -0
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -1
- package/dist/sdk/extension.d.ts +4 -0
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/get.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/test/execution.d.ts +2 -1
- package/dist/sdk/test/execution.js +3 -3
- package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +36 -0
- package/docs/GET_READ_EVIDENCE.md +17 -1
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +23 -0
- package/docs/PR_REVIEW_LOOP.md +21 -4
- package/docs/README.md +1 -0
- package/docs/RELEASING.md +18 -0
- package/docs/SDK_CONFIGURATION_SAFETY.md +123 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +3 -3
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
- package/marketplace.json +2 -2
- package/package.json +3 -3
- 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 +2 -2
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +2 -2
- package/plugins/pm-codex/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-D332RXZ7.js +0 -80
- package/dist/cli-bundle/chunks/chunk-KRVI56QE.js +0 -6
- package/dist/cli-bundle/chunks/chunk-TGMONGWX.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-RTATEN2M.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-DOVTUKJQ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-GUIF3WVC.js +0 -30
- package/dist/cli-bundle/focused-chunks/chunk-RHIH6XIW.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-XV5RV4ZT.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as or,g as St,i as Tt,j as Ct,l as Pi,m as Mi,n as cr,o as ji,p as Fi,q as $i}from"./chunk-B5RSLVE6.js";import{h as ur}from"./chunk-PSXFFQFT.js";import{$ as w,$c as Bi,A as bi,Ae as Cn,Be as On,F as rr,G as nr,H as wn,Ia as Ti,J as wi,Kc as me,Ke as ye,Lc as kn,Le as se,Ma as Ci,Mc as dr,Na as Oi,Nc as _e,Oc as In,P as ve,Pa as xi,Pb as Li,Pc as ke,Qa as Ri,Qc as Sn,Ta as ir,Tc as Ot,Ub as Hi,V as Pe,Va as Ai,Vd as Gi,W as vi,Wd as Ie,Xd as pe,Ya as sr,Yb as zi,Yd as Ki,Z as k,Za as Di,Zb as Ui,Zc as $e,Zd as tt,_ as Me,_d as he,aa as g,ab as et,bb as vn,bd as Tn,be as Xi,cb as En,ce as Yi,db as fe,dd as Wi,de as W,ed as Vi,fb as Ni,i as Qt,id as qi,ka as ue,pa as Ei,q as Zt,r as pi,ra as ki,rb as D,s as hi,sa as je,sb as ie,t as yi,ta as Fe,tb as ar,u as gi,ua as re,ub as T,va as Ee,vd as lr,wa as Ii,xa as K,y as er,ya as Si,z as tr}from"./chunk-GUIF3WVC.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 xn=new qc,Ji=/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,127})$/u;function fr(e,t){let r=typeof e=="string"?e.trim():"";return r.length>0?r.slice(0,t):void 0}function He(e,t){if(e===void 0)return;let r=typeof e=="object"&&e!==null?e:{},n=fr(r.id,128),o=fr(r.parent_id,128);if(n===void 0||!Ji.test(n)||o!==void 0&&!Ji.test(o)){if(t)throw new Error("Agent episode ids must be 1-128 letters, digits, dots, underscores, colons, or hyphens.");return}let i=fr(r.label,256);return{id:n,...i===void 0?{}:{label:i},...o===void 0?{}:{parent_id:o}}}function rt(e){let t={};for(let[r,n]of Object.entries(e??{}).slice(0,32)){let o=r.trim().toLowerCase().slice(0,64),i=fr(n,256);/^[a-z][a-z0-9_-]{0,63}$/u.test(o)&&i!==void 0&&(t[o]=i)}return t}function Gc(e,t,r){let n=xn.getStore(),o=rt({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={...rt(n?.provenance),...o,...rt(e?.provenance)},a=He(e?.episode,!1)??He(r,!1)??i??He(n?.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 Rn(e,t){return Gc(e.session_context,t,e.client_info?.episode)??{}}function Gp(e,t){let r=xn.getStore(),n=He(e.episode,!0),o=He(r?.episode,!1),i=n!==void 0&&n.parent_id===void 0&&o!==void 0?{...n,parent_id:o.id}:n,s={...rt(r?.provenance),...rt(e.provenance)};return xn.run({...Object.keys(s).length===0?{}:{provenance:s},...i===void 0?o===void 0?{}:{episode:o}:{episode:i}},t)}function Kp(e){let t=rt(e.provenance),r=He(e.episode,!0);return{...r===void 0?{}:{PM_AGENT_EPISODE_ID:r.id,...r.label===void 0?{}:{PM_AGENT_EPISODE_LABEL:r.label},...r.parent_id===void 0?{}:{PM_AGENT_EPISODE_PARENT_ID:r.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 Bn}from"node:async_hooks";import{createHash as Qc}from"node:crypto";import V from"node:fs";import ss from"node:os";import Be from"node:path";import{createHash as Qi}from"node:crypto";import{existsSync as An,promises as Zi,readFileSync as Kc}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 Xc="session.json";function Dn(e,t){return typeof e=="string"&&e.length>0&&e.length<=t}function es(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=["implementer","planner","release-operator"].includes(String(t.role)),n=["high","medium"].includes(String(t.confidence)),o=Dn(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=>Dn(c,128)),a=t.focused_item_id===void 0||Dn(t.focused_item_id,128);if([r,n,o,i,s,a,t.rule_version==="v2"].every(Boolean))return t}function Yc(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=Object.entries(e).slice(0,128).flatMap(([r,n])=>{let o=es(n);return o&&r.length<=128?[[r,o]]:[]});return t.length>0?Object.fromEntries(t):void 0}function Nn(e){return ae.join(Ni(e),Xc)}async function ts(e){try{let t=await Zi.readFile(Nn(e),"utf8"),r=JSON.parse(t);if(r===null||typeof r!="object"||Array.isArray(r))return{};let n=r,o=n.focused_item,i=Yc(n.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 Ln(e,t){let r=await W(e,"session-state",k.locks.ttl_seconds,"session-state",!1,!0,k.locks.wait_ms);try{let n=await ts(e);t(n);let o=Nn(e);await Zi.mkdir(ae.dirname(o),{recursive:!0}),await K(o,JSON.stringify(n))}finally{await r()}}function Pn(e){return/#([a-f0-9]{24})$/u.exec(e.trim())?.[1]??`author-${Qi("sha256").update(e).digest("hex").slice(0,24)}`}function Mn(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].slice(0,32).map(t=>t.slice(0,128))}function jn(e){let t=[...new Set(e)].sort((n,o)=>n.localeCompare(o));if(t.length===1)return t[0];let r=`workset:${t.join("+")}`;return r.length<=256?r:`workset:${t.join("+").slice(0,230)}+${Qi("sha256").update(t.join("\0")).digest("hex").slice(0,12)}`}async function Fn(e,t,r){await Ln(e,n=>{let o={...n.semantic_attribution},i=r(o[t]);i===void 0?delete o[t]:o[t]=i,Object.keys(o).length===0?delete n.semantic_attribution:n.semantic_attribution=o})}async function nh(e){let t=Pn(e.principal);await Fn(e.pmRoot,t,r=>{let n=[...new Set([...r?.active_item_ids??[],e.itemId])].slice(-64).sort((i,s)=>i.localeCompare(s)),o=r?.focused_item_id;return{role:"implementer",topic:o??jn(n),confidence:o?"high":"medium",rule_version:"v2",evidence:Mn([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:n,...o?{focused_item_id:o}:{}}})}async function oh(e){let t=Pn(e.principal);await Fn(e.pmRoot,t,r=>{if(!r)return;let n=r.active_item_ids.filter(i=>i!==e.itemId);if(n.length===0&&!r.focused_item_id)return;let o=r.focused_item_id;return{...r,role:"release-operator",topic:o??jn(n),confidence:o?"high":"medium",evidence:Mn([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],`release:${e.itemId}`]),active_item_ids:n}})}async function ih(e){let t=Pn(e.principal);await Fn(e.pmRoot,t,r=>{let n=r?.active_item_ids??[];if(!e.itemId&&n.length===0)return;let o=e.itemId;return{role:o?"planner":r.role,topic:o??jn(n),confidence:o?"high":"medium",rule_version:"v2",evidence:Mn([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:n,...o?{focused_item_id:o}:{}}})}function Jc(e,t){let r=t.PM_PATH?.trim();if(r){let o=ae.resolve(e,r);if(An(ae.join(o,"settings.json")))return o;let i=ae.join(o,".agents","pm");if(An(ae.join(i,"settings.json")))return i}let n=ae.resolve(e);for(let o=0;o<32;o+=1){let i=ae.join(n,".agents","pm");if(An(ae.join(i,"settings.json")))return i;let s=ae.dirname(n);if(s===n)break;n=s}}function rs(e){if(!e.key)return;let t=Jc(e.cwd,e.env);if(t)try{let r=JSON.parse(Kc(Nn(t),"utf8"));return es(r.semantic_attribution?.[e.key])}catch{return}}async function sh(e){return(await ts(e)).focused_item}async function ah(e,t){await Ln(e,r=>{r.focused_item=t})}async function ch(e){await Ln(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 Wn=["model","effort","role","topic","version"],pr=new Bn,as=new Bn,hr=new Bn,Vn=[{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:[]}],cs=Object.freeze({max_bytes:1048576,max_lines:4096,network_access:!1,subprocess_access:!1}),Zc=Object.freeze({...cs,max_bytes:4194304}),$n=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function ed(e){let t=Te(e).provenance_unavailable_dimensions,r=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([...r].sort()),native_sources:Object.freeze(["environment","argv","mcp_client",...Object.values(e.provenance_resolvers??{}).some(n=>n?.endsWith("session_file"))?["session_file"]:[]]),probe_policy:e.harness==="codex"?Zc:cs,normalization:Object.freeze({model_family:"v1",effort:"v1",preserve_raw:!0}),confidence:"high",waivers:Object.freeze(Object.fromEntries(t.map(n=>[n,"Harness does not expose this dimension."])))})}var ds=Object.freeze(Vn.filter(e=>e.harness!=="ci").map(ed).sort((e,t)=>e.harness.localeCompare(t.harness))),Ue=new Map,nt=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(!$n.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(([r,n])=>[r.trim().toLowerCase().slice(0,64),Se(n)]).filter(([r])=>$n.test(r))),provenance_resolvers:Object.fromEntries(Object.entries(e.provenance_resolvers??{}).slice(0,32).map(([r,n])=>[r.trim().toLowerCase().slice(0,64),n]).filter(r=>typeof r[0]=="string"&&$n.test(r[0])&&(r[1]==="ai_agent_version"||r[1]==="claude_session_file"||r[1]==="codex_session_file"))),provenance_unavailable_dimensions:Se(e.provenance_unavailable_dimensions).map(r=>r.toLowerCase()),argv_markers:Se(e.argv_markers).map(r=>r.toLowerCase()),client_names:Se(e.client_names).map(r=>r.toLowerCase())}}var ls=Vn.map(Te);function td(e,t){return JSON.stringify(e)===JSON.stringify(t)}function _r(e,t){return e.toLowerCase().slice(0,512).split(/[/\\\s:=]+/u).filter(r=>r.length>0).includes(t)||e.trim().toLowerCase()===t}function qn(e=[]){let t=new Map(Vn.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 r=[...t.values(),...ls.filter(o=>o.harness==="ci"),...[...nt.values()].map(o=>o.descriptor),...hr.getStore()?.descriptors??[],...e.map(Te)],n=new Set;for(let o of r){if(n.has(o.harness))throw new Error(`Harness signal descriptor collision for "${o.harness}"`);n.add(o.harness)}return r}function Gn(e,t){for(let r of t??[]){let n=P(e[r]);if(n)return n.slice(0,256)}}function rd(e,t){if(t==="role"){let r=e.slice(0,8).map(n=>n.trim().toLowerCase()).find(n=>["claim","create","update","close","release","review"].includes(n));if(r==="review")return"reviewer";if(r)return"implementer"}}function us(e,t){let r=t==="model"?["--model","--agent-model"]:[`--agent-${t}`],n=e.slice(0,8);for(let o=0;o<n.length;o+=1){let i=n[o].slice(0,512);if(r.includes(i))return P(n[o+1])?.slice(0,256);let s=r.find(a=>i.startsWith(`${a}=`));if(s)return P(i.slice(s.length+1))?.slice(0,256)}}var nd=new Set(["implementation","implementer","investigator","orchestrator","planner","release-operator","reviewer"]);function ze(e,t){if(e!=="role"||t===void 0)return t;let r=t.trim().toLowerCase().replaceAll(/[_\s]+/gu,"-");return nd.has(r)?r:void 0}function Hn(e,t){return P(e?.[t])?.slice(0,256)}var od=1048576,Un=4194304,mr=new Map,ns=Object.freeze({}),zn=new Map,os=Object.freeze({});function is(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function id(e){let t;try{t=JSON.parse(e)}catch{return os}let r=is(t);if(!r)return os;let n=[{value:r,depth:0}],o=0,i,s;for(;n.length>0&&o<64;){let a=n.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=is(c);d&&n.push({value:d,depth:a.depth+1})}}return Object.freeze({model:i,version:s})}function fs(e){try{return V.lstatSync(e).isFile()?"available":"missing"}catch(t){return Fe(t)?"missing":"failed"}}function sd(e,t){let r;try{r=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:fs(i)}})}catch(o){return{status:Fe(o)?"missing":"failed"}}let n=r.filter(({status:o})=>o==="available").map(({candidate:o})=>o);return n.length===0?{status:r.some(({status:o})=>o==="failed")?"failed":"missing"}:n.length>1?{status:"ambiguous"}:{status:"available",path:n[0]}}function ms(e,t){let r=P(t.CLAUDE_CODE_SESSION_ID);if(!r||!/^[A-Za-z0-9_-]{1,128}$/u.test(r))return{status:"unavailable"};let n=Be.resolve(e.cwd??process.cwd()).replaceAll(/[^A-Za-z0-9-]/gu,"-"),o=Be.join(e.home_dir??ss.homedir(),".claude","projects"),i=Be.join(o,n,`${r}.jsonl`),s=P(e.session_file),a=s&&Be.basename(s)===`${r}.jsonl`?s:void 0;for(let c of[a,i]){if(!c)continue;let d=fs(c);if(d==="available")return{status:d,path:c};if(d==="failed")return{status:d}}return sd(o,r)}function ad(e,t,r){let n=ms(t,r);if(n.status==="available")try{let o=V.openSync(n.path,V.constants.O_RDONLY|V.constants.O_NOFOLLOW);try{let i=V.fstatSync(o),s=`${n.path}\0${i.size}\0${i.mtimeMs}`,a=zn.get(s);if(a)return a[e];let c=Math.min(i.size,od),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 or,g as St,i as Tt,j as Ct,l as Pi,m as Mi,n as cr,o as ji,p as Fi,q as $i}from"./chunk-NM3PM6O6.js";import{h as ur}from"./chunk-PSXFFQFT.js";import{$ as w,$d as he,A as bi,Be as Cn,Ce as On,F as rr,G as nr,H as wn,Ia as Ti,J as wi,Lc as me,Le as ye,Mc as kn,Me as se,Na as Ci,Nc as dr,Oa as Oi,Oc as _e,P as ve,Pc as In,Qa as xi,Qb as Li,Qc as ke,Ra as Ri,Rc as Sn,Ua as ir,Uc as Ot,V as Pe,Vb as Hi,W as vi,Wa as Ai,Wd as Gi,Xd as Ie,Yd as pe,Z as k,Za as sr,Zb as zi,Zd as Ki,_ as Me,_a as Di,_b as Ui,_c as $e,_d as tt,aa as g,ad as Bi,bb as et,cb as vn,cd as Tn,ce as Xi,db as En,de as Yi,eb as fe,ed as Wi,ee as W,fd as Vi,gb as Ni,i as Qt,jd as qi,ka as ue,pa as Ei,q as Zt,r as pi,ra as ki,s as hi,sa as je,sb as D,t as yi,ta as Fe,tb as ie,u as gi,ua as re,ub as ar,va as Ee,vb as T,wa as Ii,wd as lr,xa as K,y as er,ya as Si,z as tr}from"./chunk-SPN5QTZ3.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 xn=new qc,Ji=/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,127})$/u;function fr(e,t){let r=typeof e=="string"?e.trim():"";return r.length>0?r.slice(0,t):void 0}function He(e,t){if(e===void 0)return;let r=typeof e=="object"&&e!==null?e:{},n=fr(r.id,128),o=fr(r.parent_id,128);if(n===void 0||!Ji.test(n)||o!==void 0&&!Ji.test(o)){if(t)throw new Error("Agent episode ids must be 1-128 letters, digits, dots, underscores, colons, or hyphens.");return}let i=fr(r.label,256);return{id:n,...i===void 0?{}:{label:i},...o===void 0?{}:{parent_id:o}}}function rt(e){let t={};for(let[r,n]of Object.entries(e??{}).slice(0,32)){let o=r.trim().toLowerCase().slice(0,64),i=fr(n,256);/^[a-z][a-z0-9_-]{0,63}$/u.test(o)&&i!==void 0&&(t[o]=i)}return t}function Gc(e,t,r){let n=xn.getStore(),o=rt({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={...rt(n?.provenance),...o,...rt(e?.provenance)},a=He(e?.episode,!1)??He(r,!1)??i??He(n?.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 Rn(e,t){return Gc(e.session_context,t,e.client_info?.episode)??{}}function Gp(e,t){let r=xn.getStore(),n=He(e.episode,!0),o=He(r?.episode,!1),i=n!==void 0&&n.parent_id===void 0&&o!==void 0?{...n,parent_id:o.id}:n,s={...rt(r?.provenance),...rt(e.provenance)};return xn.run({...Object.keys(s).length===0?{}:{provenance:s},...i===void 0?o===void 0?{}:{episode:o}:{episode:i}},t)}function Kp(e){let t=rt(e.provenance),r=He(e.episode,!0);return{...r===void 0?{}:{PM_AGENT_EPISODE_ID:r.id,...r.label===void 0?{}:{PM_AGENT_EPISODE_LABEL:r.label},...r.parent_id===void 0?{}:{PM_AGENT_EPISODE_PARENT_ID:r.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 Bn}from"node:async_hooks";import{createHash as Qc}from"node:crypto";import V from"node:fs";import ss from"node:os";import Be from"node:path";import{createHash as Qi}from"node:crypto";import{existsSync as An,promises as Zi,readFileSync as Kc}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 Xc="session.json";function Dn(e,t){return typeof e=="string"&&e.length>0&&e.length<=t}function es(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=["implementer","planner","release-operator"].includes(String(t.role)),n=["high","medium"].includes(String(t.confidence)),o=Dn(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=>Dn(c,128)),a=t.focused_item_id===void 0||Dn(t.focused_item_id,128);if([r,n,o,i,s,a,t.rule_version==="v2"].every(Boolean))return t}function Yc(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=Object.entries(e).slice(0,128).flatMap(([r,n])=>{let o=es(n);return o&&r.length<=128?[[r,o]]:[]});return t.length>0?Object.fromEntries(t):void 0}function Nn(e){return ae.join(Ni(e),Xc)}async function ts(e){try{let t=await Zi.readFile(Nn(e),"utf8"),r=JSON.parse(t);if(r===null||typeof r!="object"||Array.isArray(r))return{};let n=r,o=n.focused_item,i=Yc(n.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 Ln(e,t){let r=await W(e,"session-state",k.locks.ttl_seconds,"session-state",!1,!0,k.locks.wait_ms);try{let n=await ts(e);t(n);let o=Nn(e);await Zi.mkdir(ae.dirname(o),{recursive:!0}),await K(o,JSON.stringify(n))}finally{await r()}}function Pn(e){return/#([a-f0-9]{24})$/u.exec(e.trim())?.[1]??`author-${Qi("sha256").update(e).digest("hex").slice(0,24)}`}function Mn(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].slice(0,32).map(t=>t.slice(0,128))}function jn(e){let t=[...new Set(e)].sort((n,o)=>n.localeCompare(o));if(t.length===1)return t[0];let r=`workset:${t.join("+")}`;return r.length<=256?r:`workset:${t.join("+").slice(0,230)}+${Qi("sha256").update(t.join("\0")).digest("hex").slice(0,12)}`}async function Fn(e,t,r){await Ln(e,n=>{let o={...n.semantic_attribution},i=r(o[t]);i===void 0?delete o[t]:o[t]=i,Object.keys(o).length===0?delete n.semantic_attribution:n.semantic_attribution=o})}async function nh(e){let t=Pn(e.principal);await Fn(e.pmRoot,t,r=>{let n=[...new Set([...r?.active_item_ids??[],e.itemId])].slice(-64).sort((i,s)=>i.localeCompare(s)),o=r?.focused_item_id;return{role:"implementer",topic:o??jn(n),confidence:o?"high":"medium",rule_version:"v2",evidence:Mn([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:n,...o?{focused_item_id:o}:{}}})}async function oh(e){let t=Pn(e.principal);await Fn(e.pmRoot,t,r=>{if(!r)return;let n=r.active_item_ids.filter(i=>i!==e.itemId);if(n.length===0&&!r.focused_item_id)return;let o=r.focused_item_id;return{...r,role:"release-operator",topic:o??jn(n),confidence:o?"high":"medium",evidence:Mn([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],`release:${e.itemId}`]),active_item_ids:n}})}async function ih(e){let t=Pn(e.principal);await Fn(e.pmRoot,t,r=>{let n=r?.active_item_ids??[];if(!e.itemId&&n.length===0)return;let o=e.itemId;return{role:o?"planner":r.role,topic:o??jn(n),confidence:o?"high":"medium",rule_version:"v2",evidence:Mn([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:n,...o?{focused_item_id:o}:{}}})}function Jc(e,t){let r=t.PM_PATH?.trim();if(r){let o=ae.resolve(e,r);if(An(ae.join(o,"settings.json")))return o;let i=ae.join(o,".agents","pm");if(An(ae.join(i,"settings.json")))return i}let n=ae.resolve(e);for(let o=0;o<32;o+=1){let i=ae.join(n,".agents","pm");if(An(ae.join(i,"settings.json")))return i;let s=ae.dirname(n);if(s===n)break;n=s}}function rs(e){if(!e.key)return;let t=Jc(e.cwd,e.env);if(t)try{let r=JSON.parse(Kc(Nn(t),"utf8"));return es(r.semantic_attribution?.[e.key])}catch{return}}async function sh(e){return(await ts(e)).focused_item}async function ah(e,t){await Ln(e,r=>{r.focused_item=t})}async function ch(e){await Ln(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 Wn=["model","effort","role","topic","version"],pr=new Bn,as=new Bn,hr=new Bn,Vn=[{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:[]}],cs=Object.freeze({max_bytes:1048576,max_lines:4096,network_access:!1,subprocess_access:!1}),Zc=Object.freeze({...cs,max_bytes:4194304}),$n=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function ed(e){let t=Te(e).provenance_unavailable_dimensions,r=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([...r].sort()),native_sources:Object.freeze(["environment","argv","mcp_client",...Object.values(e.provenance_resolvers??{}).some(n=>n?.endsWith("session_file"))?["session_file"]:[]]),probe_policy:e.harness==="codex"?Zc:cs,normalization:Object.freeze({model_family:"v1",effort:"v1",preserve_raw:!0}),confidence:"high",waivers:Object.freeze(Object.fromEntries(t.map(n=>[n,"Harness does not expose this dimension."])))})}var ds=Object.freeze(Vn.filter(e=>e.harness!=="ci").map(ed).sort((e,t)=>e.harness.localeCompare(t.harness))),Ue=new Map,nt=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(!$n.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(([r,n])=>[r.trim().toLowerCase().slice(0,64),Se(n)]).filter(([r])=>$n.test(r))),provenance_resolvers:Object.fromEntries(Object.entries(e.provenance_resolvers??{}).slice(0,32).map(([r,n])=>[r.trim().toLowerCase().slice(0,64),n]).filter(r=>typeof r[0]=="string"&&$n.test(r[0])&&(r[1]==="ai_agent_version"||r[1]==="claude_session_file"||r[1]==="codex_session_file"))),provenance_unavailable_dimensions:Se(e.provenance_unavailable_dimensions).map(r=>r.toLowerCase()),argv_markers:Se(e.argv_markers).map(r=>r.toLowerCase()),client_names:Se(e.client_names).map(r=>r.toLowerCase())}}var ls=Vn.map(Te);function td(e,t){return JSON.stringify(e)===JSON.stringify(t)}function _r(e,t){return e.toLowerCase().slice(0,512).split(/[/\\\s:=]+/u).filter(r=>r.length>0).includes(t)||e.trim().toLowerCase()===t}function qn(e=[]){let t=new Map(Vn.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 r=[...t.values(),...ls.filter(o=>o.harness==="ci"),...[...nt.values()].map(o=>o.descriptor),...hr.getStore()?.descriptors??[],...e.map(Te)],n=new Set;for(let o of r){if(n.has(o.harness))throw new Error(`Harness signal descriptor collision for "${o.harness}"`);n.add(o.harness)}return r}function Gn(e,t){for(let r of t??[]){let n=P(e[r]);if(n)return n.slice(0,256)}}function rd(e,t){if(t==="role"){let r=e.slice(0,8).map(n=>n.trim().toLowerCase()).find(n=>["claim","create","update","close","release","review"].includes(n));if(r==="review")return"reviewer";if(r)return"implementer"}}function us(e,t){let r=t==="model"?["--model","--agent-model"]:[`--agent-${t}`],n=e.slice(0,8);for(let o=0;o<n.length;o+=1){let i=n[o].slice(0,512);if(r.includes(i))return P(n[o+1])?.slice(0,256);let s=r.find(a=>i.startsWith(`${a}=`));if(s)return P(i.slice(s.length+1))?.slice(0,256)}}var nd=new Set(["implementation","implementer","investigator","orchestrator","planner","release-operator","reviewer"]);function ze(e,t){if(e!=="role"||t===void 0)return t;let r=t.trim().toLowerCase().replaceAll(/[_\s]+/gu,"-");return nd.has(r)?r:void 0}function Hn(e,t){return P(e?.[t])?.slice(0,256)}var od=1048576,Un=4194304,mr=new Map,ns=Object.freeze({}),zn=new Map,os=Object.freeze({});function is(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function id(e){let t;try{t=JSON.parse(e)}catch{return os}let r=is(t);if(!r)return os;let n=[{value:r,depth:0}],o=0,i,s;for(;n.length>0&&o<64;){let a=n.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=is(c);d&&n.push({value:d,depth:a.depth+1})}}return Object.freeze({model:i,version:s})}function fs(e){try{return V.lstatSync(e).isFile()?"available":"missing"}catch(t){return Fe(t)?"missing":"failed"}}function sd(e,t){let r;try{r=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:fs(i)}})}catch(o){return{status:Fe(o)?"missing":"failed"}}let n=r.filter(({status:o})=>o==="available").map(({candidate:o})=>o);return n.length===0?{status:r.some(({status:o})=>o==="failed")?"failed":"missing"}:n.length>1?{status:"ambiguous"}:{status:"available",path:n[0]}}function ms(e,t){let r=P(t.CLAUDE_CODE_SESSION_ID);if(!r||!/^[A-Za-z0-9_-]{1,128}$/u.test(r))return{status:"unavailable"};let n=Be.resolve(e.cwd??process.cwd()).replaceAll(/[^A-Za-z0-9-]/gu,"-"),o=Be.join(e.home_dir??ss.homedir(),".claude","projects"),i=Be.join(o,n,`${r}.jsonl`),s=P(e.session_file),a=s&&Be.basename(s)===`${r}.jsonl`?s:void 0;for(let c of[a,i]){if(!c)continue;let d=fs(c);if(d==="available")return{status:d,path:c};if(d==="failed")return{status:d}}return sd(o,r)}function ad(e,t,r){let n=ms(t,r);if(n.status==="available")try{let o=V.openSync(n.path,V.constants.O_RDONLY|V.constants.O_NOFOLLOW);try{let i=V.fstatSync(o),s=`${n.path}\0${i.size}\0${i.mtimeMs}`,a=zn.get(s);if(a)return a[e];let c=Math.min(i.size,od),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 y of _){if(y.length===0||y.length>262144)continue;let S=id(y);if(p.model??=S.model,p.version??=S.version,p.model&&p.version)break}let b=Object.freeze(p);return zn.clear(),zn.set(s,b),b[e]}finally{V.closeSync(o)}}catch{return}}function cd(e,t){let r=0,n=(o,i)=>{if(i>4||r>=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(r+=1,r>512)return;let c=Be.join(o,a.name);if(a.isFile()&&a.name.endsWith(`-${t}.jsonl`))return c;if(a.isDirectory()){let d=n(c,i+1);if(d)return d}}};return n(e,0)}function dd(e){if(e<=Un)return[{offset:0,length:e}];let t=Math.floor(Un/2);return[{offset:e-t,length:t},{offset:0,length:t}]}function ld(e,t){if(t.length===0||t.length>262144)return;let r;try{r=JSON.parse(t)}catch{return}if(typeof r!="object"||r===null||Array.isArray(r))return;let n=r;if(n.type!=="turn_context")return;let o=typeof n.payload=="object"&&n.payload!==null?n.payload:void 0;e.model??=P(o?.model)?.slice(0,256),e.effort??=P(o?.effort)?.slice(0,256)}function ud(e,t){let r={},n=4096;for(let o of dd(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(n,null,2)}
|
|
163
163
|
`}async function q_(e){let t;try{t=await cc(e)}catch(a){if(Fe(a))return le();throw a}let r=et(t),n;try{n=await m_(r)}catch(a){if(Fe(a))return le();throw a}if(!n.isFile())throw new TypeError(`Transaction preview requires regular files and directories: ${r}`);let o;try{o=await Ii(r,`Transaction preview requires regular files and directories: ${r}`)}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=Ko(i);return s.success?{settings:mn(s.data),metadata:{has_explicit_item_format:Ec(i)},warnings:s.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:le("settings_read_invalid_schema")}async function xc(e){if(__(e))return q_(e);let t=et(e),r=[t];await ke({path:t,scope:"project"});let n=nc(e);if(n){let d=await Ae(n.tracked_paths);if(Xt(d,n.signatures))return fn(n.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 Zo(e,[t],d,o,[t]),d}let s=await Ae([t]);if(!Xt(o,s))return De(e),xc(e);let a;try{a=JSON.parse(i)}catch{let d=le("settings_read_invalid_json");return await Zo(e,[t],d,s,[t]),d}let c=Ko(a);if(!c.success){let d=le("settings_read_invalid_schema");return await Zo(e,[t],d,s,[t]),d}try{let d=mn(c.data),l=v_(e,d.schema,t);r=l;let f=await Ae(l),m=await Pi(e,d.schema),p=await Mi(e,d.schema),_=await Ae(l),b={...d,item_types:{definitions:wt([...d.item_types.definitions,...ni(p.type_definitions_from_file)])},schema:p.schema};oi(b,wc(c.data,b));let y={settings:b,metadata:{has_explicit_item_format:Ec(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,_)?un(e,{tracked_paths:l,signatures:_,value:fn(y)}):De(e):De(e),y}catch{let d=le("settings_read_merge_failed");return await k_(e,r,d),d}}async function Rc(e){return(await xc(e)).settings}async function jw(e,t,r=p_){let n=et(e),o=vc(t),i=V_(t,{persist_source:o}),s=JSON.parse(i);try{await va({pmRoot:e,filePath:n,mutate:a=>{let c=null;if(a!==null)try{c=JSON.parse(a)}catch{throw new g("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(Xo(o.persisted_settings,s,c),ii),null,2)}
|
|
164
164
|
`:i,result:void 0}},op:r,author:gs(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),o&&oi(t,{...o,persisted_settings:structuredClone(s)}),await _e({path:n,scope:"project",op:r})}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 G_(e,t){let r=e.trim().toLowerCase();if(r.length===0)return;let n=Math.floor(r.length/3);return t.map(o=>({candidate:o,distance:Qt(r,o.toLowerCase(),n)??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 Ac(e){return["pm",...e].map(t=>/^[A-Za-z0-9_./:@=-]+$/u.test(t)?t:JSON.stringify(t)).join(" ")}function Uw(e){let t=e.command_path.trim().replaceAll(/\s+/gu," "),r=e.token.trim(),n=r.length===0?"<empty>":r,o=[...new Set(e.allowed.map(m=>m.trim()))].filter(Boolean).sort((m,p)=>m.localeCompare(p));if(t.length===0||n.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:G_(n,o),l=Ac([...i,n,...s]),f=e.retry_command??(d?Ac([...i,d,...s]):void 0);return new g(`Unknown ${a} ${c} "${n}". Allowed: ${o.join(", ")}${e.message_suffix??""}`,e.exit_code??w.USAGE,{code:"unknown_subcommand",reason:"unknown_positional_token",value:n,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 K_ from"node:fs/promises";import X_ 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 Y_(e){return[...new Set(e.filter(t=>t.trim().length>0))].sort((t,r)=>t.localeCompare(r))}function J_(e,t){return new g(`Missing history stream for ${e}. ${t} requires history streams when settings.history.missing_stream is strict_error.`,w.NOT_FOUND)}async function Q_(e,t){return await ki(X_.dirname(e)),await(await K_.open(e,"a")).close(),_e({path:e,scope:"project",op:`${t}:history:auto_create`})}async function si(e){return Z_({pmRoot:e.pmRoot,settings:e.settings,itemIds:[e.itemId],commandLabel:e.commandLabel})}async function Z_(e){let t=Y_(e.itemIds),r=[],n=[];for(let o of t){let i=fe(e.pmRoot,o);if(!await je(i)){if(e.settings.history.missing_stream==="strict_error")throw J_(o,e.commandLabel);n.push(...await Q_(i,e.commandLabel)),n.push(`history_stream_auto_created:${o}`),r.push(o)}}return{auto_created_ids:r,warnings:n}}(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 r=e[0];if(r?.op!=="history_compact_baseline")return 0;let n=r.context?.history_compaction,o=typeof n=="object"&&n!==null&&"version_offset"in n?n.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 g("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 ep(e,t){let r=-1;return e.forEach((n,o)=>{let i=Date.parse(n.ts);if(!Number.isFinite(i))throw new g(`History for this item contains invalid timestamp at entry ${o+1}.`,w.GENERIC_FAILURE);i<=t&&(r=o)}),r}function tp(e,t){let r=e[0]?.ts??null,n=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:r,last_timestamp:n}};return n!==null&&(o.examples=[n],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:n}}function rp(e,t){let r={};if(t instanceof Error&&t.message.trim().length>0&&(r.reason=t.message.trim()),typeof t!="object"||t===null)return r;let n=t;if(typeof n.index=="number"&&Number.isInteger(n.index)&&n.index>=0&&(r.patchIndex=n.index),typeof n.operation=="object"&&n.operation!==null){let o=n.operation;Object.assign(r,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(r.patchIndex!==void 0){let o=e[r.patchIndex];o&&(r.op??=o.op,r.path??=o.path,r.from??=o.from)}return r}function Dc(e,t,r={}){let n=e.trim(),o=r.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=tp(t,Yt(t,!0));if(!n)throw new g(`Missing ${o} target. Use a timestamp or version number.`,w.USAGE,s);if(/^\d+$/.test(n)){let l=Yt(t),f=Number(n);if(f>=1&&f<=l)throw new g(`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 g(`${i} version must be between ${l+1} and ${l+t.length} for this item.`,w.USAGE,s);return{kind:"version",raw:n,historyIndex:f-l-1}}let c=Date.parse(n);if(!Number.isFinite(c))throw new g(`Invalid ${o} target "${e}". Use a positive version number or ISO timestamp.`,w.USAGE,s);let d=ep(t,c);if(d<0||r.allowFutureTimestamp!==!0&&c>Date.parse(a))throw new g(o==="restore"?`No history entries exist at or before timestamp ${n}.`:`No history entry exists at timestamp ${n}.`,w.USAGE,s);return{kind:"timestamp",raw:n,historyIndex:d}}function ai(e,t,r,n){let o=Xe(e,t);if(o.ok)return o.document;let i=rp(t,o.error),s=[`history_op=${n}`,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 g(`Failed to apply history patch at entry ${r} (${s.join(", ")}). ${i.reason??String(o.error)}`,w.GENERIC_FAILURE)}function Nc(e,t){let r=e[0];if(r&&r.op!=="create"&&r.op!=="history_compact_baseline"){let s=Xe(mt,r.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new g("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 n=e.slice(0,t+1),o=we([...n]),i=structuredClone(mt);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new g(`History target entry ${s+1} does not exist.`,w.USAGE);i=ai(i,a.patch,s+1,a.op)}if(!o.ok)throw new g(`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 iv(e,t){if(Object.keys(e.metadata).length>0){if(typeof e.metadata.id!="string"||!Array.isArray(e.metadata.tags))throw new g("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 g(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,w.USAGE)}import di from"node:fs/promises";import pn 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 li(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:$e(t),suggested_retry_args:t}}function hn(e){return new g(`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 ci(e){return new g(`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 np(e){let t=pn.resolve(e),r=pn.parse(t).root,n=pn.dirname(t);for(;n!==r;){let o;try{o=await di.stat(n)}catch(i){if(Le(i,"ENOTDIR"))throw hn(e);if(!Le(i,"ENOENT"))throw i;n=pn.dirname(n);continue}if(!o.isDirectory())throw hn(e);return}}async function vt(e){let t;try{t=await di.stat(e)}catch(r){throw Le(r,"ENOENT")?(await np(e),new g(`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:li(e)})):Le(r,"ENOTDIR")?hn(e):Le(r,"EACCES")||Le(r,"EPERM")?ci(e):r}if(!t.isDirectory())throw hn(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw ci(e);try{await(await di.opendir(e)).close()}catch(r){throw Le(r,"EACCES")||Le(r,"EPERM")?ci(e):r}}async function ui(e){if(await vt(e),!await je(et(e)))throw new g(`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:li(e)})}import Et from"node:fs/promises";import{statSync as op}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 ip(e,t){let r=-1,n=structuredClone(mt);for(let[a,c]of e.entries()){if(n=ai(n,c.patch,a+1,c.op),n.metadata.id!==void 0&&n.metadata.id!==t)throw new g(`History belongs to item ${String(n.metadata.id)}, expected ${t}.`,w.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});n.metadata.id===t&&Array.isArray(n.metadata.tags)&&(r=a)}let o=Yt(e,!0),i=r<0||o===null?null:o+r+1,s=i===null?void 0:String(i);if(r>=0&&s===void 0){let a=e[r].ts;Dc(a,e).historyIndex===r&&(s=a)}return{version:i,target:s}}async function Lc(e,t,r){let n=new Set([Ye(t,r),jt(t)]);for(let o of n){let i=fe(e,o);if(!op(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=Nc(s,s.length-1);if(Object.keys(c.metadata).length!==0)continue;let{version:d,target:l}=ip(s,o),f=l===void 0?["history",o,"--verify"]:["get",o,"--at",l],m=$e(f);return new g(`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 fi from"node:path";import{isUtf8 as sp}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]="5dd36511-d680-55ce-b535-5c1fbfaf63ec")}catch{}})();async function ap(e){try{return await Et.access(e),!0}catch{return!1}}function cp(e,t){e&&(e.includes(t)||e.push(t))}function Pc(e){return e??or(me())}function dp(e){return e==="toon"?["toon","json_markdown"]:e==="json_markdown"?["json_markdown","toon"]:["toon","json_markdown"]}async function yn(e,t,r="pm-",n,o=Pe){let i=t.trim(),s=i.startsWith("#")?i.slice(1):i;if(s.length===0)return null;let a=Ye(t,r),c=jt(t),d=[...new Set([s,a,c])].filter(m=>m.length>0),l=Object.entries(o),f=dp(n);for(let m of d){let p=new Map;for(let[_]of l)for(let b of f){let y=vn(e,_,m,b,o);await ap(y)&&p.set(y,p.get(y)??{id:m,type:_,itemPath:y,item_format:b})}if(p.size>1){let _=[...p.keys()].map(b=>fi.relative(e,b).split(fi.sep).join("/")).sort();throw new g(`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 gn(e,t={}){let r=await lp(e,t);if(r.error!==null)throw r.error;return{raw:r.raw,document:r.document}}async function lp(e,t={}){let r=await Et.readFile(e.itemPath);if(!sp(r))throw new g("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:r.length,empty:!1});let n=r.toString("utf8");await ke({path:e.itemPath,scope:"project"});let o;try{o=kr(n,{format:e.item_format,schema:t.schema,extensionFieldNames:Pc(t.extensionFieldNames),onWarning:i=>cp(t.warnings,i)})}catch(i){if(i instanceof g&&i.code==="item_document_invalid")return{raw:n,document:null,error:new g(`Cannot read ${e.id} at ${e.itemPath}${r.length===0?" (zero-length file)":""}: ${i.message}`,i.exitCode,{...i.context,item_id:e.id,item_path:e.itemPath,byte_length:r.length,empty:r.length===0,nextSteps:[`Run pm history ${e.id} --full, then pm restore ${e.id} <version> to recover a recorded state.`]})};throw i}return{raw:n,document:o,error:null}}async function up(e,t,r=Pe,n,o){await vt(e);let i=await $a(e,t,r,n,o);return Ur(i.length),i.map(s=>s.metadata)}async function Mc(e,t,r=Pe,n,o){await vt(e);let i=await Ha(e,t,r,n,o);return Ur(i.length),i.map(s=>s.metadata)}async function Jv(e,t,r=Pe,n,o,i={}){await vt(e);let s=await en(e,t,r,n,o,{includeBody:!0,forceSourceScan:i.forceSourceScan});return Ur(s.length),s.map(a=>({...a.metadata,body:a.body}))}function jc(e){return{async get(t){let r=await yn(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!r)return null;let{document:n}=await gn(r,{schema:e.settings.schema});return{item:n.metadata,body:n.body}},list:()=>up(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema)}}async function fp(e,t){let r=new Set(Object.values(t)),n=[];return await Promise.all([...r].map(async o=>{try{let i=await Et.readdir(fi.join(e,o));for(let s of i)for(let a of sr)if(s.toLowerCase().endsWith(a)){n.push(s.slice(0,-a.length));break}}catch{}})),n}async function mp(e,t,r,n){let o=Ye(t,r),i=await fp(e,n);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 _p(e,t,r,n){let o=await Lc(e,t,r);if(o)return o;let i=await mp(e,t,r,n),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 g(`Item ${t} not found`,w.NOT_FOUND,{nextSteps:s})}function pp(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 Fc(e){let t=e.typeToFolder??ir(e.settings,me()).type_to_folder,r=await yn(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,t);if(!r)throw await _p(e.pmRoot,e.id,e.settings.id_prefix,t);let n=await W(e.pmRoot,r.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 gn(r,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames,warnings:o}),a=s.metadata.assignee?.trim(),c=s.metadata.claim_principal?.trim()||a,d=ys(e.author),l=_n(e.settings);if(a&&c!==d&&!e.force&&!pp(e.op,e.bypassAssigneeConflict)){if(l.ownership_enforcement==="strict")throw new g(`Item ${r.id} is assigned to ${a}. Use --force to override.`,w.CONFLICT);l.ownership_enforcement==="warn"&&o.push(`ownership_warning:assignee_conflict:${r.id}:${a}`)}return{typeToFolder:t,located:r,originalRaw:i,document:s,warnings:o,releaseLock:n}}catch(o){throw await n(),o}}function hp(e,t,r){if(!e.handled||typeof e.result!="object"||e.result===null)return{effectiveTargetItemPath:t,effectiveSerializedAfter:r,skipItemWrite:!1};let n=e.result;return{effectiveTargetItemPath:typeof n.target_item_path=="string"&&n.target_item_path.trim().length>0?n.target_item_path:t,effectiveSerializedAfter:typeof n.contents=="string"?n.contents:r,skipItemWrite:n.skip_write===!0}}async function yp(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 $c(e){ur(e.op);let t=await Fc({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:r,located:n,originalRaw:o,document:i,warnings:s,releaseLock:a}=t;try{let c=ne(i,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),d=ne(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=ne(d,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),p=await Io({pmRoot:e.pmRoot,settings:e.settings,operation:e.op,author:e.author,before:c,after:m});await In({pm_root:e.pmRoot,operation:e.op,before:c,after:m,changed_fields:l.changedFields,sdk:jc({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:r})});let _=await si({pmRoot:e.pmRoot,settings:e.settings,itemId:n.id,commandLabel:e.op}),b="toon",y=Ls(m,{format:b,schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),S=vn(e.pmRoot,m.metadata.type,n.id,b,r),A=fe(e.pmRoot,n.id),L=await Ot("item_store_write",{op:e.op,pm_root:e.pmRoot,item_id:n.id,source_item_path:n.itemPath,target_item_path:S,history_path:A,item_format:b,before:c,after:m,contents:y}),{effectiveTargetItemPath:$,effectiveSerializedAfter:x,skipItemWrite:q}=hp(L,S,y),B=await Lo(e.pmRoot,e.author),Q=[];try{q||await K($,x),!q&&$!==n.itemPath&&await Et.rm(n.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 yp({skipItemWrite:q,effectiveTargetItemPath:$,originalItemPath:n.itemPath,originalRaw:o}),te}q||(Q=await Po({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:r,schema:e.settings.schema,itemPath:$,previousItemPath:n.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 kn({id:m.metadata.id,op:e.op,item_type:m.metadata.type,previous_status:c.metadata.status,status:m.metadata.status,previous:dr(c.metadata,l.changedFields),current:dr(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 Qv(e){return $c(e)}async function Zv(e){return $c(e)}async function eE(e){let t=await Fc({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:"delete",author:e.author,force:e.force}),{located:r,originalRaw:n,document:o,warnings:i,releaseLock:s}=t;try{let a=Pc(void 0),c=ne(o,{schema:e.settings.schema,extensionFieldNames:a}),d=await Io({pmRoot:e.pmRoot,settings:e.settings,operation:"delete",author:e.author,before:c,after:null,dryRun:e.dryRun});await In({pm_root:e.pmRoot,operation:"delete",before:c,after:null,changed_fields:["deleted"],sdk:jc({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t.typeToFolder})});let l=await si({pmRoot:e.pmRoot,settings:e.settings,itemId:r.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,r.id),b=await Ot("item_store_delete",{op:"delete",pm_root:e.pmRoot,item_id:r.id,item_path:r.itemPath,history_path:_,before:c}),y=r.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&&(y=x.item_path),x.skip_delete===!0&&(S=!0)}if(e.dryRun===!0)return{item:c.metadata,changedFields:["deleted"],targetPath:y,warnings:[...i,...d.warnings,...l.warnings,...b.warnings]};let A=await Lo(e.pmRoot,e.author),L=[];try{S||await Et.rm(y);try{await ft(_,p)}catch(x){throw S||await K(y,n),x}S||(L=await Po({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:t.typeToFolder,schema:e.settings.schema,itemPath:y,document:null}))}finally{await A()}let $=[...await _e({path:y,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 kn({id:c.metadata.id,op:"delete",item_type:c.metadata.type,previous_status:c.metadata.status,previous:dr(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 gp=["tree","graph","context"],bp=["none","repeated"],wp=["outgoing","incoming","both"],vp=32,Ep=200,kp=400,Ip=16e3;function Sp(e){let t=e?.trim().toLowerCase()??"tree";if(gp.includes(t))return t;throw new g(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,w.USAGE)}function kt(e,t){if(e===void 0)return;let r=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(r)||r<1)throw new g(`Invalid --${t} value "${e}". Use a positive integer.`,w.USAGE);return r}function zc(e){if(e===void 0)return;let t=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(t)||t<0)throw new g(`Invalid --max-depth value "${e}". Use a non-negative integer.`,w.USAGE);return t}function Tp(e){let t=e?.trim().toLowerCase()??"none";if(bp.includes(t))return t;throw new g(`Invalid --collapse value "${e}". Use "none" or "repeated".`,w.USAGE)}function Cp(e){let t=e?.trim().toLowerCase()??"both";if(wp.includes(t))return t;throw new g(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,w.USAGE)}function Op(e,t=ue()){if(e===void 0)return;let r=(Array.isArray(e)?e:[e]).flatMap(o=>o.split(",")).map(o=>o.trim()).filter(o=>o.length>0);if(r.length===0)return;let n=new Set;for(let o of r){let i=t.resolve(o);if(!i){let s=t.list().map(a=>a.kind).join(", ");throw new g(`Invalid --kind value "${o}". Registered kinds: ${s}.`,w.USAGE)}n.add(i.kind)}return[...n].sort()}function xp(e){if(!e||e.length===0)return[];let t=e.map(({id:n,kind:o})=>({id:n.trim(),kind:o.trim().toLowerCase()})).sort((n,o)=>{let i=n.kind.localeCompare(o.kind);return i!==0?i:n.id.localeCompare(o.id)}),r=new Map;for(let n of t){let o=`${n.kind.toLowerCase()}::${n.id.toLowerCase()}`;r.has(o)||r.set(o,{id:n.id,kind:n.kind})}return[...r.values()]}function Rp(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:xp(e.dependencies)}}function Ap(e){return lr(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function Dp(e,t,r,n,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(Uc(d.id,r,n,o,i,s,a,c+1,d.kind))}}function Np(e,t,r,n,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:n!==void 0&&a>=n?(t.dependencies.length>0&&(e.truncated=!0,s.reasons.add("max_depth")),!0):o==="repeated"&&i.has(r)?(e.collapsed=!0,!0):!1}function Uc(e,t,r,n,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:r.has(d),dependencies:[]};if(s.nodes+=1,s.estimatedTokens+=Ap(f),Np(f,l,d,n,o,i,s,a))return f;o==="repeated"&&i.add(d);let m=new Set(r);return m.add(d),Dp(f,l,t,m,n,o,i,s,a),f}function Hc(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 Lp(e){let t=new Map,r=new Map,n=[e];for(;n.length>0;){let a=n.pop();t.set(a.id,Hc(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,Hc(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}`;r.has(l)||r.set(l,{from:a.id,to:c.id,kind:d}),c.cycle||n.push(c)}}let o=[...t.values()].sort((a,c)=>a.id.localeCompare(c.id)),i=[...r.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 Bc(e,t,r){let n=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();n.add(l);let f=t.get(l);if(!f){i.add(l);continue}if(!(r!==void 0&&d.depth>=r)&&!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:n.size,edge_count:o.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function Pp(e,t=ue()){let r=zc(e.maxDepth),n=kt(e.nodeLimit,"node-limit"),o=kt(e.edgeLimit,"edge-limit"),i=kt(e.tokenBudget,"token-budget"),s=Op(e.kind,t);return{direction:Cp(e.direction),...s===void 0?{}:{kinds:s},...r===void 0?{}:{maxDepth:r},...n===void 0?{}:{nodeLimit:n},...o===void 0?{}:{edgeLimit:o},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function Mp(e,t,r,n){return Qa(e.graph,t,e.details.map(o=>o.id===t&&n.length>0?{...o,evidence:n}:o),r)}function mi(e,t,r,n){for(let o of r.slice(0,n)){let i=o?.trim();i&&e.push(`${t}:${i}`)}}async function jp(e,t,r,n){let o=await yn(e,t,r.id_prefix,r.item_format,n);if(!o)return[];let{document:i}=await gn(o,{schema:r.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 mi(f,"file",a.map(m=>m.path),3),mi(f,"test",c.map(m=>m.command??m.path),2),mi(f,"doc",d.map(m=>m.path),2),f}function Fp(e){let{canonicalId:t,context:r,missingCount:n,missingReferences:o,referenceLimit:i,summaryOnly:s}=e;return{id:t,format:"context",node_count:r.nodes.length+1,edge_count:r.edges.length,edge_basis:"deduplicated_directed",missing_count:n,missing_scope:"traversal",missing_reference_count:o.length,...s?{}:{missing_references:o.slice(0,i),context:r}}}function $p(e){let{row:t,missingReachableSet:r,packetIds:n,filteredKinds:o,registry:i}=e;if(t.no_active_blocker_sentinel||!r.has(t.target_id.trim().toLowerCase())||!n.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 Wc(e,t,r){let n;for(;;){let o=lr(new TextEncoder().encode(On(Tn("deps",e),t)).byteLength);if(o===n)return o;r(o),n=o}}function Hp(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function zp(e){try{return Mp(e.assembly,e.canonicalId,{...e.contextOptions,...e.internalTokenBudget===void 0?{}:{tokenBudget:e.internalTokenBudget}},e.rootEvidence)}catch(t){if(e.smallestResult!==void 0&&Hp(t))return e.smallestResult;throw t}}function Up(e){let{assembly:t,canonicalId:r,contextOptions:n,rootEvidence:o,summaryOnly:i,outputFormat:s,missingCount:a,missingReferences:c}=e,d=n.edgeLimit??40,l=n.tokenBudget,f,m;for(;;){let p=zp({assembly:t,canonicalId:r,contextOptions:n,internalTokenBudget:l,rootEvidence:o,smallestResult:m});if("format"in p)return p;let _=p;f??=_.meta.tokenBudget,l??=f;let b=Fp({canonicalId:r,context:_,missingCount:a,missingReferences:c,referenceLimit:d,summaryOnly:i});if(m=b,i||(_.meta.tokenBudget=f,_.meta.usedTokens=Wc(It(b,!1),s,A=>{_.meta.usedTokens=A}),_.meta.usedTokens<=f))return b;if(d>0){d-=1;continue}let y=l,S=y*f/_.meta.usedTokens;l=Math.min(y-1,Math.max(1,Math.floor(S*.9)))}}function Bp(e){let{assembly:t,canonicalId:r,options:n,rootEvidence:o,summaryOnly:i,outputFormat:s}=e,a=Pp(n,t.graph.registry()),c=t.graph.closure(r,{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([r,...c.value]),_=[...t.dangling.active,...t.dangling.legacy_terminal].filter(b=>$p({row:b,missingReachableSet:l,packetIds:p,filteredKinds:m,registry:f}));return Up({assembly:t,canonicalId:r,contextOptions:a,rootEvidence:o,summaryOnly:i,outputFormat:s,missingCount:d.length,missingReferences:_})}function Wp(e){let t=[e],r;for(;t.length>0;){let n=t.pop();n.dependencies.length>0&&(r=n,t.push(...n.dependencies))}return r?(r.dependencies.pop(),r.truncated=!0,!0):!1}function Vp(e,t,r,n,o,i,s){let a=o??vp,c=kt(r.nodeLimit,"node-limit")??Ep,d=kt(r.edgeLimit,"edge-limit")??kp,l=kt(r.tokenBudget,"token-budget")??Ip,f={nodeLimit:c,edgeLimit:d,tokenBudget:l,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},m=Uc(e,n,new Set,a,t==="graph"?"repeated":i,new Set,f),p=Bc(e,n,void 0),_;for(;;){let b=Lp(m),y=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,...y?{truncation:y}:{}};if(_=t==="tree"?{...S,tree:m}:{...S,graph:b},(_.truncation===void 0?lr(new TextEncoder().encode(On(Tn("deps",It(_,!1)),s)).byteLength):Wc(It(_,!1),s,A=>{_.truncation.estimated_tokens=A}))<=l)return _;if(!Wp(m))return f.reasons.add("token_budget"),_;f.reasons.add("token_budget")}}function It(e,t,r={}){let n={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"};return{...e,legacy_alias_counts:r,projection:{mode:t?"summary":"full",declared_field_groups:[n],included_field_groups:t?[]:[n.name]}}}async function vE(e,t,r){let n=Di(process.cwd(),r.path);await ui(n);let o=Sp(t.format),i=zc(t.maxDepth),s=Tp(t.collapse);Bi(t.summary===!0,t.full===!0,"--summary");let a=t.summary===!0,c=await Rc(n),d=ir(c,me()),l=await Mc(n,c.item_format,d.type_to_folder,void 0,c.schema),f=cr(c.schema),m=new Map(l.map(_=>[_.id.trim().toLowerCase(),Rp(_)])),p=Uo(l,_=>ge(_,f));for(let _ of[...p.active,...p.legacy_terminal]){let b=m.get(_.holder_id.trim().toLowerCase()),y=_.kind.trim().toLowerCase();b&&!b.dependencies.some(S=>S.id.trim().toLowerCase()===_.target_id.trim().toLowerCase()&&S.kind===y)&&b.dependencies.push({id:_.target_id,kind:y})}if(!m.has(e.trim().toLowerCase()))throw new g(`Item ${e} not found`,w.NOT_FOUND);if(o==="context"){let _=m.get(e.trim().toLowerCase()).id,b=a?[]:await jp(n,_,c,d.type_to_folder),y=L=>ge(L,f),S=de(),A=Ja().lookup(n,Xa(l,y,S),()=>sn(l,y,S));return It(Bp({assembly:A.assembly,canonicalId:_,options:t,rootEvidence:b,summaryOnly:a,outputFormat:r.json===!0?"json":"toon"}),a,A.assembly.legacyAliasCounts)}return a?It({id:e,format:o,...Bc(e,m,i)},!0,Object.fromEntries(Object.entries(sn(l,_=>ge(_,f)).legacyAliasCounts))):It(Vp(e,o,t,m,i,s,r.json===!0?"json":"toon"),!1,Object.fromEntries(Object.entries(sn(l,_=>ge(_,f)).legacyAliasCounts)))}export{Ko as a,He as b,Rn as c,Gp as d,Kp as e,ts as f,Pn as g,nh as h,oh as i,ih as j,sh as k,ah as l,ch as m,Wn as n,Vn as o,ds as p,gh as q,bh as r,wh as s,vh as t,Eh as u,kh as v,Xn as w,_s as x,Ih as y,Sh as z,Th as A,Id as B,ys as C,gs as D,xh as E,Td as F,bs as G,We as H,Ce as I,ks as J,xt as K,Bh as L,Wh as M,Yn as N,Ah as O,Dh as P,ws as Q,Cd as R,Nh as S,yr as T,ot as U,ge as V,br as W,Er as X,kr as Y,Ls as Z,ne as _,Zl as $,be as aa,ct as ba,wu as ca,Ry as da,Ay as ea,Dy as fa,Ou as ga,Dr as ha,Ge as ia,Mt as ja,rg as ka,bo as la,Pr as ma,ra as na,ng as oa,ia as pa,og as qa,ut as ra,ft as sa,Ps as ta,mt as ua,Mr as va,_g as wa,vo as xa,jr as ya,pg as za,hg as Aa,la as Ba,Xe as Ca,ma as Da,we as Ea,ef as Fa,yg as Ga,gg as Ha,pt as Ia,$r as Ja,Fg as Ka,$g as La,ba as Ma,va as Na,Hg as Oa,pw as Pa,De as Qa,Mw as Ra,__ as Sa,_n as Ta,mn as Ua,V_ as Va,xc as Wa,Rc as Xa,jw as Ya,Uw as Za,si as _a,Z_ as $a,pa as ab,jt as bb,Ye as cb,Sg as db,Yt as eb,Dc as fb,ai as gb,Nc as hb,iv as ib,lf as jb,ff as kb,mf as lb,_f as mb,pf as nb,Io as ob,nb as pb,db as qb,lb as rb,ub as sb,La as tb,Df as ub,Lo as vb,Ib as wb,Po as xb,en as yb,vt as zb,ui as Ab,yn as Bb,gn as Cb,lp as Db,up as Eb,Mc as Fb,Jv as Gb,jc as Hb,_p as Ib,Qv as Jb,Zv as Kb,eE as Lb,jo as Mb,lm as Nb,Vt as Ob,rn as Pb,Ua as Qb,um as Rb,fm as Sb,mm as Tb,hm as Ub,Vb,qb as Wb,Cm as Xb,de as Yb,Fb as Zb,on as _b,$b,Sm as ac,Hb as bc,Gt as cc,xm as dc,Am as ec,Uo as fc,Dm as gc,Zb as hc,sn as ic,Xa as jc,Bo as kc,Ja as lc,ow as mc,Qa as nc,kt as oc,zc as pc,Cp as qc,Op as rc,vE as sc};
|
|
165
|
-
//# sourceMappingURL=chunk-
|
|
165
|
+
//# sourceMappingURL=chunk-6KFKQD2D.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ab as Pe,Fb as Le,V as Oe,Xa as je,Yb as Fe,Za as Me,hc as G,ic as Ge,jc as $e,lc as qe,oc as $,pc as Ue,qc as Be,rc as ze}from"./chunk-GITOYRUW.js";import{n as Se}from"./chunk-B5RSLVE6.js";import{$ as w,$c as De,Kc as Ce,Ob as I,Ta as xe,Wd as Ae,Za as Ee,aa as k,dd as Te,de as Re,ed as oe,gc as ie,hd as Ne,ka as we,pa as ke,va as j,xa as re,za as Ie}from"./chunk-GUIF3WVC.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,r,n,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,r.id);let s=r.depth+1;return e.queue.push({id:t,depth:s}),e.cursorFound?(e.affected.push({id:t,distance:s,path:Yt(n,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function Ke(e,t,r,n){let i=Te("graph impact",{root:e,direction:r,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(n)?n:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:Ne(t.after,i)}}function C(e,t,r){e.get(t).add(r)}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,r)=>r.length-t.length||t[0].localeCompare(r[0]))}function q(e){if(Array.isArray(e))return e.map(r=>q(r));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(([r],[n])=>r.localeCompare(n)).map(([r,n])=>[r,q(n)]))}function He(e){return JSON.stringify(q(e))}function Bt(e,t,r,n){let i=[{id:e,expanded:!1}];for(;i.length>0;){let o=i.pop();if(o.expanded){n.push(o.id);continue}if(r.has(o.id))continue;r.add(o.id),i.push({id:o.id,expanded:!0});let s=[...t.get(o.id)].sort().reverse();for(let a of s)r.has(a)||i.push({id:a,expanded:!1})}}function zt(e,t){let r=new Set,n=[];for(let i of e)r.has(i)||Bt(i,t,r,n);return n}function Ht(e,t){let r=new Set,n=[];for(let i of[...e].reverse()){if(r.has(i))continue;let o=[],s=[i];for(r.add(i);s.length>0;){let a=s.pop();o.push(a);for(let c of t.get(a))r.has(c)||(r.add(c),s.push(c))}n.push(o)}return Ve(n)}function We(e,t){let r=M(e);for(let[n,i]of t)for(let o of i)C(r,o,n);return Ht(zt(e,t),r)}function Kt(e,t){let r=M(e.nodes());for(let n of e.edges()){let i=t.require(n.kind);if(!i.ordering)continue;let o=(i.precedence??"source_before_target")==="source_before_target";C(r,o?n.source:n.target,o?n.target:n.source)}return r}function Vt(e,t){let r=new Map(e.map(o=>[o,0]));for(let o of t.values())for(let s of o)r.set(s,r.get(s)+1);let n=e.filter(o=>r.get(o)===0).sort(),i=[];for(;n.length>0;){i.push(n);let o=[];for(let s of n)for(let a of t.get(s)){let c=r.get(a)-1;r.set(a,c),c===0&&o.push(a)}n=o.sort()}return i}function Wt(e,t){let r=new Map(e.map(s=>[s,0])),n=new Map;for(let s of e)for(let a of t.get(s)){if(!r.has(a))continue;let c=r.get(s)+1,d=n.get(a);(c>r.get(a)||c===r.get(a)&&(d===void 0||s.localeCompare(d)<0))&&(r.set(a,c),n.set(a,s))}let i=[...e].sort((s,a)=>r.get(a)-r.get(s)||s.localeCompare(a))[0],o=i===void 0?[]:[i];for(;o[0]!==void 0&&n.has(o[0]);)o.unshift(n.get(o[0]));return{depth:Object.fromEntries(r),path:o}}function Yt(e,t,r){let n=[t],i=t;for(;i!==e;)i=r.get(i),n.push(i);return n.reverse()}function B(e,t={}){let r=t.registry??we(),n=[...e.nodes()],i=Kt(e,r),o=Vt(n,i),s=o.flat(),a=s.length===n.length,c=a?[]:We(n,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,r){let n=M(e.nodes()),i=r===void 0?void 0:new Set(r.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(n,t==="incoming"?s.target:s.source,t==="incoming"?s.source:s.target)}return{adjacency:n,inspectedEdges:o.length}}function Jt(e,t,r,n,i,o){let s=U(e,t,{...r,after:void 0,direction:"incoming",limit:void 0}),a=U(e,t,{...r,after:void 0,direction:"outgoing",limit:void 0}),c=new Map,d=[...s.affected,...a.affected].sort((h,m)=>h.distance-m.distance||h.id.localeCompare(m.id)||h.path.join("\0").localeCompare(m.path.join("\0")));for(let h of d)c.has(h.id)||c.set(h.id,h);let l=[...c.values()].sort((h,m)=>h.distance-m.distance||h.id.localeCompare(m.id)),g=n===void 0||n===t?-1:l.findIndex(h=>h.id===n);if(n!==void 0&&n!==t&&g<0)throw new TypeError(`Unknown impact cursor item: ${n}`);let u=l.slice(g+1,g+1+i),p=g+1+u.length<l.length;return{root:t,affected:u,exact:!0,truncated:s.truncated||a.truncated||p,...p?{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,r){let n=r.direction,i=r.maxDepth??Number.POSITIVE_INFINITY,o=r.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,r,n,i),{adjacency:c,inspectedEdges:d}=Xt(e,n,r.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,p=!1;e:for(let h=0;h<l.queue.length;h+=1){r.signal?.throwIfAborted();let m=l.queue[h];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,p=!0;break e}}if(!l.cursorFound)throw new TypeError(`Unknown impact cursor item: ${a}`);return{root:t,affected:l.affected,exact:!0,truncated:u,...p?{nextCursor:oe(s,l.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:g,inspectedEdges:d}}}function U(e,t,r={}){let n=r.direction??"outgoing";if(n!=="both")return Qt(e,t,{...r,direction:n});let i=r.maxDepth??Number.POSITIVE_INFINITY,o=r.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,r,n,i);return Jt(e,t,r,a,o,s)}function Ye(e){let t=[...e.nodes()],r=M(t),n=M(t);for(let c of e.edges())C(r,c.source,c.target),C(r,c.target,c.source),C(n,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 r.get(g))o.has(u)||(o.add(u),l.push(u))}i.push(d)}let s=t.map(c=>({id:c,degree:r.get(c).size})),a=Math.max(0,...s.map(({degree:c})=>c));return{components:Ve(i),stronglyConnected:We(t,n),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 r=new Map(e.edges.map(i=>[He(i),i])),n=new Map(t.edges.map(i=>[He(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),removed:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),unchangedCount:[...r.keys()].filter(i=>n.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 r=P(e,t);return{predecessor:r,successor:r===e.source?e.target:e.source}}function nn(e,t,r){if(t===void 0)return;let n=e.registry(),i=new Set;for(let o of t){let s=n.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!==r&&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,r,n,i){let o=e.registry(),s=e.neighborEdges(t,{direction:"both",...r===void 0?{}:{kinds:[...r]}}),a=[],c=new Set;for(let d of s.value){let l=o.require(d.edge.kind);r===void 0&&!l[n]||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,r,n,i,o){if(t>=r)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>=n)return o.truncated=!0,!0;o.value.push(s)}return!1}function H(e,t,r,n,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let o=nn(e,r.kinds,n),s=r.limit??Number.POSITIVE_INFINITY,a=r.maxDepth??Number.POSITIVE_INFINITY,c=r.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){r.signal?.throwIfAborted();let p=d.queue[u];l+=1;let h=rn(e,p.id,o,n,i);if(g+=h.inspectedEdges,on(h,p.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,r,n,i){let o=e.neighborEdges(t.nodes.at(-1),{direction:n,...r.kinds===void 0?{}:{kinds:r.kinds}});return i.inspectedEdges+=o.meta.inspectedEdges,o.value.filter(s=>!t.nodeSet.has(s.id))}function sn(e,t,r,n,i,o,s){for(let a of Je(e,t,n,i,s)){let c=[...t.nodes,a.id],d=new Set(t.nodeSet).add(a.id),l=[...t.edges,a.edge];if(a.id===r){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,r={}){return H(e,t,r,"hierarchy",(n,i)=>z(n.edge,i)===n.id)}function Ze(e,t,r={}){return H(e,t,r,"hierarchy",(n,i,o)=>z(n.edge,i)===o)}function et(e,t,r={}){return H(e,t,r,"ordering",(n,i)=>P(n.edge,i)===n.id)}function tt(e,t,r={}){return H(e,t,r,"ordering",(n,i,o)=>P(n.edge,i)===o)}function an(e,t,r,n,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(n.signal?.throwIfAborted(),c.value.length>=g||d>=o){l=!0;break}let p=c.queue[u];if(d+=1,p.edges.length>=s){Je(e,p,n,a,c).length>0&&(l=!0);continue}if(sn(e,p,r,n,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,r,n={}){Xe(e,t),Xe(e,r);let i=n.maxPaths??Zt,o=n.maxVisitedPaths??en,s=n.maxDepth??tn;se("maxPaths",i),se("maxVisitedPaths",o),se("maxDepth",s);let a=n.direction??"outgoing";n.signal?.throwIfAborted();for(let c of n.kinds??[])e.registry().require(c);return t===r?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,r,n,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,r){let n=e.registry(),i=t===void 0?void 0:new Set(t.map(o=>n.require(o).kind));for(let o of e.edges()){if(o.source===o.target)continue;let s=n.require(o.kind);i!==void 0&&!(i.has(s.kind)||s.inverse!==void 0&&i.has(s.inverse))||r(o,s)}}function un(e,t){let r=new Map;V(e,t,n=>{rt(r,n.source,n.target),rt(r,n.target,n.source)});for(let n of r.values())n.sort();return r}function rt(e,t,r){let n=e.get(t);n===void 0?e.set(t,[r]):n.push(r)}function gn(e,t){let r=new Map;for(let o of e){let s=t.get(o);r.set(s,(r.get(s)??0)+1)}let n,i=0;for(let[o,s]of r)(s>i||s===i&&o<n)&&(n=o,i=s);return n}function pn(e,t){let r=new Map;for(let[i,o]of e){let s=r.get(o);s===void 0?r.set(o,[i]):s.push(i)}let n=[];for(let i of r.values())i.length<t||(i.sort(),n.push({representative:i[0],size:i.length,members:i}));return n.sort((i,o)=>o.size-i.size||i.representative.localeCompare(o.representative))}function it(e,t={}){let r=t.maxIterations??cn,n=t.minSize??dn;K("maxIterations",r),K("minSize",n);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<r&&!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 p=gn(u,s);p!==s.get(g)&&(s.set(g,p),c=!1)}}return{value:{communities:pn(s,n),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 hn(e,t){if(t===void 0)return;let r=e.registry(),n=new Set;for(let i of t){let o=r.require(i);if(!W(o))throw new TypeError(`Relationship kind ${o.kind} is not a directed ordering or hierarchy kind`);n.add(Y(o))}return n}function fn(e,t){let r=e.registry(),n=new Map;for(let i of e.edges()){let o=r.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=n.get(s);c===void 0&&(c={adjacency:new Map,records:[]},n.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 n}function mn(e){let t=new Map;for(let[r,n]of e.adjacency)t.set(r,[...n].sort());return t}function _n(e,t,r,n){let i=[n];for(let o=r;o!==t;o=e.get(o))i.push(o);return i.push(t),i.reverse()}function yn(e,t,r,n,i,o){for(let s of e.get(r.id)??[])if(o.inspectedEdges+=1,!(r.depth===0&&s===t.to)&&!n.has(s)){if(n.set(s,r.id),s===t.to)return _n(n,t.from,r.id,s);i.push({id:s,depth:r.depth+1})}}function bn(e,t,r,n){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(n.visitedNodes+=1,a.depth>=r)continue;let c=yn(e,t,a,i,o,n);if(c!==void 0)return c}}function T(e,t={}){let r=t.maxDepth??ln;K("maxDepth",r),t.limit!==void 0&&K("limit",t.limit);let n=t.limit??Number.POSITIVE_INFINITY,i=hn(e,t.kinds),o=fn(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 p=bn(g,u,r,a);if(p!==void 0){if(s.length>=n){c=!0;break e}s.push({edge:u.edge,witness:p})}}}return{value:s,meta:{visitedNodes:a.visitedNodes,inspectedEdges:a.inspectedEdges,truncated:c}}}function vn(e,t,r,n,i){let o=new Set,s=[];for(let a of r){if(a.id===e||o.has(a.id))continue;if(!i.seen.has(a.id)){if(t>=n){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,r){let n=r.direction??"outgoing",i=r.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){r.signal?.throwIfAborted();let{id:l,depth:g}=a.queue[d];o.push(l);let u=e.neighborEdges(l,{direction:n,...r.kinds===void 0?{}:{kinds:r.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 r=[],n=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,n.has(a)||(n.add(a),i.push({id:a,index:0}))}else r.push(o.id),i.pop()}return r.reverse()}function In(e,t,r,n){let i=e,o=t;for(;i!==o;){for(;n.get(i)>n.get(o);)i=r.get(i);for(;n.get(o)>n.get(i);)o=r.get(o)}return i}function xn(e,t,r){let n;for(let i of[...e].sort())t.has(i)&&(n=n===void 0?i:In(n,i,t,r));return n}function En(e,t,r,n,i){let o=new Map([[t,t]]),s=!0;for(;s;){s=!1;for(let a of r){if(i?.throwIfAborted(),a===t)continue;let c=xn(e.predecessors.get(a),o,n);c!==void 0&&o.get(a)!==c&&(o.set(a,c),s=!0)}}return o}function ot(e,t,r={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(r.maxDepth!==void 0&&(!Number.isInteger(r.maxDepth)||r.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(r.maxDepth)}`);let n=wn(e,t,r),i=kn(n,t),o=new Map(i.map((d,l)=>[d,l])),s=En(n,t,i,o,r.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:n.order.length,rows:c},meta:{visitedNodes:n.order.length,inspectedEdges:n.inspectedEdges,truncated:n.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,r){let n=e.get(t);n===void 0?e.set(t,new Set([r])):n.add(r)}function ct(e,t){let r=new Map(e.nodes().map(i=>[i,new Set]));V(e,t,i=>{r.get(i.source).add(i.target),r.get(i.target).add(i.source)});let n=new Map;for(let[i,o]of r)n.set(i,[...o].sort());return n}function Sn(e,t){let r=new Map,n=new Map;return V(e,t,(i,o)=>{if(!o.ordering)return;let{predecessor:s,successor:a}=D(i,o);at(n,s,a),at(r,a,s)}),{incoming:r,outgoing:n}}function Cn(e,t,r){let n=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];r.visitedNodes+=1,s.push(g);let u=n.get(g);g!==e&&(c+=1,d+=u);for(let p of t.get(g))if(r.inspectedEdges+=1,n.has(p)||(n.set(p,u+1),a.push(p)),n.get(p)===u+1){i.set(p,(i.get(p)??0)+i.get(g));let h=o.get(p);h===void 0?o.set(p,[g]):h.push(g)}}return{stack:s,sigma:i,predecessors:o,reachableCount:c,distanceSum:d}}function Dn(e,t,r){let n=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let o=e.stack[i],s=(1+(n.get(o)??0))/e.sigma.get(o);for(let a of e.predecessors.get(o)??[])n.set(a,(n.get(a)??0)+e.sigma.get(a)*s);o!==t&&r.set(o,(r.get(o)??0)+(n.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,r,n,i){return{id:e,degree:t.get(e).length,inDegree:r.incoming.get(e)?.size??0,outDegree:r.outgoing.get(e)?.size??0,betweenness:st((n.get(e)??0)/2),closeness:st(i.get(e))}}function dt(e,t={}){let r=ct(e,t.kinds),n=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,r,a);s.set(l,Tn(g,i.length)),Dn(g,l,o)}let c=0;for(let l of r.values())c+=l.length;let d=i.map(l=>Nn(l,r,n,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,r){let n=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,r.inspectedEdges+=1,n!==e.parent){if(r.discovery.has(n)){r.low.set(e.node,Math.min(r.low.get(e.node),r.discovery.get(n)));return}return e.children+=1,r.discovery.set(n,r.timer),r.low.set(n,r.timer),r.timer+=1,{node:n,parent:e.node,neighborIndex:0,children:0}}}function On(e,t,r){if(e.parent===null){e.children>1&&r.articulation.add(e.node);return}let n=e.parent,i=r.low.get(e.node);r.low.set(n,Math.min(r.low.get(n),i)),n!==t&&i>=r.discovery.get(n)&&r.articulation.add(n),i>r.discovery.get(n)&&r.bridges.push(An(n,e.node))}function jn(e,t,r,n){r.discovery.set(e,r.timer),r.low.set(e,r.timer),r.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){n?.throwIfAborted();let o=i.at(-1);if(o.neighborIndex<t.get(o.node).length){let s=Rn(o,t,r);s!==void 0&&i.push(s)}else On(o,e,r),i.pop()}}function X(e,t={}){let r=ct(e,t.kinds),n={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())n.discovery.has(i)||jn(i,r,n,t.signal);return{value:{articulationPoints:[...n.articulation].sort(),bridges:n.bridges.sort((i,o)=>i.source.localeCompare(o.source)||i.target.localeCompare(o.target))},meta:{visitedNodes:n.discovery.size,inspectedEdges:n.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(),r=new Map,n=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(n.add(s),n.add(a),s===a)continue;let c=r.get(s);c===void 0?r.set(s,new Set([a])):c.add(a)}return{forward:r,participants:n}}function Pn(e,t,r,n){if(e===void 0)return n;let i=n;for(let o of e)t.has(o)&&(i=Math.min(i,r.get(o)));return i}function Ln(e,t,r){let n=r-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:r,latestFinish:r+1,slack:n,critical:n===0}}function Fn(e,t,r,n,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),n,o,i);o.set(a,c-1)}return e.map(s=>Ln(s,r[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 r=B(e,{registry:e.registry()}),n=Mn(e),i=new Set(r.order),o=r.order.filter(d=>n.participants.has(d)),s=o.reduce((d,l)=>Math.max(d,r.depth[l]+1),0),a=Fn(o,n,r.depth,i,s),c=a.length>0;return{exact:!0,acyclic:r.acyclic,makespan:s,scheduledCount:a.length,criticalPath:c?r.criticalPath:[],criticalPathLength:c?r.criticalPathLength:0,cycles:r.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,r){for(let n=e.length-1;n>=0;n-=1){r?.throwIfAborted();let i=t.get(e[n]);for(let o of i.successors){r?.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,r,n){let i=[],o=e;for(;o!==void 0&&i.length<r;)n?.throwIfAborted(),i.push(o),o=t.get(o).predecessor;return i.reverse(),{path:i,path_truncated:o!==void 0}}function qn(e,t,r,n,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-r)/6e4,g.latest=g.deadline,g.anchor=a):n(a,"invalid_deadline")}s.set(a,g)}return s}function Un(e,t,r){for(let n of e.edges()){r?.throwIfAborted();let i=e.registry().require(n.kind);if(!i.ordering)continue;let{predecessor:o,successor:s}=D(n,i),a=t.get(o);a.successors.has(s)||(a.successors.add(s),t.get(s).pending+=1)}}function Bn(e,t,r){let n=e.filter(i=>t.get(i).pending===0);for(let i=0;i<n.length;i+=1){r?.throwIfAborted();let o=n[i],s=t.get(o),a=s.earliest===null||s.duration===void 0?null:s.earliest+s.duration;for(let c of s.successors){r?.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&&n.push(c)}}return n}function zn(e,t,r,n,i,o,s,a){let c=t.duration;if(t.latest!==void 0){n.scheduled_count+=1;let d=t.latest-c;n.rows.length<o?n.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}):n.truncated=!0}if(t.deadline!==void 0&&t.earliest!==null&&t.earliest+c>t.deadline)if(n.overcommitted_count+=1,n.overcommitted.length<o){let d=$n(e,r,Math.min(o,s.remaining),a);s.remaining-=d.path.length,d.path_truncated&&(n.truncated=!0),n.overcommitted.push({deadline_id:e,deadline:t.item.deadline,shortfall_minutes:t.earliest+c-t.deadline,...d})}else n.truncated=!0}function Hn(e,t,r,n,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(n+(l.latest-l.duration)*6e4).getTime())){s(d,"date_range_exceeded");continue}l.earliest===null&&s(d,"unknown_predecessor_estimate"),zn(d,l,t,r,n,i,c,a)}}function ut(e,t,r={}){r.signal?.throwIfAborted();let n=Date.parse(r.now??new Date().toISOString());if(!Number.isFinite(n))throw new TypeError("Invalid scheduling clock");let i=r.maxWork??1e5,o=r.limit??10;for(let[u,p]of[["maxWork",i],["limit",o]])if(!Number.isSafeInteger(p)||p<1)throw new TypeError(`Invalid scheduling ${u}`);let s={as_of:new Date(n).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,p)=>{s.complete=!1,s.residual_count+=1,s.residuals.length<o?s.residuals.push({id:u,reason:p}):s.truncated=!0},l=qn(a,t,n,d,r.signal);Un(e,l,r.signal);let g=Bn(a,l,r.signal);return Gn(g,l,r.signal),Hn(a,l,s,n,o,i,d,r.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 ht(e,t,r,n){let i={all:N(),active:N(),terminal:N()},o=new Map;for(let s of e.details){if(n?.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=>r(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(n=>Number.isSafeInteger(t[n])&&Number(t[n])>=0)||!J(t.degree_histogram))return!1;let r=Object.entries(t.degree_histogram);return r.every(([n,i])=>/^(0|[1-9]\d*)$/.test(n)&&Number.isSafeInteger(i)&&Number(i)>=0)&&r.reduce((n,[,i])=>n+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 ft(e){for(let n of["ordering_acyclic","active_ordering_acyclic"])if(e[n]!==void 0&&typeof e[n]!="boolean")return!1;let t=e.coverage_by_lifecycle,r=e.coverage_by_status;return t===void 0&&r===void 0?!0:!J(t)||!J(r)?!1:["all","active","terminal"].every(n=>gt(t[n]))&&Object.values(r).every(gt)}function pt(e,t){return Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].sort().map(r=>{let n=Object.hasOwn(e,r)?e[r]:N(),i=Object.hasOwn(t,r)?t[r]:N(),o=Object.fromEntries([...new Set([...Object.keys(n.degree_histogram),...Object.keys(i.degree_histogram)])].sort().map(s=>[s,(i.degree_histogram[s]??0)-(n.degree_histogram[s]??0)]));return[r,{nodes:i.nodes-n.nodes,isolated:i.isolated-n.isolated,degree_leq_one:i.degree_leq_one-n.degree_leq_one,semantic_nodes:i.semantic_nodes-n.semantic_nodes,without_semantic_edges:i.without_semantic_edges-n.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:pt(e.coverage_by_lifecycle,t.coverage_by_lifecycle),coverage_by_status:pt(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,r,n,i,o,s,a){let c=[...i].sort((d,l)=>d.localeCompare(l));return{code:e,severity:t,policy:r,message:n(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(r=>R(r.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",r.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",n=>`${n} items participate in one hierarchy cycle.`,r.item_ids,t,r.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,r){let n=e.cardinality_violations.filter(i=>i.legacy_terminal===r);return n.length===0?[]:[R(r?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",r?"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.`,n.map(i=>i.child_id),t,r?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",n.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function vt(e,t,r){let n=e.divergences.filter(i=>i.legacy_terminal===r);return n.length===0?[]:[R(r?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",r?"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.`,n.map(i=>i.child_id),t,r?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",n.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function Jn(e,t){let r=G(e);return r?[...Xn(r,t),...bt(r,t,!1),...bt(r,t,!0),...vt(r,t,!1),...vt(r,t,!0)]:[]}function Qn(e){let t=e.graph.registry(),r=new Map;for(let n of e.graph.edges()){let i=t.require(n.kind);if(!i.ordering)continue;let[o,s]=(i.precedence??"source_before_target")==="target_before_source"?[n.target,n.source]:[n.source,n.target],a=r.get(o);a?a.push(s):r.set(o,[s])}for(let n of r.values())n.sort((i,o)=>i.localeCompare(o));return r}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,r,n){let i=r.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let o=i[e.neighborIndex];return e.neighborIndex+=1,n.indexes.has(o)?n.onStack.has(o)&&n.lowLinks.set(e.node,Math.min(n.lowLinks.get(e.node),n.indexes.get(o))):(kt(o,n),t.push({node:o,neighborIndex:0})),!0}function er(e,t,r,n){t.pop();let i=t.at(-1);if(i&&n.lowLinks.set(i.node,Math.min(n.lowLinks.get(i.node),n.lowLinks.get(e.node))),n.lowLinks.get(e.node)!==n.indexes.get(e.node))return;let o=[];for(;;){let s=n.stack.pop();if(n.onStack.delete(s),o.push(s),s===e.node)break}(o.length>1||o.length===1&&r.get(o[0])?.includes(o[0]))&&n.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},r=[...e.keys()].sort((n,i)=>n.localeCompare(i));for(let n of r){if(t.indexes.has(n))continue;let i=[{node:n,neighborIndex:0}];for(kt(n,t);i.length>0;){let o=i.at(-1);Zn(o,i,e,t)||er(o,i,e,t)}}return t.components.sort((n,i)=>n[0].localeCompare(i[0]))}function ce(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function y(e,t,r,n,i,o,s,a){t.length!==0&&e.push(R(n,i,o,s,t,r,a))}function nr(e,t,r){let n=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(o=>!o.no_active_blocker_sentinel);return y(n,i.filter(o=>!t(o.holder_status)).map(ce),r,"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(n,i.filter(o=>t(o.holder_status)).map(ce),r,"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(n,e.dangling.no_active_blocker_sentinels.map(ce),r,"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."),n}function le(e,t){let r=t.get(e);return r?!r.terminal:!0}function It(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function rr(e,t){let r=[],n=[];for(let o of e.orderingContradictions??[])(o.legacy_terminal?n:r).push(It(o));let i=[];return y(i,r,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,n,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,r,n){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,n,"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,n,"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&&r(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,n,"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(r=>r.kind).sort((r,n)=>r.localeCompare(n));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function ue(e){let t=e.graph.registry(),r=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=r.get(a);c?c.edges.push(i):r.set(a,{...s,edges:[i]})}let n=[...r.values()].filter(i=>i.edges.length>=2);for(let i of n)i.edges.sort((o,s)=>o.kind.localeCompare(s.kind));return n.sort((i,o)=>i.from.localeCompare(o.from)||i.to.localeCompare(o.to))}function or(e,t,r){let n=[],i=[];for(let s of ue(e))(le(s.from,t)||le(s.to,t)?n:i).push(Z(s));let o=[];return y(o,n,r,"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,r,"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 r=[],n=[];for(let o of e.duplicateRows??[])(o.legacy_terminal?n:r).push(`${o.holder_id} -> ${o.target_id} (${o.kind} x${o.occurrences})`);let i=[];return y(i,r,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,n,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 r=new Map,n={source_to_target:[],target_to_source:[],both:[]};for(let s of e.graph.registry().list())s.outcomeTraversal!==void 0&&n[s.outcomeTraversal].push(s.kind);let i={source_to_target:n.source_to_target.join(","),target_to_source:n.target_to_source.join(","),both:n.both.join(",")},o=(s,a)=>{let c=r.get(a)??new Set;c.add(s),r.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:r}}function cr(e,t,r){let n=new Set(e),i=[...e].sort();for(let o=0;o<i.length;o+=1){r?.throwIfAborted();for(let s of[...t.get(i[o])??[]].sort())n.has(s)||(n.add(s),i.push(s))}return n}function dr(e,t,r,n){let i=0,o=0,s=0,a=0;for(let p of e.values())if(n?.throwIfAborted(),!t.has(p.id)&&!(p.missing||p.status==="external")){if(p.terminal){s+=1,r.has(p.id)&&(a+=1);continue}r.has(p.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,r){let n=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,r),s=cr(n,o,r);return{outcome_nodes:n.size,outcome_reachability_basis:i,...dr(t,n,s,r)}}function ur(e,t,r,n,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,!(r>1)&&(e.degreeLeqOne+=1,s.degree_leq_one+=1,r===0&&(e.isolated+=1,s.isolated+=1),!(n.has(t.id.toLowerCase())||i.has(o.toLowerCase()))&&(r===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function gr(e,t,r,n,i,o,s){let a={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let f of e.graph.nodes()){s?.throwIfAborted();let _=t.get(f);if(_){if(_.missing){a.missing+=1;continue}_.terminal||ur(a,_,e.graph.incidentEdges(f).length,r,n)}}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.",f=>`${f} 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.",f=>`${f} 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,p=new Set(u.map(({edge:f})=>`${f.source.toLowerCase()}\0${f.target.toLowerCase()}\0${f.kind}`));for(let f of e.orderingContradictions??[])p.add(`${f.holder_id.toLowerCase()}\0${f.target_id.toLowerCase()}\0${f.dependency_kind}`);let h=Object.fromEntries(Object.entries(o).sort(([f],[_])=>f.localeCompare(_))),m=Object.entries(h).reduce((f,[_,E])=>f+(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(f=>f.status!=="missing"&&f.status!=="external").length,edges:g,informative_edges:g-p.size,redundant_edges:u.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:h,edge_share_by_kind:Object.fromEntries(Object.entries(h).map(([f,_])=>[f,_/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(([f],[_])=>f<_?-1:1)),articulation_points:b.articulationPoints.length,bridge_edges:b.bridges.length,...v,finding_subjects_by_code:Object.fromEntries(A.map(f=>[f,0]))}}}function ee(e,t={}){let r=t.isTerminal??(u=>u==="closed"||u==="canceled"),n=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:r(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,r,i);d.push(...Jn(e,i)),t.signal?.throwIfAborted(),d.push(...rr(e,i)),t.signal?.throwIfAborted(),d.push(...ir(e,a,n,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,p)=>_t[u.severity]-_t[p.severity]||u.code.localeCompare(p.code)||u.sample[0].localeCompare(p.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,...ht(e,r,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 r=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),n={};for(let i of r){let o=(t[i]??0)-(e[i]??0);o!==0&&(n[i]=o)}return n}function wt(e){return e.profile.coverage_by_type??{}}function pr(e,t){let r={},n=wt(e),i=wt(t),o=[...new Set([...Object.keys(n),...Object.keys(i)])].sort();for(let s of o){let a=Object.assign({active:0,isolated:0,degree_leq_one:0},n[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)&&(r[s]=d)}return r}function xt(e,t){let r=pr(e,t),{edge_share_by_kind:n={},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,p=e.profile.redundant_edges??0,h=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:h-p,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(n,s),semantic_edges:a-i,semantic_edge_share:c-o,coverage_by_type:r,...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,hr=64,fr="graph-durable-cache";function Ct(e){return Re(e,fr,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 pe(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 he(e,t){let r=await j(F(e)),n=pe(r),i=n?.fingerprint===t;return{exists:r!==null,fresh:i,results:i?n.results:{}}}async function fe(e,t,r,n,i){let o=await Ct(e);try{let s=pe(await j(F(e))),a=s?.fingerprint===t?s.results:{};delete a[n],a[n]=i;let c=Object.keys(a);for(let d of c.slice(0,Math.max(0,c.length-hr)))delete a[d];await re(F(e),JSON.stringify({version:St,fingerprint:t,saved_at:new Date().toISOString(),results:a})),r.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 r=F(e),n=await j(r),i=pe(n);return i===void 0?{exists:n!==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(n,"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,r){let n=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=n.filter(s=>e[s]!==void 0).length;if(i!==0&&i!==n.length||!n.every(s=>L(e[s],x)))return;let o={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??r,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return o.recorded_nodes<=t&&o.informative_edges<=r&&o.redundant_edges<=r&&o.ordering_contradiction_edges<=r?o:void 0}function br(e,t,r){let n=[...t,...r,"finding_subjects_by_code"],i=n.filter(o=>e[o]!==void 0).length;return i!==0&&i!==n.length?!1:t.every(o=>L(e[o],x))&&r.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,r,n){let i=yr(e,r,n);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,r,n,i){let o=[r,n,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(r)||!x(n)||!Nt(i))return;let a=Object.entries(t);if(a.reduce((d,[,l])=>d+l,0)!==e||Object.keys(r).length!==a.length||a.some(([d,l])=>r[d]!==(e===0?0:l/e)))return;let c=a.reduce((d,[l,g])=>d+(Q(l)?g:0),0);if(!(n!==c||i!==(e===0?0:c/e)))return{edge_share_by_kind:r,semantic_edges:n,semantic_edge_share:i}}function kr(e){if(e!==null)try{let t=JSON.parse(e);if(!O(t))return;let r=t,n=r.profile;if(typeof r.saved_at!="string"||typeof r.fingerprint!="string")return;let i=r.affected_subjects_by_code;if(!te(i)||!O(n)||!ft(n)||![n.nodes,n.edges,n.active_nodes,n.missing_nodes,n.isolated_active_nodes,n.degree_leq_one_active_nodes].every(x)||!te(n.edges_by_kind)||!L(n.coverage_by_type,_r))return;let o=wr(n.edges,n.edges_by_kind,n.edge_share_by_kind,n.semantic_edges,n.semantic_edge_share);if(o===void 0)return;let s=vr(n,i,n.nodes,n.edges);if(s===void 0)return;let{coverage_by_type:a={}}=n;return{...r,profile:{...n,...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,...r]=e.edges;return r.map(n=>({op:"remove",code:"duplicate_edge",subject:Ot(n),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(n=>xr(t.get(n)));let r=Ir[e.code];return e.sample.map(n=>({op:r.op,code:e.code,subject:n,rationale:r.rationale,evidence:[e.policy],confidence:r.confidence}))}function jt(e,t={}){let{redundancyLimit:r,...n}=t,i=ee(e,n),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:r??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,r){let n=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,p=Object.fromEntries(Object.entries(u).map(([h,m])=>{let{degree_histogram:b,...v}=m;return[h,v]}));n={...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:p}}}return{...n,projection:{mode:t?"summary":"full",declared_field_groups:r===void 0?[]:[{name:r,restore_with:"--full"}],included_field_groups:r===void 0||t?[]:[r]}}}function Sr(e,t,r,n){return{assembly:t,...r===void 0?{}:{kinds:r},maxDepth:Ue(n.maxDepth),limit:e==="impact"&&Number(n.limit)===0?0:$(n.limit,"limit")??(n.full===!0?Number.MAX_SAFE_INTEGER:I.rows),after:n.after?.trim()||void 0,direction:Be(n.direction),maxPaths:$(n.maxPaths,"max-paths"),sample:$(n.sample,"sample")??I.samples,exemptIsolates:Pt(n.exemptIsolate),exemptIsolateTypes:Pt(n.exemptIsolateType),saveBaseline:n.saveBaseline===!0,summary:n.summary===!0,unbounded:n.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,r){let n=e.trim().toLowerCase();if(!ie.includes(n))throw Me({command_path:"graph",token:n||"<empty>",allowed:ie});let i=n;if(Ft.has(i)&&!t?.trim())throw new k(`graph ${i} requires an item id.`,w.USAGE);if(i==="paths"&&!r?.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 r=t.trim().toLowerCase();for(let n of e.details)if(n.id.trim().toLowerCase()===r&&!e.missingIdSet.has(n.id.toLowerCase()))return n.id;throw new k(`Item ${t} not found`,w.NOT_FOUND)}function Dr(e,t,r){let n={ancestors:Qe,descendants:Ze,predecessors:et,successors:tt}[e],i;try{i=n(r.assembly.graph,t,{...r.kinds===void 0?{}:{kinds:r.kinds},...r.maxDepth===void 0?{}:{maxDepth:r.maxDepth},limit:r.limit,...r.after===void 0?{}:{after:r.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},...r.summary?{}:{ids:i.value}}}function Tr(e,t,r){let n=nt(r.assembly.graph,e,t,{direction:r.direction,...r.kinds===void 0?{}:{kinds:r.kinds},...r.maxDepth===void 0?{}:{maxDepth:r.maxDepth},...r.maxPaths===void 0?{}:{maxPaths:r.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:r.direction,count:n.value.length,...be(n.meta),...r.summary?{}:{paths:n.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(o=>o.kind),length:i.length}))}}}function Nr(e,t){let r;try{r=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(n){ye(n)}return{subcommand:"impact",root:e,direction:t.direction,count:r.affected.length,truncated:r.truncated,...r.nextCursor===void 0?{}:{next_cursor:r.nextCursor},cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...t.summary?{}:{affected:r.affected}}}function Ar(e,t,r){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,r),critical_path:e.criticalPath.slice(0,r),cycles:e.cycles.slice(0,r)}}}function Rr(e,t,r){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,r),hubs:e.hubs.slice(0,r)}}}function Or(e,t,r){let n=0,i=0,o=0;for(let s of e.cycles)n+=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-n,legacy_cycle_count:n,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,r).map(s=>s.item_ids)}}}function jr(e){let t=e.assembly.graph,r=e.limit,n=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:r,execution:Ar(n,e.summary,r),knowledge:Rr(i,e.summary,r),hierarchy:Or(G(e.assembly),e.summary,r)}}function Mr(e,t){let r=ee(e.assembly,{isTerminal:t,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),n={},i={},o={},s={};for(let d of r.findings)n[d.severity]=(n[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}=r.profile;return{subcommand:"audit",truncated:r.findings.length>e.limit,finding_count:r.findings.length,findings_by_severity:n,findings_by_code:i,affected_subjects_by_severity:o,affected_subjects_by_code:s,profile:e.summary?c:r.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:r.findings.slice(0,e.limit)}}}function Pr(e){let t=e.limit,r={};e.kinds!==void 0&&(r.kinds=e.kinds);let n=it(e.assembly.graph,r),i=n.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:n.meta.visitedNodes,inspected_edges:n.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(r){ye(r)}return{subcommand:"redundancy",redundant_count:t.value.length,...be(t.meta),...e.summary?{}:{redundant:t.value.map(r=>({source:r.edge.source,target:r.edge.target,kind:r.edge.kind,witness:r.witness}))}}}function Fr(e,t){let r=t.limit,n=ot(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=n.value.rows.filter(o=>o.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:n.value.reachableCount,bottleneck_count:i.length,truncated:n.meta.truncated||i.length>r,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,r).map(o=>({id:o.id,idom:o.idom,dominated_count:o.dominatedCount}))}}}function Gr(e){let t=e.limit,r=lt(e.assembly.graph),n=r.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:r.acyclic,makespan:r.makespan,scheduled_count:r.scheduledCount,critical_count:n,critical_path_length:r.criticalPathLength,cycle_count:r.cycles.length,truncated:r.rows.length>t,...e.summary?{}:{critical_path:r.criticalPath.slice(0,t),rows:r.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,r=dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),n=r.value;return{subcommand:"centrality",node_count:n.nodeCount,edge_count:n.edgeCount,edge_basis:"simple_undirected",truncated:n.rows.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{rows:n.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,r=X(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:n,bridges:i}=r.value;return{subcommand:"articulation",articulation_count:n.length,bridge_count:i.length,truncated:n.length>t||i.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{articulation_points:n.slice(0,t),bridges:i.slice(0,t)}}}function Ur(e,t){let r=e.limit,n=jt(e.assembly,{isTerminal:t,redundancyLimit:r,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},o={};for(let s of n.steps)i[s.op]=(i[s.op]??0)+1,o[s.code]=(o[s.code]??0)+1;return{subcommand:"plan",step_count:n.steps.length,steps_by_op:i,steps_by_code:o,finding_count:n.report.findings.length,truncated:n.truncated||n.steps.length>r,cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...e.summary?{}:{steps:n.steps.slice(0,r)}}}function Gt(e,t,r,n){return JSON.stringify({projection_version:2,subcommand:e,root:t??null,target:r??null,kinds:n.kinds??null,maxDepth:n.maxDepth??null,limit:n.limit,after:n.after??null,direction:n.direction,maxPaths:n.maxPaths??null,sample:n.sample,exemptIsolates:[...new Set(n.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(n.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:n.summary,unbounded:n.unbounded})}function $t(e,t,r,n,i){return e==="analyze"?jr(n):e==="audit"?Mr(n,i):e==="plan"?Ur(n,i):e==="communities"?Pr(n):e==="redundancy"?Lr(n):e==="dominators"?Fr(t,n):e==="slack"?Gr(n):e==="centrality"?$r(n):e==="articulation"?qr(n):e==="paths"?Tr(t,r,n):e==="impact"?Nr(t,n):Dr(e,t,n)}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,r,n,i,o){let s="status";if(o.clear===!0&&(await me(e),s="cleared"),o.rebuild===!0){await me(e);let c=await he(e,t),d={assembly:r.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,limit:I.rows,sample:I.samples,unbounded:!1};for(let l of["analyze","audit"])await fe(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:n,min_items_threshold:ge,persist_enabled:_e(n,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,r,n){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:r.affected_subjects_by_code,profile:{...r.profile,finding_subjects_by_code:Object.fromEntries(A.map(s=>[s,r.affected_subjects_by_code[s]??0]))}},o=await At(e);return n&&await Rt(e,i),o===void 0?r:{...r,baseline:xt(o,i)}}async function Kr(e,t,r,n,i){try{await fe(e,t,r,n,i)}catch{}}function Vr(e,t,r,n){if(e.subcommand!=="slack")return;let i=new Set(t.assembly.details.filter(u=>n(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,r.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,r,n,i){let o=Cr(e,t,r);De(n.summary===!0,n.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,n);let u=Fe(),p=ze(n.kind,u),h=qe().lookup(s,$e(d,g,u),()=>Ge(d,g,u)),m=Sr(o,h.assembly,p,n);if(o==="index")return Mt(await zr(s,h.fingerprint,m,d.length,g,n),!1);let b=Ft.has(o)?Lt(m.assembly,t):void 0,v=o==="paths"?Lt(m.assembly,r):void 0,f=Gt(o,b,v,m),_=await he(s,h.fingerprint),E=_.results[f],S=h.memoize(f,()=>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,h.fingerprint,_,f,S.value);let ne=S.value.subcommand==="audit"?await Hr(s,h.fingerprint,S.value,m.saveBaseline):S.value;return ne.cache={fingerprint:h.fingerprint.slice(0,12),assembly:h.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,he as B,fe 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{Ab as Pe,Fb as Le,V as Oe,Xa as je,Yb as Fe,Za as Me,hc as G,ic as Ge,jc as $e,lc as qe,oc as $,pc as Ue,qc as Be,rc as ze}from"./chunk-6KFKQD2D.js";import{n as Se}from"./chunk-NM3PM6O6.js";import{$ as w,Lc as Ce,Pb as I,Ua as xe,Xd as Ae,_a as Ee,aa as k,ad as De,ed as Te,ee as Re,fd as oe,hc as ie,id as Ne,ka as we,pa as ke,va as j,xa as re,za as Ie}from"./chunk-SPN5QTZ3.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,r,n,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,r.id);let s=r.depth+1;return e.queue.push({id:t,depth:s}),e.cursorFound?(e.affected.push({id:t,distance:s,path:Yt(n,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function Ke(e,t,r,n){let i=Te("graph impact",{root:e,direction:r,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(n)?n:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:Ne(t.after,i)}}function C(e,t,r){e.get(t).add(r)}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,r)=>r.length-t.length||t[0].localeCompare(r[0]))}function q(e){if(Array.isArray(e))return e.map(r=>q(r));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(([r],[n])=>r.localeCompare(n)).map(([r,n])=>[r,q(n)]))}function He(e){return JSON.stringify(q(e))}function Bt(e,t,r,n){let i=[{id:e,expanded:!1}];for(;i.length>0;){let o=i.pop();if(o.expanded){n.push(o.id);continue}if(r.has(o.id))continue;r.add(o.id),i.push({id:o.id,expanded:!0});let s=[...t.get(o.id)].sort().reverse();for(let a of s)r.has(a)||i.push({id:a,expanded:!1})}}function zt(e,t){let r=new Set,n=[];for(let i of e)r.has(i)||Bt(i,t,r,n);return n}function Ht(e,t){let r=new Set,n=[];for(let i of[...e].reverse()){if(r.has(i))continue;let o=[],s=[i];for(r.add(i);s.length>0;){let a=s.pop();o.push(a);for(let c of t.get(a))r.has(c)||(r.add(c),s.push(c))}n.push(o)}return Ve(n)}function We(e,t){let r=M(e);for(let[n,i]of t)for(let o of i)C(r,o,n);return Ht(zt(e,t),r)}function Kt(e,t){let r=M(e.nodes());for(let n of e.edges()){let i=t.require(n.kind);if(!i.ordering)continue;let o=(i.precedence??"source_before_target")==="source_before_target";C(r,o?n.source:n.target,o?n.target:n.source)}return r}function Vt(e,t){let r=new Map(e.map(o=>[o,0]));for(let o of t.values())for(let s of o)r.set(s,r.get(s)+1);let n=e.filter(o=>r.get(o)===0).sort(),i=[];for(;n.length>0;){i.push(n);let o=[];for(let s of n)for(let a of t.get(s)){let c=r.get(a)-1;r.set(a,c),c===0&&o.push(a)}n=o.sort()}return i}function Wt(e,t){let r=new Map(e.map(s=>[s,0])),n=new Map;for(let s of e)for(let a of t.get(s)){if(!r.has(a))continue;let c=r.get(s)+1,d=n.get(a);(c>r.get(a)||c===r.get(a)&&(d===void 0||s.localeCompare(d)<0))&&(r.set(a,c),n.set(a,s))}let i=[...e].sort((s,a)=>r.get(a)-r.get(s)||s.localeCompare(a))[0],o=i===void 0?[]:[i];for(;o[0]!==void 0&&n.has(o[0]);)o.unshift(n.get(o[0]));return{depth:Object.fromEntries(r),path:o}}function Yt(e,t,r){let n=[t],i=t;for(;i!==e;)i=r.get(i),n.push(i);return n.reverse()}function B(e,t={}){let r=t.registry??we(),n=[...e.nodes()],i=Kt(e,r),o=Vt(n,i),s=o.flat(),a=s.length===n.length,c=a?[]:We(n,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,r){let n=M(e.nodes()),i=r===void 0?void 0:new Set(r.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(n,t==="incoming"?s.target:s.source,t==="incoming"?s.source:s.target)}return{adjacency:n,inspectedEdges:o.length}}function Jt(e,t,r,n,i,o){let s=U(e,t,{...r,after:void 0,direction:"incoming",limit:void 0}),a=U(e,t,{...r,after:void 0,direction:"outgoing",limit:void 0}),c=new Map,d=[...s.affected,...a.affected].sort((h,m)=>h.distance-m.distance||h.id.localeCompare(m.id)||h.path.join("\0").localeCompare(m.path.join("\0")));for(let h of d)c.has(h.id)||c.set(h.id,h);let l=[...c.values()].sort((h,m)=>h.distance-m.distance||h.id.localeCompare(m.id)),g=n===void 0||n===t?-1:l.findIndex(h=>h.id===n);if(n!==void 0&&n!==t&&g<0)throw new TypeError(`Unknown impact cursor item: ${n}`);let u=l.slice(g+1,g+1+i),p=g+1+u.length<l.length;return{root:t,affected:u,exact:!0,truncated:s.truncated||a.truncated||p,...p?{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,r){let n=r.direction,i=r.maxDepth??Number.POSITIVE_INFINITY,o=r.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,r,n,i),{adjacency:c,inspectedEdges:d}=Xt(e,n,r.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,p=!1;e:for(let h=0;h<l.queue.length;h+=1){r.signal?.throwIfAborted();let m=l.queue[h];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,p=!0;break e}}if(!l.cursorFound)throw new TypeError(`Unknown impact cursor item: ${a}`);return{root:t,affected:l.affected,exact:!0,truncated:u,...p?{nextCursor:oe(s,l.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:g,inspectedEdges:d}}}function U(e,t,r={}){let n=r.direction??"outgoing";if(n!=="both")return Qt(e,t,{...r,direction:n});let i=r.maxDepth??Number.POSITIVE_INFINITY,o=r.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=Ke(t,r,n,i);return Jt(e,t,r,a,o,s)}function Ye(e){let t=[...e.nodes()],r=M(t),n=M(t);for(let c of e.edges())C(r,c.source,c.target),C(r,c.target,c.source),C(n,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 r.get(g))o.has(u)||(o.add(u),l.push(u))}i.push(d)}let s=t.map(c=>({id:c,degree:r.get(c).size})),a=Math.max(0,...s.map(({degree:c})=>c));return{components:Ve(i),stronglyConnected:We(t,n),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 r=new Map(e.edges.map(i=>[He(i),i])),n=new Map(t.edges.map(i=>[He(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),removed:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),unchangedCount:[...r.keys()].filter(i=>n.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 r=P(e,t);return{predecessor:r,successor:r===e.source?e.target:e.source}}function nn(e,t,r){if(t===void 0)return;let n=e.registry(),i=new Set;for(let o of t){let s=n.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!==r&&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,r,n,i){let o=e.registry(),s=e.neighborEdges(t,{direction:"both",...r===void 0?{}:{kinds:[...r]}}),a=[],c=new Set;for(let d of s.value){let l=o.require(d.edge.kind);r===void 0&&!l[n]||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,r,n,i,o){if(t>=r)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>=n)return o.truncated=!0,!0;o.value.push(s)}return!1}function H(e,t,r,n,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let o=nn(e,r.kinds,n),s=r.limit??Number.POSITIVE_INFINITY,a=r.maxDepth??Number.POSITIVE_INFINITY,c=r.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){r.signal?.throwIfAborted();let p=d.queue[u];l+=1;let h=rn(e,p.id,o,n,i);if(g+=h.inspectedEdges,on(h,p.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,r,n,i){let o=e.neighborEdges(t.nodes.at(-1),{direction:n,...r.kinds===void 0?{}:{kinds:r.kinds}});return i.inspectedEdges+=o.meta.inspectedEdges,o.value.filter(s=>!t.nodeSet.has(s.id))}function sn(e,t,r,n,i,o,s){for(let a of Je(e,t,n,i,s)){let c=[...t.nodes,a.id],d=new Set(t.nodeSet).add(a.id),l=[...t.edges,a.edge];if(a.id===r){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,r={}){return H(e,t,r,"hierarchy",(n,i)=>z(n.edge,i)===n.id)}function Ze(e,t,r={}){return H(e,t,r,"hierarchy",(n,i,o)=>z(n.edge,i)===o)}function et(e,t,r={}){return H(e,t,r,"ordering",(n,i)=>P(n.edge,i)===n.id)}function tt(e,t,r={}){return H(e,t,r,"ordering",(n,i,o)=>P(n.edge,i)===o)}function an(e,t,r,n,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(n.signal?.throwIfAborted(),c.value.length>=g||d>=o){l=!0;break}let p=c.queue[u];if(d+=1,p.edges.length>=s){Je(e,p,n,a,c).length>0&&(l=!0);continue}if(sn(e,p,r,n,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,r,n={}){Xe(e,t),Xe(e,r);let i=n.maxPaths??Zt,o=n.maxVisitedPaths??en,s=n.maxDepth??tn;se("maxPaths",i),se("maxVisitedPaths",o),se("maxDepth",s);let a=n.direction??"outgoing";n.signal?.throwIfAborted();for(let c of n.kinds??[])e.registry().require(c);return t===r?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,r,n,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,r){let n=e.registry(),i=t===void 0?void 0:new Set(t.map(o=>n.require(o).kind));for(let o of e.edges()){if(o.source===o.target)continue;let s=n.require(o.kind);i!==void 0&&!(i.has(s.kind)||s.inverse!==void 0&&i.has(s.inverse))||r(o,s)}}function un(e,t){let r=new Map;V(e,t,n=>{rt(r,n.source,n.target),rt(r,n.target,n.source)});for(let n of r.values())n.sort();return r}function rt(e,t,r){let n=e.get(t);n===void 0?e.set(t,[r]):n.push(r)}function gn(e,t){let r=new Map;for(let o of e){let s=t.get(o);r.set(s,(r.get(s)??0)+1)}let n,i=0;for(let[o,s]of r)(s>i||s===i&&o<n)&&(n=o,i=s);return n}function pn(e,t){let r=new Map;for(let[i,o]of e){let s=r.get(o);s===void 0?r.set(o,[i]):s.push(i)}let n=[];for(let i of r.values())i.length<t||(i.sort(),n.push({representative:i[0],size:i.length,members:i}));return n.sort((i,o)=>o.size-i.size||i.representative.localeCompare(o.representative))}function it(e,t={}){let r=t.maxIterations??cn,n=t.minSize??dn;K("maxIterations",r),K("minSize",n);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<r&&!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 p=gn(u,s);p!==s.get(g)&&(s.set(g,p),c=!1)}}return{value:{communities:pn(s,n),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 hn(e,t){if(t===void 0)return;let r=e.registry(),n=new Set;for(let i of t){let o=r.require(i);if(!W(o))throw new TypeError(`Relationship kind ${o.kind} is not a directed ordering or hierarchy kind`);n.add(Y(o))}return n}function fn(e,t){let r=e.registry(),n=new Map;for(let i of e.edges()){let o=r.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=n.get(s);c===void 0&&(c={adjacency:new Map,records:[]},n.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 n}function mn(e){let t=new Map;for(let[r,n]of e.adjacency)t.set(r,[...n].sort());return t}function _n(e,t,r,n){let i=[n];for(let o=r;o!==t;o=e.get(o))i.push(o);return i.push(t),i.reverse()}function yn(e,t,r,n,i,o){for(let s of e.get(r.id)??[])if(o.inspectedEdges+=1,!(r.depth===0&&s===t.to)&&!n.has(s)){if(n.set(s,r.id),s===t.to)return _n(n,t.from,r.id,s);i.push({id:s,depth:r.depth+1})}}function bn(e,t,r,n){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(n.visitedNodes+=1,a.depth>=r)continue;let c=yn(e,t,a,i,o,n);if(c!==void 0)return c}}function T(e,t={}){let r=t.maxDepth??ln;K("maxDepth",r),t.limit!==void 0&&K("limit",t.limit);let n=t.limit??Number.POSITIVE_INFINITY,i=hn(e,t.kinds),o=fn(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 p=bn(g,u,r,a);if(p!==void 0){if(s.length>=n){c=!0;break e}s.push({edge:u.edge,witness:p})}}}return{value:s,meta:{visitedNodes:a.visitedNodes,inspectedEdges:a.inspectedEdges,truncated:c}}}function vn(e,t,r,n,i){let o=new Set,s=[];for(let a of r){if(a.id===e||o.has(a.id))continue;if(!i.seen.has(a.id)){if(t>=n){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,r){let n=r.direction??"outgoing",i=r.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){r.signal?.throwIfAborted();let{id:l,depth:g}=a.queue[d];o.push(l);let u=e.neighborEdges(l,{direction:n,...r.kinds===void 0?{}:{kinds:r.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 r=[],n=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,n.has(a)||(n.add(a),i.push({id:a,index:0}))}else r.push(o.id),i.pop()}return r.reverse()}function In(e,t,r,n){let i=e,o=t;for(;i!==o;){for(;n.get(i)>n.get(o);)i=r.get(i);for(;n.get(o)>n.get(i);)o=r.get(o)}return i}function xn(e,t,r){let n;for(let i of[...e].sort())t.has(i)&&(n=n===void 0?i:In(n,i,t,r));return n}function En(e,t,r,n,i){let o=new Map([[t,t]]),s=!0;for(;s;){s=!1;for(let a of r){if(i?.throwIfAborted(),a===t)continue;let c=xn(e.predecessors.get(a),o,n);c!==void 0&&o.get(a)!==c&&(o.set(a,c),s=!0)}}return o}function ot(e,t,r={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(r.maxDepth!==void 0&&(!Number.isInteger(r.maxDepth)||r.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(r.maxDepth)}`);let n=wn(e,t,r),i=kn(n,t),o=new Map(i.map((d,l)=>[d,l])),s=En(n,t,i,o,r.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:n.order.length,rows:c},meta:{visitedNodes:n.order.length,inspectedEdges:n.inspectedEdges,truncated:n.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,r){let n=e.get(t);n===void 0?e.set(t,new Set([r])):n.add(r)}function ct(e,t){let r=new Map(e.nodes().map(i=>[i,new Set]));V(e,t,i=>{r.get(i.source).add(i.target),r.get(i.target).add(i.source)});let n=new Map;for(let[i,o]of r)n.set(i,[...o].sort());return n}function Sn(e,t){let r=new Map,n=new Map;return V(e,t,(i,o)=>{if(!o.ordering)return;let{predecessor:s,successor:a}=D(i,o);at(n,s,a),at(r,a,s)}),{incoming:r,outgoing:n}}function Cn(e,t,r){let n=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];r.visitedNodes+=1,s.push(g);let u=n.get(g);g!==e&&(c+=1,d+=u);for(let p of t.get(g))if(r.inspectedEdges+=1,n.has(p)||(n.set(p,u+1),a.push(p)),n.get(p)===u+1){i.set(p,(i.get(p)??0)+i.get(g));let h=o.get(p);h===void 0?o.set(p,[g]):h.push(g)}}return{stack:s,sigma:i,predecessors:o,reachableCount:c,distanceSum:d}}function Dn(e,t,r){let n=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let o=e.stack[i],s=(1+(n.get(o)??0))/e.sigma.get(o);for(let a of e.predecessors.get(o)??[])n.set(a,(n.get(a)??0)+e.sigma.get(a)*s);o!==t&&r.set(o,(r.get(o)??0)+(n.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,r,n,i){return{id:e,degree:t.get(e).length,inDegree:r.incoming.get(e)?.size??0,outDegree:r.outgoing.get(e)?.size??0,betweenness:st((n.get(e)??0)/2),closeness:st(i.get(e))}}function dt(e,t={}){let r=ct(e,t.kinds),n=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,r,a);s.set(l,Tn(g,i.length)),Dn(g,l,o)}let c=0;for(let l of r.values())c+=l.length;let d=i.map(l=>Nn(l,r,n,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,r){let n=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,r.inspectedEdges+=1,n!==e.parent){if(r.discovery.has(n)){r.low.set(e.node,Math.min(r.low.get(e.node),r.discovery.get(n)));return}return e.children+=1,r.discovery.set(n,r.timer),r.low.set(n,r.timer),r.timer+=1,{node:n,parent:e.node,neighborIndex:0,children:0}}}function On(e,t,r){if(e.parent===null){e.children>1&&r.articulation.add(e.node);return}let n=e.parent,i=r.low.get(e.node);r.low.set(n,Math.min(r.low.get(n),i)),n!==t&&i>=r.discovery.get(n)&&r.articulation.add(n),i>r.discovery.get(n)&&r.bridges.push(An(n,e.node))}function jn(e,t,r,n){r.discovery.set(e,r.timer),r.low.set(e,r.timer),r.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){n?.throwIfAborted();let o=i.at(-1);if(o.neighborIndex<t.get(o.node).length){let s=Rn(o,t,r);s!==void 0&&i.push(s)}else On(o,e,r),i.pop()}}function X(e,t={}){let r=ct(e,t.kinds),n={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())n.discovery.has(i)||jn(i,r,n,t.signal);return{value:{articulationPoints:[...n.articulation].sort(),bridges:n.bridges.sort((i,o)=>i.source.localeCompare(o.source)||i.target.localeCompare(o.target))},meta:{visitedNodes:n.discovery.size,inspectedEdges:n.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(),r=new Map,n=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(n.add(s),n.add(a),s===a)continue;let c=r.get(s);c===void 0?r.set(s,new Set([a])):c.add(a)}return{forward:r,participants:n}}function Pn(e,t,r,n){if(e===void 0)return n;let i=n;for(let o of e)t.has(o)&&(i=Math.min(i,r.get(o)));return i}function Ln(e,t,r){let n=r-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:r,latestFinish:r+1,slack:n,critical:n===0}}function Fn(e,t,r,n,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),n,o,i);o.set(a,c-1)}return e.map(s=>Ln(s,r[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 r=B(e,{registry:e.registry()}),n=Mn(e),i=new Set(r.order),o=r.order.filter(d=>n.participants.has(d)),s=o.reduce((d,l)=>Math.max(d,r.depth[l]+1),0),a=Fn(o,n,r.depth,i,s),c=a.length>0;return{exact:!0,acyclic:r.acyclic,makespan:s,scheduledCount:a.length,criticalPath:c?r.criticalPath:[],criticalPathLength:c?r.criticalPathLength:0,cycles:r.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,r){for(let n=e.length-1;n>=0;n-=1){r?.throwIfAborted();let i=t.get(e[n]);for(let o of i.successors){r?.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,r,n){let i=[],o=e;for(;o!==void 0&&i.length<r;)n?.throwIfAborted(),i.push(o),o=t.get(o).predecessor;return i.reverse(),{path:i,path_truncated:o!==void 0}}function qn(e,t,r,n,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-r)/6e4,g.latest=g.deadline,g.anchor=a):n(a,"invalid_deadline")}s.set(a,g)}return s}function Un(e,t,r){for(let n of e.edges()){r?.throwIfAborted();let i=e.registry().require(n.kind);if(!i.ordering)continue;let{predecessor:o,successor:s}=D(n,i),a=t.get(o);a.successors.has(s)||(a.successors.add(s),t.get(s).pending+=1)}}function Bn(e,t,r){let n=e.filter(i=>t.get(i).pending===0);for(let i=0;i<n.length;i+=1){r?.throwIfAborted();let o=n[i],s=t.get(o),a=s.earliest===null||s.duration===void 0?null:s.earliest+s.duration;for(let c of s.successors){r?.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&&n.push(c)}}return n}function zn(e,t,r,n,i,o,s,a){let c=t.duration;if(t.latest!==void 0){n.scheduled_count+=1;let d=t.latest-c;n.rows.length<o?n.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}):n.truncated=!0}if(t.deadline!==void 0&&t.earliest!==null&&t.earliest+c>t.deadline)if(n.overcommitted_count+=1,n.overcommitted.length<o){let d=$n(e,r,Math.min(o,s.remaining),a);s.remaining-=d.path.length,d.path_truncated&&(n.truncated=!0),n.overcommitted.push({deadline_id:e,deadline:t.item.deadline,shortfall_minutes:t.earliest+c-t.deadline,...d})}else n.truncated=!0}function Hn(e,t,r,n,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(n+(l.latest-l.duration)*6e4).getTime())){s(d,"date_range_exceeded");continue}l.earliest===null&&s(d,"unknown_predecessor_estimate"),zn(d,l,t,r,n,i,c,a)}}function ut(e,t,r={}){r.signal?.throwIfAborted();let n=Date.parse(r.now??new Date().toISOString());if(!Number.isFinite(n))throw new TypeError("Invalid scheduling clock");let i=r.maxWork??1e5,o=r.limit??10;for(let[u,p]of[["maxWork",i],["limit",o]])if(!Number.isSafeInteger(p)||p<1)throw new TypeError(`Invalid scheduling ${u}`);let s={as_of:new Date(n).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,p)=>{s.complete=!1,s.residual_count+=1,s.residuals.length<o?s.residuals.push({id:u,reason:p}):s.truncated=!0},l=qn(a,t,n,d,r.signal);Un(e,l,r.signal);let g=Bn(a,l,r.signal);return Gn(g,l,r.signal),Hn(a,l,s,n,o,i,d,r.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 ht(e,t,r,n){let i={all:N(),active:N(),terminal:N()},o=new Map;for(let s of e.details){if(n?.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=>r(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(n=>Number.isSafeInteger(t[n])&&Number(t[n])>=0)||!J(t.degree_histogram))return!1;let r=Object.entries(t.degree_histogram);return r.every(([n,i])=>/^(0|[1-9]\d*)$/.test(n)&&Number.isSafeInteger(i)&&Number(i)>=0)&&r.reduce((n,[,i])=>n+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 ft(e){for(let n of["ordering_acyclic","active_ordering_acyclic"])if(e[n]!==void 0&&typeof e[n]!="boolean")return!1;let t=e.coverage_by_lifecycle,r=e.coverage_by_status;return t===void 0&&r===void 0?!0:!J(t)||!J(r)?!1:["all","active","terminal"].every(n=>gt(t[n]))&&Object.values(r).every(gt)}function pt(e,t){return Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].sort().map(r=>{let n=Object.hasOwn(e,r)?e[r]:N(),i=Object.hasOwn(t,r)?t[r]:N(),o=Object.fromEntries([...new Set([...Object.keys(n.degree_histogram),...Object.keys(i.degree_histogram)])].sort().map(s=>[s,(i.degree_histogram[s]??0)-(n.degree_histogram[s]??0)]));return[r,{nodes:i.nodes-n.nodes,isolated:i.isolated-n.isolated,degree_leq_one:i.degree_leq_one-n.degree_leq_one,semantic_nodes:i.semantic_nodes-n.semantic_nodes,without_semantic_edges:i.without_semantic_edges-n.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:pt(e.coverage_by_lifecycle,t.coverage_by_lifecycle),coverage_by_status:pt(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,r,n,i,o,s,a){let c=[...i].sort((d,l)=>d.localeCompare(l));return{code:e,severity:t,policy:r,message:n(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(r=>R(r.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",r.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",n=>`${n} items participate in one hierarchy cycle.`,r.item_ids,t,r.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,r){let n=e.cardinality_violations.filter(i=>i.legacy_terminal===r);return n.length===0?[]:[R(r?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",r?"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.`,n.map(i=>i.child_id),t,r?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",n.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function vt(e,t,r){let n=e.divergences.filter(i=>i.legacy_terminal===r);return n.length===0?[]:[R(r?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",r?"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.`,n.map(i=>i.child_id),t,r?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",n.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function Jn(e,t){let r=G(e);return r?[...Xn(r,t),...bt(r,t,!1),...bt(r,t,!0),...vt(r,t,!1),...vt(r,t,!0)]:[]}function Qn(e){let t=e.graph.registry(),r=new Map;for(let n of e.graph.edges()){let i=t.require(n.kind);if(!i.ordering)continue;let[o,s]=(i.precedence??"source_before_target")==="target_before_source"?[n.target,n.source]:[n.source,n.target],a=r.get(o);a?a.push(s):r.set(o,[s])}for(let n of r.values())n.sort((i,o)=>i.localeCompare(o));return r}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,r,n){let i=r.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let o=i[e.neighborIndex];return e.neighborIndex+=1,n.indexes.has(o)?n.onStack.has(o)&&n.lowLinks.set(e.node,Math.min(n.lowLinks.get(e.node),n.indexes.get(o))):(kt(o,n),t.push({node:o,neighborIndex:0})),!0}function er(e,t,r,n){t.pop();let i=t.at(-1);if(i&&n.lowLinks.set(i.node,Math.min(n.lowLinks.get(i.node),n.lowLinks.get(e.node))),n.lowLinks.get(e.node)!==n.indexes.get(e.node))return;let o=[];for(;;){let s=n.stack.pop();if(n.onStack.delete(s),o.push(s),s===e.node)break}(o.length>1||o.length===1&&r.get(o[0])?.includes(o[0]))&&n.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},r=[...e.keys()].sort((n,i)=>n.localeCompare(i));for(let n of r){if(t.indexes.has(n))continue;let i=[{node:n,neighborIndex:0}];for(kt(n,t);i.length>0;){let o=i.at(-1);Zn(o,i,e,t)||er(o,i,e,t)}}return t.components.sort((n,i)=>n[0].localeCompare(i[0]))}function ce(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function y(e,t,r,n,i,o,s,a){t.length!==0&&e.push(R(n,i,o,s,t,r,a))}function nr(e,t,r){let n=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(o=>!o.no_active_blocker_sentinel);return y(n,i.filter(o=>!t(o.holder_status)).map(ce),r,"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(n,i.filter(o=>t(o.holder_status)).map(ce),r,"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(n,e.dangling.no_active_blocker_sentinels.map(ce),r,"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."),n}function le(e,t){let r=t.get(e);return r?!r.terminal:!0}function It(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function rr(e,t){let r=[],n=[];for(let o of e.orderingContradictions??[])(o.legacy_terminal?n:r).push(It(o));let i=[];return y(i,r,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,n,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,r,n){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,n,"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,n,"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&&r(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,n,"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(r=>r.kind).sort((r,n)=>r.localeCompare(n));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function ue(e){let t=e.graph.registry(),r=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=r.get(a);c?c.edges.push(i):r.set(a,{...s,edges:[i]})}let n=[...r.values()].filter(i=>i.edges.length>=2);for(let i of n)i.edges.sort((o,s)=>o.kind.localeCompare(s.kind));return n.sort((i,o)=>i.from.localeCompare(o.from)||i.to.localeCompare(o.to))}function or(e,t,r){let n=[],i=[];for(let s of ue(e))(le(s.from,t)||le(s.to,t)?n:i).push(Z(s));let o=[];return y(o,n,r,"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,r,"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 r=[],n=[];for(let o of e.duplicateRows??[])(o.legacy_terminal?n:r).push(`${o.holder_id} -> ${o.target_id} (${o.kind} x${o.occurrences})`);let i=[];return y(i,r,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,n,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 r=new Map,n={source_to_target:[],target_to_source:[],both:[]};for(let s of e.graph.registry().list())s.outcomeTraversal!==void 0&&n[s.outcomeTraversal].push(s.kind);let i={source_to_target:n.source_to_target.join(","),target_to_source:n.target_to_source.join(","),both:n.both.join(",")},o=(s,a)=>{let c=r.get(a)??new Set;c.add(s),r.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:r}}function cr(e,t,r){let n=new Set(e),i=[...e].sort();for(let o=0;o<i.length;o+=1){r?.throwIfAborted();for(let s of[...t.get(i[o])??[]].sort())n.has(s)||(n.add(s),i.push(s))}return n}function dr(e,t,r,n){let i=0,o=0,s=0,a=0;for(let p of e.values())if(n?.throwIfAborted(),!t.has(p.id)&&!(p.missing||p.status==="external")){if(p.terminal){s+=1,r.has(p.id)&&(a+=1);continue}r.has(p.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,r){let n=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,r),s=cr(n,o,r);return{outcome_nodes:n.size,outcome_reachability_basis:i,...dr(t,n,s,r)}}function ur(e,t,r,n,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,!(r>1)&&(e.degreeLeqOne+=1,s.degree_leq_one+=1,r===0&&(e.isolated+=1,s.isolated+=1),!(n.has(t.id.toLowerCase())||i.has(o.toLowerCase()))&&(r===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function gr(e,t,r,n,i,o,s){let a={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let f of e.graph.nodes()){s?.throwIfAborted();let _=t.get(f);if(_){if(_.missing){a.missing+=1;continue}_.terminal||ur(a,_,e.graph.incidentEdges(f).length,r,n)}}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.",f=>`${f} 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.",f=>`${f} 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,p=new Set(u.map(({edge:f})=>`${f.source.toLowerCase()}\0${f.target.toLowerCase()}\0${f.kind}`));for(let f of e.orderingContradictions??[])p.add(`${f.holder_id.toLowerCase()}\0${f.target_id.toLowerCase()}\0${f.dependency_kind}`);let h=Object.fromEntries(Object.entries(o).sort(([f],[_])=>f.localeCompare(_))),m=Object.entries(h).reduce((f,[_,E])=>f+(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(f=>f.status!=="missing"&&f.status!=="external").length,edges:g,informative_edges:g-p.size,redundant_edges:u.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:h,edge_share_by_kind:Object.fromEntries(Object.entries(h).map(([f,_])=>[f,_/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(([f],[_])=>f<_?-1:1)),articulation_points:b.articulationPoints.length,bridge_edges:b.bridges.length,...v,finding_subjects_by_code:Object.fromEntries(A.map(f=>[f,0]))}}}function ee(e,t={}){let r=t.isTerminal??(u=>u==="closed"||u==="canceled"),n=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:r(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,r,i);d.push(...Jn(e,i)),t.signal?.throwIfAborted(),d.push(...rr(e,i)),t.signal?.throwIfAborted(),d.push(...ir(e,a,n,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,p)=>_t[u.severity]-_t[p.severity]||u.code.localeCompare(p.code)||u.sample[0].localeCompare(p.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,...ht(e,r,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 r=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),n={};for(let i of r){let o=(t[i]??0)-(e[i]??0);o!==0&&(n[i]=o)}return n}function wt(e){return e.profile.coverage_by_type??{}}function pr(e,t){let r={},n=wt(e),i=wt(t),o=[...new Set([...Object.keys(n),...Object.keys(i)])].sort();for(let s of o){let a=Object.assign({active:0,isolated:0,degree_leq_one:0},n[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)&&(r[s]=d)}return r}function xt(e,t){let r=pr(e,t),{edge_share_by_kind:n={},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,p=e.profile.redundant_edges??0,h=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:h-p,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(n,s),semantic_edges:a-i,semantic_edge_share:c-o,coverage_by_type:r,...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,hr=64,fr="graph-durable-cache";function Ct(e){return Re(e,fr,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 pe(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 he(e,t){let r=await j(F(e)),n=pe(r),i=n?.fingerprint===t;return{exists:r!==null,fresh:i,results:i?n.results:{}}}async function fe(e,t,r,n,i){let o=await Ct(e);try{let s=pe(await j(F(e))),a=s?.fingerprint===t?s.results:{};delete a[n],a[n]=i;let c=Object.keys(a);for(let d of c.slice(0,Math.max(0,c.length-hr)))delete a[d];await re(F(e),JSON.stringify({version:St,fingerprint:t,saved_at:new Date().toISOString(),results:a})),r.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 r=F(e),n=await j(r),i=pe(n);return i===void 0?{exists:n!==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(n,"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,r){let n=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=n.filter(s=>e[s]!==void 0).length;if(i!==0&&i!==n.length||!n.every(s=>L(e[s],x)))return;let o={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??r,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return o.recorded_nodes<=t&&o.informative_edges<=r&&o.redundant_edges<=r&&o.ordering_contradiction_edges<=r?o:void 0}function br(e,t,r){let n=[...t,...r,"finding_subjects_by_code"],i=n.filter(o=>e[o]!==void 0).length;return i!==0&&i!==n.length?!1:t.every(o=>L(e[o],x))&&r.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,r,n){let i=yr(e,r,n);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,r,n,i){let o=[r,n,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(r)||!x(n)||!Nt(i))return;let a=Object.entries(t);if(a.reduce((d,[,l])=>d+l,0)!==e||Object.keys(r).length!==a.length||a.some(([d,l])=>r[d]!==(e===0?0:l/e)))return;let c=a.reduce((d,[l,g])=>d+(Q(l)?g:0),0);if(!(n!==c||i!==(e===0?0:c/e)))return{edge_share_by_kind:r,semantic_edges:n,semantic_edge_share:i}}function kr(e){if(e!==null)try{let t=JSON.parse(e);if(!O(t))return;let r=t,n=r.profile;if(typeof r.saved_at!="string"||typeof r.fingerprint!="string")return;let i=r.affected_subjects_by_code;if(!te(i)||!O(n)||!ft(n)||![n.nodes,n.edges,n.active_nodes,n.missing_nodes,n.isolated_active_nodes,n.degree_leq_one_active_nodes].every(x)||!te(n.edges_by_kind)||!L(n.coverage_by_type,_r))return;let o=wr(n.edges,n.edges_by_kind,n.edge_share_by_kind,n.semantic_edges,n.semantic_edge_share);if(o===void 0)return;let s=vr(n,i,n.nodes,n.edges);if(s===void 0)return;let{coverage_by_type:a={}}=n;return{...r,profile:{...n,...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,...r]=e.edges;return r.map(n=>({op:"remove",code:"duplicate_edge",subject:Ot(n),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(n=>xr(t.get(n)));let r=Ir[e.code];return e.sample.map(n=>({op:r.op,code:e.code,subject:n,rationale:r.rationale,evidence:[e.policy],confidence:r.confidence}))}function jt(e,t={}){let{redundancyLimit:r,...n}=t,i=ee(e,n),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:r??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,r){let n=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,p=Object.fromEntries(Object.entries(u).map(([h,m])=>{let{degree_histogram:b,...v}=m;return[h,v]}));n={...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:p}}}return{...n,projection:{mode:t?"summary":"full",declared_field_groups:r===void 0?[]:[{name:r,restore_with:"--full"}],included_field_groups:r===void 0||t?[]:[r]}}}function Sr(e,t,r,n){return{assembly:t,...r===void 0?{}:{kinds:r},maxDepth:Ue(n.maxDepth),limit:e==="impact"&&Number(n.limit)===0?0:$(n.limit,"limit")??(n.full===!0?Number.MAX_SAFE_INTEGER:I.rows),after:n.after?.trim()||void 0,direction:Be(n.direction),maxPaths:$(n.maxPaths,"max-paths"),sample:$(n.sample,"sample")??I.samples,exemptIsolates:Pt(n.exemptIsolate),exemptIsolateTypes:Pt(n.exemptIsolateType),saveBaseline:n.saveBaseline===!0,summary:n.summary===!0,unbounded:n.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,r){let n=e.trim().toLowerCase();if(!ie.includes(n))throw Me({command_path:"graph",token:n||"<empty>",allowed:ie});let i=n;if(Ft.has(i)&&!t?.trim())throw new k(`graph ${i} requires an item id.`,w.USAGE);if(i==="paths"&&!r?.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 r=t.trim().toLowerCase();for(let n of e.details)if(n.id.trim().toLowerCase()===r&&!e.missingIdSet.has(n.id.toLowerCase()))return n.id;throw new k(`Item ${t} not found`,w.NOT_FOUND)}function Dr(e,t,r){let n={ancestors:Qe,descendants:Ze,predecessors:et,successors:tt}[e],i;try{i=n(r.assembly.graph,t,{...r.kinds===void 0?{}:{kinds:r.kinds},...r.maxDepth===void 0?{}:{maxDepth:r.maxDepth},limit:r.limit,...r.after===void 0?{}:{after:r.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},...r.summary?{}:{ids:i.value}}}function Tr(e,t,r){let n=nt(r.assembly.graph,e,t,{direction:r.direction,...r.kinds===void 0?{}:{kinds:r.kinds},...r.maxDepth===void 0?{}:{maxDepth:r.maxDepth},...r.maxPaths===void 0?{}:{maxPaths:r.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:r.direction,count:n.value.length,...be(n.meta),...r.summary?{}:{paths:n.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(o=>o.kind),length:i.length}))}}}function Nr(e,t){let r;try{r=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(n){ye(n)}return{subcommand:"impact",root:e,direction:t.direction,count:r.affected.length,truncated:r.truncated,...r.nextCursor===void 0?{}:{next_cursor:r.nextCursor},cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...t.summary?{}:{affected:r.affected}}}function Ar(e,t,r){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,r),critical_path:e.criticalPath.slice(0,r),cycles:e.cycles.slice(0,r)}}}function Rr(e,t,r){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,r),hubs:e.hubs.slice(0,r)}}}function Or(e,t,r){let n=0,i=0,o=0;for(let s of e.cycles)n+=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-n,legacy_cycle_count:n,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,r).map(s=>s.item_ids)}}}function jr(e){let t=e.assembly.graph,r=e.limit,n=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:r,execution:Ar(n,e.summary,r),knowledge:Rr(i,e.summary,r),hierarchy:Or(G(e.assembly),e.summary,r)}}function Mr(e,t){let r=ee(e.assembly,{isTerminal:t,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),n={},i={},o={},s={};for(let d of r.findings)n[d.severity]=(n[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}=r.profile;return{subcommand:"audit",truncated:r.findings.length>e.limit,finding_count:r.findings.length,findings_by_severity:n,findings_by_code:i,affected_subjects_by_severity:o,affected_subjects_by_code:s,profile:e.summary?c:r.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:r.findings.slice(0,e.limit)}}}function Pr(e){let t=e.limit,r={};e.kinds!==void 0&&(r.kinds=e.kinds);let n=it(e.assembly.graph,r),i=n.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:n.meta.visitedNodes,inspected_edges:n.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(r){ye(r)}return{subcommand:"redundancy",redundant_count:t.value.length,...be(t.meta),...e.summary?{}:{redundant:t.value.map(r=>({source:r.edge.source,target:r.edge.target,kind:r.edge.kind,witness:r.witness}))}}}function Fr(e,t){let r=t.limit,n=ot(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=n.value.rows.filter(o=>o.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:n.value.reachableCount,bottleneck_count:i.length,truncated:n.meta.truncated||i.length>r,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,r).map(o=>({id:o.id,idom:o.idom,dominated_count:o.dominatedCount}))}}}function Gr(e){let t=e.limit,r=lt(e.assembly.graph),n=r.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:r.acyclic,makespan:r.makespan,scheduled_count:r.scheduledCount,critical_count:n,critical_path_length:r.criticalPathLength,cycle_count:r.cycles.length,truncated:r.rows.length>t,...e.summary?{}:{critical_path:r.criticalPath.slice(0,t),rows:r.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,r=dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),n=r.value;return{subcommand:"centrality",node_count:n.nodeCount,edge_count:n.edgeCount,edge_basis:"simple_undirected",truncated:n.rows.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{rows:n.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,r=X(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:n,bridges:i}=r.value;return{subcommand:"articulation",articulation_count:n.length,bridge_count:i.length,truncated:n.length>t||i.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{articulation_points:n.slice(0,t),bridges:i.slice(0,t)}}}function Ur(e,t){let r=e.limit,n=jt(e.assembly,{isTerminal:t,redundancyLimit:r,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},o={};for(let s of n.steps)i[s.op]=(i[s.op]??0)+1,o[s.code]=(o[s.code]??0)+1;return{subcommand:"plan",step_count:n.steps.length,steps_by_op:i,steps_by_code:o,finding_count:n.report.findings.length,truncated:n.truncated||n.steps.length>r,cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...e.summary?{}:{steps:n.steps.slice(0,r)}}}function Gt(e,t,r,n){return JSON.stringify({projection_version:2,subcommand:e,root:t??null,target:r??null,kinds:n.kinds??null,maxDepth:n.maxDepth??null,limit:n.limit,after:n.after??null,direction:n.direction,maxPaths:n.maxPaths??null,sample:n.sample,exemptIsolates:[...new Set(n.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(n.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:n.summary,unbounded:n.unbounded})}function $t(e,t,r,n,i){return e==="analyze"?jr(n):e==="audit"?Mr(n,i):e==="plan"?Ur(n,i):e==="communities"?Pr(n):e==="redundancy"?Lr(n):e==="dominators"?Fr(t,n):e==="slack"?Gr(n):e==="centrality"?$r(n):e==="articulation"?qr(n):e==="paths"?Tr(t,r,n):e==="impact"?Nr(t,n):Dr(e,t,n)}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,r,n,i,o){let s="status";if(o.clear===!0&&(await me(e),s="cleared"),o.rebuild===!0){await me(e);let c=await he(e,t),d={assembly:r.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,limit:I.rows,sample:I.samples,unbounded:!1};for(let l of["analyze","audit"])await fe(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:n,min_items_threshold:ge,persist_enabled:_e(n,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,r,n){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:r.affected_subjects_by_code,profile:{...r.profile,finding_subjects_by_code:Object.fromEntries(A.map(s=>[s,r.affected_subjects_by_code[s]??0]))}},o=await At(e);return n&&await Rt(e,i),o===void 0?r:{...r,baseline:xt(o,i)}}async function Kr(e,t,r,n,i){try{await fe(e,t,r,n,i)}catch{}}function Vr(e,t,r,n){if(e.subcommand!=="slack")return;let i=new Set(t.assembly.details.filter(u=>n(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,r.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,r,n,i){let o=Cr(e,t,r);De(n.summary===!0,n.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,n);let u=Fe(),p=ze(n.kind,u),h=qe().lookup(s,$e(d,g,u),()=>Ge(d,g,u)),m=Sr(o,h.assembly,p,n);if(o==="index")return Mt(await zr(s,h.fingerprint,m,d.length,g,n),!1);let b=Ft.has(o)?Lt(m.assembly,t):void 0,v=o==="paths"?Lt(m.assembly,r):void 0,f=Gt(o,b,v,m),_=await he(s,h.fingerprint),E=_.results[f],S=h.memoize(f,()=>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,h.fingerprint,_,f,S.value);let ne=S.value.subcommand==="audit"?await Hr(s,h.fingerprint,S.value,m.saveBaseline):S.value;return ne.cache={fingerprint:h.fingerprint.slice(0,12),assembly:h.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,he as B,fe 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-FOHRPFIT.js.map
|