@unbrained/pm-cli 2026.11.25 → 2026.11.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/commander-usage.js +9 -9
  3. package/dist/cli/error-guidance.js +5 -5
  4. package/dist/cli/help-content.js +4 -4
  5. package/dist/cli/register-setup.js +1 -1
  6. package/dist/cli/runtime/selection.js +1 -1
  7. package/dist/cli-bundle/bundle-manifest.json +1 -1
  8. package/dist/cli-bundle/chunks/{chunk-LPW7S5KA.js → chunk-5AAIRHNE.js} +2 -2
  9. package/dist/cli-bundle/chunks/chunk-5BPDT7G2.js +2 -0
  10. package/dist/cli-bundle/chunks/{chunk-7EPYCU7U.js → chunk-5FY2VHRF.js} +5 -5
  11. package/dist/cli-bundle/chunks/{chunk-YIGBEY7K.js → chunk-7F3UFYZA.js} +2 -2
  12. package/dist/cli-bundle/chunks/chunk-B2GM6KOM.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-BITDGTAX.js +2 -0
  14. package/dist/cli-bundle/chunks/{chunk-L6VS7F3R.js → chunk-CBBKXTJG.js} +2 -2
  15. package/dist/cli-bundle/chunks/chunk-DUJSME77.js +3 -0
  16. package/dist/cli-bundle/chunks/{chunk-OWK2JL4I.js → chunk-DYL2N3OC.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-GBVF2ZB3.js → chunk-FWBR3OW7.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-OS5W4ZG2.js → chunk-GQXK4KKH.js} +31 -31
  19. package/dist/cli-bundle/chunks/{chunk-FHLOGAGA.js → chunk-HOLQZ56F.js} +2 -2
  20. package/dist/cli-bundle/chunks/chunk-HTGN24XM.js +3 -0
  21. package/dist/cli-bundle/chunks/{chunk-K34FR5CO.js → chunk-IGW3RVJC.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-FVY7U3SU.js → chunk-KCRRTJ4X.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-DF6A7C32.js → chunk-KES4VHU4.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-CZEMEPPQ.js → chunk-LNZKNVMT.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-MNFCJNQA.js +35 -0
  26. package/dist/cli-bundle/chunks/{chunk-CONBVY2O.js → chunk-NDS4MXZX.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-BVJMVU4Z.js → chunk-PQSEEVOA.js} +6 -6
  28. package/dist/cli-bundle/chunks/chunk-QMM46SJM.js +4 -0
  29. package/dist/cli-bundle/chunks/chunk-RFK3ERYX.js +2 -0
  30. package/dist/cli-bundle/chunks/chunk-T3GJPXIZ.js +69 -0
  31. package/dist/cli-bundle/chunks/{chunk-CNUFU454.js → chunk-WZOJSHJT.js} +3 -3
  32. package/dist/cli-bundle/chunks/{chunk-C4KIZQHW.js → chunk-XRCE4QNL.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-SCIPT7WF.js → chunk-ZDL45VTB.js} +2 -2
  34. package/dist/cli-bundle/chunks/{field-option-collisions-QE65APSD.js → field-option-collisions-CGRJEAPQ.js} +2 -2
  35. package/dist/cli-bundle/chunks/{item-revision-INDHJV6X.js → item-revision-FGDR5NSF.js} +2 -2
  36. package/dist/cli-bundle/chunks/item-transaction-C3KAMEYO.js +2 -0
  37. package/dist/cli-bundle/chunks/{mutation-actor-KU7BMLUN.js → mutation-actor-HGG47KXV.js} +2 -2
  38. package/dist/cli-bundle/chunks/{mutation-admission-3OMCTQD4.js → mutation-admission-LLHIRY6O.js} +2 -2
  39. package/dist/cli-bundle/chunks/{register-list-query-3GV3LBOT.js → register-list-query-EKSCZWEZ.js} +2 -2
  40. package/dist/cli-bundle/chunks/{register-mutation-GZLF47SX.js → register-mutation-ZIAOKKUJ.js} +2 -2
  41. package/dist/cli-bundle/chunks/{register-operations-PBJZGCAL.js → register-operations-ECVBZ5FM.js} +2 -2
  42. package/dist/cli-bundle/chunks/register-setup-3QYD5H4H.js +2 -0
  43. package/dist/cli-bundle/chunks/{stage-3WIZBD4N.js → stage-RSCSUYEJ.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-VU2PH4PF.js → chunk-3BR5NWQI.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-BOIMP2AR.js → chunk-3GQRWIT5.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-X4EWD6TL.js → chunk-AAB3ZR7Z.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-C3FEDTSD.js → chunk-AVLB4L7M.js} +26 -26
  48. package/dist/cli-bundle/focused-chunks/{chunk-5RBC4WSE.js → chunk-FQWKESMI.js} +58 -59
  49. package/dist/cli-bundle/focused-chunks/{chunk-BYQK5DGH.js → chunk-FW5Q26HA.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/chunk-GQBWI4KA.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/{chunk-TQIKDFOD.js → chunk-IWEGGRRD.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-ZLRRII55.js → chunk-JUG3BAZZ.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-KEZ4VXYD.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-XKLBTDJ7.js → chunk-NSFS3VWP.js} +3 -3
  55. package/dist/cli-bundle/focused-chunks/{chunk-TRL4JDWX.js → chunk-NXUFVQ33.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-YYEWIKNI.js → chunk-QNWNUQSJ.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-QSRXF6XS.js +15 -0
  58. package/dist/cli-bundle/focused-chunks/{chunk-WVA5KOXF.js → chunk-R6QFPHWW.js} +3 -3
  59. package/dist/cli-bundle/focused-chunks/{chunk-PKX2EHE3.js → chunk-RDELKGLS.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-3Y5PTQ2F.js → chunk-RFJ3MEFP.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-SXC2EO3E.js → chunk-RMJKVQYE.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-UWWAVXG4.js → chunk-TNVLDU7Z.js} +3 -3
  63. package/dist/cli-bundle/focused-chunks/chunk-UA2JNKMY.js +4 -0
  64. package/dist/cli-bundle/focused-chunks/{chunk-7SSGTGZO.js → chunk-VV2QF5IE.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-MB56Y4M6.js → chunk-WHHFPATO.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/{chunk-JOKRDFMQ.js → chunk-YNRW2FWB.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/{chunk-4LQL4EO6.js → chunk-YSZZSV6M.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{field-option-collisions-5ROXGUME.js → field-option-collisions-WV6GPYYP.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/{item-revision-KYMSQVZE.js → item-revision-RPTXN7WW.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{item-transaction-I4HLVHEJ.js → item-transaction-A6MVNPT7.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{mutation-actor-GGOQKAE6.js → mutation-actor-6ZVW6OME.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/{mutation-admission-OS36ZCMH.js → mutation-admission-2DA4CINP.js} +2 -2
  73. package/dist/cli-bundle/focused-chunks/{stage-4ZFWJUKO.js → stage-RG3PKST7.js} +2 -2
  74. package/dist/cli-bundle/main.js +26 -26
  75. package/dist/cli-bundle/sdk-authoring.js +1 -1
  76. package/dist/cli-bundle/sdk-contracts.js +4 -4
  77. package/dist/cli-bundle/sdk-core.js +1 -1
  78. package/dist/cli-bundle/sdk-governance.js +1 -1
  79. package/dist/cli-bundle/sdk-graph.js +1 -1
  80. package/dist/cli-bundle/sdk-merge.js +63 -63
  81. package/dist/cli-bundle/sdk-query.js +1 -1
  82. package/dist/cli-bundle/sdk-runtime.js +1 -1
  83. package/dist/cli-bundle/sdk-testing.js +1 -1
  84. package/dist/cli-bundle/sdk.js +11 -11
  85. package/dist/core/reproducibility/context.d.ts +2 -0
  86. package/dist/core/reproducibility/context.js +1 -1
  87. package/dist/sdk/cli-bootstrap.d.ts +17 -0
  88. package/dist/sdk/cli-bootstrap.js +1 -1
  89. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  90. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  91. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  92. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  93. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  94. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  95. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  96. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  97. package/dist/sdk/cli-contracts.d.ts +1 -1
  98. package/dist/sdk/cli-contracts.js +1 -1
  99. package/dist/sdk/completion/shared.d.ts +1 -1
  100. package/dist/sdk/completion/shared.js +1 -1
  101. package/dist/sdk/extension/bundled-catalog.js +1 -1
  102. package/dist/sdk/extension/install-sources.js +5 -5
  103. package/dist/sdk/extension/listing-fields.d.ts +15 -0
  104. package/dist/sdk/extension/listing-fields.js +2 -0
  105. package/dist/sdk/extension/managed-update-status.js +1 -1
  106. package/dist/sdk/extension/npm-spec.d.ts +18 -0
  107. package/dist/sdk/extension/npm-spec.js +2 -0
  108. package/dist/sdk/extension/static-inventory.d.ts +53 -1
  109. package/dist/sdk/extension/static-inventory.js +1 -1
  110. package/dist/sdk/extension/update-check.js +1 -1
  111. package/dist/sdk/extension/update-observations.js +3 -0
  112. package/dist/sdk/extension/upgrade-hints.js +2 -0
  113. package/dist/sdk/extension.d.ts +2 -0
  114. package/dist/sdk/extension.js +1 -1
  115. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  116. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  117. package/dist/sdk/governance/upgrade.d.ts +7 -2
  118. package/dist/sdk/governance/upgrade.js +2 -2
  119. package/dist/sdk/index.d.ts +1 -1
  120. package/dist/sdk/public-surface.json +1 -1
  121. package/dist/sdk/query/context.d.ts +20 -7
  122. package/dist/sdk/query/context.js +4 -2
  123. package/dist/sdk/runtime-input.js +1 -1
  124. package/dist/sdk/testing.d.ts +20 -2
  125. package/docs/COMMANDS.md +19 -1
  126. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +6 -0
  127. package/docs/EXTENSION_LIFECYCLE.md +72 -2
  128. package/docs/SDK.md +21 -2
  129. package/marketplace.json +1 -1
  130. package/package.json +1 -1
  131. package/packages/pm-beads/package.json +1 -1
  132. package/packages/pm-calendar/package.json +1 -1
  133. package/packages/pm-command-kit/package.json +1 -1
  134. package/packages/pm-digital-twin/package.json +1 -1
  135. package/packages/pm-governance-audit/package.json +1 -1
  136. package/packages/pm-guide-shell/package.json +1 -1
  137. package/packages/pm-kanban/package.json +1 -1
  138. package/packages/pm-lifecycle-hooks/package.json +1 -1
  139. package/packages/pm-linked-test-adapters/package.json +1 -1
  140. package/packages/pm-search-advanced/package.json +1 -1
  141. package/packages/pm-templates/package.json +1 -1
  142. package/packages/pm-todos/package.json +1 -1
  143. package/packages/pm-vcs/package.json +1 -1
  144. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  145. package/plugins/pm-claude/package.json +1 -1
  146. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  147. package/plugins/pm-codex/package.json +1 -1
  148. package/plugins/pm-codex/plugin.json +1 -1
  149. package/runtime-dependencies.json +1 -1
  150. package/dist/cli-bundle/chunks/chunk-4FZH5BTV.js +0 -2
  151. package/dist/cli-bundle/chunks/chunk-GZI7ZAB7.js +0 -2
  152. package/dist/cli-bundle/chunks/chunk-LOX3VY4T.js +0 -2
  153. package/dist/cli-bundle/chunks/chunk-VA4T37Q4.js +0 -70
  154. package/dist/cli-bundle/chunks/chunk-WQOEVGLQ.js +0 -2
  155. package/dist/cli-bundle/chunks/chunk-XHCIOLJP.js +0 -3
  156. package/dist/cli-bundle/chunks/chunk-XKWJONAO.js +0 -2
  157. package/dist/cli-bundle/chunks/chunk-ZBOQEZ2H.js +0 -33
  158. package/dist/cli-bundle/chunks/chunk-ZLICQPRG.js +0 -3
  159. package/dist/cli-bundle/chunks/item-transaction-LCKK4XXB.js +0 -2
  160. package/dist/cli-bundle/chunks/register-setup-ZLJEF6NZ.js +0 -2
  161. package/dist/cli-bundle/focused-chunks/chunk-A4R57E4K.js +0 -2
  162. package/dist/cli-bundle/focused-chunks/chunk-IAOKVKWW.js +0 -2
  163. package/dist/cli-bundle/focused-chunks/chunk-VMYVN36N.js +0 -13
  164. package/dist/cli-bundle/focused-chunks/chunk-WL2R7T5G.js +0 -2
@@ -1,2 +1,2 @@
1
- import{d as Fe,o as G,p as Ge,q as $e,s as qe,w as $,x as Ue,y as Be,z as ze}from"./chunk-JOKRDFMQ.js";import{L as Le,e as je}from"./chunk-7SSGTGZO.js";import{s as Me,y as Pe}from"./chunk-MB56Y4M6.js";import{a as k}from"./chunk-BWOVFE5B.js";import{Cf as De,Df as se,Gb as Ne,Gf as Oe,Q as Ee,W as Ie,dc as Ae,je as Te,q as ve,v as xe,va as ie,ze as Re}from"./chunk-XKLBTDJ7.js";import{t as Ce}from"./chunk-WVA5KOXF.js";import{O as Se}from"./chunk-OCKKIECS.js";import{A as x,F as j,I as re,K as ke,z as v}from"./chunk-NGFDPEP7.js";function Ut(e,t,n,r,i,s){if(e.seen.has(t))return"skip";if(e.cursorFound&&e.affected.length>=s)return"truncate";e.seen.add(t),e.parents.set(t,n.id);let o=n.depth+1;return e.queue.push({id:t,depth:o}),e.cursorFound?(e.affected.push({id:t,distance:o,path:Yt(r,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function Ke(e,t,n,r){let i=De("graph impact",{root:e,direction:n,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(r)?r:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:Oe(t.after,i)}}function C(e,t,n){e.get(t).add(n)}function M(e){return new Map(e.map(t=>[t,new Set]))}function Ve(e){for(let t of e)t.sort();return e.sort((t,n)=>n.length-t.length||t[0].localeCompare(n[0]))}function q(e){if(Array.isArray(e))return e.map(n=>q(n));if(e===null||typeof e!="object")return e;let t=e.toJSON;return typeof t=="function"?q(t.call(e)):Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,q(r)]))}function He(e){return JSON.stringify(q(e))}function Bt(e,t,n,r){let i=[{id:e,expanded:!1}];for(;i.length>0;){let s=i.pop();if(s.expanded){r.push(s.id);continue}if(n.has(s.id))continue;n.add(s.id),i.push({id:s.id,expanded:!0});let o=[...t.get(s.id)].sort().reverse();for(let c of o)n.has(c)||i.push({id:c,expanded:!1})}}function zt(e,t){let n=new Set,r=[];for(let i of e)n.has(i)||Bt(i,t,n,r);return r}function Ht(e,t){let n=new Set,r=[];for(let i of[...e].reverse()){if(n.has(i))continue;let s=[],o=[i];for(n.add(i);o.length>0;){let c=o.pop();s.push(c);for(let a of t.get(c))n.has(a)||(n.add(a),o.push(a))}r.push(s)}return Ve(r)}function We(e,t){let n=M(e);for(let[r,i]of t)for(let s of i)C(n,s,r);return Ht(zt(e,t),n)}function Kt(e,t){let n=M(e.nodes());for(let r of e.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let s=(i.precedence??"source_before_target")==="source_before_target";C(n,s?r.source:r.target,s?r.target:r.source)}return n}function Vt(e,t){let n=new Map(e.map(s=>[s,0]));for(let s of t.values())for(let o of s)n.set(o,n.get(o)+1);let r=e.filter(s=>n.get(s)===0).sort(),i=[];for(;r.length>0;){i.push(r);let s=[];for(let o of r)for(let c of t.get(o)){let a=n.get(c)-1;n.set(c,a),a===0&&s.push(c)}r=s.sort()}return i}function Wt(e,t){let n=new Map(e.map(o=>[o,0])),r=new Map;for(let o of e)for(let c of t.get(o)){if(!n.has(c))continue;let a=n.get(o)+1,d=r.get(c);(a>n.get(c)||a===n.get(c)&&(d===void 0||o.localeCompare(d)<0))&&(n.set(c,a),r.set(c,o))}let i=[...e].sort((o,c)=>n.get(c)-n.get(o)||o.localeCompare(c))[0],s=i===void 0?[]:[i];for(;s[0]!==void 0&&r.has(s[0]);)s.unshift(r.get(s[0]));return{depth:Object.fromEntries(n),path:s}}function Yt(e,t,n){let r=[t],i=t;for(;i!==e;)i=n.get(i),r.push(i);return r.reverse()}function B(e,t={}){let n=t.registry??ve(),r=[...e.nodes()],i=Kt(e,n),s=Vt(r,i),o=s.flat(),c=o.length===r.length,a=c?[]:We(r,i).filter(l=>l.length>1||i.get(l[0]).has(l[0])),d=Wt(o,i);return{exact:!0,acyclic:c,order:o,layers:s,frontier:s[0]??[],depth:d.depth,criticalPath:d.path,criticalPathLength:Math.max(0,d.path.length-1),cycles:a,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function Xt(e,t,n){let r=M(e.nodes()),i=n===void 0?void 0:new Set(n.map(o=>e.registry().require(o).kind)),s=e.edges();for(let o of s){let c=e.registry().require(o.kind);i!==void 0&&!i.has(o.kind)&&(c.inverse===void 0||!i.has(c.inverse))||C(r,t==="incoming"?o.target:o.source,t==="incoming"?o.source:o.target)}return{adjacency:r,inspectedEdges:s.length}}function Jt(e,t,n,r,i,s){let o=U(e,t,{...n,after:void 0,direction:"incoming",limit:void 0}),c=U(e,t,{...n,after:void 0,direction:"outgoing",limit:void 0}),a=new Map,d=[...o.affected,...c.affected].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)||p.path.join("\0").localeCompare(m.path.join("\0")));for(let p of d)a.has(p.id)||a.set(p.id,p);let l=[...a.values()].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)),f=r===void 0||r===t?-1:l.findIndex(p=>p.id===r);if(r!==void 0&&r!==t&&f<0)throw new TypeError(`Unknown impact cursor item: ${r}`);let u=l.slice(f+1,f+1+i),g=f+1+u.length<l.length;return{root:t,affected:u,exact:!0,truncated:o.truncated||c.truncated||g,...g?{nextCursor:se(s,u.at(-1)?.id??t)}:{},cost:{visitedNodes:o.cost.visitedNodes+c.cost.visitedNodes,inspectedEdges:o.cost.inspectedEdges+c.cost.inspectedEdges}}}function Qt(e,t,n){let r=n.direction,i=n.maxDepth??Number.POSITIVE_INFINITY,s=n.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=Ke(t,n,r,i),{adjacency:a,inspectedEdges:d}=Xt(e,r,n.kinds),l={queue:[{id:t,depth:0}],seen:new Set([t]),parents:new Map,affected:[],cursorFound:c===void 0||c===t},f=0,u=!1,g=!1;e:for(let p=0;p<l.queue.length;p+=1){n.signal?.throwIfAborted();let m=l.queue[p];f+=1;let b=[...a.get(m.id)].sort();if(m.depth>=i){b.some(w=>!l.seen.has(w))&&(u=!0);continue}for(let w of b)if(Ut(l,w,m,t,c,s)==="truncate"){u=!0,g=!0;break e}}if(!l.cursorFound)throw new TypeError(`Unknown impact cursor item: ${c}`);return{root:t,affected:l.affected,exact:!0,truncated:u,...g?{nextCursor:se(o,l.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:f,inspectedEdges:d}}}function U(e,t,n={}){let r=n.direction??"outgoing";if(r!=="both")return Qt(e,t,{...n,direction:r});let i=n.maxDepth??Number.POSITIVE_INFINITY,s=n.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=Ke(t,n,r,i);return Jt(e,t,n,c,s,o)}function Ye(e){let t=[...e.nodes()],n=M(t),r=M(t);for(let a of e.edges())C(n,a.source,a.target),C(n,a.target,a.source),C(r,a.source,a.target);let i=[],s=new Set;for(let a of t){if(s.has(a))continue;let d=[],l=[a];for(s.add(a);l.length>0;){let f=l.pop();d.push(f);for(let u of n.get(f))s.has(u)||(s.add(u),l.push(u))}i.push(d)}let o=t.map(a=>({id:a,degree:n.get(a).size})),c=Math.max(0,...o.map(({degree:a})=>a));return{components:Ve(i),stronglyConnected:We(t,r),orphans:o.filter(({degree:a})=>a===0).map(({id:a})=>a),hubs:o.filter(({degree:a})=>a>0&&a===c),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function Xr(e,t){let n=new Map(e.edges.map(i=>[He(i),i])),r=new Map(t.edges.map(i=>[He(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),removed:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),unchangedCount:[...n.keys()].filter(i=>r.has(i)).length,exact:!0}}var Zt=k.paths,en=k.visited_paths,tn=k.path_depth;function oe(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 N(e,t){let n=P(e,t);return{predecessor:n,successor:n===e.source?e.target:e.source}}function nn(e,t,n){if(t===void 0)return;let r=e.registry(),i=new Set;for(let s of t){let o=r.require(s),c=o.traversal;if(c==="association")throw new TypeError(`Relationship kind ${o.kind} uses association traversal; use graph impact --direction both`);if(c!==n&&c!=="semantic"){let a=c==="hierarchy"?"graph ancestors or graph descendants":"graph predecessors or graph successors";throw new TypeError(`Relationship kind ${o.kind} uses ${c} traversal; use ${a}`)}i.add(o.kind)}return i}function rn(e,t,n,r,i){let s=e.registry(),o=e.neighborEdges(t,{direction:"both",...n===void 0?{}:{kinds:[...n]}}),c=[],a=new Set;for(let d of o.value){let l=s.require(d.edge.kind);n===void 0&&!l[r]||i(d,l,t)&&(a.has(d.id)||(a.add(d.id),c.push(d.id)))}return{neighbors:c,inspectedEdges:o.meta.inspectedEdges}}function sn(e,t,n,r,i,s){if(t>=n)return e.neighbors.some(o=>!s.seen.has(o))&&(s.truncated=!0),!1;for(let o of e.neighbors)if(!s.seen.has(o)){if(s.seen.add(o),s.queue.push({id:o,depth:t+1}),!s.resumed){o===i&&(s.resumed=!0);continue}if(s.value.length>=r)return s.truncated=!0,!0;s.value.push(o)}return!1}function H(e,t,n,r,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let s=nn(e,n.kinds,r),o=n.limit??Number.POSITIVE_INFINITY,c=n.maxDepth??Number.POSITIVE_INFINITY,a=n.after,d={seen:new Set([t]),value:[],queue:[{id:t,depth:0}],resumed:a===void 0,truncated:!1},l=0,f=0;for(let u=0;u<d.queue.length;u+=1){n.signal?.throwIfAborted();let g=d.queue[u];l+=1;let p=rn(e,g.id,s,r,i);if(f+=p.inspectedEdges,sn(p,g.depth,c,o,a,d))break}if(!d.resumed)throw new TypeError(`Traversal cursor not found in sequence: ${a}`);return{value:d.value,meta:{visitedNodes:l,inspectedEdges:f,truncated:d.truncated,nextCursor:d.value.at(-1)}}}function Xe(e,t){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`)}function Je(e,t,n,r,i){let s=e.neighborEdges(t.nodes.at(-1),{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});return i.inspectedEdges+=s.meta.inspectedEdges,s.value.filter(o=>!t.nodeSet.has(o.id))}function on(e,t,n,r,i,s,o){for(let c of Je(e,t,r,i,o)){let a=[...t.nodes,c.id],d=new Set(t.nodeSet).add(c.id),l=[...t.edges,c.edge];if(c.id===n){if(o.value.push({nodes:a,edges:l,length:l.length}),o.value.length>=s)return!0}else o.queue.push({nodes:a,nodeSet:d,edges:l})}return!1}function Qe(e,t,n={}){return H(e,t,n,"hierarchy",(r,i)=>z(r.edge,i)===r.id)}function Ze(e,t,n={}){return H(e,t,n,"hierarchy",(r,i,s)=>z(r.edge,i)===s)}function et(e,t,n={}){return H(e,t,n,"ordering",(r,i)=>P(r.edge,i)===r.id)}function tt(e,t,n={}){return H(e,t,n,"ordering",(r,i,s)=>P(r.edge,i)===s)}function cn(e,t,n,r,i,s,o,c){let a={value:[],queue:[{nodes:[t],nodeSet:new Set([t]),edges:[]}],inspectedEdges:0},d=0,l=!1,f=i+1;for(let u=0;u<a.queue.length;u+=1){if(r.signal?.throwIfAborted(),a.value.length>=f||d>=s){l=!0;break}let g=a.queue[u];if(d+=1,g.edges.length>=o){Je(e,g,r,c,a).length>0&&(l=!0);continue}if(on(e,g,n,r,c,f,a)){l=!0;break}}return{value:a.value.slice(0,i),meta:{visitedNodes:d,inspectedEdges:a.inspectedEdges,truncated:l}}}function nt(e,t,n,r={}){Xe(e,t),Xe(e,n);let i=r.maxPaths??Zt,s=r.maxVisitedPaths??en,o=r.maxDepth??tn;oe("maxPaths",i),oe("maxVisitedPaths",s),oe("maxDepth",o);let c=r.direction??"outgoing";r.signal?.throwIfAborted();for(let a of r.kinds??[])e.registry().require(a);return t===n?i===0?{value:[],meta:{visitedNodes:1,inspectedEdges:0,truncated:!0}}:{value:[{nodes:[t],edges:[],length:0}],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}}:cn(e,t,n,r,i,s,o,c)}var an=16,dn=2,ln=8;function K(e,t){if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`)}function V(e,t,n){let r=e.registry(),i=t===void 0?void 0:new Set(t.map(s=>r.require(s).kind));for(let s of e.edges()){if(s.source===s.target)continue;let o=r.require(s.kind);i!==void 0&&!(i.has(o.kind)||o.inverse!==void 0&&i.has(o.inverse))||n(s,o)}}function un(e,t){let n=new Map;V(e,t,r=>{rt(n,r.source,r.target),rt(n,r.target,r.source)});for(let r of n.values())r.sort();return n}function rt(e,t,n){let r=e.get(t);r===void 0?e.set(t,[n]):r.push(n)}function fn(e,t){let n=new Map;for(let s of e){let o=t.get(s);n.set(o,(n.get(o)??0)+1)}let r,i=0;for(let[s,o]of n)(o>i||o===i&&s<r)&&(r=s,i=o);return r}function gn(e,t){let n=new Map;for(let[i,s]of e){let o=n.get(s);o===void 0?n.set(s,[i]):o.push(i)}let r=[];for(let i of n.values())i.length<t||(i.sort(),r.push({representative:i[0],size:i.length,members:i}));return r.sort((i,s)=>s.size-i.size||i.representative.localeCompare(s.representative))}function it(e,t={}){let n=t.maxIterations??an,r=t.minSize??dn;K("maxIterations",n),K("minSize",r);let i=un(e,t.kinds),s=e.nodes(),o=new Map(s.map(f=>[f,f])),c=0,a=!1,d=0,l=0;for(;c<n&&!a;){t.signal?.throwIfAborted(),c+=1,a=!0;for(let f of s){d+=1;let u=i.get(f);if(u===void 0)continue;l+=u.length;let g=fn(u,o);g!==o.get(f)&&(o.set(f,g),a=!1)}}return{value:{communities:gn(o,r),iterations:c,converged:a},meta:{visitedNodes:d,inspectedEdges:l,truncated:!a}}}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 ce(e,t){return(t.hierarchy?z(e,t):e.source===P(e,t)?e.target:e.source)===e.target?{from:e.source,to:e.target}:{from:e.target,to:e.source}}function pn(e,t){if(t===void 0)return;let n=e.registry(),r=new Set;for(let i of t){let s=n.require(i);if(!W(s))throw new TypeError(`Relationship kind ${s.kind} is not a directed ordering or hierarchy kind`);r.add(Y(s))}return r}function hn(e,t){let n=e.registry(),r=new Map;for(let i of e.edges()){let s=n.require(i.kind);if(!W(s))continue;let o=Y(s);if(t!==void 0&&!t.has(o))continue;let c=ce(i,s);if(c.from===c.to)continue;let a=r.get(o);a===void 0&&(a={adjacency:new Map,records:[]},r.set(o,a));let d=a.adjacency.get(c.from);d===void 0?a.adjacency.set(c.from,new Set([c.to])):d.add(c.to),a.records.push({...c,edge:i})}return r}function mn(e){let t=new Map;for(let[n,r]of e.adjacency)t.set(n,[...r].sort());return t}function _n(e,t,n,r){let i=[r];for(let s=n;s!==t;s=e.get(s))i.push(s);return i.push(t),i.reverse()}function yn(e,t,n,r,i,s){for(let o of e.get(n.id)??[])if(s.inspectedEdges+=1,!(n.depth===0&&o===t.to)&&!r.has(o)){if(r.set(o,n.id),o===t.to)return _n(r,t.from,n.id,o);i.push({id:o,depth:n.depth+1})}}function bn(e,t,n,r){let i=new Map([[t.from,t.from]]),s=[{id:t.from,depth:0}];for(let o=0;o<s.length;o+=1){let c=s[o];if(r.visitedNodes+=1,c.depth>=n)continue;let a=yn(e,t,c,i,s,r);if(a!==void 0)return a}}function A(e,t={}){let n=t.maxDepth??ln;K("maxDepth",n),t.limit!==void 0&&K("limit",t.limit);let r=t.limit??Number.POSITIVE_INFINITY,i=pn(e,t.kinds),s=hn(e,i),o=[],c={visitedNodes:0,inspectedEdges:0},a=!1;e:for(let d of[...s.keys()].sort()){let l=s.get(d),f=mn(l);for(let u of l.records){t.signal?.throwIfAborted();let g=bn(f,u,n,c);if(g!==void 0){if(o.length>=r){a=!0;break e}o.push({edge:u.edge,witness:g})}}}return{value:o,meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:a}}}function wn(e,t,n,r,i){let s=new Set,o=[];for(let c of n){if(c.id===e||s.has(c.id))continue;if(!i.seen.has(c.id)){if(t>=r){i.truncated=!0;continue}i.seen.add(c.id),i.queue.push({id:c.id,depth:t+1})}s.add(c.id),o.push(c.id);let a=i.predecessors.get(c.id);a===void 0&&(a=new Set,i.predecessors.set(c.id,a)),a.add(e)}return o}function vn(e,t,n){let r=n.direction??"outgoing",i=n.maxDepth??Number.POSITIVE_INFINITY,s=[],o=new Map,c={seen:new Set([t]),queue:[{id:t,depth:0}],predecessors:new Map,truncated:!1},a=0;for(let d=0;d<c.queue.length;d+=1){n.signal?.throwIfAborted();let{id:l,depth:f}=c.queue[d];s.push(l);let u=e.neighborEdges(l,{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});a+=u.meta.inspectedEdges,o.set(l,wn(l,f,u.value,i,c))}return{order:s,successors:o,predecessors:c.predecessors,inspectedEdges:a,truncated:c.truncated}}function xn(e,t){let n=[],r=new Set([t]),i=[{id:t,index:0}];for(;i.length>0;){let s=i.at(-1),o=e.successors.get(s.id);if(s.index<o.length){let c=o[s.index];s.index+=1,r.has(c)||(r.add(c),i.push({id:c,index:0}))}else n.push(s.id),i.pop()}return n.reverse()}function kn(e,t,n,r){let i=e,s=t;for(;i!==s;){for(;r.get(i)>r.get(s);)i=n.get(i);for(;r.get(s)>r.get(i);)s=n.get(s)}return i}function En(e,t,n){let r;for(let i of[...e].sort())t.has(i)&&(r=r===void 0?i:kn(r,i,t,n));return r}function In(e,t,n,r,i){let s=new Map([[t,t]]),o=!0;for(;o;){o=!1;for(let c of n){if(i?.throwIfAborted(),c===t)continue;let a=En(e.predecessors.get(c),s,r);a!==void 0&&s.get(c)!==a&&(s.set(c,a),o=!0)}}return s}function st(e,t,n={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(n.maxDepth!==void 0&&(!Number.isInteger(n.maxDepth)||n.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(n.maxDepth)}`);let r=vn(e,t,n),i=xn(r,t),s=new Map(i.map((d,l)=>[d,l])),o=In(r,t,i,s,n.signal),c=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 f=o.get(l);c.set(f,c.get(f)+c.get(l))}let a=i.filter(d=>d!==t).map(d=>({id:d,idom:o.get(d),dominatedCount:c.get(d)-1})).sort((d,l)=>l.dominatedCount-d.dominatedCount||d.id.localeCompare(l.id));return{value:{root:t,reachableCount:r.order.length,rows:a},meta:{visitedNodes:r.order.length,inspectedEdges:r.inspectedEdges,truncated:r.truncated}}}function ot(e){return Math.round(e*1e6)/1e6}function ct(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function at(e,t){let n=new Map(e.nodes().map(i=>[i,new Set]));V(e,t,i=>{n.get(i.source).add(i.target),n.get(i.target).add(i.source)});let r=new Map;for(let[i,s]of n)r.set(i,[...s].sort());return r}function Sn(e,t){let n=new Map,r=new Map;return V(e,t,(i,s)=>{if(!s.ordering)return;let{predecessor:o,successor:c}=N(i,s);ct(r,o,c),ct(n,c,o)}),{incoming:n,outgoing:r}}function Cn(e,t,n){let r=new Map([[e,0]]),i=new Map([[e,1]]),s=new Map,o=[],c=[e],a=0,d=0;for(let l=0;l<c.length;l+=1){let f=c[l];n.visitedNodes+=1,o.push(f);let u=r.get(f);f!==e&&(a+=1,d+=u);for(let g of t.get(f))if(n.inspectedEdges+=1,r.has(g)||(r.set(g,u+1),c.push(g)),r.get(g)===u+1){i.set(g,(i.get(g)??0)+i.get(f));let p=s.get(g);p===void 0?s.set(g,[f]):p.push(f)}}return{stack:o,sigma:i,predecessors:s,reachableCount:a,distanceSum:d}}function Nn(e,t,n){let r=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let s=e.stack[i],o=(1+(r.get(s)??0))/e.sigma.get(s);for(let c of e.predecessors.get(s)??[])r.set(c,(r.get(c)??0)+e.sigma.get(c)*o);s!==t&&n.set(s,(n.get(s)??0)+(r.get(s)??0))}}function An(e,t){return t<=1||e.reachableCount===0?0:e.reachableCount/(t-1)*(e.reachableCount/e.distanceSum)}function Tn(e,t,n,r,i){return{id:e,degree:t.get(e).length,inDegree:n.incoming.get(e)?.size??0,outDegree:n.outgoing.get(e)?.size??0,betweenness:ot((r.get(e)??0)/2),closeness:ot(i.get(e))}}function dt(e,t={}){let n=at(e,t.kinds),r=Sn(e,t.kinds),i=e.nodes(),s=new Map,o=new Map,c={visitedNodes:0,inspectedEdges:0};for(let l of i){t.signal?.throwIfAborted();let f=Cn(l,n,c);o.set(l,An(f,i.length)),Nn(f,l,s)}let a=0;for(let l of n.values())a+=l.length;let d=i.map(l=>Tn(l,n,r,s,o)).sort((l,f)=>f.betweenness-l.betweenness||f.degree-l.degree||l.id.localeCompare(f.id));return{value:{nodeCount:i.length,edgeCount:a/2,rows:d},meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:!1}}}function Rn(e,t){return e<=t?{source:e,target:t}:{source:t,target:e}}function Dn(e,t,n){let i=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,n.inspectedEdges+=1,i!==e.parent){if(n.discovery.has(i)){n.low.set(e.node,Math.min(n.low.get(e.node),n.discovery.get(i)));return}return e.children+=1,n.discovery.set(i,n.timer),n.low.set(i,n.timer),n.timer+=1,{node:i,parent:e.node,neighborIndex:0,children:0}}}function On(e,t,n){if(e.parent===null){e.children>1&&n.articulation.add(e.node);return}let r=e.parent,i=n.low.get(e.node);n.low.set(r,Math.min(n.low.get(r),i)),r!==t&&i>=n.discovery.get(r)&&n.articulation.add(r),i>n.discovery.get(r)&&n.bridges.push(Rn(r,e.node))}function jn(e,t,n,r){n.discovery.set(e,n.timer),n.low.set(e,n.timer),n.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){r?.throwIfAborted();let s=i.at(-1);if(s.neighborIndex<t.get(s.node).length){let o=Dn(s,t,n);o!==void 0&&i.push(o)}else On(s,e,n),i.pop()}}function X(e,t={}){let n=at(e,t.kinds),r={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())r.discovery.has(i)||jn(i,n,r,t.signal);return{value:{articulationPoints:[...r.articulation].sort(),bridges:r.bridges.sort((i,s)=>i.source.localeCompare(s.source)||i.target.localeCompare(s.target))},meta:{visitedNodes:r.discovery.size,inspectedEdges:r.inspectedEdges,truncated:!1}}}function Mn(e){let t=e.registry(),n=new Map,r=new Set;for(let i of e.edges()){let s=t.require(i.kind);if(!s.ordering)continue;let{predecessor:o,successor:c}=N(i,s);if(r.add(o),r.add(c),o===c)continue;let a=n.get(o);a===void 0?n.set(o,new Set([c])):a.add(c)}return{forward:n,participants:r}}function Pn(e,t,n,r){if(e===void 0)return r;let i=r;for(let s of e)t.has(s)&&(i=Math.min(i,n.get(s)));return i}function Ln(e,t,n){let r=n-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:n,latestFinish:n+1,slack:r,critical:r===0}}function Fn(e,t,n,r,i){let s=new Map;for(let o=e.length-1;o>=0;o-=1){let c=e[o],a=Pn(t.forward.get(c),r,s,i);s.set(c,a-1)}return e.map(o=>Ln(o,n[o],s.get(o))).sort((o,c)=>o.slack-c.slack||o.earliestStart-c.earliestStart||o.id.localeCompare(c.id))}function lt(e,t={}){t.signal?.throwIfAborted();let n=B(e,{registry:e.registry()}),r=Mn(e),i=new Set(n.order),s=n.order.filter(d=>r.participants.has(d)),o=s.reduce((d,l)=>Math.max(d,n.depth[l]+1),0),c=Fn(s,r,n.depth,i,o),a=c.length>0;return{exact:!0,acyclic:n.acyclic,makespan:o,scheduledCount:c.length,criticalPath:a?n.criticalPath:[],criticalPathLength:a?n.criticalPathLength:0,cycles:n.cycles,rows:c,provenance:{algorithm:"critical-path-method",edgeFamily:"ordering",weighting:"unit"}}}function Gn(e,t,n){for(let r=e.length-1;r>=0;r-=1){n?.throwIfAborted();let i=t.get(e[r]);for(let s of i.successors){n?.throwIfAborted();let o=t.get(s);if(o.latest===void 0||o.duration===void 0)continue;let c=o.latest-o.duration;(i.latest===void 0||c<i.latest)&&(i.latest=c,i.anchor=o.anchor)}}}function $n(e,t,n,r){let i=[],s=e;for(;s!==void 0&&i.length<n;)r?.throwIfAborted(),i.push(s),s=t.get(s).predecessor;return i.reverse(),{path:i,path_truncated:s!==void 0}}function qn(e,t,n,r,i){let s=new Map(t.map(c=>[c.id,c])),o=new Map;for(let c of e){i?.throwIfAborted();let a=s.get(c),d=a?.estimated_minutes,l=typeof d=="number"&&Number.isFinite(d)&&d>=0?d:void 0,f={item:a,duration:l,pending:0,successors:new Set,earliest:0};if(a?.deadline!==void 0){let u=Date.parse(a.deadline);Number.isFinite(u)?(f.deadline=(u-n)/6e4,f.latest=f.deadline,f.anchor=c):r(c,"invalid_deadline")}o.set(c,f)}return o}function Un(e,t,n){for(let r of e.edges()){n?.throwIfAborted();let i=e.registry().require(r.kind);if(!i.ordering)continue;let{predecessor:s,successor:o}=N(r,i),c=t.get(s);c.successors.has(o)||(c.successors.add(o),t.get(o).pending+=1)}}function Bn(e,t,n){let r=e.filter(i=>t.get(i).pending===0);for(let i=0;i<r.length;i+=1){n?.throwIfAborted();let s=r[i],o=t.get(s),c=o.earliest===null||o.duration===void 0?null:o.earliest+o.duration;for(let a of o.successors){n?.throwIfAborted();let d=t.get(a);c===null?d.earliest=null:d.earliest!==null&&(c>d.earliest||c===d.earliest&&(d.predecessor===void 0||s<d.predecessor))&&(d.earliest=c,d.predecessor=s),d.pending-=1,d.pending===0&&r.push(a)}}return r}function zn(e,t,n,r,i,s,o,c){let a=t.duration;if(t.latest!==void 0){r.scheduled_count+=1;let d=t.latest-a;r.rows.length<s?r.rows.push({id:e,deadline_id:t.anchor,latest_start:new Date(i+d*6e4).toISOString(),slack_minutes:t.earliest===null?null:d-t.earliest}):r.truncated=!0}if(t.deadline!==void 0&&t.earliest!==null&&t.earliest+a>t.deadline)if(r.overcommitted_count+=1,r.overcommitted.length<s){let d=$n(e,n,Math.min(s,o.remaining),c);o.remaining-=d.path.length,d.path_truncated&&(r.truncated=!0),r.overcommitted.push({deadline_id:e,deadline:t.item.deadline,shortfall_minutes:t.earliest+a-t.deadline,...d})}else r.truncated=!0}function Hn(e,t,n,r,i,s,o,c){let a={remaining:s};for(let d of e){c?.throwIfAborted();let l=t.get(d);if(l.pending>0){o(d,"cycle_or_gated_by_cycle");continue}if(l.duration===void 0){o(d,"unknown_estimate");continue}if(l.latest!==void 0&&!Number.isFinite(new Date(r+(l.latest-l.duration)*6e4).getTime())){o(d,"date_range_exceeded");continue}l.earliest===null&&o(d,"unknown_predecessor_estimate"),zn(d,l,t,n,r,i,a,c)}}function ut(e,t,n={}){n.signal?.throwIfAborted();let r=Date.parse(n.now??new Date().toISOString());if(!Number.isFinite(r))throw new TypeError("Invalid scheduling clock");let i=n.maxWork??1e5,s=n.limit??10;for(let[u,g]of[["maxWork",i],["limit",s]])if(!Number.isSafeInteger(g)||g<1)throw new TypeError(`Invalid scheduling ${u}`);let o={as_of:new Date(r).toISOString(),basis:"derived_elapsed_minutes",complete:!0,truncated:!1,work_limit_exceeded:!1,scheduled_count:0,residual_count:0,overcommitted_count:0,rows:[],residuals:[],overcommitted:[]},c=e.nodes(),a=e.edges();if(c.length+a.length+t.length>i)return{...o,complete:!1,work_limit_exceeded:!0};let d=(u,g)=>{o.complete=!1,o.residual_count+=1,o.residuals.length<s?o.residuals.push({id:u,reason:g}):o.truncated=!0},l=qn(c,t,r,d,n.signal);Un(e,l,n.signal);let f=Bn(c,l,n.signal);return Gn(f,l,n.signal),Hn(c,l,o,r,s,i,d,n.signal),o}function T(){return{nodes:0,isolated:0,degree_leq_one:0,semantic_nodes:0,without_semantic_edges:0,degree_histogram:{}}}function pt(e,t,n,r){let i={all:T(),active:T(),terminal:T()},s=new Map;for(let o of e.details){if(r?.throwIfAborted(),e.missingIdSet.has(o.id.toLowerCase())||o.status==="external")continue;let c=s.get(o.status)??T();s.set(o.status,c);let a=e.graph.incidentEdges(o.id),d=a.some(l=>n(l.kind));for(let l of[i.all,i[t(o.status)?"terminal":"active"],c]){l.nodes+=1,l.isolated+=+(a.length===0),a.length<=1&&(l.degree_leq_one+=1),d?l.semantic_nodes+=1:l.without_semantic_edges+=1;let f=String(a.length);l.degree_histogram[f]=(l.degree_histogram[f]??0)+1}}return{coverage_by_lifecycle:i,coverage_by_status:Object.fromEntries([...s].sort(([o],[c])=>o.localeCompare(c)))}}function ft(e){if(!J(e))return!1;let t=e;if(!["nodes","isolated","degree_leq_one","semantic_nodes","without_semantic_edges"].every(i=>Number.isSafeInteger(t[i])&&Number(t[i])>=0)||!J(t.degree_histogram))return!1;let r=Object.entries(t.degree_histogram);return r.every(([i,s])=>/^(0|[1-9]\d*)$/.test(i)&&Number.isSafeInteger(s)&&Number(s)>=0)&&r.reduce((i,[,s])=>i+Number(s),0)===t.nodes&&Number(t.isolated)<=Number(t.degree_leq_one)&&Number(t.degree_leq_one)<=Number(t.nodes)&&Number(t.semantic_nodes)+Number(t.without_semantic_edges)===t.nodes}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ht(e){for(let r of["ordering_acyclic","active_ordering_acyclic"])if(e[r]!==void 0&&typeof e[r]!="boolean")return!1;let t=e.coverage_by_lifecycle,n=e.coverage_by_status;return t===void 0&&n===void 0?!0:!J(t)||!J(n)?!1:["all","active","terminal"].every(r=>ft(t[r]))&&Object.values(n).every(ft)}function gt(e,t){return Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].sort().map(n=>{let r=Object.hasOwn(e,n)?e[n]:T(),i=Object.hasOwn(t,n)?t[n]:T(),s=Object.fromEntries([...new Set([...Object.keys(r.degree_histogram),...Object.keys(i.degree_histogram)])].sort().map(o=>[o,(i.degree_histogram[o]??0)-(r.degree_histogram[o]??0)]));return[n,{nodes:i.nodes-r.nodes,isolated:i.isolated-r.isolated,degree_leq_one:i.degree_leq_one-r.degree_leq_one,semantic_nodes:i.semantic_nodes-r.semantic_nodes,without_semantic_edges:i.without_semantic_edges-r.without_semantic_edges,degree_histogram:s}]}))}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:gt(e.coverage_by_lifecycle,t.coverage_by_lifecycle),coverage_by_status:gt(e.coverage_by_status,t.coverage_by_status)}}var R=["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"];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 D(e,t,n,r,i,s,o,c){let a=[...i].sort((d,l)=>d.localeCompare(l));return{code:e,severity:t,policy:n,message:r(a.length),count:a.length,sample:a.slice(0,s),sample_truncated:a.length>s,remediation:o,...c===void 0?{}:{evidence:[...c].sort((d,l)=>d.localeCompare(l)).slice(0,s)}}}function Xn(e,t){return e.cycles.map(n=>D(n.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",n.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",r=>`${r} items participate in one hierarchy cycle.`,n.item_ids,t,n.legacy_terminal?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove or retype one exact hierarchy relation before continuing mutation."))}function bt(e,t,n){let r=e.cardinality_violations.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[D(n?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",n?"info":"error","Every structural child must resolve to at most one logical parent across all hierarchy spellings.",i=>`${i} child item${i===1?"":"s"} resolve to multiple hierarchy parents.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",r.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function wt(e,t,n){let r=e.divergences.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[D(n?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",n?"info":"error","Scalar parent metadata and dependency-backed hierarchy rows must resolve to the same logical parent.",i=>`${i} child item${i===1?"":"s"} have divergent hierarchy storage surfaces.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",r.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function Jn(e,t){let n=G(e);return n?[...Xn(n,t),...bt(n,t,!1),...bt(n,t,!0),...wt(n,t,!1),...wt(n,t,!0)]:[]}function Qn(e){let t=e.graph.registry(),n=new Map;for(let r of e.graph.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let[s,o]=(i.precedence??"source_before_target")==="target_before_source"?[r.target,r.source]:[r.source,r.target],c=n.get(s);c?c.push(o):n.set(s,[o])}for(let r of n.values())r.sort((i,s)=>i.localeCompare(s));return n}function xt(e,t){t.indexes.set(e,t.nextIndex),t.lowLinks.set(e,t.nextIndex),t.nextIndex+=1,t.stack.push(e),t.onStack.add(e)}function Zn(e,t,n,r){let i=n.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let s=i[e.neighborIndex];return e.neighborIndex+=1,r.indexes.has(s)?r.onStack.has(s)&&r.lowLinks.set(e.node,Math.min(r.lowLinks.get(e.node),r.indexes.get(s))):(xt(s,r),t.push({node:s,neighborIndex:0})),!0}function er(e,t,n,r){t.pop();let i=t.at(-1);if(i&&r.lowLinks.set(i.node,Math.min(r.lowLinks.get(i.node),r.lowLinks.get(e.node))),r.lowLinks.get(e.node)!==r.indexes.get(e.node))return;let s=[];for(;;){let o=r.stack.pop();if(r.onStack.delete(o),s.push(o),o===e.node)break}(s.length>1||s.length===1&&n.get(s[0])?.includes(s[0]))&&r.components.push(s.sort((o,c)=>o.localeCompare(c)))}function tr(e){let t={indexes:new Map,lowLinks:new Map,onStack:new Set,stack:[],components:[],nextIndex:0},n=[...e.keys()].sort((r,i)=>r.localeCompare(i));for(let r of n){if(t.indexes.has(r))continue;let i=[{node:r,neighborIndex:0}];for(xt(r,t);i.length>0;){let s=i.at(-1);Zn(s,i,e,t)||er(s,i,e,t)}}return t.components.sort((r,i)=>r[0].localeCompare(i[0]))}function ae(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function y(e,t,n,r,i,s,o,c){t.length!==0&&e.push(D(r,i,s,o,t,n,c))}function nr(e,t,n){let r=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(s=>!s.no_active_blocker_sentinel);return y(r,i.filter(s=>!t(s.holder_status)).map(ae),n,"missing_reference_active","error","Active items must not reference absent targets; missing prerequisites distort scheduling.",s=>`${s} active dangling reference(s) to absent items`,"Restore or re-create the referenced item, or remove/retype the reference on the holder."),y(r,i.filter(s=>t(s.holder_status)).map(ae),n,"missing_reference_terminal","info","Terminal items may retain historical references, but absent targets remain unexplainable context.",s=>`${s} terminal dangling reference(s) to absent items`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),y(r,e.dangling.no_active_blocker_sentinels.map(ae),n,"legacy_no_blocker_sentinel","info","The pre-structured-dependency no-active-blocker sentinel is retired; real edges carry blocker state.",s=>`${s} legacy no-active-blocker sentinel reference(s)`,"Delete the sentinel reference; blocker state is derived from blocked_by edges."),r}function le(e,t){let n=t.get(e);return n?!n.terminal:!0}function kt(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function rr(e,t){let n=[],r=[];for(let s of e.orderingContradictions??[])(s.legacy_terminal?r:n).push(kt(s));let i=[];return y(i,n,t,"ordering_storage_contradiction","error","A scalar blocker and same-target structured ordering row must not assert opposite precedence.",s=>`${s} active scalar-versus-structured ordering contradiction(s)`,"Remove the structured dependency row that points the holder before its scalar blocker, or replace both representations with one unambiguous ordering edge."),y(i,r,t,"legacy_ordering_storage_contradiction","info","Terminal scalar-versus-structured ordering contradictions are exact historical storage defects with no live scheduling effect.",s=>`${s} terminal scalar-versus-structured ordering contradiction(s)`,"Remove the contradictory blocks dependency row in a dedicated changelog-safe closed-item batch; preserve the scalar blocker as the historical precedence record."),i}function ir(e,t,n,r){let i=[],s=Qn(e);for(let a of tr(s)){let d=a.some(u=>le(u,t)),l=new Set(a.map(u=>u.toLowerCase())),f=(e.orderingContradictions??[]).filter(u=>l.has(u.holder_id.toLowerCase())&&l.has(u.target_id.toLowerCase())).map(kt);i.push(d?D("ordering_cycle","error","Order-bearing relationship kinds must stay acyclic; a cycle makes every member unschedulable.",u=>`execution-order cycle across ${u} item(s)`,a,r,"Remove or retype one ordering edge inside the cycle, or split the work so precedence is linear.",f.length===0?void 0:f):D("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)`,a,r,"Leave as history debt, or clean up in a dedicated changelog-safe closed-item batch; never repair closed items ad hoc.",f.length===0?void 0:f))}let o=new Map;for(let[a,d]of s)for(let l of d){let f=o.get(l);f?f.push(a):o.set(l,[a])}let c=[...t.values()].filter(a=>!a.missing&&!a.terminal&&n(a.status)&&!(o.get(a.id)??[]).some(d=>{let l=t.get(d);return l===void 0||!l.terminal})).map(a=>a.id);return y(i,c,r,"stale_lifecycle_block","warning","A blocked lifecycle status must be backed by at least one open ordering predecessor.",a=>`${a} status-blocked item(s) with no open blocker edge`,'Add a local blocker edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status.'),i}function Z(e){let t=e.edges.map(n=>n.kind).sort((n,r)=>n.localeCompare(r));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function ue(e){let t=e.graph.registry(),n=new Map;for(let i of e.graph.edges()){let s=t.require(i.kind);if(!W(s))continue;let o=ce(i,s);if(o.from===o.to)continue;let c=`${Y(s)}::${o.from}::${o.to}`,a=n.get(c);a?a.edges.push(i):n.set(c,{...o,edges:[i]})}let r=[...n.values()].filter(i=>i.edges.length>=2);for(let i of r)i.edges.sort((s,o)=>s.kind.localeCompare(o.kind));return r.sort((i,s)=>i.from.localeCompare(s.from)||i.to.localeCompare(s.to))}function sr(e,t,n){let r=[],i=[];for(let o of ue(e))(le(o.from,t)||le(o.to,t)?r:i).push(Z(o));let s=[];return y(s,r,n,"duplicate_edge","info","One semantic relationship should be stored once; parallel same-family spellings (reciprocal inverse pairs included) add no information and skew degree metrics.",o=>`${o} duplicated relationship(s) between active endpoints`,"Remove all but one stored spelling of the relationship; keep the canonical direction the holder declared first."),y(s,i,n,"legacy_duplicate_edge","info","Duplicated spellings between exclusively terminal items are historical noise with no scheduling effect.",o=>`${o} duplicated relationship(s) between terminal endpoints`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),s}function or(e,t){let n=[],r=[];for(let s of e.duplicateRows??[])(s.legacy_terminal?r:n).push(`${s.holder_id} -> ${s.target_id} (${s.kind} x${s.occurrences})`);let i=[];return y(i,n,t,"duplicate_dependency_row","warning","One dependency row must be stored once per holder; identical repeated rows are a storage-layer defect invisible to the assembled graph.",s=>`${s} exactly duplicated stored dependency row(s) on active holder(s)`,"Remove the repeated rows so the dependency is stored exactly once; graph semantics are unchanged."),y(i,r,t,"legacy_duplicate_dependency_row","info","Identical repeated dependency rows on terminal holders are historical storage noise with no scheduling effect.",s=>`${s} 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 cr(e,t){let n=new Map,r={source_to_target:[],target_to_source:[],both:[]};for(let o of e.graph.registry().list())o.outcomeTraversal!==void 0&&r[o.outcomeTraversal].push(o.kind);let i={source_to_target:r.source_to_target.join(","),target_to_source:r.target_to_source.join(","),both:r.both.join(",")},s=(o,c)=>{let a=n.get(c)??new Set;a.add(o),n.set(c,a)};for(let o of e.graph.edges()){t?.throwIfAborted();let c=e.graph.registry().require(o.kind);(c.outcomeTraversal==="source_to_target"||c.outcomeTraversal==="both")&&s(o.source,o.target),(c.outcomeTraversal==="target_to_source"||c.outcomeTraversal==="both")&&s(o.target,o.source)}return{basis:i,reverse:n}}function ar(e,t,n){let r=new Set(e),i=[...e].sort();for(let s=0;s<i.length;s+=1){n?.throwIfAborted();for(let o of[...t.get(i[s])??[]].sort())r.has(o)||(r.add(o),i.push(o))}return r}function dr(e,t,n,r){let i=0,s=0,o=0,c=0;for(let g of e.values())if(r?.throwIfAborted(),!t.has(g.id)&&!(g.missing||g.status==="external")){if(g.terminal){o+=1,n.has(g.id)&&(c+=1);continue}n.has(g.id)?i+=1:s+=1}let a=i+s,d=o-c,l=i+c,f=s+d,u=l+f;return{active_outcome_reachable_nodes:i,active_outcome_unreachable_nodes:s,active_outcome_reachability_basis_points:a===0?0:Math.floor(i*1e4/a),terminal_nodes:o,terminal_outcome_reachable_nodes:c,terminal_outcome_unreachable_nodes:d,terminal_outcome_reachability_basis_points:o===0?0:Math.floor(c*1e4/o),outcome_reachable_nodes:l,outcome_unreachable_nodes:f,outcome_reachability_basis_points:u===0?0:Math.floor(l*1e4/u)}}function lr(e,t,n){let r=new Set(e.details.filter(c=>c.type?.toLowerCase()===Vn&&c.title.trim().toLowerCase().startsWith(Wn)).map(c=>c.id)),{basis:i,reverse:s}=cr(e,n),o=ar(r,s,n);return{outcome_nodes:r.size,outcome_reachability_basis:i,...dr(t,r,o,n)}}function ur(e,t,n,r,i){e.active+=1;let s=t.type??"(untyped)",o=e.byType.get(s);o||(o={active:0,isolated:0,degree_leq_one:0},e.byType.set(s,o)),o.active+=1,!(n>1)&&(e.degreeLeqOne+=1,o.degree_leq_one+=1,n===0&&(e.isolated+=1,o.isolated+=1),!(r.has(t.id.toLowerCase())||i.has(s.toLowerCase()))&&(n===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function fr(e,t,n,r,i,s,o){let c={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let h of e.graph.nodes()){o?.throwIfAborted();let _=t.get(h);if(_){if(_.missing){c.missing+=1;continue}_.terminal||ur(c,_,e.graph.incidentEdges(h).length,n,r)}}let{isolates:a,sparse:d}=c,l=[];y(l,a,i,"isolated_active_node","warning","Active work should be reachable from the graph unless explicitly declared a valid isolate.",h=>`${h} active item(s) with no relationships`,"Link the item to its parent, prerequisite, or origin \u2014 or register it as an exempt isolate."),y(l,d,i,"sparse_active_node","info","Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.",h=>`${h} active item(s) with exactly one relationship`,"Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");let f=e.graph.edges().length,u=A(e.graph,{signal:o}).value,g=new Set(u.map(({edge:h})=>`${h.source.toLowerCase()}\0${h.target.toLowerCase()}\0${h.kind}`));for(let h of e.orderingContradictions??[])g.add(`${h.holder_id.toLowerCase()}\0${h.target_id.toLowerCase()}\0${h.dependency_kind}`);let p=Object.fromEntries(Object.entries(s).sort(([h],[_])=>h.localeCompare(_))),m=Object.entries(p).reduce((h,[_,I])=>h+(Q(_)?I:0),0),b=X(e.graph,{signal:o}).value,w=lr(e,t,o);return{findings:l,profile:{nodes:e.graph.nodes().length,recorded_nodes:e.details.filter(h=>h.status!=="missing"&&h.status!=="external").length,edges:f,informative_edges:f-g.size,redundant_edges:u.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:p,edge_share_by_kind:Object.fromEntries(Object.entries(p).map(([h,_])=>[h,_/f])),semantic_edges:m,semantic_edge_share:f===0?0:m/f,active_nodes:c.active,missing_nodes:c.missing,isolated_active_nodes:c.isolated,degree_leq_one_active_nodes:c.degreeLeqOne,coverage_by_type:Object.fromEntries([...c.byType.entries()].sort(([h],[_])=>h<_?-1:1)),articulation_points:b.articulationPoints.length,bridge_edges:b.bridges.length,...w,finding_subjects_by_code:Object.fromEntries(R.map(h=>[h,0]))}}}function ee(e,t={}){let n=t.isTerminal??(u=>u==="closed"||u==="canceled"),r=t.isBlocked??(u=>u==="blocked"),i=t.maxSampleSize??Kn;if(!Number.isInteger(i)||i<1)throw new TypeError(`Invalid audit sample bound: ${String(t.maxSampleSize)}`);let s=yt(t.exemptIsolates),o=yt(t.isolateExemptTypes),c=new Map(e.details.map(u=>[u.id,{id:u.id,status:u.status,missing:e.missingIdSet.has(u.id.toLowerCase()),terminal:n(u.status),...u.type===void 0?{}:{type:u.type}}]));t.signal?.throwIfAborted();let a={};for(let u of e.graph.edges())a[u.kind]=(a[u.kind]??0)+1;let d=nr(e,n,i);d.push(...Jn(e,i)),t.signal?.throwIfAborted(),d.push(...rr(e,i)),t.signal?.throwIfAborted(),d.push(...ir(e,c,r,i)),t.signal?.throwIfAborted(),d.push(...sr(e,c,i),...or(e,i)),t.signal?.throwIfAborted();let l=fr(e,c,s,o,i,a,t.signal);d.push(...l.findings),d.sort((u,g)=>_t[u.severity]-_t[g.severity]||u.code.localeCompare(g.code)||u.sample[0].localeCompare(g.sample[0]));let f=l.profile.finding_subjects_by_code;for(let u of d)f[u.code]+=u.count;return{findings:d,profile:{...l.profile,...pt(e,n,Q,t.signal),ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"||u.code==="legacy_ordering_cycle"),active_ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"),finding_subjects_by_code:f}}}function de(e,t){let n=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),r={};for(let i of n){let s=(t[i]??0)-(e[i]??0);s!==0&&(r[i]=s)}return r}function vt(e){return e.profile.coverage_by_type??{}}function gr(e,t){let n={},r=vt(e),i=vt(t),s=[...new Set([...Object.keys(r),...Object.keys(i)])].sort();for(let o of s){let c=Object.assign({active:0,isolated:0,degree_leq_one:0},r[o]),a=Object.assign({active:0,isolated:0,degree_leq_one:0},i[o]),d={active:a.active-c.active,isolated:a.isolated-c.isolated,degree_leq_one:a.degree_leq_one-c.degree_leq_one};Object.values(d).some(l=>l!==0)&&(n[o]=d)}return n}function Et(e,t){let n=gr(e,t),{edge_share_by_kind:r={},semantic_edges:i=0,semantic_edge_share:s=0}=e.profile,{edge_share_by_kind:o={},semantic_edges:c=0,semantic_edge_share:a=0}=t.profile,d=e.profile.recorded_nodes??e.profile.nodes,l=t.profile.recorded_nodes??t.profile.nodes,f=e.profile.informative_edges??e.profile.edges,u=t.profile.informative_edges??t.profile.edges,g=e.profile.redundant_edges??0,p=t.profile.redundant_edges??0,m=e.profile.ordering_contradiction_edges??0,b=t.profile.ordering_contradiction_edges??0;return{baseline_saved_at:e.saved_at,same_snapshot:e.fingerprint===t.fingerprint,affected_subjects_by_code:de(e.affected_subjects_by_code,t.affected_subjects_by_code),profile:{nodes:t.profile.nodes-e.profile.nodes,recorded_nodes:l-d,edges:t.profile.edges-e.profile.edges,informative_edges:u-f,redundant_edges:p-g,ordering_contradiction_edges:b-m,active_nodes:t.profile.active_nodes-e.profile.active_nodes,missing_nodes:t.profile.missing_nodes-e.profile.missing_nodes,isolated_active_nodes:t.profile.isolated_active_nodes-e.profile.isolated_active_nodes,degree_leq_one_active_nodes:t.profile.degree_leq_one_active_nodes-e.profile.degree_leq_one_active_nodes,edges_by_kind:de(e.profile.edges_by_kind,t.profile.edges_by_kind),edge_share_by_kind:de(r,o),semantic_edges:c-i,semantic_edge_share:a-s,coverage_by_type:n,...mt(e.profile,t.profile)}}}import It from"node:path";var St=2,fe=500,pr=64,hr="graph-durable-cache";function Ct(e){return Ae(e,hr,30,`graph-cache:${process.pid}`,!1,!1,3e3)}function F(e){return It.join(e,"runtime","graph-cache.json")}function Nt(e){return It.join(e,"runtime","graph-audit-baseline.json")}function ge(e){if(e!==null)try{let t=JSON.parse(e);return typeof t!="object"||t===null||t.version!==St||typeof t.fingerprint!="string"||typeof t.saved_at!="string"||typeof t.results!="object"||t.results===null||Array.isArray(t.results)?void 0:t}catch{return}}async function pe(e,t){let n=await j(F(e)),r=ge(n),i=r?.fingerprint===t;return{exists:n!==null,fresh:i,results:i?r.results:{}}}async function he(e,t,n,r,i){let s=await Ct(e);try{let o=ge(await j(F(e))),c=o?.fingerprint===t?o.results:{};delete c[r],c[r]=i;let a=Object.keys(c);for(let d of a.slice(0,Math.max(0,a.length-pr)))delete c[d];await re(F(e),JSON.stringify({version:St,fingerprint:t,saved_at:new Date().toISOString(),results:c})),n.results=c}finally{await s()}}async function me(e){let t=await Ct(e);try{await ke(F(e))}finally{await t()}}async function At(e,t){let n=F(e),r=await j(n),i=ge(r);return i===void 0?{exists:r!==null,fresh:!1,entry_count:0}:{exists:!0,fresh:i.fingerprint===t,entry_count:Object.keys(i.results).length,fingerprint:i.fingerprint.slice(0,12),saved_at:i.saved_at,bytes:Buffer.byteLength(r,"utf8")}}function _e(e,t){return t||e>=fe}function te(e){return O(e)&&Object.values(e).every(E)}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function E(e){return Number.isInteger(e)&&Number(e)>=0}function Tt(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(Tt)}function _r(e){return O(e)?Object.values(e).every(t=>O(t)&&[t.active,t.isolated,t.degree_leq_one].every(E)):!1}function yr(e,t,n){let r=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=r.filter(o=>e[o]!==void 0).length;if(i!==0&&i!==r.length||!r.every(o=>L(e[o],E)))return;let s={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??n,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return s.recorded_nodes<=t&&s.informative_edges<=n&&s.redundant_edges<=n&&s.ordering_contradiction_edges<=n?s:void 0}function br(e,t,n){let r=[...t,...n,"finding_subjects_by_code"],i=r.filter(s=>e[s]!==void 0).length;return i!==0&&i!==r.length?!1:t.every(s=>L(e[s],E))&&n.every(s=>L(e[s],E)&&(e[s]===void 0||Number(e[s])<=1e4))&&L(e.finding_subjects_by_code,te)}function wr(e,t,n,r){let i=yr(e,n,r);if(i===void 0)return;let s=["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"],o=["active_outcome_reachability_basis_points","terminal_outcome_reachability_basis_points","outcome_reachability_basis_points"];if(!br(e,s,o)||e.edge_basis!==void 0&&e.edge_basis!=="deduplicated_directed")return;let c=te(e.finding_subjects_by_code)?e.finding_subjects_by_code:{};return{edge_basis:"deduplicated_directed",...i,...Object.fromEntries(s.map(a=>[a,e[a]??0])),...Object.fromEntries(o.map(a=>[a,e[a]??0])),finding_subjects_by_code:Object.fromEntries(R.map(a=>[a,c[a]??t[a]??0]))}}function vr(e,t,n,r,i){let s=[n,r,i],o=s.filter(d=>d!==void 0).length;if(o===0)return{edge_share_by_kind:{},semantic_edges:0,semantic_edge_share:0};if(o!==s.length||!mr(n)||!E(r)||!Tt(i))return;let c=Object.entries(t);if(c.reduce((d,[,l])=>d+l,0)!==e||Object.keys(n).length!==c.length||c.some(([d,l])=>n[d]!==(e===0?0:l/e)))return;let a=c.reduce((d,[l,f])=>d+(Q(l)?f:0),0);if(!(r!==a||i!==(e===0?0:a/e)))return{edge_share_by_kind:n,semantic_edges:r,semantic_edge_share:i}}function xr(e){if(e!==null)try{let t=JSON.parse(e);if(!O(t))return;let n=t,r=n.profile;if(typeof n.saved_at!="string"||typeof n.fingerprint!="string")return;let i=n.affected_subjects_by_code;if(!te(i)||!O(r)||!ht(r)||![r.nodes,r.edges,r.active_nodes,r.missing_nodes,r.isolated_active_nodes,r.degree_leq_one_active_nodes].every(E)||!te(r.edges_by_kind)||!L(r.coverage_by_type,_r))return;let s=vr(r.edges,r.edges_by_kind,r.edge_share_by_kind,r.semantic_edges,r.semantic_edge_share);if(s===void 0)return;let o=wr(r,i,r.nodes,r.edges);if(o===void 0)return;let{coverage_by_type:c={}}=r;return{...n,profile:{...r,...s,...o,coverage_by_type:c}}}catch{return}}async function Rt(e){return xr(await j(Nt(e)))}async function Dt(e,t){await re(Nt(e),JSON.stringify(t))}var kr={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 Er(e){let[t,...n]=e.edges;return n.map(r=>({op:"remove",code:"duplicate_edge",subject:Ot(r),rationale:"This stored spelling restates the kept canonical edge of the same semantic family; removing it leaves the relationship stated exactly once.",evidence:[`keep: ${Ot(t)}`,`group: ${Z(e)}`],confidence:"high"}))}function Ir(e,t){if(e.code==="duplicate_edge")return e.sample.flatMap(r=>Er(t.get(r)));let n=kr[e.code];return e.sample.map(r=>({op:n.op,code:e.code,subject:r,rationale:n.rationale,evidence:[e.policy],confidence:n.confidence}))}function jt(e,t={}){let{redundancyLimit:n,...r}=t,i=ee(e,r),s=new Map(ue(e).map(d=>[Z(d),d])),o=i.findings.flatMap(d=>Ir(d,s)),c=i.findings.some(d=>d.sample_truncated);t.signal?.throwIfAborted();let a=A(e.graph,{limit:n??t.maxSampleSize??25,...t.signal===void 0?{}:{signal:t.signal}});for(let d of a.value)o.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 c=c||a.meta.truncated,{steps:o,report:i,truncated:c,cost:{visitedNodes:a.meta.visitedNodes,inspectedEdges:a.meta.inspectedEdges}}}var Ft=new Set(["ancestors","descendants","predecessors","successors","paths","impact","dominators"]);function Mt(e,t,n){let r=e;if(t&&e.subcommand==="audit"){let{nodes:i,recorded_nodes:s,edges:o,active_nodes:c,terminal_nodes:a,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:f,coverage_by_lifecycle:u}=e.profile,g=Object.fromEntries(Object.entries(u).map(([p,m])=>{let{degree_histogram:b,...w}=m;return[p,w]}));r={...e,profile:{nodes:i,recorded_nodes:s,edges:o,active_nodes:c,terminal_nodes:a,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:f,coverage_by_lifecycle:g}}}return{...r,projection:{mode:t?"summary":"full",declared_field_groups:n===void 0?[]:[{name:n,restore_with:"--full"}],included_field_groups:n===void 0||t?[]:[n]}}}function Sr(e,t,n,r){return{assembly:t,...n===void 0?{}:{kinds:n},maxDepth:Ue(r.maxDepth),limit:e==="impact"&&Number(r.limit)===0?0:$(r.limit,"limit")??(r.full===!0?Number.MAX_SAFE_INTEGER:k.rows),after:r.after?.trim()||void 0,direction:Be(r.direction),maxPaths:$(r.maxPaths,"max-paths"),sample:$(r.sample,"sample")??k.samples,exemptIsolates:Pt(r.exemptIsolate),exemptIsolateTypes:Pt(r.exemptIsolateType),saveBaseline:r.saveBaseline===!0,summary:r.summary===!0,unbounded:r.full===!0}}function Pt(e){return e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",")).map(t=>t.trim()).filter(t=>t.length>0)}function Cr(e,t,n){let r=e.trim().toLowerCase();if(!ie.includes(r))throw je({command_path:"graph",token:r||"<empty>",allowed:ie});let i=r;if(Ft.has(i)&&!t?.trim())throw new x(`graph ${i} requires an item id.`,v.USAGE);if(i==="paths"&&!n?.trim())throw new x("graph paths requires a source and a target item id.",v.USAGE);return i}function ye(e){throw e instanceof TypeError?new x(e.message,v.USAGE):e}function be(e){return{truncated:e.truncated,cost:{visited_nodes:e.visitedNodes,inspected_edges:e.inspectedEdges}}}function Lt(e,t){let n=t.trim().toLowerCase();for(let r of e.details)if(r.id.trim().toLowerCase()===n&&!e.missingIdSet.has(r.id.toLowerCase()))return r.id;throw new x(`Item ${t} not found`,v.NOT_FOUND)}function Nr(e,t,n){let r={ancestors:Qe,descendants:Ze,predecessors:et,successors:tt}[e],i;try{i=r(n.assembly.graph,t,{...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},limit:n.limit,...n.after===void 0?{}:{after:n.after}})}catch(o){ye(o)}let s=be(i.meta);return{subcommand:e,root:t,count:i.value.length,...s,...i.meta.nextCursor===void 0?{}:{next_cursor:i.meta.nextCursor},...n.summary?{}:{ids:i.value}}}function Ar(e,t,n){let r=nt(n.assembly.graph,e,t,{direction:n.direction,...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},...n.maxPaths===void 0?{}:{maxPaths:n.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:n.direction,count:r.value.length,...be(r.meta),...n.summary?{}:{paths:r.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(s=>s.kind),length:i.length}))}}}function Tr(e,t){let n;try{n=U(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth},...t.unbounded?{}:{limit:t.limit},...t.after===void 0?{}:{after:t.after}})}catch(r){ye(r)}return{subcommand:"impact",root:e,direction:t.direction,count:n.affected.length,truncated:n.truncated,...n.nextCursor===void 0?{}:{next_cursor:n.nextCursor},cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...t.summary?{}:{affected:n.affected}}}function Rr(e,t,n){return{acyclic:e.acyclic,ordered_node_count:e.order.length,layer_count:e.layers.length,frontier_count:e.frontier.length,critical_path_length:e.criticalPathLength,cycle_count:e.cycles.length,...t?{}:{frontier:e.frontier.slice(0,n),critical_path:e.criticalPath.slice(0,n),cycles:e.cycles.slice(0,n)}}}function Dr(e,t,n){return{component_count:e.components.length,largest_component_size:e.components[0]?.length??0,orphan_count:e.orphans.length,...t?{}:{orphans:e.orphans.slice(0,n),hubs:e.hubs.slice(0,n)}}}function Or(e,t,n){let r=0,i=0,s=0;for(let o of e.cycles)r+=Number(o.legacy_terminal);for(let o of e.cardinality_violations)i+=Number(o.legacy_terminal);for(let o of e.divergences)s+=Number(o.legacy_terminal);return{acyclic:e.cycles.length===0,relation_count:e.relations.length,cycle_count:e.cycles.length,active_cycle_count:e.cycles.length-r,legacy_cycle_count:r,cardinality_violation_count:e.cardinality_violations.length,active_cardinality_violation_count:e.cardinality_violations.length-i,legacy_cardinality_violation_count:i,parent_divergence_count:e.divergences.length,active_parent_divergence_count:e.divergences.length-s,legacy_parent_divergence_count:s,...t?{}:{cycles:e.cycles.slice(0,n).map(o=>o.item_ids)}}}function jr(e){let t=e.assembly.graph,n=e.limit,r=B(t,{registry:t.registry()}),i=Ye(t);return{subcommand:"analyze",node_count:t.nodes().length,edge_count:t.edges().length,edge_basis:"deduplicated_directed",sample_limit:n,execution:Rr(r,e.summary,n),knowledge:Dr(i,e.summary,n),hierarchy:Or(G(e.assembly),e.summary,n)}}function Mr(e,t){let n=ee(e.assembly,{isTerminal:t,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),r={},i={},s={},o={};for(let d of n.findings)r[d.severity]=(r[d.severity]??0)+1,i[d.code]=(i[d.code]??0)+1,s[d.severity]=(s[d.severity]??0)+d.count,o[d.code]=(o[d.code]??0)+d.count;let{finding_subjects_by_code:c,...a}=n.profile;return{subcommand:"audit",truncated:n.findings.length>e.limit,finding_count:n.findings.length,findings_by_severity:r,findings_by_code:i,affected_subjects_by_severity:s,affected_subjects_by_code:o,profile:e.summary?a:n.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:n.findings.slice(0,e.limit)}}}function Pr(e){let t=e.limit,n={};e.kinds!==void 0&&(n.kinds=e.kinds);let r=it(e.assembly.graph,n),i=r.value;return{subcommand:"communities",community_count:i.communities.length,largest_community_size:i.communities[0]?.size??0,iterations:i.iterations,converged:i.converged,truncated:!i.converged||i.communities.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{communities:i.communities.slice(0,t).map(s=>({representative:s.representative,size:s.size,members:s.members.slice(0,t)}))}}}function Lr(e){let t;try{t=A(e.assembly.graph,{...e.kinds===void 0?{}:{kinds:e.kinds},...e.maxDepth===void 0?{}:{maxDepth:e.maxDepth},limit:e.limit})}catch(n){ye(n)}return{subcommand:"redundancy",redundant_count:t.value.length,...be(t.meta),...e.summary?{}:{redundant:t.value.map(n=>({source:n.edge.source,target:n.edge.target,kind:n.edge.kind,witness:n.witness}))}}}function Fr(e,t){let n=t.limit,r=st(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=r.value.rows.filter(s=>s.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:r.value.reachableCount,bottleneck_count:i.length,truncated:r.meta.truncated||i.length>n,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,n).map(s=>({id:s.id,idom:s.idom,dominated_count:s.dominatedCount}))}}}function Gr(e){let t=e.limit,n=lt(e.assembly.graph),r=n.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:n.acyclic,makespan:n.makespan,scheduled_count:n.scheduledCount,critical_count:r,critical_path_length:n.criticalPathLength,cycle_count:n.cycles.length,truncated:n.rows.length>t,...e.summary?{}:{critical_path:n.criticalPath.slice(0,t),rows:n.rows.slice(0,t).map(i=>({id:i.id,earliest_start:i.earliestStart,latest_start:i.latestStart,slack:i.slack,critical:i.critical}))}}}function $r(e){let t=e.limit,n=dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),r=n.value;return{subcommand:"centrality",node_count:r.nodeCount,edge_count:r.edgeCount,edge_basis:"simple_undirected",truncated:r.rows.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{rows:r.rows.slice(0,t).map(i=>({id:i.id,degree:i.degree,in_degree:i.inDegree,out_degree:i.outDegree,betweenness:i.betweenness,closeness:i.closeness}))}}}function qr(e){let t=e.limit,n=X(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:r,bridges:i}=n.value;return{subcommand:"articulation",articulation_count:r.length,bridge_count:i.length,truncated:r.length>t||i.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{articulation_points:r.slice(0,t),bridges:i.slice(0,t)}}}function Ur(e,t){let n=e.limit,r=jt(e.assembly,{isTerminal:t,redundancyLimit:n,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},s={};for(let o of r.steps)i[o.op]=(i[o.op]??0)+1,s[o.code]=(s[o.code]??0)+1;return{subcommand:"plan",step_count:r.steps.length,steps_by_op:i,steps_by_code:s,finding_count:r.report.findings.length,truncated:r.truncated||r.steps.length>n,cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...e.summary?{}:{steps:r.steps.slice(0,n)}}}function Gt(e,t,n,r){return JSON.stringify({projection_version:2,subcommand:e,root:t??null,target:n??null,kinds:r.kinds??null,maxDepth:r.maxDepth??null,limit:r.limit,after:r.after??null,direction:r.direction,maxPaths:r.maxPaths??null,sample:r.sample,exemptIsolates:[...new Set(r.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(r.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:r.summary,unbounded:r.unbounded})}function $t(e,t,n,r,i){return e==="analyze"?jr(r):e==="audit"?Mr(r,i):e==="plan"?Ur(r,i):e==="communities"?Pr(r):e==="redundancy"?Lr(r):e==="dominators"?Fr(t,r):e==="slack"?Gr(r):e==="centrality"?$r(r):e==="articulation"?qr(r):e==="paths"?Ar(t,n,r):e==="impact"?Tr(t,r):Nr(e,t,r)}function Br(e,t){if(e!=="index"&&(t.rebuild===!0||t.clear===!0))throw new x("--rebuild and --clear apply only to graph index.",v.USAGE);if(e!=="audit"&&t.saveBaseline===!0)throw new x("--save-baseline applies only to graph audit.",v.USAGE);if(e==="slack"&&t.kind!==void 0)throw new x("graph slack analyzes every ordering kind; --kind is not supported.",v.USAGE);if(t.rebuild===!0&&t.clear===!0)throw new x("graph index accepts either --rebuild or --clear, not both.",v.USAGE);if(t.full===!0&&t.limit!==void 0)throw new x(`graph ${e} accepts either --full or --limit, not both.`,v.USAGE)}async function zr(e,t,n,r,i,s){let o="status";if(s.clear===!0&&(await me(e),o="cleared"),s.rebuild===!0){await me(e);let a=await pe(e,t),d={assembly:n.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,limit:k.rows,sample:k.samples,unbounded:!1};for(let l of["analyze","audit"])await he(e,t,a,Gt(l,void 0,void 0,d),$t(l,void 0,void 0,d,i));o="rebuilt"}let c=await At(e,t);return{subcommand:"index",action:o,state:c.exists?c.fresh?"fresh":"stale":"absent",entry_count:c.entry_count,item_count:r,min_items_threshold:fe,persist_enabled:_e(r,c.exists),current_fingerprint:t.slice(0,12),...c.saved_at===void 0?{}:{saved_at:c.saved_at},...c.bytes===void 0?{}:{bytes:c.bytes}}}async function Hr(e,t,n,r){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:n.affected_subjects_by_code,profile:{...n.profile,finding_subjects_by_code:Object.fromEntries(R.map(o=>[o,n.affected_subjects_by_code[o]??0]))}},s=await Rt(e);return r&&await Dt(e,i),s===void 0?n:{...n,baseline:Et(s,i)}}async function Kr(e,t,n,r,i){try{await he(e,t,n,r,i)}catch{}}function Vr(e,t,n,r){if(e.subcommand!=="slack")return;let i=new Set(t.assembly.details.filter(u=>r(u.status)).map(u=>u.id)),s=t.assembly.graph,o=new xe(s.nodes().filter(u=>!i.has(u)),s.edges().filter(u=>!i.has(u.source)&&!i.has(u.target)),s.registry()),c=ut(o,n.filter(u=>!i.has(u.id)),{now:Ce(),limit:t.limit}),{rows:a,residuals:d,overcommitted:l,...f}=c;e.deadline_schedule={population:"active",...f,...t.summary?{}:{rows:a,residuals:d,overcommitted:l}}}async function rs(e,t,n,r,i){let s=Cr(e,t,n);Re(r.summary===!0,r.full===!0,"--summary");let o=Ie(process.cwd(),i.path);await Pe(o);let c=await Me(o),a=Ee(c,Te()),d=await Le(o,c.item_format,a.type_to_folder,void 0,c.schema),l=Se(c.schema),f=qt=>Ne(qt,l);Br(s,r);let u=Fe(),g=ze(r.kind,u),p=qe().lookup(o,$e(d,f,u),()=>Ge(d,f,u)),m=Sr(s,p.assembly,g,r);if(s==="index")return Mt(await zr(o,p.fingerprint,m,d.length,f,r),!1);let b=Ft.has(s)?Lt(m.assembly,t):void 0,w=s==="paths"?Lt(m.assembly,n):void 0,h=Gt(s,b,w,m),_=await pe(o,p.fingerprint),I=_.results[h],S=p.memoize(h,()=>I!==void 0?structuredClone(I):$t(s,b,w,m,f)),we=_e(d.length,_.exists);!S.reused&&I===void 0&&we&&await Kr(o,p.fingerprint,_,h,S.value);let ne=S.value.subcommand==="audit"?await Hr(o,p.fingerprint,S.value,m.saveBaseline):S.value;return ne.cache={fingerprint:p.fingerprint.slice(0,12),assembly:p.assemblyReused?"hit":"miss",result:S.reused?"hit":"miss",durable:I!==void 0?"hit":we?"miss":"off"},Vr(ne,m,d,f),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,A as l,st as m,dt as n,X as o,lt as p,ut as q,tr as r,kt as s,Z as t,ue as u,ee as v,Et as w,St as x,fe as y,F as z,Nt as A,pe as B,he as C,me as D,At as E,_e as F,Rt as G,Dt as H,jt as I,Cr as J,rs as K};
2
- //# sourceMappingURL=chunk-ZLRRII55.js.map
1
+ import{d as Fe,o as G,p as Ge,q as $e,s as qe,w as $,x as Ue,y as Be,z as ze}from"./chunk-YNRW2FWB.js";import{L as Le,e as je}from"./chunk-VV2QF5IE.js";import{s as Me,y as Pe}from"./chunk-WHHFPATO.js";import{a as k}from"./chunk-BWOVFE5B.js";import{Cf as De,Df as se,Gb as Ne,Gf as Oe,Q as Ee,W as Ie,dc as Ae,je as Te,q as ve,v as xe,va as ie,ze as Re}from"./chunk-NSFS3VWP.js";import{u as Ce}from"./chunk-R6QFPHWW.js";import{O as Se}from"./chunk-OCKKIECS.js";import{A as x,F as j,I as re,K as ke,z as v}from"./chunk-NGFDPEP7.js";function Ut(e,t,n,r,i,s){if(e.seen.has(t))return"skip";if(e.cursorFound&&e.affected.length>=s)return"truncate";e.seen.add(t),e.parents.set(t,n.id);let o=n.depth+1;return e.queue.push({id:t,depth:o}),e.cursorFound?(e.affected.push({id:t,distance:o,path:Yt(r,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function Ke(e,t,n,r){let i=De("graph impact",{root:e,direction:n,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(r)?r:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:Oe(t.after,i)}}function C(e,t,n){e.get(t).add(n)}function M(e){return new Map(e.map(t=>[t,new Set]))}function Ve(e){for(let t of e)t.sort();return e.sort((t,n)=>n.length-t.length||t[0].localeCompare(n[0]))}function q(e){if(Array.isArray(e))return e.map(n=>q(n));if(e===null||typeof e!="object")return e;let t=e.toJSON;return typeof t=="function"?q(t.call(e)):Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,q(r)]))}function He(e){return JSON.stringify(q(e))}function Bt(e,t,n,r){let i=[{id:e,expanded:!1}];for(;i.length>0;){let s=i.pop();if(s.expanded){r.push(s.id);continue}if(n.has(s.id))continue;n.add(s.id),i.push({id:s.id,expanded:!0});let o=[...t.get(s.id)].sort().reverse();for(let c of o)n.has(c)||i.push({id:c,expanded:!1})}}function zt(e,t){let n=new Set,r=[];for(let i of e)n.has(i)||Bt(i,t,n,r);return r}function Ht(e,t){let n=new Set,r=[];for(let i of[...e].reverse()){if(n.has(i))continue;let s=[],o=[i];for(n.add(i);o.length>0;){let c=o.pop();s.push(c);for(let a of t.get(c))n.has(a)||(n.add(a),o.push(a))}r.push(s)}return Ve(r)}function We(e,t){let n=M(e);for(let[r,i]of t)for(let s of i)C(n,s,r);return Ht(zt(e,t),n)}function Kt(e,t){let n=M(e.nodes());for(let r of e.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let s=(i.precedence??"source_before_target")==="source_before_target";C(n,s?r.source:r.target,s?r.target:r.source)}return n}function Vt(e,t){let n=new Map(e.map(s=>[s,0]));for(let s of t.values())for(let o of s)n.set(o,n.get(o)+1);let r=e.filter(s=>n.get(s)===0).sort(),i=[];for(;r.length>0;){i.push(r);let s=[];for(let o of r)for(let c of t.get(o)){let a=n.get(c)-1;n.set(c,a),a===0&&s.push(c)}r=s.sort()}return i}function Wt(e,t){let n=new Map(e.map(o=>[o,0])),r=new Map;for(let o of e)for(let c of t.get(o)){if(!n.has(c))continue;let a=n.get(o)+1,d=r.get(c);(a>n.get(c)||a===n.get(c)&&(d===void 0||o.localeCompare(d)<0))&&(n.set(c,a),r.set(c,o))}let i=[...e].sort((o,c)=>n.get(c)-n.get(o)||o.localeCompare(c))[0],s=i===void 0?[]:[i];for(;s[0]!==void 0&&r.has(s[0]);)s.unshift(r.get(s[0]));return{depth:Object.fromEntries(n),path:s}}function Yt(e,t,n){let r=[t],i=t;for(;i!==e;)i=n.get(i),r.push(i);return r.reverse()}function B(e,t={}){let n=t.registry??ve(),r=[...e.nodes()],i=Kt(e,n),s=Vt(r,i),o=s.flat(),c=o.length===r.length,a=c?[]:We(r,i).filter(l=>l.length>1||i.get(l[0]).has(l[0])),d=Wt(o,i);return{exact:!0,acyclic:c,order:o,layers:s,frontier:s[0]??[],depth:d.depth,criticalPath:d.path,criticalPathLength:Math.max(0,d.path.length-1),cycles:a,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function Xt(e,t,n){let r=M(e.nodes()),i=n===void 0?void 0:new Set(n.map(o=>e.registry().require(o).kind)),s=e.edges();for(let o of s){let c=e.registry().require(o.kind);i!==void 0&&!i.has(o.kind)&&(c.inverse===void 0||!i.has(c.inverse))||C(r,t==="incoming"?o.target:o.source,t==="incoming"?o.source:o.target)}return{adjacency:r,inspectedEdges:s.length}}function Jt(e,t,n,r,i,s){let o=U(e,t,{...n,after:void 0,direction:"incoming",limit:void 0}),c=U(e,t,{...n,after:void 0,direction:"outgoing",limit:void 0}),a=new Map,d=[...o.affected,...c.affected].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)||p.path.join("\0").localeCompare(m.path.join("\0")));for(let p of d)a.has(p.id)||a.set(p.id,p);let l=[...a.values()].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)),f=r===void 0||r===t?-1:l.findIndex(p=>p.id===r);if(r!==void 0&&r!==t&&f<0)throw new TypeError(`Unknown impact cursor item: ${r}`);let u=l.slice(f+1,f+1+i),g=f+1+u.length<l.length;return{root:t,affected:u,exact:!0,truncated:o.truncated||c.truncated||g,...g?{nextCursor:se(s,u.at(-1)?.id??t)}:{},cost:{visitedNodes:o.cost.visitedNodes+c.cost.visitedNodes,inspectedEdges:o.cost.inspectedEdges+c.cost.inspectedEdges}}}function Qt(e,t,n){let r=n.direction,i=n.maxDepth??Number.POSITIVE_INFINITY,s=n.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=Ke(t,n,r,i),{adjacency:a,inspectedEdges:d}=Xt(e,r,n.kinds),l={queue:[{id:t,depth:0}],seen:new Set([t]),parents:new Map,affected:[],cursorFound:c===void 0||c===t},f=0,u=!1,g=!1;e:for(let p=0;p<l.queue.length;p+=1){n.signal?.throwIfAborted();let m=l.queue[p];f+=1;let b=[...a.get(m.id)].sort();if(m.depth>=i){b.some(w=>!l.seen.has(w))&&(u=!0);continue}for(let w of b)if(Ut(l,w,m,t,c,s)==="truncate"){u=!0,g=!0;break e}}if(!l.cursorFound)throw new TypeError(`Unknown impact cursor item: ${c}`);return{root:t,affected:l.affected,exact:!0,truncated:u,...g?{nextCursor:se(o,l.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:f,inspectedEdges:d}}}function U(e,t,n={}){let r=n.direction??"outgoing";if(r!=="both")return Qt(e,t,{...n,direction:r});let i=n.maxDepth??Number.POSITIVE_INFINITY,s=n.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=Ke(t,n,r,i);return Jt(e,t,n,c,s,o)}function Ye(e){let t=[...e.nodes()],n=M(t),r=M(t);for(let a of e.edges())C(n,a.source,a.target),C(n,a.target,a.source),C(r,a.source,a.target);let i=[],s=new Set;for(let a of t){if(s.has(a))continue;let d=[],l=[a];for(s.add(a);l.length>0;){let f=l.pop();d.push(f);for(let u of n.get(f))s.has(u)||(s.add(u),l.push(u))}i.push(d)}let o=t.map(a=>({id:a,degree:n.get(a).size})),c=Math.max(0,...o.map(({degree:a})=>a));return{components:Ve(i),stronglyConnected:We(t,r),orphans:o.filter(({degree:a})=>a===0).map(({id:a})=>a),hubs:o.filter(({degree:a})=>a>0&&a===c),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function Xr(e,t){let n=new Map(e.edges.map(i=>[He(i),i])),r=new Map(t.edges.map(i=>[He(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),removed:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),unchangedCount:[...n.keys()].filter(i=>r.has(i)).length,exact:!0}}var Zt=k.paths,en=k.visited_paths,tn=k.path_depth;function oe(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 N(e,t){let n=P(e,t);return{predecessor:n,successor:n===e.source?e.target:e.source}}function nn(e,t,n){if(t===void 0)return;let r=e.registry(),i=new Set;for(let s of t){let o=r.require(s),c=o.traversal;if(c==="association")throw new TypeError(`Relationship kind ${o.kind} uses association traversal; use graph impact --direction both`);if(c!==n&&c!=="semantic"){let a=c==="hierarchy"?"graph ancestors or graph descendants":"graph predecessors or graph successors";throw new TypeError(`Relationship kind ${o.kind} uses ${c} traversal; use ${a}`)}i.add(o.kind)}return i}function rn(e,t,n,r,i){let s=e.registry(),o=e.neighborEdges(t,{direction:"both",...n===void 0?{}:{kinds:[...n]}}),c=[],a=new Set;for(let d of o.value){let l=s.require(d.edge.kind);n===void 0&&!l[r]||i(d,l,t)&&(a.has(d.id)||(a.add(d.id),c.push(d.id)))}return{neighbors:c,inspectedEdges:o.meta.inspectedEdges}}function sn(e,t,n,r,i,s){if(t>=n)return e.neighbors.some(o=>!s.seen.has(o))&&(s.truncated=!0),!1;for(let o of e.neighbors)if(!s.seen.has(o)){if(s.seen.add(o),s.queue.push({id:o,depth:t+1}),!s.resumed){o===i&&(s.resumed=!0);continue}if(s.value.length>=r)return s.truncated=!0,!0;s.value.push(o)}return!1}function H(e,t,n,r,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let s=nn(e,n.kinds,r),o=n.limit??Number.POSITIVE_INFINITY,c=n.maxDepth??Number.POSITIVE_INFINITY,a=n.after,d={seen:new Set([t]),value:[],queue:[{id:t,depth:0}],resumed:a===void 0,truncated:!1},l=0,f=0;for(let u=0;u<d.queue.length;u+=1){n.signal?.throwIfAborted();let g=d.queue[u];l+=1;let p=rn(e,g.id,s,r,i);if(f+=p.inspectedEdges,sn(p,g.depth,c,o,a,d))break}if(!d.resumed)throw new TypeError(`Traversal cursor not found in sequence: ${a}`);return{value:d.value,meta:{visitedNodes:l,inspectedEdges:f,truncated:d.truncated,nextCursor:d.value.at(-1)}}}function Xe(e,t){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`)}function Je(e,t,n,r,i){let s=e.neighborEdges(t.nodes.at(-1),{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});return i.inspectedEdges+=s.meta.inspectedEdges,s.value.filter(o=>!t.nodeSet.has(o.id))}function on(e,t,n,r,i,s,o){for(let c of Je(e,t,r,i,o)){let a=[...t.nodes,c.id],d=new Set(t.nodeSet).add(c.id),l=[...t.edges,c.edge];if(c.id===n){if(o.value.push({nodes:a,edges:l,length:l.length}),o.value.length>=s)return!0}else o.queue.push({nodes:a,nodeSet:d,edges:l})}return!1}function Qe(e,t,n={}){return H(e,t,n,"hierarchy",(r,i)=>z(r.edge,i)===r.id)}function Ze(e,t,n={}){return H(e,t,n,"hierarchy",(r,i,s)=>z(r.edge,i)===s)}function et(e,t,n={}){return H(e,t,n,"ordering",(r,i)=>P(r.edge,i)===r.id)}function tt(e,t,n={}){return H(e,t,n,"ordering",(r,i,s)=>P(r.edge,i)===s)}function cn(e,t,n,r,i,s,o,c){let a={value:[],queue:[{nodes:[t],nodeSet:new Set([t]),edges:[]}],inspectedEdges:0},d=0,l=!1,f=i+1;for(let u=0;u<a.queue.length;u+=1){if(r.signal?.throwIfAborted(),a.value.length>=f||d>=s){l=!0;break}let g=a.queue[u];if(d+=1,g.edges.length>=o){Je(e,g,r,c,a).length>0&&(l=!0);continue}if(on(e,g,n,r,c,f,a)){l=!0;break}}return{value:a.value.slice(0,i),meta:{visitedNodes:d,inspectedEdges:a.inspectedEdges,truncated:l}}}function nt(e,t,n,r={}){Xe(e,t),Xe(e,n);let i=r.maxPaths??Zt,s=r.maxVisitedPaths??en,o=r.maxDepth??tn;oe("maxPaths",i),oe("maxVisitedPaths",s),oe("maxDepth",o);let c=r.direction??"outgoing";r.signal?.throwIfAborted();for(let a of r.kinds??[])e.registry().require(a);return t===n?i===0?{value:[],meta:{visitedNodes:1,inspectedEdges:0,truncated:!0}}:{value:[{nodes:[t],edges:[],length:0}],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}}:cn(e,t,n,r,i,s,o,c)}var an=16,dn=2,ln=8;function K(e,t){if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`)}function V(e,t,n){let r=e.registry(),i=t===void 0?void 0:new Set(t.map(s=>r.require(s).kind));for(let s of e.edges()){if(s.source===s.target)continue;let o=r.require(s.kind);i!==void 0&&!(i.has(o.kind)||o.inverse!==void 0&&i.has(o.inverse))||n(s,o)}}function un(e,t){let n=new Map;V(e,t,r=>{rt(n,r.source,r.target),rt(n,r.target,r.source)});for(let r of n.values())r.sort();return n}function rt(e,t,n){let r=e.get(t);r===void 0?e.set(t,[n]):r.push(n)}function fn(e,t){let n=new Map;for(let s of e){let o=t.get(s);n.set(o,(n.get(o)??0)+1)}let r,i=0;for(let[s,o]of n)(o>i||o===i&&s<r)&&(r=s,i=o);return r}function gn(e,t){let n=new Map;for(let[i,s]of e){let o=n.get(s);o===void 0?n.set(s,[i]):o.push(i)}let r=[];for(let i of n.values())i.length<t||(i.sort(),r.push({representative:i[0],size:i.length,members:i}));return r.sort((i,s)=>s.size-i.size||i.representative.localeCompare(s.representative))}function it(e,t={}){let n=t.maxIterations??an,r=t.minSize??dn;K("maxIterations",n),K("minSize",r);let i=un(e,t.kinds),s=e.nodes(),o=new Map(s.map(f=>[f,f])),c=0,a=!1,d=0,l=0;for(;c<n&&!a;){t.signal?.throwIfAborted(),c+=1,a=!0;for(let f of s){d+=1;let u=i.get(f);if(u===void 0)continue;l+=u.length;let g=fn(u,o);g!==o.get(f)&&(o.set(f,g),a=!1)}}return{value:{communities:gn(o,r),iterations:c,converged:a},meta:{visitedNodes:d,inspectedEdges:l,truncated:!a}}}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 ce(e,t){return(t.hierarchy?z(e,t):e.source===P(e,t)?e.target:e.source)===e.target?{from:e.source,to:e.target}:{from:e.target,to:e.source}}function pn(e,t){if(t===void 0)return;let n=e.registry(),r=new Set;for(let i of t){let s=n.require(i);if(!W(s))throw new TypeError(`Relationship kind ${s.kind} is not a directed ordering or hierarchy kind`);r.add(Y(s))}return r}function hn(e,t){let n=e.registry(),r=new Map;for(let i of e.edges()){let s=n.require(i.kind);if(!W(s))continue;let o=Y(s);if(t!==void 0&&!t.has(o))continue;let c=ce(i,s);if(c.from===c.to)continue;let a=r.get(o);a===void 0&&(a={adjacency:new Map,records:[]},r.set(o,a));let d=a.adjacency.get(c.from);d===void 0?a.adjacency.set(c.from,new Set([c.to])):d.add(c.to),a.records.push({...c,edge:i})}return r}function mn(e){let t=new Map;for(let[n,r]of e.adjacency)t.set(n,[...r].sort());return t}function _n(e,t,n,r){let i=[r];for(let s=n;s!==t;s=e.get(s))i.push(s);return i.push(t),i.reverse()}function yn(e,t,n,r,i,s){for(let o of e.get(n.id)??[])if(s.inspectedEdges+=1,!(n.depth===0&&o===t.to)&&!r.has(o)){if(r.set(o,n.id),o===t.to)return _n(r,t.from,n.id,o);i.push({id:o,depth:n.depth+1})}}function bn(e,t,n,r){let i=new Map([[t.from,t.from]]),s=[{id:t.from,depth:0}];for(let o=0;o<s.length;o+=1){let c=s[o];if(r.visitedNodes+=1,c.depth>=n)continue;let a=yn(e,t,c,i,s,r);if(a!==void 0)return a}}function A(e,t={}){let n=t.maxDepth??ln;K("maxDepth",n),t.limit!==void 0&&K("limit",t.limit);let r=t.limit??Number.POSITIVE_INFINITY,i=pn(e,t.kinds),s=hn(e,i),o=[],c={visitedNodes:0,inspectedEdges:0},a=!1;e:for(let d of[...s.keys()].sort()){let l=s.get(d),f=mn(l);for(let u of l.records){t.signal?.throwIfAborted();let g=bn(f,u,n,c);if(g!==void 0){if(o.length>=r){a=!0;break e}o.push({edge:u.edge,witness:g})}}}return{value:o,meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:a}}}function wn(e,t,n,r,i){let s=new Set,o=[];for(let c of n){if(c.id===e||s.has(c.id))continue;if(!i.seen.has(c.id)){if(t>=r){i.truncated=!0;continue}i.seen.add(c.id),i.queue.push({id:c.id,depth:t+1})}s.add(c.id),o.push(c.id);let a=i.predecessors.get(c.id);a===void 0&&(a=new Set,i.predecessors.set(c.id,a)),a.add(e)}return o}function vn(e,t,n){let r=n.direction??"outgoing",i=n.maxDepth??Number.POSITIVE_INFINITY,s=[],o=new Map,c={seen:new Set([t]),queue:[{id:t,depth:0}],predecessors:new Map,truncated:!1},a=0;for(let d=0;d<c.queue.length;d+=1){n.signal?.throwIfAborted();let{id:l,depth:f}=c.queue[d];s.push(l);let u=e.neighborEdges(l,{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});a+=u.meta.inspectedEdges,o.set(l,wn(l,f,u.value,i,c))}return{order:s,successors:o,predecessors:c.predecessors,inspectedEdges:a,truncated:c.truncated}}function xn(e,t){let n=[],r=new Set([t]),i=[{id:t,index:0}];for(;i.length>0;){let s=i.at(-1),o=e.successors.get(s.id);if(s.index<o.length){let c=o[s.index];s.index+=1,r.has(c)||(r.add(c),i.push({id:c,index:0}))}else n.push(s.id),i.pop()}return n.reverse()}function kn(e,t,n,r){let i=e,s=t;for(;i!==s;){for(;r.get(i)>r.get(s);)i=n.get(i);for(;r.get(s)>r.get(i);)s=n.get(s)}return i}function En(e,t,n){let r;for(let i of[...e].sort())t.has(i)&&(r=r===void 0?i:kn(r,i,t,n));return r}function In(e,t,n,r,i){let s=new Map([[t,t]]),o=!0;for(;o;){o=!1;for(let c of n){if(i?.throwIfAborted(),c===t)continue;let a=En(e.predecessors.get(c),s,r);a!==void 0&&s.get(c)!==a&&(s.set(c,a),o=!0)}}return s}function st(e,t,n={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(n.maxDepth!==void 0&&(!Number.isInteger(n.maxDepth)||n.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(n.maxDepth)}`);let r=vn(e,t,n),i=xn(r,t),s=new Map(i.map((d,l)=>[d,l])),o=In(r,t,i,s,n.signal),c=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 f=o.get(l);c.set(f,c.get(f)+c.get(l))}let a=i.filter(d=>d!==t).map(d=>({id:d,idom:o.get(d),dominatedCount:c.get(d)-1})).sort((d,l)=>l.dominatedCount-d.dominatedCount||d.id.localeCompare(l.id));return{value:{root:t,reachableCount:r.order.length,rows:a},meta:{visitedNodes:r.order.length,inspectedEdges:r.inspectedEdges,truncated:r.truncated}}}function ot(e){return Math.round(e*1e6)/1e6}function ct(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function at(e,t){let n=new Map(e.nodes().map(i=>[i,new Set]));V(e,t,i=>{n.get(i.source).add(i.target),n.get(i.target).add(i.source)});let r=new Map;for(let[i,s]of n)r.set(i,[...s].sort());return r}function Sn(e,t){let n=new Map,r=new Map;return V(e,t,(i,s)=>{if(!s.ordering)return;let{predecessor:o,successor:c}=N(i,s);ct(r,o,c),ct(n,c,o)}),{incoming:n,outgoing:r}}function Cn(e,t,n){let r=new Map([[e,0]]),i=new Map([[e,1]]),s=new Map,o=[],c=[e],a=0,d=0;for(let l=0;l<c.length;l+=1){let f=c[l];n.visitedNodes+=1,o.push(f);let u=r.get(f);f!==e&&(a+=1,d+=u);for(let g of t.get(f))if(n.inspectedEdges+=1,r.has(g)||(r.set(g,u+1),c.push(g)),r.get(g)===u+1){i.set(g,(i.get(g)??0)+i.get(f));let p=s.get(g);p===void 0?s.set(g,[f]):p.push(f)}}return{stack:o,sigma:i,predecessors:s,reachableCount:a,distanceSum:d}}function Nn(e,t,n){let r=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let s=e.stack[i],o=(1+(r.get(s)??0))/e.sigma.get(s);for(let c of e.predecessors.get(s)??[])r.set(c,(r.get(c)??0)+e.sigma.get(c)*o);s!==t&&n.set(s,(n.get(s)??0)+(r.get(s)??0))}}function An(e,t){return t<=1||e.reachableCount===0?0:e.reachableCount/(t-1)*(e.reachableCount/e.distanceSum)}function Tn(e,t,n,r,i){return{id:e,degree:t.get(e).length,inDegree:n.incoming.get(e)?.size??0,outDegree:n.outgoing.get(e)?.size??0,betweenness:ot((r.get(e)??0)/2),closeness:ot(i.get(e))}}function dt(e,t={}){let n=at(e,t.kinds),r=Sn(e,t.kinds),i=e.nodes(),s=new Map,o=new Map,c={visitedNodes:0,inspectedEdges:0};for(let l of i){t.signal?.throwIfAborted();let f=Cn(l,n,c);o.set(l,An(f,i.length)),Nn(f,l,s)}let a=0;for(let l of n.values())a+=l.length;let d=i.map(l=>Tn(l,n,r,s,o)).sort((l,f)=>f.betweenness-l.betweenness||f.degree-l.degree||l.id.localeCompare(f.id));return{value:{nodeCount:i.length,edgeCount:a/2,rows:d},meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:!1}}}function Rn(e,t){return e<=t?{source:e,target:t}:{source:t,target:e}}function Dn(e,t,n){let i=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,n.inspectedEdges+=1,i!==e.parent){if(n.discovery.has(i)){n.low.set(e.node,Math.min(n.low.get(e.node),n.discovery.get(i)));return}return e.children+=1,n.discovery.set(i,n.timer),n.low.set(i,n.timer),n.timer+=1,{node:i,parent:e.node,neighborIndex:0,children:0}}}function On(e,t,n){if(e.parent===null){e.children>1&&n.articulation.add(e.node);return}let r=e.parent,i=n.low.get(e.node);n.low.set(r,Math.min(n.low.get(r),i)),r!==t&&i>=n.discovery.get(r)&&n.articulation.add(r),i>n.discovery.get(r)&&n.bridges.push(Rn(r,e.node))}function jn(e,t,n,r){n.discovery.set(e,n.timer),n.low.set(e,n.timer),n.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){r?.throwIfAborted();let s=i.at(-1);if(s.neighborIndex<t.get(s.node).length){let o=Dn(s,t,n);o!==void 0&&i.push(o)}else On(s,e,n),i.pop()}}function X(e,t={}){let n=at(e,t.kinds),r={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())r.discovery.has(i)||jn(i,n,r,t.signal);return{value:{articulationPoints:[...r.articulation].sort(),bridges:r.bridges.sort((i,s)=>i.source.localeCompare(s.source)||i.target.localeCompare(s.target))},meta:{visitedNodes:r.discovery.size,inspectedEdges:r.inspectedEdges,truncated:!1}}}function Mn(e){let t=e.registry(),n=new Map,r=new Set;for(let i of e.edges()){let s=t.require(i.kind);if(!s.ordering)continue;let{predecessor:o,successor:c}=N(i,s);if(r.add(o),r.add(c),o===c)continue;let a=n.get(o);a===void 0?n.set(o,new Set([c])):a.add(c)}return{forward:n,participants:r}}function Pn(e,t,n,r){if(e===void 0)return r;let i=r;for(let s of e)t.has(s)&&(i=Math.min(i,n.get(s)));return i}function Ln(e,t,n){let r=n-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:n,latestFinish:n+1,slack:r,critical:r===0}}function Fn(e,t,n,r,i){let s=new Map;for(let o=e.length-1;o>=0;o-=1){let c=e[o],a=Pn(t.forward.get(c),r,s,i);s.set(c,a-1)}return e.map(o=>Ln(o,n[o],s.get(o))).sort((o,c)=>o.slack-c.slack||o.earliestStart-c.earliestStart||o.id.localeCompare(c.id))}function lt(e,t={}){t.signal?.throwIfAborted();let n=B(e,{registry:e.registry()}),r=Mn(e),i=new Set(n.order),s=n.order.filter(d=>r.participants.has(d)),o=s.reduce((d,l)=>Math.max(d,n.depth[l]+1),0),c=Fn(s,r,n.depth,i,o),a=c.length>0;return{exact:!0,acyclic:n.acyclic,makespan:o,scheduledCount:c.length,criticalPath:a?n.criticalPath:[],criticalPathLength:a?n.criticalPathLength:0,cycles:n.cycles,rows:c,provenance:{algorithm:"critical-path-method",edgeFamily:"ordering",weighting:"unit"}}}function Gn(e,t,n){for(let r=e.length-1;r>=0;r-=1){n?.throwIfAborted();let i=t.get(e[r]);for(let s of i.successors){n?.throwIfAborted();let o=t.get(s);if(o.latest===void 0||o.duration===void 0)continue;let c=o.latest-o.duration;(i.latest===void 0||c<i.latest)&&(i.latest=c,i.anchor=o.anchor)}}}function $n(e,t,n,r){let i=[],s=e;for(;s!==void 0&&i.length<n;)r?.throwIfAborted(),i.push(s),s=t.get(s).predecessor;return i.reverse(),{path:i,path_truncated:s!==void 0}}function qn(e,t,n,r,i){let s=new Map(t.map(c=>[c.id,c])),o=new Map;for(let c of e){i?.throwIfAborted();let a=s.get(c),d=a?.estimated_minutes,l=typeof d=="number"&&Number.isFinite(d)&&d>=0?d:void 0,f={item:a,duration:l,pending:0,successors:new Set,earliest:0};if(a?.deadline!==void 0){let u=Date.parse(a.deadline);Number.isFinite(u)?(f.deadline=(u-n)/6e4,f.latest=f.deadline,f.anchor=c):r(c,"invalid_deadline")}o.set(c,f)}return o}function Un(e,t,n){for(let r of e.edges()){n?.throwIfAborted();let i=e.registry().require(r.kind);if(!i.ordering)continue;let{predecessor:s,successor:o}=N(r,i),c=t.get(s);c.successors.has(o)||(c.successors.add(o),t.get(o).pending+=1)}}function Bn(e,t,n){let r=e.filter(i=>t.get(i).pending===0);for(let i=0;i<r.length;i+=1){n?.throwIfAborted();let s=r[i],o=t.get(s),c=o.earliest===null||o.duration===void 0?null:o.earliest+o.duration;for(let a of o.successors){n?.throwIfAborted();let d=t.get(a);c===null?d.earliest=null:d.earliest!==null&&(c>d.earliest||c===d.earliest&&(d.predecessor===void 0||s<d.predecessor))&&(d.earliest=c,d.predecessor=s),d.pending-=1,d.pending===0&&r.push(a)}}return r}function zn(e,t,n,r,i,s,o,c){let a=t.duration;if(t.latest!==void 0){r.scheduled_count+=1;let d=t.latest-a;r.rows.length<s?r.rows.push({id:e,deadline_id:t.anchor,latest_start:new Date(i+d*6e4).toISOString(),slack_minutes:t.earliest===null?null:d-t.earliest}):r.truncated=!0}if(t.deadline!==void 0&&t.earliest!==null&&t.earliest+a>t.deadline)if(r.overcommitted_count+=1,r.overcommitted.length<s){let d=$n(e,n,Math.min(s,o.remaining),c);o.remaining-=d.path.length,d.path_truncated&&(r.truncated=!0),r.overcommitted.push({deadline_id:e,deadline:t.item.deadline,shortfall_minutes:t.earliest+a-t.deadline,...d})}else r.truncated=!0}function Hn(e,t,n,r,i,s,o,c){let a={remaining:s};for(let d of e){c?.throwIfAborted();let l=t.get(d);if(l.pending>0){o(d,"cycle_or_gated_by_cycle");continue}if(l.duration===void 0){o(d,"unknown_estimate");continue}if(l.latest!==void 0&&!Number.isFinite(new Date(r+(l.latest-l.duration)*6e4).getTime())){o(d,"date_range_exceeded");continue}l.earliest===null&&o(d,"unknown_predecessor_estimate"),zn(d,l,t,n,r,i,a,c)}}function ut(e,t,n={}){n.signal?.throwIfAborted();let r=Date.parse(n.now??new Date().toISOString());if(!Number.isFinite(r))throw new TypeError("Invalid scheduling clock");let i=n.maxWork??1e5,s=n.limit??10;for(let[u,g]of[["maxWork",i],["limit",s]])if(!Number.isSafeInteger(g)||g<1)throw new TypeError(`Invalid scheduling ${u}`);let o={as_of:new Date(r).toISOString(),basis:"derived_elapsed_minutes",complete:!0,truncated:!1,work_limit_exceeded:!1,scheduled_count:0,residual_count:0,overcommitted_count:0,rows:[],residuals:[],overcommitted:[]},c=e.nodes(),a=e.edges();if(c.length+a.length+t.length>i)return{...o,complete:!1,work_limit_exceeded:!0};let d=(u,g)=>{o.complete=!1,o.residual_count+=1,o.residuals.length<s?o.residuals.push({id:u,reason:g}):o.truncated=!0},l=qn(c,t,r,d,n.signal);Un(e,l,n.signal);let f=Bn(c,l,n.signal);return Gn(f,l,n.signal),Hn(c,l,o,r,s,i,d,n.signal),o}function T(){return{nodes:0,isolated:0,degree_leq_one:0,semantic_nodes:0,without_semantic_edges:0,degree_histogram:{}}}function pt(e,t,n,r){let i={all:T(),active:T(),terminal:T()},s=new Map;for(let o of e.details){if(r?.throwIfAborted(),e.missingIdSet.has(o.id.toLowerCase())||o.status==="external")continue;let c=s.get(o.status)??T();s.set(o.status,c);let a=e.graph.incidentEdges(o.id),d=a.some(l=>n(l.kind));for(let l of[i.all,i[t(o.status)?"terminal":"active"],c]){l.nodes+=1,l.isolated+=+(a.length===0),a.length<=1&&(l.degree_leq_one+=1),d?l.semantic_nodes+=1:l.without_semantic_edges+=1;let f=String(a.length);l.degree_histogram[f]=(l.degree_histogram[f]??0)+1}}return{coverage_by_lifecycle:i,coverage_by_status:Object.fromEntries([...s].sort(([o],[c])=>o.localeCompare(c)))}}function ft(e){if(!J(e))return!1;let t=e;if(!["nodes","isolated","degree_leq_one","semantic_nodes","without_semantic_edges"].every(i=>Number.isSafeInteger(t[i])&&Number(t[i])>=0)||!J(t.degree_histogram))return!1;let r=Object.entries(t.degree_histogram);return r.every(([i,s])=>/^(0|[1-9]\d*)$/.test(i)&&Number.isSafeInteger(s)&&Number(s)>=0)&&r.reduce((i,[,s])=>i+Number(s),0)===t.nodes&&Number(t.isolated)<=Number(t.degree_leq_one)&&Number(t.degree_leq_one)<=Number(t.nodes)&&Number(t.semantic_nodes)+Number(t.without_semantic_edges)===t.nodes}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ht(e){for(let r of["ordering_acyclic","active_ordering_acyclic"])if(e[r]!==void 0&&typeof e[r]!="boolean")return!1;let t=e.coverage_by_lifecycle,n=e.coverage_by_status;return t===void 0&&n===void 0?!0:!J(t)||!J(n)?!1:["all","active","terminal"].every(r=>ft(t[r]))&&Object.values(n).every(ft)}function gt(e,t){return Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].sort().map(n=>{let r=Object.hasOwn(e,n)?e[n]:T(),i=Object.hasOwn(t,n)?t[n]:T(),s=Object.fromEntries([...new Set([...Object.keys(r.degree_histogram),...Object.keys(i.degree_histogram)])].sort().map(o=>[o,(i.degree_histogram[o]??0)-(r.degree_histogram[o]??0)]));return[n,{nodes:i.nodes-r.nodes,isolated:i.isolated-r.isolated,degree_leq_one:i.degree_leq_one-r.degree_leq_one,semantic_nodes:i.semantic_nodes-r.semantic_nodes,without_semantic_edges:i.without_semantic_edges-r.without_semantic_edges,degree_histogram:s}]}))}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:gt(e.coverage_by_lifecycle,t.coverage_by_lifecycle),coverage_by_status:gt(e.coverage_by_status,t.coverage_by_status)}}var R=["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"];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 D(e,t,n,r,i,s,o,c){let a=[...i].sort((d,l)=>d.localeCompare(l));return{code:e,severity:t,policy:n,message:r(a.length),count:a.length,sample:a.slice(0,s),sample_truncated:a.length>s,remediation:o,...c===void 0?{}:{evidence:[...c].sort((d,l)=>d.localeCompare(l)).slice(0,s)}}}function Xn(e,t){return e.cycles.map(n=>D(n.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",n.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",r=>`${r} items participate in one hierarchy cycle.`,n.item_ids,t,n.legacy_terminal?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove or retype one exact hierarchy relation before continuing mutation."))}function bt(e,t,n){let r=e.cardinality_violations.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[D(n?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",n?"info":"error","Every structural child must resolve to at most one logical parent across all hierarchy spellings.",i=>`${i} child item${i===1?"":"s"} resolve to multiple hierarchy parents.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",r.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function wt(e,t,n){let r=e.divergences.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[D(n?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",n?"info":"error","Scalar parent metadata and dependency-backed hierarchy rows must resolve to the same logical parent.",i=>`${i} child item${i===1?"":"s"} have divergent hierarchy storage surfaces.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",r.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function Jn(e,t){let n=G(e);return n?[...Xn(n,t),...bt(n,t,!1),...bt(n,t,!0),...wt(n,t,!1),...wt(n,t,!0)]:[]}function Qn(e){let t=e.graph.registry(),n=new Map;for(let r of e.graph.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let[s,o]=(i.precedence??"source_before_target")==="target_before_source"?[r.target,r.source]:[r.source,r.target],c=n.get(s);c?c.push(o):n.set(s,[o])}for(let r of n.values())r.sort((i,s)=>i.localeCompare(s));return n}function xt(e,t){t.indexes.set(e,t.nextIndex),t.lowLinks.set(e,t.nextIndex),t.nextIndex+=1,t.stack.push(e),t.onStack.add(e)}function Zn(e,t,n,r){let i=n.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let s=i[e.neighborIndex];return e.neighborIndex+=1,r.indexes.has(s)?r.onStack.has(s)&&r.lowLinks.set(e.node,Math.min(r.lowLinks.get(e.node),r.indexes.get(s))):(xt(s,r),t.push({node:s,neighborIndex:0})),!0}function er(e,t,n,r){t.pop();let i=t.at(-1);if(i&&r.lowLinks.set(i.node,Math.min(r.lowLinks.get(i.node),r.lowLinks.get(e.node))),r.lowLinks.get(e.node)!==r.indexes.get(e.node))return;let s=[];for(;;){let o=r.stack.pop();if(r.onStack.delete(o),s.push(o),o===e.node)break}(s.length>1||s.length===1&&n.get(s[0])?.includes(s[0]))&&r.components.push(s.sort((o,c)=>o.localeCompare(c)))}function tr(e){let t={indexes:new Map,lowLinks:new Map,onStack:new Set,stack:[],components:[],nextIndex:0},n=[...e.keys()].sort((r,i)=>r.localeCompare(i));for(let r of n){if(t.indexes.has(r))continue;let i=[{node:r,neighborIndex:0}];for(xt(r,t);i.length>0;){let s=i.at(-1);Zn(s,i,e,t)||er(s,i,e,t)}}return t.components.sort((r,i)=>r[0].localeCompare(i[0]))}function ae(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function y(e,t,n,r,i,s,o,c){t.length!==0&&e.push(D(r,i,s,o,t,n,c))}function nr(e,t,n){let r=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(s=>!s.no_active_blocker_sentinel);return y(r,i.filter(s=>!t(s.holder_status)).map(ae),n,"missing_reference_active","error","Active items must not reference absent targets; missing prerequisites distort scheduling.",s=>`${s} active dangling reference(s) to absent items`,"Restore or re-create the referenced item, or remove/retype the reference on the holder."),y(r,i.filter(s=>t(s.holder_status)).map(ae),n,"missing_reference_terminal","info","Terminal items may retain historical references, but absent targets remain unexplainable context.",s=>`${s} terminal dangling reference(s) to absent items`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),y(r,e.dangling.no_active_blocker_sentinels.map(ae),n,"legacy_no_blocker_sentinel","info","The pre-structured-dependency no-active-blocker sentinel is retired; real edges carry blocker state.",s=>`${s} legacy no-active-blocker sentinel reference(s)`,"Delete the sentinel reference; blocker state is derived from blocked_by edges."),r}function le(e,t){let n=t.get(e);return n?!n.terminal:!0}function kt(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function rr(e,t){let n=[],r=[];for(let s of e.orderingContradictions??[])(s.legacy_terminal?r:n).push(kt(s));let i=[];return y(i,n,t,"ordering_storage_contradiction","error","A scalar blocker and same-target structured ordering row must not assert opposite precedence.",s=>`${s} active scalar-versus-structured ordering contradiction(s)`,"Remove the structured dependency row that points the holder before its scalar blocker, or replace both representations with one unambiguous ordering edge."),y(i,r,t,"legacy_ordering_storage_contradiction","info","Terminal scalar-versus-structured ordering contradictions are exact historical storage defects with no live scheduling effect.",s=>`${s} terminal scalar-versus-structured ordering contradiction(s)`,"Remove the contradictory blocks dependency row in a dedicated changelog-safe closed-item batch; preserve the scalar blocker as the historical precedence record."),i}function ir(e,t,n,r){let i=[],s=Qn(e);for(let a of tr(s)){let d=a.some(u=>le(u,t)),l=new Set(a.map(u=>u.toLowerCase())),f=(e.orderingContradictions??[]).filter(u=>l.has(u.holder_id.toLowerCase())&&l.has(u.target_id.toLowerCase())).map(kt);i.push(d?D("ordering_cycle","error","Order-bearing relationship kinds must stay acyclic; a cycle makes every member unschedulable.",u=>`execution-order cycle across ${u} item(s)`,a,r,"Remove or retype one ordering edge inside the cycle, or split the work so precedence is linear.",f.length===0?void 0:f):D("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)`,a,r,"Leave as history debt, or clean up in a dedicated changelog-safe closed-item batch; never repair closed items ad hoc.",f.length===0?void 0:f))}let o=new Map;for(let[a,d]of s)for(let l of d){let f=o.get(l);f?f.push(a):o.set(l,[a])}let c=[...t.values()].filter(a=>!a.missing&&!a.terminal&&n(a.status)&&!(o.get(a.id)??[]).some(d=>{let l=t.get(d);return l===void 0||!l.terminal})).map(a=>a.id);return y(i,c,r,"stale_lifecycle_block","warning","A blocked lifecycle status must be backed by at least one open ordering predecessor.",a=>`${a} status-blocked item(s) with no open blocker edge`,'Add a local blocker edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status.'),i}function Z(e){let t=e.edges.map(n=>n.kind).sort((n,r)=>n.localeCompare(r));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function ue(e){let t=e.graph.registry(),n=new Map;for(let i of e.graph.edges()){let s=t.require(i.kind);if(!W(s))continue;let o=ce(i,s);if(o.from===o.to)continue;let c=`${Y(s)}::${o.from}::${o.to}`,a=n.get(c);a?a.edges.push(i):n.set(c,{...o,edges:[i]})}let r=[...n.values()].filter(i=>i.edges.length>=2);for(let i of r)i.edges.sort((s,o)=>s.kind.localeCompare(o.kind));return r.sort((i,s)=>i.from.localeCompare(s.from)||i.to.localeCompare(s.to))}function sr(e,t,n){let r=[],i=[];for(let o of ue(e))(le(o.from,t)||le(o.to,t)?r:i).push(Z(o));let s=[];return y(s,r,n,"duplicate_edge","info","One semantic relationship should be stored once; parallel same-family spellings (reciprocal inverse pairs included) add no information and skew degree metrics.",o=>`${o} duplicated relationship(s) between active endpoints`,"Remove all but one stored spelling of the relationship; keep the canonical direction the holder declared first."),y(s,i,n,"legacy_duplicate_edge","info","Duplicated spellings between exclusively terminal items are historical noise with no scheduling effect.",o=>`${o} duplicated relationship(s) between terminal endpoints`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),s}function or(e,t){let n=[],r=[];for(let s of e.duplicateRows??[])(s.legacy_terminal?r:n).push(`${s.holder_id} -> ${s.target_id} (${s.kind} x${s.occurrences})`);let i=[];return y(i,n,t,"duplicate_dependency_row","warning","One dependency row must be stored once per holder; identical repeated rows are a storage-layer defect invisible to the assembled graph.",s=>`${s} exactly duplicated stored dependency row(s) on active holder(s)`,"Remove the repeated rows so the dependency is stored exactly once; graph semantics are unchanged."),y(i,r,t,"legacy_duplicate_dependency_row","info","Identical repeated dependency rows on terminal holders are historical storage noise with no scheduling effect.",s=>`${s} 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 cr(e,t){let n=new Map,r={source_to_target:[],target_to_source:[],both:[]};for(let o of e.graph.registry().list())o.outcomeTraversal!==void 0&&r[o.outcomeTraversal].push(o.kind);let i={source_to_target:r.source_to_target.join(","),target_to_source:r.target_to_source.join(","),both:r.both.join(",")},s=(o,c)=>{let a=n.get(c)??new Set;a.add(o),n.set(c,a)};for(let o of e.graph.edges()){t?.throwIfAborted();let c=e.graph.registry().require(o.kind);(c.outcomeTraversal==="source_to_target"||c.outcomeTraversal==="both")&&s(o.source,o.target),(c.outcomeTraversal==="target_to_source"||c.outcomeTraversal==="both")&&s(o.target,o.source)}return{basis:i,reverse:n}}function ar(e,t,n){let r=new Set(e),i=[...e].sort();for(let s=0;s<i.length;s+=1){n?.throwIfAborted();for(let o of[...t.get(i[s])??[]].sort())r.has(o)||(r.add(o),i.push(o))}return r}function dr(e,t,n,r){let i=0,s=0,o=0,c=0;for(let g of e.values())if(r?.throwIfAborted(),!t.has(g.id)&&!(g.missing||g.status==="external")){if(g.terminal){o+=1,n.has(g.id)&&(c+=1);continue}n.has(g.id)?i+=1:s+=1}let a=i+s,d=o-c,l=i+c,f=s+d,u=l+f;return{active_outcome_reachable_nodes:i,active_outcome_unreachable_nodes:s,active_outcome_reachability_basis_points:a===0?0:Math.floor(i*1e4/a),terminal_nodes:o,terminal_outcome_reachable_nodes:c,terminal_outcome_unreachable_nodes:d,terminal_outcome_reachability_basis_points:o===0?0:Math.floor(c*1e4/o),outcome_reachable_nodes:l,outcome_unreachable_nodes:f,outcome_reachability_basis_points:u===0?0:Math.floor(l*1e4/u)}}function lr(e,t,n){let r=new Set(e.details.filter(c=>c.type?.toLowerCase()===Vn&&c.title.trim().toLowerCase().startsWith(Wn)).map(c=>c.id)),{basis:i,reverse:s}=cr(e,n),o=ar(r,s,n);return{outcome_nodes:r.size,outcome_reachability_basis:i,...dr(t,r,o,n)}}function ur(e,t,n,r,i){e.active+=1;let s=t.type??"(untyped)",o=e.byType.get(s);o||(o={active:0,isolated:0,degree_leq_one:0},e.byType.set(s,o)),o.active+=1,!(n>1)&&(e.degreeLeqOne+=1,o.degree_leq_one+=1,n===0&&(e.isolated+=1,o.isolated+=1),!(r.has(t.id.toLowerCase())||i.has(s.toLowerCase()))&&(n===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function fr(e,t,n,r,i,s,o){let c={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let h of e.graph.nodes()){o?.throwIfAborted();let _=t.get(h);if(_){if(_.missing){c.missing+=1;continue}_.terminal||ur(c,_,e.graph.incidentEdges(h).length,n,r)}}let{isolates:a,sparse:d}=c,l=[];y(l,a,i,"isolated_active_node","warning","Active work should be reachable from the graph unless explicitly declared a valid isolate.",h=>`${h} active item(s) with no relationships`,"Link the item to its parent, prerequisite, or origin \u2014 or register it as an exempt isolate."),y(l,d,i,"sparse_active_node","info","Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.",h=>`${h} active item(s) with exactly one relationship`,"Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");let f=e.graph.edges().length,u=A(e.graph,{signal:o}).value,g=new Set(u.map(({edge:h})=>`${h.source.toLowerCase()}\0${h.target.toLowerCase()}\0${h.kind}`));for(let h of e.orderingContradictions??[])g.add(`${h.holder_id.toLowerCase()}\0${h.target_id.toLowerCase()}\0${h.dependency_kind}`);let p=Object.fromEntries(Object.entries(s).sort(([h],[_])=>h.localeCompare(_))),m=Object.entries(p).reduce((h,[_,I])=>h+(Q(_)?I:0),0),b=X(e.graph,{signal:o}).value,w=lr(e,t,o);return{findings:l,profile:{nodes:e.graph.nodes().length,recorded_nodes:e.details.filter(h=>h.status!=="missing"&&h.status!=="external").length,edges:f,informative_edges:f-g.size,redundant_edges:u.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:p,edge_share_by_kind:Object.fromEntries(Object.entries(p).map(([h,_])=>[h,_/f])),semantic_edges:m,semantic_edge_share:f===0?0:m/f,active_nodes:c.active,missing_nodes:c.missing,isolated_active_nodes:c.isolated,degree_leq_one_active_nodes:c.degreeLeqOne,coverage_by_type:Object.fromEntries([...c.byType.entries()].sort(([h],[_])=>h<_?-1:1)),articulation_points:b.articulationPoints.length,bridge_edges:b.bridges.length,...w,finding_subjects_by_code:Object.fromEntries(R.map(h=>[h,0]))}}}function ee(e,t={}){let n=t.isTerminal??(u=>u==="closed"||u==="canceled"),r=t.isBlocked??(u=>u==="blocked"),i=t.maxSampleSize??Kn;if(!Number.isInteger(i)||i<1)throw new TypeError(`Invalid audit sample bound: ${String(t.maxSampleSize)}`);let s=yt(t.exemptIsolates),o=yt(t.isolateExemptTypes),c=new Map(e.details.map(u=>[u.id,{id:u.id,status:u.status,missing:e.missingIdSet.has(u.id.toLowerCase()),terminal:n(u.status),...u.type===void 0?{}:{type:u.type}}]));t.signal?.throwIfAborted();let a={};for(let u of e.graph.edges())a[u.kind]=(a[u.kind]??0)+1;let d=nr(e,n,i);d.push(...Jn(e,i)),t.signal?.throwIfAborted(),d.push(...rr(e,i)),t.signal?.throwIfAborted(),d.push(...ir(e,c,r,i)),t.signal?.throwIfAborted(),d.push(...sr(e,c,i),...or(e,i)),t.signal?.throwIfAborted();let l=fr(e,c,s,o,i,a,t.signal);d.push(...l.findings),d.sort((u,g)=>_t[u.severity]-_t[g.severity]||u.code.localeCompare(g.code)||u.sample[0].localeCompare(g.sample[0]));let f=l.profile.finding_subjects_by_code;for(let u of d)f[u.code]+=u.count;return{findings:d,profile:{...l.profile,...pt(e,n,Q,t.signal),ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"||u.code==="legacy_ordering_cycle"),active_ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"),finding_subjects_by_code:f}}}function de(e,t){let n=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),r={};for(let i of n){let s=(t[i]??0)-(e[i]??0);s!==0&&(r[i]=s)}return r}function vt(e){return e.profile.coverage_by_type??{}}function gr(e,t){let n={},r=vt(e),i=vt(t),s=[...new Set([...Object.keys(r),...Object.keys(i)])].sort();for(let o of s){let c=Object.assign({active:0,isolated:0,degree_leq_one:0},r[o]),a=Object.assign({active:0,isolated:0,degree_leq_one:0},i[o]),d={active:a.active-c.active,isolated:a.isolated-c.isolated,degree_leq_one:a.degree_leq_one-c.degree_leq_one};Object.values(d).some(l=>l!==0)&&(n[o]=d)}return n}function Et(e,t){let n=gr(e,t),{edge_share_by_kind:r={},semantic_edges:i=0,semantic_edge_share:s=0}=e.profile,{edge_share_by_kind:o={},semantic_edges:c=0,semantic_edge_share:a=0}=t.profile,d=e.profile.recorded_nodes??e.profile.nodes,l=t.profile.recorded_nodes??t.profile.nodes,f=e.profile.informative_edges??e.profile.edges,u=t.profile.informative_edges??t.profile.edges,g=e.profile.redundant_edges??0,p=t.profile.redundant_edges??0,m=e.profile.ordering_contradiction_edges??0,b=t.profile.ordering_contradiction_edges??0;return{baseline_saved_at:e.saved_at,same_snapshot:e.fingerprint===t.fingerprint,affected_subjects_by_code:de(e.affected_subjects_by_code,t.affected_subjects_by_code),profile:{nodes:t.profile.nodes-e.profile.nodes,recorded_nodes:l-d,edges:t.profile.edges-e.profile.edges,informative_edges:u-f,redundant_edges:p-g,ordering_contradiction_edges:b-m,active_nodes:t.profile.active_nodes-e.profile.active_nodes,missing_nodes:t.profile.missing_nodes-e.profile.missing_nodes,isolated_active_nodes:t.profile.isolated_active_nodes-e.profile.isolated_active_nodes,degree_leq_one_active_nodes:t.profile.degree_leq_one_active_nodes-e.profile.degree_leq_one_active_nodes,edges_by_kind:de(e.profile.edges_by_kind,t.profile.edges_by_kind),edge_share_by_kind:de(r,o),semantic_edges:c-i,semantic_edge_share:a-s,coverage_by_type:n,...mt(e.profile,t.profile)}}}import It from"node:path";var St=2,fe=500,pr=64,hr="graph-durable-cache";function Ct(e){return Ae(e,hr,30,`graph-cache:${process.pid}`,!1,!1,3e3)}function F(e){return It.join(e,"runtime","graph-cache.json")}function Nt(e){return It.join(e,"runtime","graph-audit-baseline.json")}function ge(e){if(e!==null)try{let t=JSON.parse(e);return typeof t!="object"||t===null||t.version!==St||typeof t.fingerprint!="string"||typeof t.saved_at!="string"||typeof t.results!="object"||t.results===null||Array.isArray(t.results)?void 0:t}catch{return}}async function pe(e,t){let n=await j(F(e)),r=ge(n),i=r?.fingerprint===t;return{exists:n!==null,fresh:i,results:i?r.results:{}}}async function he(e,t,n,r,i){let s=await Ct(e);try{let o=ge(await j(F(e))),c=o?.fingerprint===t?o.results:{};delete c[r],c[r]=i;let a=Object.keys(c);for(let d of a.slice(0,Math.max(0,a.length-pr)))delete c[d];await re(F(e),JSON.stringify({version:St,fingerprint:t,saved_at:new Date().toISOString(),results:c})),n.results=c}finally{await s()}}async function me(e){let t=await Ct(e);try{await ke(F(e))}finally{await t()}}async function At(e,t){let n=F(e),r=await j(n),i=ge(r);return i===void 0?{exists:r!==null,fresh:!1,entry_count:0}:{exists:!0,fresh:i.fingerprint===t,entry_count:Object.keys(i.results).length,fingerprint:i.fingerprint.slice(0,12),saved_at:i.saved_at,bytes:Buffer.byteLength(r,"utf8")}}function _e(e,t){return t||e>=fe}function te(e){return O(e)&&Object.values(e).every(E)}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function E(e){return Number.isInteger(e)&&Number(e)>=0}function Tt(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(Tt)}function _r(e){return O(e)?Object.values(e).every(t=>O(t)&&[t.active,t.isolated,t.degree_leq_one].every(E)):!1}function yr(e,t,n){let r=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=r.filter(o=>e[o]!==void 0).length;if(i!==0&&i!==r.length||!r.every(o=>L(e[o],E)))return;let s={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??n,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return s.recorded_nodes<=t&&s.informative_edges<=n&&s.redundant_edges<=n&&s.ordering_contradiction_edges<=n?s:void 0}function br(e,t,n){let r=[...t,...n,"finding_subjects_by_code"],i=r.filter(s=>e[s]!==void 0).length;return i!==0&&i!==r.length?!1:t.every(s=>L(e[s],E))&&n.every(s=>L(e[s],E)&&(e[s]===void 0||Number(e[s])<=1e4))&&L(e.finding_subjects_by_code,te)}function wr(e,t,n,r){let i=yr(e,n,r);if(i===void 0)return;let s=["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"],o=["active_outcome_reachability_basis_points","terminal_outcome_reachability_basis_points","outcome_reachability_basis_points"];if(!br(e,s,o)||e.edge_basis!==void 0&&e.edge_basis!=="deduplicated_directed")return;let c=te(e.finding_subjects_by_code)?e.finding_subjects_by_code:{};return{edge_basis:"deduplicated_directed",...i,...Object.fromEntries(s.map(a=>[a,e[a]??0])),...Object.fromEntries(o.map(a=>[a,e[a]??0])),finding_subjects_by_code:Object.fromEntries(R.map(a=>[a,c[a]??t[a]??0]))}}function vr(e,t,n,r,i){let s=[n,r,i],o=s.filter(d=>d!==void 0).length;if(o===0)return{edge_share_by_kind:{},semantic_edges:0,semantic_edge_share:0};if(o!==s.length||!mr(n)||!E(r)||!Tt(i))return;let c=Object.entries(t);if(c.reduce((d,[,l])=>d+l,0)!==e||Object.keys(n).length!==c.length||c.some(([d,l])=>n[d]!==(e===0?0:l/e)))return;let a=c.reduce((d,[l,f])=>d+(Q(l)?f:0),0);if(!(r!==a||i!==(e===0?0:a/e)))return{edge_share_by_kind:n,semantic_edges:r,semantic_edge_share:i}}function xr(e){if(e!==null)try{let t=JSON.parse(e);if(!O(t))return;let n=t,r=n.profile;if(typeof n.saved_at!="string"||typeof n.fingerprint!="string")return;let i=n.affected_subjects_by_code;if(!te(i)||!O(r)||!ht(r)||![r.nodes,r.edges,r.active_nodes,r.missing_nodes,r.isolated_active_nodes,r.degree_leq_one_active_nodes].every(E)||!te(r.edges_by_kind)||!L(r.coverage_by_type,_r))return;let s=vr(r.edges,r.edges_by_kind,r.edge_share_by_kind,r.semantic_edges,r.semantic_edge_share);if(s===void 0)return;let o=wr(r,i,r.nodes,r.edges);if(o===void 0)return;let{coverage_by_type:c={}}=r;return{...n,profile:{...r,...s,...o,coverage_by_type:c}}}catch{return}}async function Rt(e){return xr(await j(Nt(e)))}async function Dt(e,t){await re(Nt(e),JSON.stringify(t))}var kr={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 Er(e){let[t,...n]=e.edges;return n.map(r=>({op:"remove",code:"duplicate_edge",subject:Ot(r),rationale:"This stored spelling restates the kept canonical edge of the same semantic family; removing it leaves the relationship stated exactly once.",evidence:[`keep: ${Ot(t)}`,`group: ${Z(e)}`],confidence:"high"}))}function Ir(e,t){if(e.code==="duplicate_edge")return e.sample.flatMap(r=>Er(t.get(r)));let n=kr[e.code];return e.sample.map(r=>({op:n.op,code:e.code,subject:r,rationale:n.rationale,evidence:[e.policy],confidence:n.confidence}))}function jt(e,t={}){let{redundancyLimit:n,...r}=t,i=ee(e,r),s=new Map(ue(e).map(d=>[Z(d),d])),o=i.findings.flatMap(d=>Ir(d,s)),c=i.findings.some(d=>d.sample_truncated);t.signal?.throwIfAborted();let a=A(e.graph,{limit:n??t.maxSampleSize??25,...t.signal===void 0?{}:{signal:t.signal}});for(let d of a.value)o.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 c=c||a.meta.truncated,{steps:o,report:i,truncated:c,cost:{visitedNodes:a.meta.visitedNodes,inspectedEdges:a.meta.inspectedEdges}}}var Ft=new Set(["ancestors","descendants","predecessors","successors","paths","impact","dominators"]);function Mt(e,t,n){let r=e;if(t&&e.subcommand==="audit"){let{nodes:i,recorded_nodes:s,edges:o,active_nodes:c,terminal_nodes:a,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:f,coverage_by_lifecycle:u}=e.profile,g=Object.fromEntries(Object.entries(u).map(([p,m])=>{let{degree_histogram:b,...w}=m;return[p,w]}));r={...e,profile:{nodes:i,recorded_nodes:s,edges:o,active_nodes:c,terminal_nodes:a,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:f,coverage_by_lifecycle:g}}}return{...r,projection:{mode:t?"summary":"full",declared_field_groups:n===void 0?[]:[{name:n,restore_with:"--full"}],included_field_groups:n===void 0||t?[]:[n]}}}function Sr(e,t,n,r){return{assembly:t,...n===void 0?{}:{kinds:n},maxDepth:Ue(r.maxDepth),limit:e==="impact"&&Number(r.limit)===0?0:$(r.limit,"limit")??(r.full===!0?Number.MAX_SAFE_INTEGER:k.rows),after:r.after?.trim()||void 0,direction:Be(r.direction),maxPaths:$(r.maxPaths,"max-paths"),sample:$(r.sample,"sample")??k.samples,exemptIsolates:Pt(r.exemptIsolate),exemptIsolateTypes:Pt(r.exemptIsolateType),saveBaseline:r.saveBaseline===!0,summary:r.summary===!0,unbounded:r.full===!0}}function Pt(e){return e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",")).map(t=>t.trim()).filter(t=>t.length>0)}function Cr(e,t,n){let r=e.trim().toLowerCase();if(!ie.includes(r))throw je({command_path:"graph",token:r||"<empty>",allowed:ie});let i=r;if(Ft.has(i)&&!t?.trim())throw new x(`graph ${i} requires an item id.`,v.USAGE);if(i==="paths"&&!n?.trim())throw new x("graph paths requires a source and a target item id.",v.USAGE);return i}function ye(e){throw e instanceof TypeError?new x(e.message,v.USAGE):e}function be(e){return{truncated:e.truncated,cost:{visited_nodes:e.visitedNodes,inspected_edges:e.inspectedEdges}}}function Lt(e,t){let n=t.trim().toLowerCase();for(let r of e.details)if(r.id.trim().toLowerCase()===n&&!e.missingIdSet.has(r.id.toLowerCase()))return r.id;throw new x(`Item ${t} not found`,v.NOT_FOUND)}function Nr(e,t,n){let r={ancestors:Qe,descendants:Ze,predecessors:et,successors:tt}[e],i;try{i=r(n.assembly.graph,t,{...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},limit:n.limit,...n.after===void 0?{}:{after:n.after}})}catch(o){ye(o)}let s=be(i.meta);return{subcommand:e,root:t,count:i.value.length,...s,...i.meta.nextCursor===void 0?{}:{next_cursor:i.meta.nextCursor},...n.summary?{}:{ids:i.value}}}function Ar(e,t,n){let r=nt(n.assembly.graph,e,t,{direction:n.direction,...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},...n.maxPaths===void 0?{}:{maxPaths:n.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:n.direction,count:r.value.length,...be(r.meta),...n.summary?{}:{paths:r.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(s=>s.kind),length:i.length}))}}}function Tr(e,t){let n;try{n=U(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth},...t.unbounded?{}:{limit:t.limit},...t.after===void 0?{}:{after:t.after}})}catch(r){ye(r)}return{subcommand:"impact",root:e,direction:t.direction,count:n.affected.length,truncated:n.truncated,...n.nextCursor===void 0?{}:{next_cursor:n.nextCursor},cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...t.summary?{}:{affected:n.affected}}}function Rr(e,t,n){return{acyclic:e.acyclic,ordered_node_count:e.order.length,layer_count:e.layers.length,frontier_count:e.frontier.length,critical_path_length:e.criticalPathLength,cycle_count:e.cycles.length,...t?{}:{frontier:e.frontier.slice(0,n),critical_path:e.criticalPath.slice(0,n),cycles:e.cycles.slice(0,n)}}}function Dr(e,t,n){return{component_count:e.components.length,largest_component_size:e.components[0]?.length??0,orphan_count:e.orphans.length,...t?{}:{orphans:e.orphans.slice(0,n),hubs:e.hubs.slice(0,n)}}}function Or(e,t,n){let r=0,i=0,s=0;for(let o of e.cycles)r+=Number(o.legacy_terminal);for(let o of e.cardinality_violations)i+=Number(o.legacy_terminal);for(let o of e.divergences)s+=Number(o.legacy_terminal);return{acyclic:e.cycles.length===0,relation_count:e.relations.length,cycle_count:e.cycles.length,active_cycle_count:e.cycles.length-r,legacy_cycle_count:r,cardinality_violation_count:e.cardinality_violations.length,active_cardinality_violation_count:e.cardinality_violations.length-i,legacy_cardinality_violation_count:i,parent_divergence_count:e.divergences.length,active_parent_divergence_count:e.divergences.length-s,legacy_parent_divergence_count:s,...t?{}:{cycles:e.cycles.slice(0,n).map(o=>o.item_ids)}}}function jr(e){let t=e.assembly.graph,n=e.limit,r=B(t,{registry:t.registry()}),i=Ye(t);return{subcommand:"analyze",node_count:t.nodes().length,edge_count:t.edges().length,edge_basis:"deduplicated_directed",sample_limit:n,execution:Rr(r,e.summary,n),knowledge:Dr(i,e.summary,n),hierarchy:Or(G(e.assembly),e.summary,n)}}function Mr(e,t){let n=ee(e.assembly,{isTerminal:t,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),r={},i={},s={},o={};for(let d of n.findings)r[d.severity]=(r[d.severity]??0)+1,i[d.code]=(i[d.code]??0)+1,s[d.severity]=(s[d.severity]??0)+d.count,o[d.code]=(o[d.code]??0)+d.count;let{finding_subjects_by_code:c,...a}=n.profile;return{subcommand:"audit",truncated:n.findings.length>e.limit,finding_count:n.findings.length,findings_by_severity:r,findings_by_code:i,affected_subjects_by_severity:s,affected_subjects_by_code:o,profile:e.summary?a:n.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:n.findings.slice(0,e.limit)}}}function Pr(e){let t=e.limit,n={};e.kinds!==void 0&&(n.kinds=e.kinds);let r=it(e.assembly.graph,n),i=r.value;return{subcommand:"communities",community_count:i.communities.length,largest_community_size:i.communities[0]?.size??0,iterations:i.iterations,converged:i.converged,truncated:!i.converged||i.communities.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{communities:i.communities.slice(0,t).map(s=>({representative:s.representative,size:s.size,members:s.members.slice(0,t)}))}}}function Lr(e){let t;try{t=A(e.assembly.graph,{...e.kinds===void 0?{}:{kinds:e.kinds},...e.maxDepth===void 0?{}:{maxDepth:e.maxDepth},limit:e.limit})}catch(n){ye(n)}return{subcommand:"redundancy",redundant_count:t.value.length,...be(t.meta),...e.summary?{}:{redundant:t.value.map(n=>({source:n.edge.source,target:n.edge.target,kind:n.edge.kind,witness:n.witness}))}}}function Fr(e,t){let n=t.limit,r=st(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=r.value.rows.filter(s=>s.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:r.value.reachableCount,bottleneck_count:i.length,truncated:r.meta.truncated||i.length>n,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,n).map(s=>({id:s.id,idom:s.idom,dominated_count:s.dominatedCount}))}}}function Gr(e){let t=e.limit,n=lt(e.assembly.graph),r=n.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:n.acyclic,makespan:n.makespan,scheduled_count:n.scheduledCount,critical_count:r,critical_path_length:n.criticalPathLength,cycle_count:n.cycles.length,truncated:n.rows.length>t,...e.summary?{}:{critical_path:n.criticalPath.slice(0,t),rows:n.rows.slice(0,t).map(i=>({id:i.id,earliest_start:i.earliestStart,latest_start:i.latestStart,slack:i.slack,critical:i.critical}))}}}function $r(e){let t=e.limit,n=dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),r=n.value;return{subcommand:"centrality",node_count:r.nodeCount,edge_count:r.edgeCount,edge_basis:"simple_undirected",truncated:r.rows.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{rows:r.rows.slice(0,t).map(i=>({id:i.id,degree:i.degree,in_degree:i.inDegree,out_degree:i.outDegree,betweenness:i.betweenness,closeness:i.closeness}))}}}function qr(e){let t=e.limit,n=X(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:r,bridges:i}=n.value;return{subcommand:"articulation",articulation_count:r.length,bridge_count:i.length,truncated:r.length>t||i.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{articulation_points:r.slice(0,t),bridges:i.slice(0,t)}}}function Ur(e,t){let n=e.limit,r=jt(e.assembly,{isTerminal:t,redundancyLimit:n,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},s={};for(let o of r.steps)i[o.op]=(i[o.op]??0)+1,s[o.code]=(s[o.code]??0)+1;return{subcommand:"plan",step_count:r.steps.length,steps_by_op:i,steps_by_code:s,finding_count:r.report.findings.length,truncated:r.truncated||r.steps.length>n,cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...e.summary?{}:{steps:r.steps.slice(0,n)}}}function Gt(e,t,n,r){return JSON.stringify({projection_version:2,subcommand:e,root:t??null,target:n??null,kinds:r.kinds??null,maxDepth:r.maxDepth??null,limit:r.limit,after:r.after??null,direction:r.direction,maxPaths:r.maxPaths??null,sample:r.sample,exemptIsolates:[...new Set(r.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(r.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:r.summary,unbounded:r.unbounded})}function $t(e,t,n,r,i){return e==="analyze"?jr(r):e==="audit"?Mr(r,i):e==="plan"?Ur(r,i):e==="communities"?Pr(r):e==="redundancy"?Lr(r):e==="dominators"?Fr(t,r):e==="slack"?Gr(r):e==="centrality"?$r(r):e==="articulation"?qr(r):e==="paths"?Ar(t,n,r):e==="impact"?Tr(t,r):Nr(e,t,r)}function Br(e,t){if(e!=="index"&&(t.rebuild===!0||t.clear===!0))throw new x("--rebuild and --clear apply only to graph index.",v.USAGE);if(e!=="audit"&&t.saveBaseline===!0)throw new x("--save-baseline applies only to graph audit.",v.USAGE);if(e==="slack"&&t.kind!==void 0)throw new x("graph slack analyzes every ordering kind; --kind is not supported.",v.USAGE);if(t.rebuild===!0&&t.clear===!0)throw new x("graph index accepts either --rebuild or --clear, not both.",v.USAGE);if(t.full===!0&&t.limit!==void 0)throw new x(`graph ${e} accepts either --full or --limit, not both.`,v.USAGE)}async function zr(e,t,n,r,i,s){let o="status";if(s.clear===!0&&(await me(e),o="cleared"),s.rebuild===!0){await me(e);let a=await pe(e,t),d={assembly:n.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,limit:k.rows,sample:k.samples,unbounded:!1};for(let l of["analyze","audit"])await he(e,t,a,Gt(l,void 0,void 0,d),$t(l,void 0,void 0,d,i));o="rebuilt"}let c=await At(e,t);return{subcommand:"index",action:o,state:c.exists?c.fresh?"fresh":"stale":"absent",entry_count:c.entry_count,item_count:r,min_items_threshold:fe,persist_enabled:_e(r,c.exists),current_fingerprint:t.slice(0,12),...c.saved_at===void 0?{}:{saved_at:c.saved_at},...c.bytes===void 0?{}:{bytes:c.bytes}}}async function Hr(e,t,n,r){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:n.affected_subjects_by_code,profile:{...n.profile,finding_subjects_by_code:Object.fromEntries(R.map(o=>[o,n.affected_subjects_by_code[o]??0]))}},s=await Rt(e);return r&&await Dt(e,i),s===void 0?n:{...n,baseline:Et(s,i)}}async function Kr(e,t,n,r,i){try{await he(e,t,n,r,i)}catch{}}function Vr(e,t,n,r){if(e.subcommand!=="slack")return;let i=new Set(t.assembly.details.filter(u=>r(u.status)).map(u=>u.id)),s=t.assembly.graph,o=new xe(s.nodes().filter(u=>!i.has(u)),s.edges().filter(u=>!i.has(u.source)&&!i.has(u.target)),s.registry()),c=ut(o,n.filter(u=>!i.has(u.id)),{now:Ce(),limit:t.limit}),{rows:a,residuals:d,overcommitted:l,...f}=c;e.deadline_schedule={population:"active",...f,...t.summary?{}:{rows:a,residuals:d,overcommitted:l}}}async function rs(e,t,n,r,i){let s=Cr(e,t,n);Re(r.summary===!0,r.full===!0,"--summary");let o=Ie(process.cwd(),i.path);await Pe(o);let c=await Me(o),a=Ee(c,Te()),d=await Le(o,c.item_format,a.type_to_folder,void 0,c.schema),l=Se(c.schema),f=qt=>Ne(qt,l);Br(s,r);let u=Fe(),g=ze(r.kind,u),p=qe().lookup(o,$e(d,f,u),()=>Ge(d,f,u)),m=Sr(s,p.assembly,g,r);if(s==="index")return Mt(await zr(o,p.fingerprint,m,d.length,f,r),!1);let b=Ft.has(s)?Lt(m.assembly,t):void 0,w=s==="paths"?Lt(m.assembly,n):void 0,h=Gt(s,b,w,m),_=await pe(o,p.fingerprint),I=_.results[h],S=p.memoize(h,()=>I!==void 0?structuredClone(I):$t(s,b,w,m,f)),we=_e(d.length,_.exists);!S.reused&&I===void 0&&we&&await Kr(o,p.fingerprint,_,h,S.value);let ne=S.value.subcommand==="audit"?await Hr(o,p.fingerprint,S.value,m.saveBaseline):S.value;return ne.cache={fingerprint:p.fingerprint.slice(0,12),assembly:p.assemblyReused?"hit":"miss",result:S.reused?"hit":"miss",durable:I!==void 0?"hit":we?"miss":"off"},Vr(ne,m,d,f),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,A as l,st as m,dt as n,X as o,lt as p,ut as q,tr as r,kt as s,Z as t,ue as u,ee as v,Et as w,St as x,fe as y,F as z,Nt as A,pe as B,he as C,me as D,At as E,_e as F,Rt as G,Dt as H,jt as I,Cr as J,rs as K};
2
+ //# sourceMappingURL=chunk-JUG3BAZZ.js.map
@@ -0,0 +1,2 @@
1
+ import{ua as l}from"./chunk-NSFS3VWP.js";import{k as y,m,n as f,o as h}from"./chunk-R6QFPHWW.js";import{z as a}from"./chunk-NGFDPEP7.js";var R=[{exit_code:a.SUCCESS,outcome:"effect",success:!0,meaning:"The requested operation completed with its intended effect."},{exit_code:a.GENERIC_FAILURE,outcome:"internal_failure",success:!1,meaning:"An unexpected runtime or internal failure prevented completion."},{exit_code:a.USAGE,outcome:"refused_input",success:!1,meaning:"The invocation was refused because its input or composition was invalid."},{exit_code:a.NOT_FOUND,outcome:"refused_tracker_state",success:!1,meaning:"The requested tracker, item, or resource was not present."},{exit_code:a.CONFLICT,outcome:"conflict",success:!1,meaning:"Current state or concurrency prevented the requested effect."},{exit_code:a.DEPENDENCY_FAILED,outcome:"dependency_failed",success:!1,meaning:"A required dependency operation failed."},{exit_code:a.NO_EFFECT,outcome:"no_effect",success:!0,meaning:"The request was valid and completed, but matched nothing to change."},{exit_code:a.PARTIAL_EFFECT,outcome:"partial_effect",success:!0,meaning:"The request completed and changed some, but not all, selected targets."}],b=[a.SUCCESS,a.GENERIC_FAILURE,a.USAGE,a.NOT_FOUND,a.CONFLICT,a.DEPENDENCY_FAILED],I=new Set(["close-many","update-many"]),w=l.map(t=>({command:t,exit_codes:I.has(t)?[...b,a.NO_EFFECT,a.PARTIAL_EFFECT]:[...b]})),v=new Map(w.map(t=>[t.command,t])),D=[a.SUCCESS,a.NO_EFFECT,a.PARTIAL_EFFECT];function Ee(t){return D.includes(t)}function Ae(t){return R.some(e=>e.exit_code===t)}function Oe(t){let e=t.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(" ");return v.get(e)??v.get(e.split(" ")[0])}function Te(t,e=l,s=w){let o=new Map(s.map(r=>[r.command,r])),i=e.filter(r=>!o.has(r)),n=t.filter(r=>{let _=o.get(r.command)??o.get(r.command.split(" ")[0]);return _===void 0||!_.exit_codes.includes(r.exit_code)}),d=new Set(t.map(r=>r.exit_code)),c=[...new Set(s.flatMap(r=>r.exit_codes))].filter(r=>!d.has(r)).sort((r,_)=>r-_);return{ok:i.length===0&&n.length===0&&c.length===0,missing_commands:i,undeclared_observations:n,unreachable_exit_codes:c}}function Se(t){return t.applied===0&&t.failed>0?{outcome:"dependency_failed",exit_code:a.DEPENDENCY_FAILED}:t.applied===0?{outcome:"no_effect",exit_code:a.NO_EFFECT}:t.skipped>0||t.failed>0||t.unmatched>0?{outcome:"partial_effect",exit_code:a.PARTIAL_EFFECT}:{outcome:"effect",exit_code:a.SUCCESS}}var g=[{exit_code:1,class:"generic_failure"},{exit_code:2,class:"usage"},{exit_code:3,class:"not_found"},{exit_code:4,class:"conflict"},{exit_code:5,class:"dependency_failed"}],q=new Map(g.map(t=>[t.exit_code,t.class]));function x(t){return[...new Set(t.map(e=>e.trim()).filter(Boolean))].sort()}function L(t){if(!t)return[];let e=new Set,s=new Set;return t.map(o=>{let i=o.state.trim(),n=o.probe_id.trim(),d=x(o.entrypoints);if(!/^[a-z][a-z0-9_]*$/.test(i)||!/^[a-z][a-z0-9-]*$/.test(n)||d.length===0||e.has(i)||s.has(n))throw new TypeError("Invalid pm refusal state contract");return e.add(i),s.add(n),{state:i,probe_id:n,entrypoints:d,expected_exit_class:o.expected_exit_class}}).sort((o,i)=>o.state.localeCompare(i.state))}function j(t,e,s,o,i){return![[1,2,3,4,5].includes(t.exit_code),t.meaning.trim().length>0,t.recovery.trim().length>0,e.length>0,s.length>0,/^[a-z][a-z0-9_]*$/.test(o),i.every(n=>/^[a-z][a-z0-9_]*$/.test(n)),q.get(t.exit_code)===t.class].includes(!1)}function F(t,e){let s=t,o=new Set;for(;s.canonical_code!==s.code;){if(o.has(s.code))throw new TypeError(`Alias cycle in pm error code catalog: ${t.code}`);o.add(s.code);let i=e.get(s.canonical_code);if(!i)throw new TypeError(`Invalid pm error code contract: ${t.code}`);s=i}return s}function $(t){let e=new Map(t.map(s=>[s.code,s]));for(let s of t){let o=F(s,e);if(o.exit_code!==s.exit_code||o.class!==s.class)throw new TypeError(`Alias transport mismatch for pm error code: ${s.code}`);let i=t.filter(n=>n.code!==o.code&&n.canonical_code===o.code).map(n=>n.code).sort();if(s.code===o.code?JSON.stringify(s.aliases)!==JSON.stringify(i):s.aliases.length>0)throw new TypeError(`Invalid pm error code contract: ${s.code}`)}}function E(t){let e=new Set,s=t.map(o=>{let i=o.code.trim();if(!/^[a-z][a-z0-9_]*$/.test(i))throw new TypeError(`Invalid pm error code: ${JSON.stringify(o.code)}`);if(e.has(i))throw new TypeError(`Duplicate pm error code: ${i}`);e.add(i);let n=x(o.sources),d=x(o.emitting_commands),u=(o.canonical_code??i).trim(),c=x(o.aliases??[]),r=L(o.owned_states);if(!j(o,n,d,u,c))throw new TypeError(`Invalid pm error code contract: ${i}`);if(r.some(_=>_.expected_exit_class!==o.class))throw new TypeError(`Invalid pm refusal state exit class: ${i}`);return Object.freeze({...o,code:i,meaning:o.meaning.trim(),recovery:o.recovery.trim(),sources:n,emitting_commands:d,canonical_code:u,aliases:c,owned_states:r})});return $(s),Object.freeze(s.sort((o,i)=>o.code.localeCompare(i.code)))}function Ne(t,e){let s=C(t,e);return C(s.canonical_code??s.code,e)}function C(t,e){let s=t.trim(),o=e.find(i=>i.code===s);if(!o)throw new TypeError(`Unknown pm error code "${s}"`);return o}var z="Inspect the structured error guidance, then retry the suggested command when one is present.",U=new Map(g.map(t=>[t.exit_code,t.class]));function A(t){return t.map(e=>{let s=`${e.code.replaceAll("_"," ")} condition.`,o={code:e.code,meaning:`${s.charAt(0).toUpperCase()}${s.slice(1)}`,stability:e.stable?"stable":"provisional",exit_code:e.exit_code,class:U.get(e.exit_code),recovery:z,sources:e.sources,emitting_commands:e.emitting_commands??["*"],canonical_code:e.canonical_code??e.code,aliases:e.aliases??[]};return e.owned_states&&(o.owned_states=e.owned_states),o})}var O=[{code:"acceptance_criteria_mutation_conflict",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_remove_unmatched",exit_code:3,sources:["sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_semicolon_forbidden",exit_code:2,stable:!0,sources:["core/item/parse.ts"]},{code:"accepted_rejected_value",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"alias_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"alias_target_missing",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"already_claimed_by",exit_code:4,stable:!0,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"ambiguous_option_combination",exit_code:2,stable:!0,sources:["sdk/lifecycle/claim.ts","sdk/lifecycle/plan.ts"],emitting_commands:["claim","plan"]},{code:"annotation_alias_conflict",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"annotation_entry_mismatch",exit_code:4,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_invalid",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_without_target",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_flag_like_value",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_if_absent_without_append",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_message_without_text",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_text_compacted",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_text_source_conflict",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"annotation_transposed_subcommand",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"append_empty_body",exit_code:2,stable:!0,sources:["sdk/lifecycle/append.ts"],emitting_commands:["append"]},{code:"assurance_registry_invalid",exit_code:1,sources:["sdk/governance/assurance.ts"]},{code:"bare_comma_entry_ambiguous",exit_code:2,sources:["core/item/parse.ts"]},{code:"blocker_identity_read_failed",exit_code:1,sources:["sdk/query/declared-blockers.ts"]},{code:"body_file_conflicts_with_body",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_missing_path",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_unreadable",exit_code:3,stable:!0,sources:["core/io/body-file.ts"]},{code:"budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"bulk_create_route",exit_code:2,sources:["cli/register-mutation.ts"]},{code:"bulk_ids_input_empty",exit_code:2,sources:["core/io/bulk-ids-input.ts","sdk/history-compact.ts","sdk/history-mcp.ts"],owned_states:[{state:"bulk_ids_stdin_contains_no_nonempty_ids",probe_id:"bulk-ids-stdin-empty",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_missing_path",exit_code:2,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_token_omits_its_path",probe_id:"bulk-ids-file-path-missing",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_unreadable",exit_code:3,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_path_cannot_be_read",probe_id:"bulk-ids-file-unreadable",entrypoints:["update-many"],expected_exit_class:"not_found"}]},{code:"bundle_integrity_torn_install",exit_code:1,stable:!0,sources:["cli/bundle-integrity.ts"]},{code:"capability_undeclared",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"capability_unused",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"child_projection_item_bound_exceeded",exit_code:1,stable:!0,sources:["sdk/item-children.ts"]},{code:"close_reason_required",exit_code:2,stable:!0,sources:["sdk/lifecycle-policy.ts","sdk/lifecycle/close-many.ts"],emitting_commands:["*","close-many"]},{code:"close_through_update",exit_code:1,stable:!0,sources:["core/telemetry/observability.ts"]},{code:"close_validation_deferred_fields",exit_code:2,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"close_validation_missing_fields",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"collected_zero_items",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"collection_transposed_subcommand",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"command_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"command_namespace",exit_code:2,stable:!0,sources:["sdk/cli-contracts/runtime-contracts.ts"]},{code:"command_override_conflict",exit_code:4,stable:!0,sources:["sdk/compose.ts"]},{code:"config_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_key_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts","sdk/config.ts"]},{code:"config_value_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"conflicting_lifecycle_owner",exit_code:2,stable:!0,sources:["cli/register-operations.ts"]},{code:"context_evaluation_read_incomplete",exit_code:2,sources:["sdk/context-relevance.ts"]},{code:"context_signal_store_invalid",exit_code:2,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_stale",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_write_failed",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_takes_no_item_argument",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"core_item_field_requires_dedicated_flag",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"create_deferral_conflict",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_field_unsupported",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_fields_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_reason_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_positional_type_without_title",exit_code:2,stable:!0,sources:["cli/register-mutation.ts"]},{code:"dependency_cardinality_created",exit_code:2,sources:["sdk/graph/cardinality-integrity.ts"]},{code:"dependency_edge_not_allowed",exit_code:2,stable:!0,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_flag_value_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_remove_no_match",exit_code:3,sources:["sdk/lifecycle/dependency-removal.ts"],emitting_commands:["update"]},{code:"dependency_target_not_found",exit_code:3,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_temporal_order_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"duplicate_canonical_flag",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"duplicate_command",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"duplicate_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"duplicate_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"duplicate_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"duplicate_probe",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"duplicate_sweep_cost_limit",exit_code:4,stable:!0,sources:["sdk/query/duplicate-candidates.ts"],emitting_commands:["duplicate-candidates"]},{code:"duplicate_target_circular",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_is_duplicate",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_missing",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_self",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"empty_corpus",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"empty_surface",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"event_cursor_query_mismatch",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"event_history_integrity_failed",exit_code:1,sources:["core/history/event-index.ts"]},{code:"event_index_unavailable",exit_code:1,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"exit_code_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"expect_hash_background_unsupported",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invalid",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invocation_rewritten",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_requires_mutation",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_target_required",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expected_revision_duplicate",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"expected_revision_scope_conflict",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"extension_command_activation_failed",exit_code:1,stable:!0,sources:["cli/commander-usage.ts"]},{code:"extension_dependency_name_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_spec_invalid",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_version_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_flag_value_invalid",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_install_incomplete_source_scan",exit_code:2,sources:["sdk/extension/install-plan.ts"]},{code:"extension_install_rollback_failed",exit_code:1,sources:["sdk/extension/install-snapshot.ts"]},{code:"extension_install_soft_failed",exit_code:1,stable:!0,sources:["cli/register-setup.ts"]},{code:"extension_install_source_contains_destination",exit_code:2,stable:!0,sources:["sdk/extension/install-runtime.ts"]},{code:"extension_item_field_reserved",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_type_conflict",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_unknown",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_mutation_guard_failed",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_decision",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_denial",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_timed_out",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_option_disabled",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_option_spelling_conflict",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_read_output_invalid",exit_code:2,sources:["sdk/read-output/extension.ts"]},{code:"extension_update_health_partial_coverage",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"extensions_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"field_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_flag_invalid",exit_code:2,sources:["core/profile/profile-lint.ts"]},{code:"field_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_mcp_input_collision",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_option_collision",exit_code:1,sources:["core/profile/profile-lint.ts"]},{code:"finalization_invalid_document",exit_code:2,sources:["sdk/transactions/item-finalization.ts"]},{code:"github_source_entry_unbuilt",exit_code:2,stable:!0,sources:["sdk/extension/shared.ts"]},{code:"hierarchy_cardinality_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_cycle_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_parent_divergence_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"history_append_only_repair_unavailable",exit_code:4,sources:["sdk/history/append-only-repair.ts"]},{code:"history_author_acknowledge_plan_conflict",exit_code:4,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_plan_fingerprint_required",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_preview_limit_invalid",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_required_values_missing",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_conflict",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_required",exit_code:2,stable:!0,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_not_actionable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_unreadable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_baseline_unavailable",exit_code:1,sources:["core/history/projection.ts"]},{code:"history_compact_boundary_bridged",exit_code:2,sources:["sdk/history-compact.ts"]},{code:"history_drift_chain_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_chain_mismatches"]},{code:"history_drift_chain_unbridgeable",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_hash_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_hash_mismatches"]},{code:"history_drift_merge_receipt",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_missing_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_missing_streams"]},{code:"history_drift_unreadable_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_unreadable_streams"]},{code:"history_drift_unrepairable_stream",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_version_skew",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_version_skews"]},{code:"history_json_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/history/read.ts"],canonical_code:"merge_conflict_markers_detected"},{code:"history_record_integrity_invalid",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_record_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_record_version_unsupported",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_redact_bridge_unlocated",exit_code:1,sources:["sdk/history-redact.ts"]},{code:"history_replay_invalid",exit_code:1,sources:["core/history/projection.ts","core/history/tombstone.ts"]},{code:"history_salvage_refused",exit_code:4,sources:["sdk/history/salvage.ts"]},{code:"history_stream_over_compact_threshold",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"history_target_out_of_range",exit_code:1,stable:!0,sources:["core/history/projection.ts"]},{code:"history_timestamp_invalid",exit_code:1,sources:["core/history/event-index.ts","core/history/history.ts"]},{code:"history_union_rebase_conflict",exit_code:4,sources:["sdk/merge/history-scalar-rebase.ts"]},{code:"history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_unknown_author_events"]},{code:"history_version_mapping_unavailable",exit_code:2,sources:["core/history/version-address.ts"]},{code:"history_version_pruned",exit_code:2,sources:["core/history/projection.ts"]},{code:"history_version_unreconstructable",exit_code:2,sources:["core/history/projection.ts"]},{code:"host_environment_capacity_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_operation_invalid",exit_code:2,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_permission_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_resource_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"improvement_metric_contract_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"improvement_observation_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"in_progress_idle",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"in_progress_unowned",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"incomplete_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"inconsistent_concept_kind",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"init_existing_settings_requires_force",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_gitignore_unwritable",exit_code:1,stable:!0,sources:["sdk/workspace.ts"]},{code:"init_id_prefix_conflict",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_id_prefix_path_like",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"integrity_history_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_history_conflict_markers"]},{code:"integrity_history_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_history_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_ahead_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_ahead_items"]},{code:"integrity_item_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_outdated_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_outdated_items"]},{code:"integrity_item_parse_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"invalid_argument_value",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/item/priority.ts","core/shared/url-credentials.ts","core/telemetry/observability.ts","sdk/config.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/extension/listing-fields.ts","sdk/extension/static-inventory.ts","sdk/governance/assurance-mutation-error.ts","sdk/history-redact.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/linked-artifacts.ts","sdk/query/next.ts","sdk/runtime-input.ts","sdk/runtime.ts","sdk/runtime/mutation-admission.ts","sdk/runtime/mutation-value-validation.ts","sdk/runtime/schema-preview.ts","sdk/test/run-phases.ts","sdk/workspace.ts"],emitting_commands:["*","create","next","task-composition","update","update-many"]},{code:"invalid_command_usage",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"invalid_event_cursor",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_cursor_mode",exit_code:2,sources:["cli/register-list-query.ts","sdk/mutation-events.ts","sdk/runtime-extended-actions.ts"]},{code:"invalid_event_follow_interval",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_limit",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_since",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_history_analytics_limit",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_minimum_sample",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_since",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_improvement_ledger",exit_code:1,sources:["sdk/improvement-ledger-validation.ts"]},{code:"invalid_improvement_metric",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_limit",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_timestamp",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_provenance_predicate",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"invalid_query_cursor",exit_code:2,stable:!0,sources:["sdk/pagination.ts","sdk/query/window-pagination.ts"]},{code:"invalid_read_output_session",exit_code:2,sources:["sdk/read-output-session.ts"]},{code:"invalid_reproducible_process_environment",exit_code:2,sources:["sdk/reproducibility/process.ts"]},{code:"invalid_workspace_snapshot_target",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"item_already_active",exit_code:4,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"item_already_exists",exit_code:4,stable:!0,sources:["sdk/lifecycle/create.ts"],emitting_commands:["create"]},{code:"item_deleted",exit_code:3,sources:["core/history/tombstone.ts"]},{code:"item_document_encoding_invalid",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_document_invalid",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_document_roundtrip_failed",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_format_version_unsupported",exit_code:4,sources:["core/item/item-format.ts"]},{code:"item_id_collision",exit_code:4,stable:!0,sources:["sdk/lifecycle/copy.ts"],emitting_commands:["copy"]},{code:"item_identity_ambiguous",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_identity_conflict",exit_code:4,sources:["sdk/governance/validate-history-drift.ts","sdk/lifecycle/item-revision.ts","sdk/merge/three-way.ts","sdk/query/declared-blockers.ts"]},{code:"item_identity_reserved",exit_code:4,sources:["core/history/history.ts"]},{code:"item_not_found",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/item-store.ts","core/telemetry/observability.ts","sdk/governance/validate-history-drift.ts"]},{code:"item_revision_conflict",exit_code:4,sources:["core/store/item-mutation-precondition.ts"]},{code:"likely_duplicate",exit_code:4,stable:!0,sources:["sdk/similarity.ts"]},{code:"linked_artifact_mutation_conflict",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_conflict",exit_code:4,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_key_misread",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_resource_positional_value",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_test_command_immutable",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_command_not_executable",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_context_invalid",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_patch_fields_unsupported",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_remove_no_match",exit_code:3,sources:["sdk/test/execution.ts"]},{code:"linked_test_update_ambiguous",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_update_no_match",exit_code:3,sources:["sdk/test/update.ts"]},{code:"linked_test_value_not_quoted",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"list_source_incomplete",exit_code:1,stable:!0,sources:["sdk/query/list.ts"],emitting_commands:["list"]},{code:"local_package_archive_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"local_source_not_found_bare_name",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"lock_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/lock/lock.ts","core/telemetry/observability.ts"]},{code:"lock_lost",exit_code:4,sources:["core/lock/lock.ts"]},{code:"lock_path_unsafe",exit_code:4,sources:["core/lock/lock-confinement.ts"]},{code:"locks_stale_count",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"locks_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"malformed_plan_step_evidence",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"managed_state_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"managed_state_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_capabilities_absent",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"manifest_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_unknown_key",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_declares_an_unknown_top_level_key",probe_id:"author-manifest-unknown-key",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"manifest_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"mcp_annotation_file_unavailable",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"mcp_stdin_unavailable",exit_code:2,sources:["sdk/annotations.ts"]},{code:"mcp_task_not_found_or_not_authorized",exit_code:3,sources:["sdk/mcp/tasks.ts"]},{code:"merge_artifacts_ignored",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_bun_launcher_unavailable",exit_code:5,sources:["sdk/merge/install.ts"]},{code:"merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/item/item-format.ts"],aliases:["history_merge_conflict_markers_detected"]},{code:"merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]}];var T=[{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]},{code:"merge_receipt_history_reference_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_receipt_not_portable",exit_code:4,sources:["sdk/merge/receipts.ts"]},{code:"merge_receipts_pending",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_reconcile_receipt_evidence_untrusted",exit_code:4,sources:["sdk/history-repair.ts"]},{code:"merge_root_not_found",exit_code:3,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_settlement_hook_conflict",exit_code:4,sources:["sdk/merge/settlement-hook.ts"]},{code:"merge_settlement_review_required",exit_code:4,sources:["sdk/merge/ignored-artifacts.ts","sdk/merge/reconcile.ts","sdk/merge/stage.ts"]},{code:"missing_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"missing_cli_flag",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_directory",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"missing_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_lifecycle_target",exit_code:2,stable:!0,sources:["sdk/extension.ts"]},{code:"missing_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"missing_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_parameter_alias",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_positive_execution_receipt",exit_code:1,sources:["sdk/test/execution.ts"]},{code:"missing_probe",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_required_argument",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/main.ts","cli/register-mutation.ts","cli/schema/registration.ts","core/telemetry/observability.ts","sdk/governance/assurance-action.ts","sdk/history-redact.ts","sdk/invocation-author.ts","sdk/lifecycle/claim.ts","sdk/linked-artifacts.ts"],emitting_commands:["*","claim"]},{code:"missing_required_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/context-intent-contracts.ts","sdk/extension/command-options.ts","sdk/lifecycle/create.ts","sdk/lifecycle/plan.ts"],emitting_commands:["*","create","plan"]},{code:"missing_suggested_retry",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_suggested_retry_args",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"module_import_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"multi_target_github_install_ambiguous",exit_code:2,stable:!0,sources:["cli/register-setup.ts"]},{code:"mutation_author_required",exit_code:2,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"mutation_document_unreadable",exit_code:2,sources:["cli/register-structured-mutation.ts"]},{code:"mutation_option_value_invalid",exit_code:2,sources:["sdk/lifecycle/mutation-option-validation.ts"],emitting_commands:["item mutate"]},{code:"mutation_secret_guard_blocked",exit_code:4,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"no_matching_tests",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_projects_matched_filters",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_test_files_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_tests_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_update_fields",exit_code:1,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"no_version_bounds_declared",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_omits_canonical_pm_version_bounds",probe_id:"author-manifest-version-bounds-missing",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"non_refusal_exit",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"npm_pack_json_shape_unsupported",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_missing",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_unsafe",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_not_found",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"npm_source_shorthand_ambiguous",exit_code:2,sources:["sdk/extension/install-sources.ts"]},{code:"output_budget_exceeded",exit_code:2,sources:["sdk/testing.ts"]},{code:"ownership_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/annotations.ts"]},{code:"ownership_dependency_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"ownership_metadata_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"package_spec_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"package_upgrade_modes_mutually_exclusive",exit_code:2,sources:["sdk/governance/upgrade.ts"]},{code:"positional_shape_budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"positional_signature_mismatch",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"profile_name_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_name_not_normalized",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_summary_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_title_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"project_runtime_history_epoch_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_item_format_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_mutation",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_read",exit_code:1,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_schema_field_requires_declared_flag",exit_code:2,sources:["core/extensions/item-fields.ts"]},{code:"projection_options_mutually_exclusive",exit_code:2,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"provenance_value_domain_invalid",exit_code:2,sources:["core/diagnostics/remediation.ts"]},{code:"read_output_cursor_command_mismatch",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_invalid",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_stale",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_mutation_conflict",exit_code:2,sources:["sdk/read-output-contracts.ts"]},{code:"read_output_surface_unsupported",exit_code:2,sources:["sdk/extension/static-inventory.ts","sdk/read-output-contracts.ts"]},{code:"recovery_kind_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"redundant_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"refusal_allowed_values_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_exit_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_mutated_state",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_probe_missing",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_recovery_failed",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"reindex_already_running",exit_code:4,stable:!0,sources:["sdk/governance/reindex.ts"]},{code:"removed_canonical_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"removed_compatibility_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"reopen_reason_required",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reopen_receipt_missing",exit_code:1,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"reopen_target_status_invalid",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reported_zero_passes",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reported_zero_tests",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reserved_item_field",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"retry_failed",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"schema_field_flag_invalid",exit_code:2,sources:["sdk/schema/field-option-collisions.ts"]},{code:"schema_field_option_collision",exit_code:2,sources:["sdk/schema/field-option-collisions.ts"]},{code:"schema_migration_input_required",exit_code:2,stable:!0,sources:["cli/migration-gates.ts"]},{code:"semantic_spelling_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"settings_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_read_fs_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_schema",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_merge_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_section_document_malformed",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_document_missing",exit_code:3,sources:["core/store/settings-sections.ts"]},{code:"settings_section_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_name_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_reserved",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_revision_conflict",exit_code:4,sources:["core/store/settings-sections.ts"]},{code:"settings_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_write_assigned_path_invalid",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_json",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_schema",exit_code:2,sources:["core/store/settings.ts"]},{code:"stale_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"stale_claim_takeover_refused",exit_code:4,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"stale_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_in_progress_items",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"stale_lock_requires_override",exit_code:4,sources:["core/lock/lock.ts"]},{code:"stale_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_revision",exit_code:4,sources:["core/store/item-store.ts"]},{code:"start_blocked_by_open_dependency",exit_code:4,sources:["sdk/lifecycle/start-blockers.ts"],emitting_commands:["claim","start-task","update"]},{code:"status_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_lifecycle_role_required",exit_code:2,sources:["sdk/schema.ts"]},{code:"stdin_json_invalid",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"stdin_json_persisted_annotation_changed",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"stdin_json_unknown_key",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"structured_entry_key_repeated",exit_code:2,sources:["core/item/parse.ts"]},{code:"structured_event_immutable",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"structured_event_input_conflict",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_empty",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_since_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"suggested_retry_args_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"telemetry_endpoint_probe_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_endpoint_probe_http_status",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_otel_export_failing",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_high_retries",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_invalid_rows",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_pending",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_schema_version_behind",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_state_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"template_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"terminal_plan_mutation",exit_code:4,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"terminal_state_conflict",exit_code:4,stable:!0,sources:["core/telemetry/observability.ts","sdk/lifecycle/claim.ts"],emitting_commands:["*","claim"]},{code:"test_measure_requires_execution",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"test_measure_requires_run",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"text_unpaired_surrogate",exit_code:2,sources:["core/item/item-format.ts","core/shared/output-unicode.ts"]},{code:"tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_tracked_runtime_cache_files"]},{code:"tracker_not_initialized",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/tracker-preflight.ts","core/telemetry/observability.ts"],owned_states:[{state:"selected_tracker_root_exists_without_settings",probe_id:"tracker-root-settings-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_missing",exit_code:3,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_does_not_exist",probe_id:"tracker-root-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_not_directory",exit_code:2,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_a_regular_file",probe_id:"tracker-root-not-directory",entrypoints:["list"],expected_exit_class:"usage"}]},{code:"tracker_root_unreadable",exit_code:1,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_not_readable",probe_id:"tracker-root-unreadable",entrypoints:["list"],expected_exit_class:"generic_failure"}]},{code:"transaction_abandoned",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_committed",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_create_compensated",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_journal_invalid",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_partial_mutation",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_plan_mismatch",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_preview_external_schema",exit_code:2,sources:["sdk/item-transaction.ts"]},{code:"transaction_preview_non_regular_file",exit_code:2,sources:["core/fs/fs-utils.ts"]},{code:"transaction_preview_snapshot_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_recovery_plan_missing",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"type_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"type_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"undeclared_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"unexpected_refusal_probe",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"unknown_command",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/cli-contracts/runtime-contracts.ts"]},{code:"unknown_context_intent",exit_code:2,stable:!0,sources:["sdk/context-intent-contracts.ts"]},{code:"unknown_error",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"unknown_field",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_field_projection",exit_code:2,stable:!0,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"unknown_item_type",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_lifecycle_action",exit_code:2,stable:!0,sources:["sdk/agent/subcommand-recovery.ts"],canonical_code:"unknown_subcommand"},{code:"unknown_noun",exit_code:2,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"unknown_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/runtime/invocation-options.ts","core/telemetry/observability.ts","sdk/extension/command-options.ts"],owned_states:[{state:"declared_option_is_rejected_on_the_selected_command_path",probe_id:"cross-command-unknown-option",entrypoints:["deps"],expected_exit_class:"usage"}]},{code:"unknown_plan_template",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"unknown_provenance_dimension",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"unknown_status",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_subcommand",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","sdk/agent/subcommand-recovery.ts"],aliases:["unknown_lifecycle_action"],owned_states:[{state:"config_action_token_is_not_declared",probe_id:"config-unknown-action",entrypoints:["config"],expected_exit_class:"usage"},{state:"graph_command_token_is_not_declared",probe_id:"graph-unknown-subcommand",entrypoints:["graph"],expected_exit_class:"usage"},{state:"nested_command_token_is_not_declared_by_its_family",probe_id:"schema-unknown-subcommand",entrypoints:["schema"],expected_exit_class:"usage"},{state:"package_lifecycle_token_is_not_declared",probe_id:"package-unknown-action",entrypoints:["package"],expected_exit_class:"usage"}]},{code:"unsafe_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"unsupported_update_option",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"upsert_key_ambiguous",exit_code:4,sources:["sdk/structured-mutations.ts"]},{code:"upsert_key_conflict",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"upsert_key_duplicate",exit_code:2,sources:["sdk/item-transaction.ts","sdk/structured-mutations.ts"]},{code:"upsert_key_missing",exit_code:2,sources:["sdk/structured-mutations.ts"]},{code:"upsert_match_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"validate_command_references_stale_pm_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_missing_linked_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_orphaned_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_tracked_all_strict_forces_pm_internals",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_format_version_ahead_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_ahead_format_version"},{code:"validate_format_version_outdated_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_outdated_format_version"},{code:"validate_hierarchy_parent_cycle",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_hierarchy_parent_cycle_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_history_drift_chain_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_chain_mismatch"},{code:"validate_history_drift_hash_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_hash_mismatch"},{code:"validate_history_drift_missing_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_missing_stream"},{code:"validate_history_drift_unreadable_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_unreadable_stream"},{code:"validate_history_drift_version_skews",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_version_skew"},{code:"validate_history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_unknown_author_events"},{code:"validate_lifecycle_active_closure_like_metadata",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_active_terminal_parent",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_stale_blockers",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_driver_configuration",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_fence_drift",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_custom_profile_missing_required_fields",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_duplicate_issue_codes",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_acceptance_criteria",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_close_reason",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_closed_at",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_confidence",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_estimate",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_release",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_reviewer",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_risk",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_sprint",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_resolution_missing_fields",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_schema_field_option_collision",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_duplicate_item_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_history_conflict_markers",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_history_conflict_marker"},{code:"validate_storage_resurrected_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"tracked_runtime_cache_files"},{code:"validate_storage_unparseable_config",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unparseable_history",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unreadable_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_embedding_identity_changed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_stale_items_remaining",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"visible_surface_ceiling_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"workflow_duplicate_type",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_policy_approval_history_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_audit_failed",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_input_unreadable",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_invalid",exit_code:2,sources:["core/policy/workflow-policy.ts"]},{code:"workflow_policy_refused",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_registry_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_status_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_transition_malformed",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workspace_history_chain_invalid",exit_code:4,sources:["core/history/workspace-history.ts"]},{code:"workspace_history_state_conflict",exit_code:4,stable:!0,sources:["core/history/workspace-history.ts"]},{code:"workspace_root_pm_path",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"workspace_snapshot_force_required",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_manifest_mismatch",exit_code:4,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_name_reserved_fingerprint",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_not_found",exit_code:3,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_permission_denied",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_resource_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_storage_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"wrong_item_type",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]}];var ze=E(A([...O,...T]));var G=Object.freeze({"--body":"Set the item body.","--body-file":"Read the item body from a file, or from stdin when set to -.","--description":"Set the item description.","--stdin":"Read the value from stdin.","--stdin-json":"Read a complete JSON document from stdin."}),B=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),V=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),Y=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),X=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),W=["--allow-","--check-","--dry-run","--explain","--fail-","--fix-","--full","--has-","--include-","--json","--no-","--prune-","--quiet","--refresh-","--require-","--runtime-only","--schema-only","--skip-","--stream","--strict-","--summary","--today","--verbose"],H=new Set(["--activate","--active-only","--adopt","--adopt-all","--all","--all-actionable","--all-affected-ids","--all-day","--all-streams","--acknowledge-linked-tests","--append-stable","--auto-fix","--auto-pm-context","--availability-only","--background","--brief","--by-assignee","--by-priority","--by-tag","--catalog","--claim","--clear","--clear-comments","--clear-criteria","--clear-deps","--clear-docs","--clear-events","--clear-files","--clear-learnings","--clear-notes","--clear-reminders","--clear-tests","--clear-type-options","--cli-only","--closed","--compact","--completion","--count","--counts","--deactivate","--declarative","--defaults","--describe","--diff","--doctor","--empty-body","--explore","--field-utilization","--filter-empty-body","--flags-only","--follow","--force","--global","--highlight","--hybrid","--id-only","--if-available","--ignore-global","--include_unparented","--infer","--init","--install","--isolated","--lean","--list","--local","--manage","--markdown","--metadata-coverage","--next","--normalize-provenance","--only","--only-last","--output-row-contract","--override-linked-pm-context","--override-linked-workspace-context","--packages-only","--past","--phrase-exact","--profile","--progress","--project","--promote-to-item-dep","--provenance","--provenance-summary","--raw","--ready-only","--ready_only","--rebuild","--recent","--reload","--repair","--replace-deps","--replace-docs","--replace-files","--replace-tests","--required","--required-on-create","--run","--runtime-probe","--save-baseline","--scaffold","--semantic","--shared-host-safe","--storage","--takeover-stale","--title-exact","--token-accounting","--trace","--tree","--unbounded","--uninstall","--validate-paths","--verify","--watch","--with-packages"]),J=new Set(["--only-index"]),K=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),Q=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),Z=new Set(["--regression"]);function ee(t,e){return e==="--stdin"||e==="--stdin-json"?["stdin"]:Y.has(`${t}:${e}`)?["argv","file","stdin"]:e.endsWith("-file")?["argv","file"]:B.has(e)&&V.has(t)?["argv","stdin"]:["argv"]}function te(t,e){let s=K.has(`${t}:${e.flag}`)||e.value_name!==void 0||e.value_type==="string"||e.value_type==="number"||e.list===!0||e.repeatable===!0,o=e.value_type==="boolean"||e.flag==="--stdin"||e.flag==="--stdin-json"||e.flag.startsWith("--filter-")&&(e.flag.endsWith("-missing")||e.flag.startsWith("--filter-has-")||e.flag.startsWith("--filter-no-"))||W.some(i=>e.flag.startsWith(i));return s||J.has(e.flag)||!H.has(e.flag)&&!o}function se(t,e){return e.value_arity!==void 0?e.value_arity:te(t,e)?Z.has(e.flag)||Q.has(`${t}:${e.flag}`)?"optional":"required":"none"}function oe(t,e){let s=f(t),o=se(s,e),i=o!=="none",n=ee(s,e.flag),d=e.description??G[e.flag]??`${i?"Set":"Enable"} ${e.flag.slice(2).replaceAll("-"," ")}.`;return{...e,description:d,takes_value:i,value_required:o==="required",...i?{value_name:e.value_name??"value"}:{},value_type:i?e.value_type??"string":"boolean",required:e.required===!0,repeatable:e.repeatable===!0||e.list===!0,input_sources:n,...n.includes("stdin")&&e.flag!=="--stdin"&&e.flag!=="--stdin-json"?{stdin_token:"-"}:{},...X.has(`${s}:${e.flag}`)?{file_token_prefix:"@"}:{}}}function Be(t,e){return e.map(s=>oe(t,s))}function Ve(t,e,s){let o=t.trim().toLowerCase(),i=[],n=new Map,d=0;for(let c of s)if(c.command.trim().toLowerCase()===o){if(d+=1,n.has(c.flag)){i.push({code:"duplicate_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} was observed more than once.`});continue}n.set(c.flag,c)}let u=new Set(e.map(({flag:c})=>c));for(let c of e){let r=n.get(c.flag);if(!r){i.push({code:"missing_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} has no executable option observation.`});continue}for(let[_,P]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[_]!==r[_]&&i.push({code:P,command:o,flag:c.flag,detail:`${o} ${c.flag} declares ${_}=${String(c[_])} but the executable option reports ${String(r[_])}.`})}for(let c of n.values())u.has(c.flag)||i.push({code:"undeclared_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,r)=>c.flag.localeCompare(r.flag)||c.code.localeCompare(r.code)),{ok:i.length===0,declared_count:e.length,observed_count:d,findings:i}}var ie=["mutation_receipt","entity","collection","diagnostic","stream"],ce=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),re=new Set(["close-many","update-many"]),ne=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),ae=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function p(t){if(t.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!ie.includes(t.kind))throw new TypeError(`Unsupported output envelope kind: ${t.kind}`);return t}function S(t){let e=t.trim().replace(/\s+/gu," "),[s=e]=e.split(" ");return re.has(s)?p({command:e,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):ce.has(s)?p({command:e,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):ne.has(s)?p({command:e,kind:"collection",wrapper_key:s==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):ae.has(s)?p({command:e,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):p({command:e,kind:s==="get"?"entity":"diagnostic",wrapper_key:s==="get"?"item":null,cardinality:s==="get"?"one":"none",format_flag:"--json"})}var de=l.map(t=>S(t)),_e=new Map(de.map(t=>[t.command,t]));function He(t){let e=t.trim().replace(/\s+/gu," ");if(e.length===0)throw new TypeError("command must be a non-empty command path");let[s=e]=f(e).split(" "),o=_e.get(s);return o?{...o,command:e}:S(e)}function le(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ue(t){return le(t)&&typeof t.id=="string"&&t.id.length>0&&typeof t.status=="string"&&t.status.length>0&&Number.isSafeInteger(t.changed_field_count)&&Number(t.changed_field_count)>=0&&(t.close_reason===void 0||typeof t.close_reason=="string")&&(t.deleted===void 0||typeof t.deleted=="boolean")&&(t.previous_status===void 0||typeof t.previous_status=="string")&&(t.warnings===void 0||Array.isArray(t.warnings))}function Je(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new TypeError(`Mutation receipt must be valid JSON: ${String(s)}`,{cause:s})}if(!ue(e))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:e.id,status:e.status,changedFieldCount:e.changed_field_count,...typeof e.close_reason=="string"?{closeReason:e.close_reason}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previousStatus:e.previous_status}:{},...Array.isArray(e.warnings)?{warnings:e.warnings}:{}}}var me=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),pe=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]),fe=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])}),xe=new Set(["extension","install","package","packages","upgrade"]);function ge(t){let e=m(t.trim().toLowerCase());if(e==="ops")return"quality";for(let[s,o]of Object.entries(fe))if(o.has(e))return s;return xe.has(e)?"extensions":"internal"}var k=Object.freeze([...l.flatMap(t=>t==="item"?["item","item-reopen"]:[t,...y.filter(e=>e.alias===t).map(e=>e.canonical)]).map(t=>({command:t,tier:me.has(m(t))?"core":pe.has(m(t))?"standard":"full",family:ge(t)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]),ke=k,et=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),tt=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);var M={core:0,standard:1,full:2,internal:3},N=new Map(ke.map(({command:t,tier:e})=>[t,e]));function st(t,e="standard"){return N.get(t.trim().toLowerCase())??N.get(m(t.trim().toLowerCase()))??e}function ot(t){return ye(t,k)}function ye(t,e){let s=M[t];return e.filter(o=>o.tier!=="internal"&&M[o.tier]<=s).map(o=>o.command)}function he(t,e){return e.filter(s=>s.family===t).map(s=>s.command)}var be=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],ve=new Set([...h.filter(t=>t.hidden).map(t=>t.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function it(t=k){return be.map(e=>({family:e,commands:he(e,t).filter(s=>t.find(o=>o.command===s)?.tier!=="internal"&&!ve.has(s))})).filter(({commands:e})=>e.length>0)}var ct=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});var rt=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]),nt=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:!0},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:!1}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0},{name:"evidence",description:"Exact verification and outcome evidence.",required:!0}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);export{R as a,w as b,D as c,Ee as d,Ae as e,Oe as f,Te as g,Se as h,g as i,E as j,Ne as k,C as l,ze as m,oe as n,Be as o,Ve as p,k as q,st as r,ot as s,it as t,ie as u,p as v,de as w,He as x,ue as y,Je as z};
2
+ //# sourceMappingURL=chunk-KEZ4VXYD.js.map