@unbrained/pm-cli 2026.11.24 → 2026.11.25

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 (150) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/error-guidance.js +5 -5
  3. package/dist/cli-bundle/bundle-manifest.json +1 -1
  4. package/dist/cli-bundle/chunks/{chunk-I2OJ5B4A.js → chunk-4FZH5BTV.js} +2 -2
  5. package/dist/cli-bundle/chunks/{chunk-YYT3MIRF.js → chunk-6OIHST4I.js} +1 -1
  6. package/dist/cli-bundle/chunks/{chunk-ZYCOM4MS.js → chunk-7EPYCU7U.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-TVIJ2VCU.js → chunk-BVJMVU4Z.js} +5 -5
  8. package/dist/cli-bundle/chunks/{chunk-23K6DQQY.js → chunk-C4KIZQHW.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-FXJYZBWV.js → chunk-CNUFU454.js} +40 -40
  10. package/dist/cli-bundle/chunks/{chunk-PQUBVRV5.js → chunk-CONBVY2O.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-HNKK2UG6.js → chunk-CZEMEPPQ.js} +3 -3
  12. package/dist/cli-bundle/chunks/{chunk-Z7MFVRDV.js → chunk-DF6A7C32.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-ZOX4SWRL.js → chunk-FHLOGAGA.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-FVY7U3SU.js +125 -0
  15. package/dist/cli-bundle/chunks/{chunk-VJSGUXGU.js → chunk-GBVF2ZB3.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-TKRY22SO.js → chunk-GZI7ZAB7.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-PW7U7WCE.js → chunk-K34FR5CO.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-D6PDUKUG.js → chunk-KHFUHGL3.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-DQDRA3SW.js → chunk-L6VS7F3R.js} +2 -2
  20. package/dist/cli-bundle/chunks/chunk-LOX3VY4T.js +2 -0
  21. package/dist/cli-bundle/chunks/{chunk-WWTPNIC2.js → chunk-LPW7S5KA.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-5DUP4AZA.js → chunk-MGJMQSN4.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-MXUSC5RS.js → chunk-OS5W4ZG2.js} +31 -31
  24. package/dist/cli-bundle/chunks/{chunk-37UDIJ2K.js → chunk-OWK2JL4I.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-SSALO4DB.js → chunk-SCIPT7WF.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-7X253M6Z.js → chunk-SX76UGEY.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-YW2HBHRO.js → chunk-VA4T37Q4.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-STOOTHZZ.js → chunk-WQOEVGLQ.js} +2 -2
  29. package/dist/cli-bundle/chunks/chunk-XHCIOLJP.js +3 -0
  30. package/dist/cli-bundle/chunks/{chunk-XFADNMGD.js → chunk-XKWJONAO.js} +2 -2
  31. package/dist/cli-bundle/chunks/chunk-YIGBEY7K.js +2 -0
  32. package/dist/cli-bundle/chunks/{chunk-7VRFEURZ.js → chunk-ZBOQEZ2H.js} +25 -25
  33. package/dist/cli-bundle/chunks/{chunk-PLIUU37C.js → chunk-ZLICQPRG.js} +2 -2
  34. package/dist/cli-bundle/chunks/{field-option-collisions-W66HSWMK.js → field-option-collisions-QE65APSD.js} +2 -2
  35. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-BPYKN5Q7.js → indexed-receipt-blobs-H3MMNXXG.js} +2 -2
  36. package/dist/cli-bundle/chunks/{item-revision-D3LSBNIR.js → item-revision-INDHJV6X.js} +2 -2
  37. package/dist/cli-bundle/chunks/item-transaction-LCKK4XXB.js +2 -0
  38. package/dist/cli-bundle/chunks/{mutation-actor-OKL3CQVX.js → mutation-actor-KU7BMLUN.js} +2 -2
  39. package/dist/cli-bundle/chunks/mutation-admission-3OMCTQD4.js +2 -0
  40. package/dist/cli-bundle/chunks/{register-list-query-3LBV6CS2.js → register-list-query-3GV3LBOT.js} +2 -2
  41. package/dist/cli-bundle/chunks/{register-mutation-72AGTMNE.js → register-mutation-GZLF47SX.js} +2 -2
  42. package/dist/cli-bundle/chunks/{register-operations-XERFG2SH.js → register-operations-PBJZGCAL.js} +2 -2
  43. package/dist/cli-bundle/chunks/{register-setup-W22L34Z4.js → register-setup-ZLJEF6NZ.js} +2 -2
  44. package/dist/cli-bundle/chunks/{runtime-schema-JP2KBHBY.js → runtime-schema-Y4SHTEXL.js} +2 -2
  45. package/dist/cli-bundle/chunks/{settlement-hook-6MR32OOC.js → settlement-hook-ESAAEBRM.js} +2 -2
  46. package/dist/cli-bundle/chunks/{stage-T2LKWN7C.js → stage-3WIZBD4N.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/chunk-3Y5PTQ2F.js +27 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-XDBHD4CY.js → chunk-4LQL4EO6.js} +3 -3
  49. package/dist/cli-bundle/focused-chunks/{chunk-RIE3SJSE.js → chunk-4SX2BN4V.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-B6BNHKUW.js → chunk-5RBC4WSE.js} +39 -39
  51. package/dist/cli-bundle/focused-chunks/chunk-7SSGTGZO.js +91 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-LMFIAQ2V.js → chunk-A4R57E4K.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-46MP7IZN.js → chunk-BOIMP2AR.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-GXP7Q4XM.js → chunk-BYQK5DGH.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/chunk-C3FEDTSD.js +44 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-REFMQY47.js → chunk-IAOKVKWW.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-YD66IRSL.js → chunk-JOKRDFMQ.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-HL47UQZJ.js → chunk-MB56Y4M6.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-A6VEMCRR.js → chunk-NGFDPEP7.js} +1 -1
  60. package/dist/cli-bundle/focused-chunks/{chunk-RIQUIHYU.js → chunk-OCKKIECS.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-24VRBNKE.js → chunk-PKX2EHE3.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-C7WHWI7K.js → chunk-SXC2EO3E.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-3ELVASVA.js → chunk-TQIKDFOD.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-OZOCEB2Q.js → chunk-TRL4JDWX.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-3OCDKITJ.js → chunk-UWWAVXG4.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/chunk-VMYVN36N.js +13 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-LMU7DDOA.js → chunk-VU2PH4PF.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{chunk-EUQGZPGO.js → chunk-WL2R7T5G.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/chunk-WVA5KOXF.js +3 -0
  70. package/dist/cli-bundle/focused-chunks/{chunk-RLO2HCZT.js → chunk-X4EWD6TL.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{chunk-SMMOZ3H3.js → chunk-XKLBTDJ7.js} +37 -37
  72. package/dist/cli-bundle/focused-chunks/{chunk-UVTUX54T.js → chunk-YYEWIKNI.js} +2 -2
  73. package/dist/cli-bundle/focused-chunks/{chunk-Z7W2RQIB.js → chunk-ZLRRII55.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/{field-option-collisions-UODPSV6W.js → field-option-collisions-5ROXGUME.js} +2 -2
  75. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-EGEJMG3G.js → indexed-receipt-blobs-PG2VJ3MB.js} +2 -2
  76. package/dist/cli-bundle/focused-chunks/{item-revision-QH7RNBX4.js → item-revision-KYMSQVZE.js} +2 -2
  77. package/dist/cli-bundle/focused-chunks/{item-transaction-ZO72OINF.js → item-transaction-I4HLVHEJ.js} +2 -2
  78. package/dist/cli-bundle/focused-chunks/{mutation-actor-PHVLKG4I.js → mutation-actor-GGOQKAE6.js} +2 -2
  79. package/dist/cli-bundle/focused-chunks/{mutation-admission-ZSG5OECH.js → mutation-admission-OS36ZCMH.js} +2 -2
  80. package/dist/cli-bundle/focused-chunks/{runtime-schema-6RQMIDTN.js → runtime-schema-YXPYDD2C.js} +2 -2
  81. package/dist/cli-bundle/focused-chunks/{settlement-hook-FMLGKG7J.js → settlement-hook-4MGRERCT.js} +2 -2
  82. package/dist/cli-bundle/focused-chunks/{stage-AQMKRVX4.js → stage-4ZFWJUKO.js} +2 -2
  83. package/dist/cli-bundle/main.js +18 -18
  84. package/dist/cli-bundle/sdk-authoring.js +1 -1
  85. package/dist/cli-bundle/sdk-contracts.js +1 -1
  86. package/dist/cli-bundle/sdk-core.js +1 -1
  87. package/dist/cli-bundle/sdk-governance.js +1 -1
  88. package/dist/cli-bundle/sdk-graph.js +1 -1
  89. package/dist/cli-bundle/sdk-merge.js +61 -61
  90. package/dist/cli-bundle/sdk-query.js +1 -1
  91. package/dist/cli-bundle/sdk-runtime.js +1 -1
  92. package/dist/cli-bundle/sdk-testing.js +1 -1
  93. package/dist/cli-bundle/sdk.js +12 -12
  94. package/dist/core/shared/command-line.d.ts +54 -4
  95. package/dist/core/shared/command-line.js +1 -1
  96. package/dist/core/shared/errors.d.ts +9 -0
  97. package/dist/core/shared/secret-rules.js +5 -5
  98. package/dist/core/shared/url-credentials.d.ts +16 -3
  99. package/dist/core/shared/url-credentials.js +1 -1
  100. package/dist/core/store/item-store.d.ts +26 -4
  101. package/dist/core/store/item-store.js +1 -1
  102. package/dist/sdk/command-line.d.ts +1 -1
  103. package/dist/sdk/command-line.js +1 -1
  104. package/dist/sdk/context-intent-contracts.js +1 -1
  105. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  106. package/dist/sdk/index.d.ts +1 -1
  107. package/dist/sdk/lifecycle/claim.d.ts +21 -1
  108. package/dist/sdk/lifecycle/claim.js +1 -1
  109. package/dist/sdk/lifecycle/task-composition.js +1 -1
  110. package/dist/sdk/ownership-source.d.ts +15 -1
  111. package/dist/sdk/ownership-source.js +1 -1
  112. package/dist/sdk/public-surface.json +1 -1
  113. package/dist/sdk/runtime-primitives.d.ts +1 -1
  114. package/docs/AGENT_GUIDE.md +2 -2
  115. package/docs/CONFIGURATION.md +1 -0
  116. package/docs/MUTATION_INTEGRITY.md +97 -8
  117. package/docs/SDK.md +40 -3
  118. package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +17 -4
  119. package/marketplace.json +1 -1
  120. package/package.json +1 -1
  121. package/packages/pm-beads/package.json +1 -1
  122. package/packages/pm-calendar/package.json +1 -1
  123. package/packages/pm-command-kit/package.json +1 -1
  124. package/packages/pm-digital-twin/package.json +1 -1
  125. package/packages/pm-governance-audit/package.json +1 -1
  126. package/packages/pm-guide-shell/package.json +1 -1
  127. package/packages/pm-kanban/package.json +1 -1
  128. package/packages/pm-lifecycle-hooks/package.json +1 -1
  129. package/packages/pm-linked-test-adapters/package.json +1 -1
  130. package/packages/pm-search-advanced/package.json +1 -1
  131. package/packages/pm-templates/package.json +1 -1
  132. package/packages/pm-todos/package.json +1 -1
  133. package/packages/pm-vcs/package.json +1 -1
  134. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  135. package/plugins/pm-claude/package.json +1 -1
  136. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  137. package/plugins/pm-codex/package.json +1 -1
  138. package/plugins/pm-codex/plugin.json +1 -1
  139. package/runtime-dependencies.json +1 -1
  140. package/dist/cli-bundle/chunks/chunk-7IROAPWI.js +0 -3
  141. package/dist/cli-bundle/chunks/chunk-AWB5KBJS.js +0 -2
  142. package/dist/cli-bundle/chunks/chunk-I3BFCKZR.js +0 -2
  143. package/dist/cli-bundle/chunks/chunk-YOPTAIBD.js +0 -125
  144. package/dist/cli-bundle/chunks/item-transaction-M6NTBYH3.js +0 -2
  145. package/dist/cli-bundle/chunks/mutation-admission-EKPEOZMF.js +0 -2
  146. package/dist/cli-bundle/focused-chunks/chunk-3GT4A3ZN.js +0 -44
  147. package/dist/cli-bundle/focused-chunks/chunk-3Z7MCUJM.js +0 -3
  148. package/dist/cli-bundle/focused-chunks/chunk-5LDBS6MS.js +0 -91
  149. package/dist/cli-bundle/focused-chunks/chunk-FDZPRJXJ.js +0 -27
  150. package/dist/cli-bundle/focused-chunks/chunk-Q2HY44LV.js +0 -13
@@ -1,2 +1,2 @@
1
- import{S as E,T as j,U as G,V as k,W as w,X as $,Y as I,a as le,ba as F,g as P,i as J,o as N,q as U,s as B}from"./chunk-3OCDKITJ.js";import{E as ce,F as ue,H as _,I as de,W as V,fa as Z,o as K,oa as fe,p as X}from"./chunk-FDZPRJXJ.js";import{I as S}from"./chunk-SMMOZ3H3.js";import{A as p,z as f}from"./chunk-A6VEMCRR.js";var Fe=new Set(["none","null"]);function bt(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function v(e){return e===void 0?!1:Fe.has(e.trim().toLowerCase())}function Mt(e,t,r){if(!v(e))return;let n=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${n}`.trim(),f.USAGE)}function kt(e,t,r){if(!e||e.length===0||X(e)||!e.some(i=>v(i)))return;let o=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${o}`.trim(),f.USAGE)}function wt(e,t){for(let r of t){let n=e[r.optionKey];if(!Array.isArray(n)||n.length===0)continue;if(!n.every(s=>typeof s=="string"))throw new p(`${r.valueFlag} entries must be strings.`,f.USAGE);if(X(n))continue;let o=n;if(!o.some(s=>v(s)))continue;if(o.filter(s=>!v(s)).length>0)throw new p(`Cannot mix legacy clear token "none"/"null" with concrete ${r.valueFlag} entries. Use ${r.clearFlag} to clear or provide explicit entries.`,f.USAGE);e[r.optionKey]=void 0,e[r.clearFlagKey]=!0,r.disableFlagKey&&(e[r.disableFlagKey]=!1)}return e}var Ke=["close_reason","close-reason"],pe=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],me=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],De=[...pe,...me],ye=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],ee=[...De,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...ye],Le=[...pe,{canonical:"close-reason",aliases:Ke,optionKey:"closeReason",metadataKey:"close_reason"},...me,...ye],Pe=new Set(["none","null","-"]);function ge(e){return e==="create"?ee:Le}function H(e,t){let r=t.unset;if(r!==void 0&&typeof r!="string"&&!Array.isArray(r))return;let n=[];for(let o of ge(e))o.optionKey==="author"||!Object.hasOwn(t,o.optionKey)||t[o.optionKey]!==null||(Reflect.deleteProperty(t,o.optionKey),n.push(o.canonical));n.length!==0&&(t.unset=[...r===void 0?[]:typeof r=="string"?[r]:r,...n])}function Q(e){return typeof e=="string"&&Pe.has(e.trim().toLowerCase())}function Dt(e,t,r,n){return r?ge(e).flatMap(o=>{let i=t[o.optionKey],a=n[o.metadataKey];return Q(i)&&(Q(a)||Array.isArray(a)&&a.some(Q))?[`literal_sentinel_stored:${o.canonical}:${i.trim()}`]:[]}):[]}function Ue(e,t){return e.flatMap(r=>r.includes(",")&&t(r)?[r]:r.split(","))}function Be(e){let t=new Set,r=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:r};let n=Ue(e.raw,o=>e.resolveDefinition(o.trim().toLowerCase())!==void 0);for(let o of n){let i=o.trim().toLowerCase();if(!i)throw new p("--unset values must not be empty; name each field once, for example --unset parent,release",f.USAGE);if(v(i))throw new p('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',f.USAGE);let a=e.resolveDefinition(i);if(!a)throw new p(`Unsupported --unset field "${o}". Supported fields: ${e.supportedFields}`,f.USAGE);t.add(a.metadataKey),r.add(a.optionKey)}return{metadataKeys:t,optionKeys:r}}function je(e,t,r){let n=e.trim().toLowerCase();if(!r)return;let o=r.command_to_fields?.get(t)??[];for(let i of o){if(i.allow_unset===!1)continue;let a=new Set;if(typeof i.key=="string"&&i.key.length>0&&a.add(i.key.toLowerCase()),typeof i.metadata_key=="string"&&i.metadata_key.length>0&&a.add(i.metadata_key.toLowerCase()),typeof i.cli_flag=="string"&&i.cli_flag.length>0&&(a.add(i.cli_flag.replaceAll("-","_").toLowerCase()),a.add(i.cli_flag.toLowerCase())),Array.isArray(i.cli_aliases))for(let s of i.cli_aliases)typeof s!="string"||s.length===0||(a.add(s.replaceAll("-","_").toLowerCase()),a.add(s.toLowerCase()));if(a.has(n))return{optionKey:i.key,metadataKey:i.metadata_key}}}var Ge=(()=>{let e=new Map;for(let t of ee)for(let r of t.aliases)e.set(r,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),$e=ee.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function Lt(e,t){return Be({raw:e,supportedFields:$e,resolveDefinition:r=>Ge.get(r)??je(r,"create",t)})}var Ve={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function x(e,t,r){let n=`${e} ${t} must be ${r}.`;throw new p(n,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:n,examples:[Ve[e]]})}function D(e,t,r){typeof e!="string"&&x(t,r,"a string")}function te(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&x(t,"options","an object")}function Ae(e,t){(e==="append"||e==="update")&&t.id!==void 0&&D(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&D(t.id,"reopen","id"),t.reason!==void 0&&D(t.reason,"reopen","reason"),t.options!==void 0&&He(t.options))}function Wt(e){te(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&D(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&x("append","force","a boolean")}function He(e){te(e,"reopen");for(let t of F["item-reopen"].optional){let r=e[t];r!==void 0&&(S(Reflect.get(E,t)).type==="boolean"?typeof r!="boolean"&&x("reopen",t,"a boolean"):D(r,"reopen",t))}}function ze(e,t){return e?t?"a string or string array":"a string array":"a string"}function qe(e,t,r,n,o,i){r===void 0||typeof r=="string"&&(!o||i)||n==="priority"&&typeof r=="number"&&Number.isFinite(r)||o&&Array.isArray(r)&&Array.from(r).every(a=>typeof a=="string")||x(e,t,ze(o,i))}function Ye(e,t,r){let n=e==="create"?U:B;for(let{param:o}of[...n,...N,{param:"force"}]){if(S(Reflect.get(E,o)).type!=="boolean")continue;let i=r.find(a=>a.keys.includes(o))?.keys??[o];for(let a of i)t[a]!==void 0&&typeof t[a]!="boolean"&&x(e,a,"a boolean")}}function re(e,t,r=!0,n=!1){let o=e==="create"?j:w;for(let{target:i,keys:a,repeatable:s}of o)if(S(Reflect.get(E,i)).type!=="boolean")for(let u of a){let h=n&&u!==i,A=s===!0&&(i!=="acceptanceCriteria"||h);qe(e,u,t[u],i,A,r||h)}Ye(e,t,o)}function Jt(e,t){te(t,e);let r=ce(t),n=K(r);return n||H(e,r),re(e,r,!1,n),r}import{Option as hr}from"commander";function O(e,t,r){if(typeof r!="string")return;let n=r.trim();n.length!==0&&e.push(t,n)}function y(e,t,r){r===!0&&e.push(t)}function C(e,t,r){if(Array.isArray(r))for(let n of r){if(typeof n!="string")continue;let o=n.trim();o.length!==0&&e.push(t,o)}}function We(e,t){let r=["test",e,"--run","--json","--progress"];return C(r,"--add",t.add),C(r,"--add-json",t.addJson),C(r,"--remove",t.remove),C(r,"--remove-index",Array.isArray(t.removeIndex)?t.removeIndex.map(n=>typeof n=="number"?String(n):n):t.removeIndex),O(r,"--match",t.match),O(r,"--only-index",typeof t.onlyIndex=="number"?String(t.onlyIndex):t.onlyIndex),y(r,"--only-last",t.onlyLast),y(r,"--full-history",t.fullHistory),C(r,"--measure",t.measure),O(r,"--metric-below",t.metricBelow),O(r,"--metric-diff",t.metricDiff),Je(r,t),O(r,"--author",t.author),O(r,"--message",t.message),y(r,"--force",t.force),r}function Je(e,t){O(e,"--timeout",t.timeout),C(e,"--env-set",t.envSet),C(e,"--env-clear",t.envClear),y(e,"--shared-host-safe",t.sharedHostSafe),O(e,"--pm-context",t.pmContext),y(e,"--override-linked-pm-context",t.overrideLinkedPmContext),O(e,"--workspace-context",t.workspaceContext),y(e,"--override-linked-workspace-context",t.overrideLinkedWorkspaceContext),y(e,"--allow-untrusted-linked-tests",t.allowUntrustedLinkedTests),y(e,"--fail-on-context-mismatch",t.failOnContextMismatch),y(e,"--fail-on-skipped",t.failOnSkipped),y(e,"--fail-on-empty-test-run",t.failOnEmptyTestRun),y(e,"--require-assertions-for-pm",t.requireAssertionsForPm),y(e,"--check-context",t.checkContext),y(e,"--full-output",t.fullOutput),y(e,"--auto-pm-context",t.autoPmContext)}function he(e,t){let r=[],n=new Set;for(let o of t.keys){if(!Object.hasOwn(e,o))continue;let i=e[o];if(i!=null){if(typeof i=="string"){r.push(i);continue}if(!Array.isArray(i)||!i.every(a=>typeof a=="string"))return;n.has(i)||(n.add(i),r.push(...i))}}return r.length>0?r.join("; "):void 0}function R(e,t){return e.find(n=>n.target===t)??{target:t,keys:[t]}}function l(e,t){return e[t]===!0?!0:void 0}function T(e,t){return e[t]===!1?!0:void 0}function z(e,t){return t.some(r=>e[r]===!0)?!0:void 0}function ne(e,t){for(let[r,n]of Object.entries(t))r==="__proto__"||r==="constructor"||r==="prototype"||Object.hasOwn(e,r)||(e[r]=n)}function _e(e,t={}){let r=a=>P(e,R(G,a)),n=a=>J(e,R(k,a)),o=r("type");if(t.requireType!==!1&&o===void 0)throw new p("Missing required option --type <value>. Why required: create resolves runtime schema fields/workflow from item type. Retry: add --type <built-in or configured custom type> (example: --type Task).",f.USAGE);let i={title:r("title"),description:r("description"),type:o,template:r("template"),createMode:r("createMode"),defer:n("defer"),deferReason:r("deferReason"),schedulePreset:r("schedulePreset"),status:r("status"),closeReason:r("closeReason"),completedAt:r("completedAt"),priority:r("priority"),tags:r("tags"),addTags:n("addTags"),body:r("body"),deadline:r("deadline"),estimatedMinutes:r("estimatedMinutes"),acceptanceCriteria:he(e,R(k,"acceptanceCriteria")),definitionOfReady:r("definitionOfReady"),order:r("order"),rank:r("rank"),goal:r("goal"),objective:r("objective"),value:r("value"),impact:r("impact"),outcome:r("outcome"),whyNow:r("whyNow"),author:r("author"),message:r("message"),assignee:r("assignee"),parent:r("parent"),inheritFocus:e.inheritFocus,allowMissingParent:z(e,["allowMissingParent","allow_missing_parent"])===!0,allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,allowDuplicate:l(e,"allowDuplicate")===!0,reviewer:r("reviewer"),risk:r("risk"),confidence:r("confidence"),sprint:r("sprint"),release:r("release"),blockedBy:r("blockedBy"),blockedReason:r("blockedReason"),unblockNote:r("unblockNote"),reporter:r("reporter"),severity:r("severity"),environment:r("environment"),reproSteps:r("reproSteps"),resolution:r("resolution"),expectedResult:r("expectedResult"),actualResult:r("actualResult"),affectedVersion:r("affectedVersion"),fixedVersion:r("fixedVersion"),component:r("component"),regression:e.regression===!0?"true":r("regression"),customerImpact:r("customerImpact"),dep:n("dep"),comment:n("comment"),note:n("note"),learning:n("learning"),file:n("file"),test:n("test"),doc:n("doc"),reminder:n("reminder"),event:n("event"),typeOption:n("typeOption"),field:n("field"),unset:n("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(i,e),_(e,i)}function Oe(e){let t=o=>P(e,R($,o)),r=o=>J(e,R(I,o)),n={title:t("title"),description:t("description"),body:t("body"),status:t("status"),closeReason:t("closeReason"),priority:t("priority"),type:t("type"),tags:t("tags"),addTags:r("addTags"),removeTags:r("removeTags"),deadline:t("deadline"),estimatedMinutes:t("estimatedMinutes"),acceptanceCriteria:he(e,R(I,"acceptanceCriteria")),addAc:r("addAc"),removeAc:r("removeAc"),definitionOfReady:t("definitionOfReady"),order:t("order"),rank:t("rank"),goal:t("goal"),objective:t("objective"),value:t("value"),impact:t("impact"),outcome:t("outcome"),whyNow:t("whyNow"),author:t("author"),message:t("message"),force:!!e.force,ownershipMetadataBypass:e.ownershipMetadataBypass===!0?!0:void 0,ownershipDependencyBypass:e.ownershipDependencyBypass===!0?!0:void 0,assignee:t("assignee"),parent:t("parent"),allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,reviewer:t("reviewer"),risk:t("risk"),confidence:t("confidence"),sprint:t("sprint"),release:t("release"),blockedBy:t("blockedBy"),blockedReason:t("blockedReason"),unblockNote:t("unblockNote"),reporter:t("reporter"),severity:t("severity"),environment:t("environment"),reproSteps:t("reproSteps"),resolution:t("resolution"),expectedResult:t("expectedResult"),actualResult:t("actualResult"),affectedVersion:t("affectedVersion"),fixedVersion:t("fixedVersion"),component:t("component"),regression:e.regression===!0?"true":t("regression"),customerImpact:t("customerImpact"),dep:r("dep"),depRemove:r("depRemove"),replaceDeps:l(e,"replaceDeps"),replaceTests:l(e,"replaceTests"),replaceFiles:l(e,"replaceFiles"),replaceDocs:l(e,"replaceDocs"),comment:r("comment"),note:r("note"),learning:r("learning"),file:r("file"),test:r("test"),doc:r("doc"),reminder:r("reminder"),event:r("event"),typeOption:r("typeOption"),field:r("field"),unset:r("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(n,e),_(e,n)}function d(e,t){let r=R(le,t),n=P(e,r);if(n!==void 0)return n;for(let o of r.keys){let i=e[o];if(Array.isArray(i)){let a=i.filter(s=>typeof s=="string");if(a.length>0)return a.join(",")}if(t==="ids"&&typeof i=="string")return i;if(typeof i=="number"&&Number.isFinite(i))return String(i)}}function Xe(e){let t=l(e,"filterFilesMissing"),r=l(e,"filterDocsMissing");return{filterReviewerMissing:l(e,"filterReviewerMissing"),filterRiskMissing:l(e,"filterRiskMissing"),filterConfidenceMissing:l(e,"filterConfidenceMissing"),filterSprintMissing:l(e,"filterSprintMissing"),filterReleaseMissing:l(e,"filterReleaseMissing"),hasNotes:l(e,"hasNotes"),hasLearnings:l(e,"hasLearnings"),hasFiles:l(e,"hasFiles"),hasDocs:l(e,"hasDocs"),hasTests:l(e,"hasTests"),hasComments:l(e,"hasComments"),hasDeps:l(e,"hasDeps"),hasBody:l(e,"hasBody"),hasLinkedCommand:l(e,"hasLinkedCommand"),noNotes:T(e,"notes"),noLearnings:T(e,"learnings"),noFiles:T(e,"files")??t,filterFilesMissing:t,noDocs:T(e,"docs")??r,filterDocsMissing:r,noTests:T(e,"tests"),noComments:T(e,"comments"),noDeps:T(e,"deps"),emptyBody:l(e,"emptyBody"),noLinkedCommand:T(e,"linkedCommand")}}function Te(e){let t={status:d(e,"status"),type:d(e,"type"),tag:d(e,"tag"),priority:d(e,"priority"),deadlineBefore:d(e,"deadlineBefore"),deadlineAfter:d(e,"deadlineAfter"),updatedAfter:d(e,"updatedAfter"),updatedBefore:d(e,"updatedBefore"),createdAfter:d(e,"createdAfter"),createdBefore:d(e,"createdBefore"),today:l(e,"today"),recent:l(e,"recent"),ids:d(e,"ids"),assignee:d(e,"assignee"),assigneeFilter:d(e,"assigneeFilter"),parent:d(e,"parent"),sprint:d(e,"sprint"),release:d(e,"release"),limit:d(e,"limit"),offset:d(e,"offset"),noTruncate:T(e,"truncate"),includeBody:l(e,"includeBody"),strictRead:l(e,"strictRead"),compact:l(e,"compact"),brief:l(e,"brief"),full:l(e,"full"),fields:d(e,"fields"),sort:d(e,"sort"),order:d(e,"order"),tree:l(e,"tree"),treeDepth:d(e,"treeDepth"),filterAcMissing:l(e,"filterAcMissing"),filterEstimatesMissing:z(e,["filterEstimatesMissing","filterEstimateMissing"]),filterResolutionMissing:l(e,"filterResolutionMissing"),filterMetadataMissing:l(e,"filterMetadataMissing"),...Xe(e)};return ne(t,e),t}var Ze=Symbol("pm.mcp-mutation-transport"),Qe=new Set(["create","update","append"]),W={create:{parameters:U,aliases:j,strings:G,repeatables:k},update:{parameters:B,aliases:w,strings:$,repeatables:I}},et=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function L(e){return Ze in e}function Y(e,t){return L(e)?ue(t):_(e,t)}function Ur(e,t,r=[]){let n=_(e,{...e,...t});for(let o of r)Reflect.deleteProperty(n,o);return n}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r:void 0}function m(e,t){let r=e[t];return typeof r=="string"?r.trim().length>0?r:void 0:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function Br(e,t){let r=e[t];return typeof r=="string"?r:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jr(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new p(`${t} must be a finite integer.`,f.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let r=Number(e);if(!Number.isInteger(r))throw new p(`${t} must be a finite integer.`,f.USAGE);return r}}function Gr(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:c(e,"limit")??c(t,"limit")}function $r(e){let t=c(e,"outputFormat");return{json:!0,quiet:!0,author:c(e,"author"),path:c(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:c(e,"outputInclude"),outputLimit:m(e,"outputLimit"),outputBudget:m(e,"outputBudget"),outputSession:c(e,"outputSession"),outputCursor:c(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var Ee=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ve=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),tt=new Set([...ve].filter(e=>e!=="file")),rt=new Set(["files","files-discover","docs","test","test-all"]),oe=new Set(["comments","notes","learnings"]);function nt(e,t){if(!(!oe.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new p(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,f.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var it=new Set(["claim","release","start-task","pause-task","close-task"]),xe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline"],package:["dryRun","offline"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},at=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),ot=new Set(["query","keywords","id","text"]);function st(e){return at.has(e)?F[e].optional.filter(t=>!ot.has(t)):[]}var lt=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function ct(e,t){if(!lt.has(e??""))return t;let r={...t};for(let n of F[e].optional){let o=n.replace(/[A-Z]/gu,i=>`_${i.toLowerCase()}`);o===n||r[o]===void 0||(r[n]??=r[o],delete r[o])}return r}function ut(e,t,r){if(!oe.has(e??""))return r;let n=r,o=n.text??t.text;if(o===void 0)return n;if(n.add!==void 0&&n.add!==o){let a=e.replace(/s$/u,"");throw new p(`Specify ${a} text either as text or with add, not both.`,f.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${a} text once: text and add are the same source.`})}let i={...n,add:o};return delete i.text,i}function dt(e,t){let r=t.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return e[t]!==void 0||e[r]!==void 0}function ft(e){return[...xe[e]??[],...st(e),...be]}var be=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function Me(e,t=""){let r={},n=rt.has(t),o=t==="files"||t==="files-discover"||t==="docs",i=oe.has(t)?tt:ve;for(let[a,s]of Object.entries(e)){if(Array.isArray(s)&&Ee.has(a)){r[a]=s.join(",");continue}if(a==="note"&&o){r[a]=s;continue}if(typeof s=="string"&&i.has(a)){r[a]=[s];continue}if(typeof s=="string"&&n&&(a==="add"||a==="remove")){r[a]=[s];continue}r[a]=s}return Object.assign(r,Object.fromEntries(Object.getOwnPropertySymbols(e).map(a=>[a,Reflect.get(e,a)]))),r}function pt(e,t,r){let n=c(e,"author");return n!==void 0?n:r!==void 0&&it.has(r)?c(e,"assignee")??c(t,"assignee"):void 0}function mt(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function yt(e,t,r){let n={},o=W[e],i=new Set([...o.parameters.map(({param:a})=>a),...N.map(({param:a})=>a),...xe[e],...be,"force"]);for(let a of i){let s=o.aliases.find(u=>u.keys.includes(a))?.keys??[a];t[a]===void 0||s.some(u=>r[u]!==void 0)||(n[a]=t[a])}return n}function b(e,t){throw new p(`Invalid MCP ${e} value for "${t}". No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function gt(e,t,r){let n=W[e],o=[...n.parameters,...N,{param:"force"}];for(let{param:i}of o){if(S(E[i]).type!=="boolean")continue;let s=(n.aliases.find(u=>u.keys.includes(i))?.keys??[i]).find(u=>r[u]!==void 0&&typeof r[u]!="boolean");s!==void 0&&b(e,s)}for(let i of["idOnly","fullChangedFields"])t[i]!==void 0&&typeof t[i]!="boolean"&&b(e,i)}function At(e,t,r){t.options!==void 0&&!g(t.options)&&b(e,"options"),gt(e,t,r);for(let a of Ee){let s=r[a];Array.isArray(s)&&s.some(u=>typeof u!="string")&&b(e,a)}let n=Ie(r,e),o=W[e];for(let{keys:a,target:s}of o.strings)a.some(u=>r[u]!==void 0)&&n[s]===void 0&&b(e,s);let i=o.repeatables.flatMap(({keys:a})=>a).find(a=>{let s=r[a];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(u=>typeof u!="string"))});return i!==void 0&&b(e,i),n}function ht(e,t,r,n,o){let i=(t==="create"||t==="update")&&L(e),a={...i?yt(t,e,n):r,...n};if((t==="create"||t==="update")&&!i){let s=g(e.options)&&K(e.options);s||H(t,a),re(t,a,!0,s)}return i?At(t,e,a):o?Me(a,t):a}function _t(e,t){return!Qe.has(e??"")||K(t)?t:fe(t)}function Vr(e,t,{nativeAction:r=!0}={}){Ae(t,e);let n=g(e.options)?e.options:void 0,o=S(e.options),i={},a=A=>{dt(o,A)||e[A]===void 0||(i[A]=e[A])};for(let A of ft(t??""))a(A);t!==void 0&&L(e)&&nt(t,o);let s=ut(t,e,ct(t,ht(e,t,i,o,r)));if(t==="history-attest"&&L(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new p("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",f.USAGE);let u=L(e)?e:n??e,h=Y(u,mt(s,pt(e,s,t)));return _t(t,h)}function Hr(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function zr(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function Ot(e){let t=[],r=!0;for(let n of e.trim().toLowerCase()){if(n>="a"&&n<="z"||n>="0"&&n<="9"){t.push(n),r=!1;continue}r||(t.push("-"),r=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function qr(e){return!et.has(Ot(e))}function Yr(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function Tt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function Wr(e,t){let r=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),n={};for(let[i,a]of Object.entries(e))r.has(i)||(n[i]=a);let o={...n,...t};return delete o.args,delete o.author,o}function Jr(e,t){let r=Y(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:r}}function ae(e){return{type:m(e,"filterType"),tag:m(e,"filterTag"),priority:m(e,"filterPriority"),deadlineBefore:m(e,"filterDeadlineBefore"),deadlineAfter:m(e,"filterDeadlineAfter"),updatedAfter:m(e,"filterUpdatedAfter"),updatedBefore:m(e,"filterUpdatedBefore"),createdAfter:m(e,"filterCreatedAfter"),createdBefore:m(e,"filterCreatedBefore"),ids:Z(e.ids),assignee:m(e,"filterAssignee"),assigneeFilter:m(e,"filterAssigneeFilter")??m(e,"filterAssignee_filter"),parent:m(e,"filterParent"),sprint:m(e,"filterSprint"),release:m(e,"filterRelease"),limit:m(e,"limit"),offset:m(e,"offset")}}function ie(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return Tt(e)}function q(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function Xr(e){let t=ie(e.kind),r=ie(e.exemptIsolate),n=ie(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:q(e.maxDepth),limit:q(e.limit),after:c(e,"after"),direction:c(e,"direction"),maxPaths:q(e.maxPaths),sample:q(e.sample),...r===void 0?{}:{exemptIsolate:r},...n===void 0?{}:{exemptIsolateType:n},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function ke(e){let t=Te(e);return e.ids!==void 0&&(t.ids=Z(e.ids)),t}function Zr(e){return{status:c(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),reason:c(e,"reason"),completedAt:c(e,"completedAt")??c(e,"completed_at"),resolution:c(e,"resolution"),expectedResult:c(e,"expectedResult")??c(e,"expected_result")??c(e,"expected"),actualResult:c(e,"actualResult")??c(e,"actual_result")??c(e,"actual"),validateClose:c(e,"validateClose")??c(e,"validate_close"),author:c(e,"author"),message:c(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var se=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function Se(e){let t={};for(let[r,n]of Object.entries(e))se.has(r)||(t[r]=n);return we(t)}function we(e){return Ie(e,"update")}function Ie(e,t){let r=Me(e,t),n=W[t],o=new Set([...n.parameters,...N].filter(({booleanish:i})=>i===!0).map(({param:i})=>i));for(let{keys:i}of n.repeatables)for(let a of i)typeof r[a]=="string"&&(r[a]=[r[a]]);for(let i of n.strings)for(let a of i.keys){let s=r[a];(typeof s=="number"&&Number.isFinite(s)||s===!1&&o.has(a))&&(r[a]=String(s))}return t==="create"?{..._e(r,{requireType:!1})}:Oe(r)}var St=new Map(w.flatMap(({target:e,keys:t})=>t.map(r=>[r,e])));function Ct(e){return e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"}function Ce(e,t){throw new p(`update-many "${e}" cannot be null. No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:e,required:t})}function Rt(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!se.has(t)))}function Re(e,t,r){if(!e)return;let n=g(t.list)?t.list:{},o=g(t.update)?t.update:void 0,i=Object.keys(t).find(s=>t[s]===null&&(o!==void 0||se.has(s)||Ct(s)))??Object.keys(n).filter(s=>n[s]===null).map(s=>`list.${s}`)[0];i!==void 0&&Ce(i,`"${i}" selects rows or controls the run: omit it or pass a value. To clear an item field, pass null on the field itself${o===void 0?"":" inside update"}.`);let a=o??Rt(t);for(let[s,u]of Object.entries(a)){if(u!==null)continue;let h=St.get(s);h===void 0&&Ce(s,`Pass unset: ["${s}"] to clear a field, or omit "${s}".`),r[h]=null}}var Nt=["author","message"];function Et(e,t){let r=Object.fromEntries(Nt.filter(n=>typeof e[n]=="string"&&t[n]===void 0).map(n=>[n,e[n]]));return e.force===!0&&t.force===void 0&&(r.force=!0),Object.keys(r).length===0?t:_(t,{...t,...r})}function Qr(e,t=!1){if(g(e.list)||g(e.update)){let n=g(e.update)?Et(e,e.update):Se(e),o=Y(e,we(n));return Re(t,e,o),{status:m(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),update:de(n,o),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}let r=Y(e,Se(e));return Re(t,e,r),{status:m(e,"filterStatus"),list:ae(e),update:r,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function Ne(e){return"expectHash"in e||"expect_hash"in e}function en(e){if(!Ne(e)&&!(g(e.options)&&Ne(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:r,...n}=e,o=g(n.options)?n.options:{},{expectHash:i,expect_hash:a,...s}=o,u=[t,r,i,a].filter(M=>M!==void 0),h=u.length>1?u.flatMap(M=>Array.isArray(M)?M:[M]):u[0],A=_(e,"options"in n?{...n,options:g(n.options)?_(n.options,s):n.options}:n);return{expectHash:h,dispatchArgs:A}}export{bt as a,v as b,Mt as c,kt as d,wt as e,Ke as f,ee as g,Le as h,Dt as i,Ue as j,Be as k,je as l,Lt as m,D as n,te as o,Wt as p,He as q,Jt as r,We as s,L as t,Ur as u,c as v,m as w,Br as x,g as y,jr as z,Gr as A,$r as B,xe as C,Me as D,Vr as E,Hr as F,zr as G,Ot as H,qr as I,Yr as J,Tt as K,Wr as L,Jr as M,ae as N,Xr as O,Zr as P,se as Q,we as R,Qr as S,en as T};
2
- //# sourceMappingURL=chunk-UVTUX54T.js.map
1
+ import{S as E,T as j,U as G,V as k,W as w,X as $,Y as I,a as le,ba as F,g as P,i as J,o as N,q as U,s as B}from"./chunk-UWWAVXG4.js";import{E as ce,F as ue,H as _,I as de,W as V,fa as Z,o as K,oa as fe,p as X}from"./chunk-3Y5PTQ2F.js";import{I as S}from"./chunk-XKLBTDJ7.js";import{A as p,z as f}from"./chunk-NGFDPEP7.js";var Fe=new Set(["none","null"]);function bt(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function v(e){return e===void 0?!1:Fe.has(e.trim().toLowerCase())}function Mt(e,t,r){if(!v(e))return;let n=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${n}`.trim(),f.USAGE)}function kt(e,t,r){if(!e||e.length===0||X(e)||!e.some(i=>v(i)))return;let o=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${o}`.trim(),f.USAGE)}function wt(e,t){for(let r of t){let n=e[r.optionKey];if(!Array.isArray(n)||n.length===0)continue;if(!n.every(s=>typeof s=="string"))throw new p(`${r.valueFlag} entries must be strings.`,f.USAGE);if(X(n))continue;let o=n;if(!o.some(s=>v(s)))continue;if(o.filter(s=>!v(s)).length>0)throw new p(`Cannot mix legacy clear token "none"/"null" with concrete ${r.valueFlag} entries. Use ${r.clearFlag} to clear or provide explicit entries.`,f.USAGE);e[r.optionKey]=void 0,e[r.clearFlagKey]=!0,r.disableFlagKey&&(e[r.disableFlagKey]=!1)}return e}var Ke=["close_reason","close-reason"],pe=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],me=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],De=[...pe,...me],ye=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],ee=[...De,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...ye],Le=[...pe,{canonical:"close-reason",aliases:Ke,optionKey:"closeReason",metadataKey:"close_reason"},...me,...ye],Pe=new Set(["none","null","-"]);function ge(e){return e==="create"?ee:Le}function H(e,t){let r=t.unset;if(r!==void 0&&typeof r!="string"&&!Array.isArray(r))return;let n=[];for(let o of ge(e))o.optionKey==="author"||!Object.hasOwn(t,o.optionKey)||t[o.optionKey]!==null||(Reflect.deleteProperty(t,o.optionKey),n.push(o.canonical));n.length!==0&&(t.unset=[...r===void 0?[]:typeof r=="string"?[r]:r,...n])}function Q(e){return typeof e=="string"&&Pe.has(e.trim().toLowerCase())}function Dt(e,t,r,n){return r?ge(e).flatMap(o=>{let i=t[o.optionKey],a=n[o.metadataKey];return Q(i)&&(Q(a)||Array.isArray(a)&&a.some(Q))?[`literal_sentinel_stored:${o.canonical}:${i.trim()}`]:[]}):[]}function Ue(e,t){return e.flatMap(r=>r.includes(",")&&t(r)?[r]:r.split(","))}function Be(e){let t=new Set,r=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:r};let n=Ue(e.raw,o=>e.resolveDefinition(o.trim().toLowerCase())!==void 0);for(let o of n){let i=o.trim().toLowerCase();if(!i)throw new p("--unset values must not be empty; name each field once, for example --unset parent,release",f.USAGE);if(v(i))throw new p('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',f.USAGE);let a=e.resolveDefinition(i);if(!a)throw new p(`Unsupported --unset field "${o}". Supported fields: ${e.supportedFields}`,f.USAGE);t.add(a.metadataKey),r.add(a.optionKey)}return{metadataKeys:t,optionKeys:r}}function je(e,t,r){let n=e.trim().toLowerCase();if(!r)return;let o=r.command_to_fields?.get(t)??[];for(let i of o){if(i.allow_unset===!1)continue;let a=new Set;if(typeof i.key=="string"&&i.key.length>0&&a.add(i.key.toLowerCase()),typeof i.metadata_key=="string"&&i.metadata_key.length>0&&a.add(i.metadata_key.toLowerCase()),typeof i.cli_flag=="string"&&i.cli_flag.length>0&&(a.add(i.cli_flag.replaceAll("-","_").toLowerCase()),a.add(i.cli_flag.toLowerCase())),Array.isArray(i.cli_aliases))for(let s of i.cli_aliases)typeof s!="string"||s.length===0||(a.add(s.replaceAll("-","_").toLowerCase()),a.add(s.toLowerCase()));if(a.has(n))return{optionKey:i.key,metadataKey:i.metadata_key}}}var Ge=(()=>{let e=new Map;for(let t of ee)for(let r of t.aliases)e.set(r,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),$e=ee.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function Lt(e,t){return Be({raw:e,supportedFields:$e,resolveDefinition:r=>Ge.get(r)??je(r,"create",t)})}var Ve={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function x(e,t,r){let n=`${e} ${t} must be ${r}.`;throw new p(n,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:n,examples:[Ve[e]]})}function D(e,t,r){typeof e!="string"&&x(t,r,"a string")}function te(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&x(t,"options","an object")}function Ae(e,t){(e==="append"||e==="update")&&t.id!==void 0&&D(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&D(t.id,"reopen","id"),t.reason!==void 0&&D(t.reason,"reopen","reason"),t.options!==void 0&&He(t.options))}function Wt(e){te(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&D(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&x("append","force","a boolean")}function He(e){te(e,"reopen");for(let t of F["item-reopen"].optional){let r=e[t];r!==void 0&&(S(Reflect.get(E,t)).type==="boolean"?typeof r!="boolean"&&x("reopen",t,"a boolean"):D(r,"reopen",t))}}function ze(e,t){return e?t?"a string or string array":"a string array":"a string"}function qe(e,t,r,n,o,i){r===void 0||typeof r=="string"&&(!o||i)||n==="priority"&&typeof r=="number"&&Number.isFinite(r)||o&&Array.isArray(r)&&Array.from(r).every(a=>typeof a=="string")||x(e,t,ze(o,i))}function Ye(e,t,r){let n=e==="create"?U:B;for(let{param:o}of[...n,...N,{param:"force"}]){if(S(Reflect.get(E,o)).type!=="boolean")continue;let i=r.find(a=>a.keys.includes(o))?.keys??[o];for(let a of i)t[a]!==void 0&&typeof t[a]!="boolean"&&x(e,a,"a boolean")}}function re(e,t,r=!0,n=!1){let o=e==="create"?j:w;for(let{target:i,keys:a,repeatable:s}of o)if(S(Reflect.get(E,i)).type!=="boolean")for(let u of a){let h=n&&u!==i,A=s===!0&&(i!=="acceptanceCriteria"||h);qe(e,u,t[u],i,A,r||h)}Ye(e,t,o)}function Jt(e,t){te(t,e);let r=ce(t),n=K(r);return n||H(e,r),re(e,r,!1,n),r}import{Option as hr}from"commander";function O(e,t,r){if(typeof r!="string")return;let n=r.trim();n.length!==0&&e.push(t,n)}function y(e,t,r){r===!0&&e.push(t)}function C(e,t,r){if(Array.isArray(r))for(let n of r){if(typeof n!="string")continue;let o=n.trim();o.length!==0&&e.push(t,o)}}function We(e,t){let r=["test",e,"--run","--json","--progress"];return C(r,"--add",t.add),C(r,"--add-json",t.addJson),C(r,"--remove",t.remove),C(r,"--remove-index",Array.isArray(t.removeIndex)?t.removeIndex.map(n=>typeof n=="number"?String(n):n):t.removeIndex),O(r,"--match",t.match),O(r,"--only-index",typeof t.onlyIndex=="number"?String(t.onlyIndex):t.onlyIndex),y(r,"--only-last",t.onlyLast),y(r,"--full-history",t.fullHistory),C(r,"--measure",t.measure),O(r,"--metric-below",t.metricBelow),O(r,"--metric-diff",t.metricDiff),Je(r,t),O(r,"--author",t.author),O(r,"--message",t.message),y(r,"--force",t.force),r}function Je(e,t){O(e,"--timeout",t.timeout),C(e,"--env-set",t.envSet),C(e,"--env-clear",t.envClear),y(e,"--shared-host-safe",t.sharedHostSafe),O(e,"--pm-context",t.pmContext),y(e,"--override-linked-pm-context",t.overrideLinkedPmContext),O(e,"--workspace-context",t.workspaceContext),y(e,"--override-linked-workspace-context",t.overrideLinkedWorkspaceContext),y(e,"--allow-untrusted-linked-tests",t.allowUntrustedLinkedTests),y(e,"--fail-on-context-mismatch",t.failOnContextMismatch),y(e,"--fail-on-skipped",t.failOnSkipped),y(e,"--fail-on-empty-test-run",t.failOnEmptyTestRun),y(e,"--require-assertions-for-pm",t.requireAssertionsForPm),y(e,"--check-context",t.checkContext),y(e,"--full-output",t.fullOutput),y(e,"--auto-pm-context",t.autoPmContext)}function he(e,t){let r=[],n=new Set;for(let o of t.keys){if(!Object.hasOwn(e,o))continue;let i=e[o];if(i!=null){if(typeof i=="string"){r.push(i);continue}if(!Array.isArray(i)||!i.every(a=>typeof a=="string"))return;n.has(i)||(n.add(i),r.push(...i))}}return r.length>0?r.join("; "):void 0}function R(e,t){return e.find(n=>n.target===t)??{target:t,keys:[t]}}function l(e,t){return e[t]===!0?!0:void 0}function T(e,t){return e[t]===!1?!0:void 0}function z(e,t){return t.some(r=>e[r]===!0)?!0:void 0}function ne(e,t){for(let[r,n]of Object.entries(t))r==="__proto__"||r==="constructor"||r==="prototype"||Object.hasOwn(e,r)||(e[r]=n)}function _e(e,t={}){let r=a=>P(e,R(G,a)),n=a=>J(e,R(k,a)),o=r("type");if(t.requireType!==!1&&o===void 0)throw new p("Missing required option --type <value>. Why required: create resolves runtime schema fields/workflow from item type. Retry: add --type <built-in or configured custom type> (example: --type Task).",f.USAGE);let i={title:r("title"),description:r("description"),type:o,template:r("template"),createMode:r("createMode"),defer:n("defer"),deferReason:r("deferReason"),schedulePreset:r("schedulePreset"),status:r("status"),closeReason:r("closeReason"),completedAt:r("completedAt"),priority:r("priority"),tags:r("tags"),addTags:n("addTags"),body:r("body"),deadline:r("deadline"),estimatedMinutes:r("estimatedMinutes"),acceptanceCriteria:he(e,R(k,"acceptanceCriteria")),definitionOfReady:r("definitionOfReady"),order:r("order"),rank:r("rank"),goal:r("goal"),objective:r("objective"),value:r("value"),impact:r("impact"),outcome:r("outcome"),whyNow:r("whyNow"),author:r("author"),message:r("message"),assignee:r("assignee"),parent:r("parent"),inheritFocus:e.inheritFocus,allowMissingParent:z(e,["allowMissingParent","allow_missing_parent"])===!0,allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,allowDuplicate:l(e,"allowDuplicate")===!0,reviewer:r("reviewer"),risk:r("risk"),confidence:r("confidence"),sprint:r("sprint"),release:r("release"),blockedBy:r("blockedBy"),blockedReason:r("blockedReason"),unblockNote:r("unblockNote"),reporter:r("reporter"),severity:r("severity"),environment:r("environment"),reproSteps:r("reproSteps"),resolution:r("resolution"),expectedResult:r("expectedResult"),actualResult:r("actualResult"),affectedVersion:r("affectedVersion"),fixedVersion:r("fixedVersion"),component:r("component"),regression:e.regression===!0?"true":r("regression"),customerImpact:r("customerImpact"),dep:n("dep"),comment:n("comment"),note:n("note"),learning:n("learning"),file:n("file"),test:n("test"),doc:n("doc"),reminder:n("reminder"),event:n("event"),typeOption:n("typeOption"),field:n("field"),unset:n("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(i,e),_(e,i)}function Oe(e){let t=o=>P(e,R($,o)),r=o=>J(e,R(I,o)),n={title:t("title"),description:t("description"),body:t("body"),status:t("status"),closeReason:t("closeReason"),priority:t("priority"),type:t("type"),tags:t("tags"),addTags:r("addTags"),removeTags:r("removeTags"),deadline:t("deadline"),estimatedMinutes:t("estimatedMinutes"),acceptanceCriteria:he(e,R(I,"acceptanceCriteria")),addAc:r("addAc"),removeAc:r("removeAc"),definitionOfReady:t("definitionOfReady"),order:t("order"),rank:t("rank"),goal:t("goal"),objective:t("objective"),value:t("value"),impact:t("impact"),outcome:t("outcome"),whyNow:t("whyNow"),author:t("author"),message:t("message"),force:!!e.force,ownershipMetadataBypass:e.ownershipMetadataBypass===!0?!0:void 0,ownershipDependencyBypass:e.ownershipDependencyBypass===!0?!0:void 0,assignee:t("assignee"),parent:t("parent"),allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,reviewer:t("reviewer"),risk:t("risk"),confidence:t("confidence"),sprint:t("sprint"),release:t("release"),blockedBy:t("blockedBy"),blockedReason:t("blockedReason"),unblockNote:t("unblockNote"),reporter:t("reporter"),severity:t("severity"),environment:t("environment"),reproSteps:t("reproSteps"),resolution:t("resolution"),expectedResult:t("expectedResult"),actualResult:t("actualResult"),affectedVersion:t("affectedVersion"),fixedVersion:t("fixedVersion"),component:t("component"),regression:e.regression===!0?"true":t("regression"),customerImpact:t("customerImpact"),dep:r("dep"),depRemove:r("depRemove"),replaceDeps:l(e,"replaceDeps"),replaceTests:l(e,"replaceTests"),replaceFiles:l(e,"replaceFiles"),replaceDocs:l(e,"replaceDocs"),comment:r("comment"),note:r("note"),learning:r("learning"),file:r("file"),test:r("test"),doc:r("doc"),reminder:r("reminder"),event:r("event"),typeOption:r("typeOption"),field:r("field"),unset:r("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(n,e),_(e,n)}function d(e,t){let r=R(le,t),n=P(e,r);if(n!==void 0)return n;for(let o of r.keys){let i=e[o];if(Array.isArray(i)){let a=i.filter(s=>typeof s=="string");if(a.length>0)return a.join(",")}if(t==="ids"&&typeof i=="string")return i;if(typeof i=="number"&&Number.isFinite(i))return String(i)}}function Xe(e){let t=l(e,"filterFilesMissing"),r=l(e,"filterDocsMissing");return{filterReviewerMissing:l(e,"filterReviewerMissing"),filterRiskMissing:l(e,"filterRiskMissing"),filterConfidenceMissing:l(e,"filterConfidenceMissing"),filterSprintMissing:l(e,"filterSprintMissing"),filterReleaseMissing:l(e,"filterReleaseMissing"),hasNotes:l(e,"hasNotes"),hasLearnings:l(e,"hasLearnings"),hasFiles:l(e,"hasFiles"),hasDocs:l(e,"hasDocs"),hasTests:l(e,"hasTests"),hasComments:l(e,"hasComments"),hasDeps:l(e,"hasDeps"),hasBody:l(e,"hasBody"),hasLinkedCommand:l(e,"hasLinkedCommand"),noNotes:T(e,"notes"),noLearnings:T(e,"learnings"),noFiles:T(e,"files")??t,filterFilesMissing:t,noDocs:T(e,"docs")??r,filterDocsMissing:r,noTests:T(e,"tests"),noComments:T(e,"comments"),noDeps:T(e,"deps"),emptyBody:l(e,"emptyBody"),noLinkedCommand:T(e,"linkedCommand")}}function Te(e){let t={status:d(e,"status"),type:d(e,"type"),tag:d(e,"tag"),priority:d(e,"priority"),deadlineBefore:d(e,"deadlineBefore"),deadlineAfter:d(e,"deadlineAfter"),updatedAfter:d(e,"updatedAfter"),updatedBefore:d(e,"updatedBefore"),createdAfter:d(e,"createdAfter"),createdBefore:d(e,"createdBefore"),today:l(e,"today"),recent:l(e,"recent"),ids:d(e,"ids"),assignee:d(e,"assignee"),assigneeFilter:d(e,"assigneeFilter"),parent:d(e,"parent"),sprint:d(e,"sprint"),release:d(e,"release"),limit:d(e,"limit"),offset:d(e,"offset"),noTruncate:T(e,"truncate"),includeBody:l(e,"includeBody"),strictRead:l(e,"strictRead"),compact:l(e,"compact"),brief:l(e,"brief"),full:l(e,"full"),fields:d(e,"fields"),sort:d(e,"sort"),order:d(e,"order"),tree:l(e,"tree"),treeDepth:d(e,"treeDepth"),filterAcMissing:l(e,"filterAcMissing"),filterEstimatesMissing:z(e,["filterEstimatesMissing","filterEstimateMissing"]),filterResolutionMissing:l(e,"filterResolutionMissing"),filterMetadataMissing:l(e,"filterMetadataMissing"),...Xe(e)};return ne(t,e),t}var Ze=Symbol("pm.mcp-mutation-transport"),Qe=new Set(["create","update","append"]),W={create:{parameters:U,aliases:j,strings:G,repeatables:k},update:{parameters:B,aliases:w,strings:$,repeatables:I}},et=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function L(e){return Ze in e}function Y(e,t){return L(e)?ue(t):_(e,t)}function Ur(e,t,r=[]){let n=_(e,{...e,...t});for(let o of r)Reflect.deleteProperty(n,o);return n}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r:void 0}function m(e,t){let r=e[t];return typeof r=="string"?r.trim().length>0?r:void 0:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function Br(e,t){let r=e[t];return typeof r=="string"?r:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jr(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new p(`${t} must be a finite integer.`,f.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let r=Number(e);if(!Number.isInteger(r))throw new p(`${t} must be a finite integer.`,f.USAGE);return r}}function Gr(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:c(e,"limit")??c(t,"limit")}function $r(e){let t=c(e,"outputFormat");return{json:!0,quiet:!0,author:c(e,"author"),path:c(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:c(e,"outputInclude"),outputLimit:m(e,"outputLimit"),outputBudget:m(e,"outputBudget"),outputSession:c(e,"outputSession"),outputCursor:c(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var Ee=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ve=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),tt=new Set([...ve].filter(e=>e!=="file")),rt=new Set(["files","files-discover","docs","test","test-all"]),oe=new Set(["comments","notes","learnings"]);function nt(e,t){if(!(!oe.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new p(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,f.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var it=new Set(["claim","release","start-task","pause-task","close-task"]),xe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline"],package:["dryRun","offline"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},at=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),ot=new Set(["query","keywords","id","text"]);function st(e){return at.has(e)?F[e].optional.filter(t=>!ot.has(t)):[]}var lt=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function ct(e,t){if(!lt.has(e??""))return t;let r={...t};for(let n of F[e].optional){let o=n.replace(/[A-Z]/gu,i=>`_${i.toLowerCase()}`);o===n||r[o]===void 0||(r[n]??=r[o],delete r[o])}return r}function ut(e,t,r){if(!oe.has(e??""))return r;let n=r,o=n.text??t.text;if(o===void 0)return n;if(n.add!==void 0&&n.add!==o){let a=e.replace(/s$/u,"");throw new p(`Specify ${a} text either as text or with add, not both.`,f.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${a} text once: text and add are the same source.`})}let i={...n,add:o};return delete i.text,i}function dt(e,t){let r=t.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return e[t]!==void 0||e[r]!==void 0}function ft(e){return[...xe[e]??[],...st(e),...be]}var be=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function Me(e,t=""){let r={},n=rt.has(t),o=t==="files"||t==="files-discover"||t==="docs",i=oe.has(t)?tt:ve;for(let[a,s]of Object.entries(e)){if(Array.isArray(s)&&Ee.has(a)){r[a]=s.join(",");continue}if(a==="note"&&o){r[a]=s;continue}if(typeof s=="string"&&i.has(a)){r[a]=[s];continue}if(typeof s=="string"&&n&&(a==="add"||a==="remove")){r[a]=[s];continue}r[a]=s}return Object.assign(r,Object.fromEntries(Object.getOwnPropertySymbols(e).map(a=>[a,Reflect.get(e,a)]))),r}function pt(e,t,r){let n=c(e,"author");return n!==void 0?n:r!==void 0&&it.has(r)?c(e,"assignee")??c(t,"assignee"):void 0}function mt(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function yt(e,t,r){let n={},o=W[e],i=new Set([...o.parameters.map(({param:a})=>a),...N.map(({param:a})=>a),...xe[e],...be,"force"]);for(let a of i){let s=o.aliases.find(u=>u.keys.includes(a))?.keys??[a];t[a]===void 0||s.some(u=>r[u]!==void 0)||(n[a]=t[a])}return n}function b(e,t){throw new p(`Invalid MCP ${e} value for "${t}". No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function gt(e,t,r){let n=W[e],o=[...n.parameters,...N,{param:"force"}];for(let{param:i}of o){if(S(E[i]).type!=="boolean")continue;let s=(n.aliases.find(u=>u.keys.includes(i))?.keys??[i]).find(u=>r[u]!==void 0&&typeof r[u]!="boolean");s!==void 0&&b(e,s)}for(let i of["idOnly","fullChangedFields"])t[i]!==void 0&&typeof t[i]!="boolean"&&b(e,i)}function At(e,t,r){t.options!==void 0&&!g(t.options)&&b(e,"options"),gt(e,t,r);for(let a of Ee){let s=r[a];Array.isArray(s)&&s.some(u=>typeof u!="string")&&b(e,a)}let n=Ie(r,e),o=W[e];for(let{keys:a,target:s}of o.strings)a.some(u=>r[u]!==void 0)&&n[s]===void 0&&b(e,s);let i=o.repeatables.flatMap(({keys:a})=>a).find(a=>{let s=r[a];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(u=>typeof u!="string"))});return i!==void 0&&b(e,i),n}function ht(e,t,r,n,o){let i=(t==="create"||t==="update")&&L(e),a={...i?yt(t,e,n):r,...n};if((t==="create"||t==="update")&&!i){let s=g(e.options)&&K(e.options);s||H(t,a),re(t,a,!0,s)}return i?At(t,e,a):o?Me(a,t):a}function _t(e,t){return!Qe.has(e??"")||K(t)?t:fe(t)}function Vr(e,t,{nativeAction:r=!0}={}){Ae(t,e);let n=g(e.options)?e.options:void 0,o=S(e.options),i={},a=A=>{dt(o,A)||e[A]===void 0||(i[A]=e[A])};for(let A of ft(t??""))a(A);t!==void 0&&L(e)&&nt(t,o);let s=ut(t,e,ct(t,ht(e,t,i,o,r)));if(t==="history-attest"&&L(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new p("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",f.USAGE);let u=L(e)?e:n??e,h=Y(u,mt(s,pt(e,s,t)));return _t(t,h)}function Hr(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function zr(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function Ot(e){let t=[],r=!0;for(let n of e.trim().toLowerCase()){if(n>="a"&&n<="z"||n>="0"&&n<="9"){t.push(n),r=!1;continue}r||(t.push("-"),r=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function qr(e){return!et.has(Ot(e))}function Yr(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function Tt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function Wr(e,t){let r=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),n={};for(let[i,a]of Object.entries(e))r.has(i)||(n[i]=a);let o={...n,...t};return delete o.args,delete o.author,o}function Jr(e,t){let r=Y(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:r}}function ae(e){return{type:m(e,"filterType"),tag:m(e,"filterTag"),priority:m(e,"filterPriority"),deadlineBefore:m(e,"filterDeadlineBefore"),deadlineAfter:m(e,"filterDeadlineAfter"),updatedAfter:m(e,"filterUpdatedAfter"),updatedBefore:m(e,"filterUpdatedBefore"),createdAfter:m(e,"filterCreatedAfter"),createdBefore:m(e,"filterCreatedBefore"),ids:Z(e.ids),assignee:m(e,"filterAssignee"),assigneeFilter:m(e,"filterAssigneeFilter")??m(e,"filterAssignee_filter"),parent:m(e,"filterParent"),sprint:m(e,"filterSprint"),release:m(e,"filterRelease"),limit:m(e,"limit"),offset:m(e,"offset")}}function ie(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return Tt(e)}function q(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function Xr(e){let t=ie(e.kind),r=ie(e.exemptIsolate),n=ie(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:q(e.maxDepth),limit:q(e.limit),after:c(e,"after"),direction:c(e,"direction"),maxPaths:q(e.maxPaths),sample:q(e.sample),...r===void 0?{}:{exemptIsolate:r},...n===void 0?{}:{exemptIsolateType:n},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function ke(e){let t=Te(e);return e.ids!==void 0&&(t.ids=Z(e.ids)),t}function Zr(e){return{status:c(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),reason:c(e,"reason"),completedAt:c(e,"completedAt")??c(e,"completed_at"),resolution:c(e,"resolution"),expectedResult:c(e,"expectedResult")??c(e,"expected_result")??c(e,"expected"),actualResult:c(e,"actualResult")??c(e,"actual_result")??c(e,"actual"),validateClose:c(e,"validateClose")??c(e,"validate_close"),author:c(e,"author"),message:c(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var se=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function Se(e){let t={};for(let[r,n]of Object.entries(e))se.has(r)||(t[r]=n);return we(t)}function we(e){return Ie(e,"update")}function Ie(e,t){let r=Me(e,t),n=W[t],o=new Set([...n.parameters,...N].filter(({booleanish:i})=>i===!0).map(({param:i})=>i));for(let{keys:i}of n.repeatables)for(let a of i)typeof r[a]=="string"&&(r[a]=[r[a]]);for(let i of n.strings)for(let a of i.keys){let s=r[a];(typeof s=="number"&&Number.isFinite(s)||s===!1&&o.has(a))&&(r[a]=String(s))}return t==="create"?{..._e(r,{requireType:!1})}:Oe(r)}var St=new Map(w.flatMap(({target:e,keys:t})=>t.map(r=>[r,e])));function Ct(e){return e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"}function Ce(e,t){throw new p(`update-many "${e}" cannot be null. No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:e,required:t})}function Rt(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!se.has(t)))}function Re(e,t,r){if(!e)return;let n=g(t.list)?t.list:{},o=g(t.update)?t.update:void 0,i=Object.keys(t).find(s=>t[s]===null&&(o!==void 0||se.has(s)||Ct(s)))??Object.keys(n).filter(s=>n[s]===null).map(s=>`list.${s}`)[0];i!==void 0&&Ce(i,`"${i}" selects rows or controls the run: omit it or pass a value. To clear an item field, pass null on the field itself${o===void 0?"":" inside update"}.`);let a=o??Rt(t);for(let[s,u]of Object.entries(a)){if(u!==null)continue;let h=St.get(s);h===void 0&&Ce(s,`Pass unset: ["${s}"] to clear a field, or omit "${s}".`),r[h]=null}}var Nt=["author","message"];function Et(e,t){let r=Object.fromEntries(Nt.filter(n=>typeof e[n]=="string"&&t[n]===void 0).map(n=>[n,e[n]]));return e.force===!0&&t.force===void 0&&(r.force=!0),Object.keys(r).length===0?t:_(t,{...t,...r})}function Qr(e,t=!1){if(g(e.list)||g(e.update)){let n=g(e.update)?Et(e,e.update):Se(e),o=Y(e,we(n));return Re(t,e,o),{status:m(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),update:de(n,o),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}let r=Y(e,Se(e));return Re(t,e,r),{status:m(e,"filterStatus"),list:ae(e),update:r,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function Ne(e){return"expectHash"in e||"expect_hash"in e}function en(e){if(!Ne(e)&&!(g(e.options)&&Ne(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:r,...n}=e,o=g(n.options)?n.options:{},{expectHash:i,expect_hash:a,...s}=o,u=[t,r,i,a].filter(M=>M!==void 0),h=u.length>1?u.flatMap(M=>Array.isArray(M)?M:[M]):u[0],A=_(e,"options"in n?{...n,options:g(n.options)?_(n.options,s):n.options}:n);return{expectHash:h,dispatchArgs:A}}export{bt as a,v as b,Mt as c,kt as d,wt as e,Ke as f,ee as g,Le as h,Dt as i,Ue as j,Be as k,je as l,Lt as m,D as n,te as o,Wt as p,He as q,Jt as r,We as s,L as t,Ur as u,c as v,m as w,Br as x,g as y,jr as z,Gr as A,$r as B,xe as C,Me as D,Vr as E,Hr as F,zr as G,Ot as H,qr as I,Yr as J,Tt as K,Wr as L,Jr as M,ae as N,Xr as O,Zr as P,se as Q,we as R,Qr as S,en as T};
2
+ //# sourceMappingURL=chunk-YYEWIKNI.js.map
@@ -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-YD66IRSL.js";import{L as Le,e as je}from"./chunk-5LDBS6MS.js";import{s as Me,y as Pe}from"./chunk-HL47UQZJ.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-SMMOZ3H3.js";import{t as Ce}from"./chunk-3Z7MCUJM.js";import{O as Se}from"./chunk-RIQUIHYU.js";import{A as x,F as j,I as re,K as ke,z as v}from"./chunk-A6VEMCRR.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-Z7W2RQIB.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-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,2 +1,2 @@
1
- import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i}from"./chunk-C7WHWI7K.js";import"./chunk-LMFIAQ2V.js";import"./chunk-BWOVFE5B.js";import"./chunk-3Z7MCUJM.js";import"./chunk-RIQUIHYU.js";import"./chunk-A6VEMCRR.js";export{i as assertFieldDefinitionOptionsAvailable,h as assertFieldOptionsAvailable,e as describeFieldFlagSpellingDefectLine,f as describeFieldOptionCollision,d as resolveAddFieldFlagSpellingDefects,b as resolveAddFieldOptionCollisions,c as resolveFieldFlagSpellingDefects,a as resolveFieldOptionCollisions,g as scanFieldOptionCollisions};
2
- //# sourceMappingURL=field-option-collisions-UODPSV6W.js.map
1
+ import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i}from"./chunk-SXC2EO3E.js";import"./chunk-A4R57E4K.js";import"./chunk-BWOVFE5B.js";import"./chunk-WVA5KOXF.js";import"./chunk-OCKKIECS.js";import"./chunk-NGFDPEP7.js";export{i as assertFieldDefinitionOptionsAvailable,h as assertFieldOptionsAvailable,e as describeFieldFlagSpellingDefectLine,f as describeFieldOptionCollision,d as resolveAddFieldFlagSpellingDefects,b as resolveAddFieldOptionCollisions,c as resolveFieldFlagSpellingDefects,a as resolveFieldOptionCollisions,g as scanFieldOptionCollisions};
2
+ //# sourceMappingURL=field-option-collisions-5ROXGUME.js.map
@@ -1,4 +1,4 @@
1
- import{b as E}from"./chunk-RIE3SJSE.js";import{c as I}from"./chunk-AIDL2ZNT.js";import"./chunk-A6VEMCRR.js";import{execFile as M}from"node:child_process";import{realpath as x}from"node:fs/promises";import w from"node:path";import{promisify as N}from"node:util";var b=N(M),_="[a-f0-9]{40}(?:[a-f0-9]{24})?",R=new RegExp(`^100(?:644|755) (${_}) 0$`,"u"),B=new RegExp(`^(${_}) blob (\\d+)$`,"u");async function v(o,a,r){let t=b("git",o,{...r,encoding:"buffer"}),e=t.child.stdin;return e!==null&&(e.on("error",()=>{t.child.kill()}),e.end(`${a.join(`
1
+ import{b as E}from"./chunk-4SX2BN4V.js";import{c as I}from"./chunk-AIDL2ZNT.js";import"./chunk-NGFDPEP7.js";import{execFile as M}from"node:child_process";import{realpath as x}from"node:fs/promises";import w from"node:path";import{promisify as N}from"node:util";var b=N(M),_="[a-f0-9]{40}(?:[a-f0-9]{24})?",R=new RegExp(`^100(?:644|755) (${_}) 0$`,"u"),B=new RegExp(`^(${_}) blob (\\d+)$`,"u");async function v(o,a,r){let t=b("git",o,{...r,encoding:"buffer"}),e=t.child.stdin;return e!==null&&(e.on("error",()=>{t.child.kill()}),e.end(`${a.join(`
2
2
  `)}
3
3
  `)),(await t).stdout}function S(o,a){let r=new Map;for(let t of o.split("\0")){let e=t.indexOf(" "),i=t.slice(e+1),n=R.exec(t.slice(0,e));n!==null&&a.has(i)&&r.set(i,n[1])}return r}function y(o,a,r){let t=[],e=[],i=0;for(let n of o.trimEnd().split(/\r?\n/u)){let s=B.exec(n);if(s===null||!a.has(s[1]))continue;let c=Number(s[2]);!Number.isSafeInteger(c)||c>r||(e.length>0&&i+c+128>r&&(t.push(e),e=[],i=0),e.push({id:s[1],size:c}),i+=c+128)}return e.length>0&&t.push(e),t}function z(o,a,r){let t=0;for(let{id:e,size:i}of a){let n=o.indexOf(10,t)+1;if(n===0||o.subarray(t,n-1).toString("ascii")!==`${e} blob ${i}`||o[n+i]!==10)throw new Error("Invalid indexed receipt batch framing");r.set(e,o.subarray(n,n+i).toString("utf8")),t=n+i+1}if(t!==o.length)throw new Error("Unexpected indexed receipt batch data")}async function C(o,a,r,t,e,i={}){let n=I();n.GIT_NO_REPLACE_OBJECTS="1",e===void 0&&process.env.GIT_INDEX_FILE!==void 0&&(n.GIT_INDEX_FILE=w.resolve(process.env.GIT_INDEX_FILE));let s={cwd:o,env:n,windowsHide:!0,timeout:1e4,maxBuffer:t+256};try{let c=(await b("git",["rev-parse","--show-toplevel"],{...s,encoding:"utf8"})).stdout.trim(),[g,$]=await Promise.all([x(c),x(e??a)]),d=w.relative(g,e===void 0?$:w.resolve(e)).replaceAll("\\","/");if(E(d))return new Map;s.cwd=g;let m=new Map(r.map(f=>[`${d}/${f}`,f])),O=(await b("git",["ls-files","--stage","-z","--",`:(literal)${d}/`],{...s,encoding:"utf8"})).stdout,p=S(O,new Set(m.keys()));if(p.size===0)return new Map;let u=new Set(p.values()),T=(await v(["cat-file","--batch-check"],[...u],s)).toString("utf8"),l=new Map;for(let f of y(T,u,t))z(await v(["cat-file","--batch"],f.map(h=>h.id),s),f,l);if(i.failOnReadError&&l.size!==u.size)throw new Error("Unable to read every indexed receipt blob");return new Map([...p].filter(([,f])=>l.has(f)).map(([f,h])=>[m.get(f),l.get(h)]))}catch(c){if(i.failOnReadError)throw c;return new Map}}export{C as readIndexedReceiptBlobs};
4
- //# sourceMappingURL=indexed-receipt-blobs-EGEJMG3G.js.map
4
+ //# sourceMappingURL=indexed-receipt-blobs-PG2VJ3MB.js.map
@@ -1,2 +1,2 @@
1
- import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-3ELVASVA.js";import"./chunk-GXP7Q4XM.js";import"./chunk-FDZPRJXJ.js";import"./chunk-LMU7DDOA.js";import"./chunk-BKPUUW5O.js";import"./chunk-5LDBS6MS.js";import"./chunk-HL47UQZJ.js";import"./chunk-X6CXWWNB.js";import{Dd as a,Ed as b,Fd as c,Gd as d}from"./chunk-SMMOZ3H3.js";import"./chunk-3Z7MCUJM.js";import"./chunk-RIQUIHYU.js";import"./chunk-A6VEMCRR.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
2
- //# sourceMappingURL=item-revision-QH7RNBX4.js.map
1
+ import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-TQIKDFOD.js";import"./chunk-BYQK5DGH.js";import"./chunk-3Y5PTQ2F.js";import"./chunk-VU2PH4PF.js";import"./chunk-BKPUUW5O.js";import"./chunk-7SSGTGZO.js";import"./chunk-MB56Y4M6.js";import"./chunk-X6CXWWNB.js";import{Dd as a,Ed as b,Fd as c,Gd as d}from"./chunk-XKLBTDJ7.js";import"./chunk-WVA5KOXF.js";import"./chunk-OCKKIECS.js";import"./chunk-NGFDPEP7.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
2
+ //# sourceMappingURL=item-revision-KYMSQVZE.js.map