@unbrained/pm-cli 2026.11.25 → 2026.11.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/commander-usage.js +9 -9
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/help-content.js +4 -4
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/runtime/selection.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-CZEMEPPQ.js → chunk-5CMR4R5V.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YIGBEY7K.js → chunk-5M7UTO2G.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-63AVXDZS.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CONBVY2O.js → chunk-66TNCHHG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LPW7S5KA.js → chunk-6NJ3BONB.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-AVHRMUXJ.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-FVY7U3SU.js → chunk-HTT52JL3.js} +37 -37
- package/dist/cli-bundle/chunks/{chunk-OS5W4ZG2.js → chunk-J25DZRYJ.js} +31 -31
- package/dist/cli-bundle/chunks/chunk-J6TFG34A.js +4 -0
- package/dist/cli-bundle/chunks/{chunk-K34FR5CO.js → chunk-JX475QVU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-KP75JTTO.js +35 -0
- package/dist/cli-bundle/chunks/chunk-KS47NGMQ.js +69 -0
- package/dist/cli-bundle/chunks/{chunk-BVJMVU4Z.js → chunk-O23KTJL6.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-DF6A7C32.js → chunk-OFX2VA5Z.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FHLOGAGA.js → chunk-QVDEZBSV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-SIRZ4VMT.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-C4KIZQHW.js → chunk-VC4BJIA7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GBVF2ZB3.js → chunk-W7SPEGSP.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WY7467RY.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-7EPYCU7U.js → chunk-X6TE47CS.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-XB6QEVUK.js +2 -0
- package/dist/cli-bundle/chunks/chunk-XYX4CXFR.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-SCIPT7WF.js → chunk-Y5U7QCNX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-L6VS7F3R.js → chunk-YGK6SA7P.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OWK2JL4I.js → chunk-ZGV4ZXDS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CNUFU454.js → chunk-ZILIHDDY.js} +41 -41
- package/dist/cli-bundle/chunks/{field-option-collisions-QE65APSD.js → field-option-collisions-UL6BIPAK.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-INDHJV6X.js → item-revision-WNUDY5DM.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-ER3OWOPV.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-KU7BMLUN.js → mutation-actor-SFYTD2ZB.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-3OMCTQD4.js → mutation-admission-AVOOT3KH.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-3GV3LBOT.js → register-list-query-Q7UW2EPV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-GZLF47SX.js → register-mutation-YNW7E3T4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-PBJZGCAL.js → register-operations-DAUTQCIO.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-VSURGF7V.js +2 -0
- package/dist/cli-bundle/chunks/{stage-3WIZBD4N.js → stage-N5GDBS5A.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-X4EWD6TL.js → chunk-24W63UPP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-C3FEDTSD.js → chunk-2XGHBYDA.js} +26 -26
- package/dist/cli-bundle/focused-chunks/{chunk-ZLRRII55.js → chunk-3QRMY6KF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PKX2EHE3.js → chunk-4HLZOOZI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-52PHSTGP.js +27 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YYEWIKNI.js → chunk-7FKGIJEB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7GZMOLQY.js +15 -0
- package/dist/cli-bundle/focused-chunks/chunk-AL47ODFZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-AN4NFFLL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-BYQK5DGH.js → chunk-B2HJI6KA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JOKRDFMQ.js → chunk-C2HW7BSE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TQIKDFOD.js → chunk-GISZWMBS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BOIMP2AR.js → chunk-GUAT4OAC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VU2PH4PF.js → chunk-H4JBS477.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XKLBTDJ7.js → chunk-HGJ4MILN.js} +37 -37
- package/dist/cli-bundle/focused-chunks/{chunk-TRL4JDWX.js → chunk-HSWL6L2O.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SXC2EO3E.js → chunk-I4GY7HAP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KMG4O2IU.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4LQL4EO6.js → chunk-N7ZAMULP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UWWAVXG4.js → chunk-REORRDPH.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-MB56Y4M6.js → chunk-SXWUKNTY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5RBC4WSE.js → chunk-UGQ2EXTU.js} +58 -59
- package/dist/cli-bundle/focused-chunks/chunk-YPOATPTX.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7SSGTGZO.js → chunk-ZZYJS74B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-5ROXGUME.js → field-option-collisions-BP7ILGQK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-KYMSQVZE.js → item-revision-NOHVIOQQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-I4HLVHEJ.js → item-transaction-O26COBOJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-GGOQKAE6.js → mutation-actor-HVJV5S76.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-OS36ZCMH.js → mutation-admission-JRICEVYN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-4ZFWJUKO.js → stage-NSX6ASBZ.js} +2 -2
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +4 -4
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +63 -63
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/reproducibility/context.d.ts +2 -0
- package/dist/core/reproducibility/context.js +1 -1
- package/dist/core/shared/command-line.d.ts +2 -2
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/secret-rules.js +5 -5
- package/dist/sdk/cli-bootstrap.d.ts +17 -0
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/completion/shared.d.ts +1 -1
- package/dist/sdk/completion/shared.js +1 -1
- package/dist/sdk/extension/bundled-catalog.js +1 -1
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/extension/listing-fields.d.ts +15 -0
- package/dist/sdk/extension/listing-fields.js +2 -0
- package/dist/sdk/extension/managed-update-status.js +1 -1
- package/dist/sdk/extension/npm-spec.d.ts +18 -0
- package/dist/sdk/extension/npm-spec.js +2 -0
- package/dist/sdk/extension/static-inventory.d.ts +53 -1
- package/dist/sdk/extension/static-inventory.js +1 -1
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension/update-observations.js +3 -0
- package/dist/sdk/extension/upgrade-hints.js +2 -0
- package/dist/sdk/extension.d.ts +2 -0
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/upgrade.d.ts +7 -2
- package/dist/sdk/governance/upgrade.js +2 -2
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/context.d.ts +20 -7
- package/dist/sdk/query/context.js +4 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/testing.d.ts +20 -2
- package/docs/COMMANDS.md +19 -1
- package/docs/CONFIGURATION.md +1 -1
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +6 -0
- package/docs/EXTENSION_LIFECYCLE.md +72 -2
- package/docs/MUTATION_INTEGRITY.md +47 -0
- package/docs/SDK.md +24 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-4FZH5BTV.js +0 -2
- package/dist/cli-bundle/chunks/chunk-GZI7ZAB7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-LOX3VY4T.js +0 -2
- package/dist/cli-bundle/chunks/chunk-VA4T37Q4.js +0 -70
- package/dist/cli-bundle/chunks/chunk-WQOEVGLQ.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XHCIOLJP.js +0 -3
- package/dist/cli-bundle/chunks/chunk-XKWJONAO.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZBOQEZ2H.js +0 -33
- package/dist/cli-bundle/chunks/chunk-ZLICQPRG.js +0 -3
- package/dist/cli-bundle/chunks/item-transaction-LCKK4XXB.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-ZLJEF6NZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3Y5PTQ2F.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-A4R57E4K.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IAOKVKWW.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VMYVN36N.js +0 -13
- package/dist/cli-bundle/focused-chunks/chunk-WL2R7T5G.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WVA5KOXF.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as Fe,o as G,p as Ge,q as $e,s as qe,w as $,x as Ue,y as Be,z as ze}from"./chunk-JOKRDFMQ.js";import{L as Le,e as je}from"./chunk-7SSGTGZO.js";import{s as Me,y as Pe}from"./chunk-MB56Y4M6.js";import{a as k}from"./chunk-BWOVFE5B.js";import{Cf as De,Df as se,Gb as Ne,Gf as Oe,Q as Ee,W as Ie,dc as Ae,je as Te,q as ve,v as xe,va as ie,ze as Re}from"./chunk-XKLBTDJ7.js";import{t as Ce}from"./chunk-WVA5KOXF.js";import{O as Se}from"./chunk-OCKKIECS.js";import{A as x,F as j,I as re,K as ke,z as v}from"./chunk-NGFDPEP7.js";function Ut(e,t,n,r,i,s){if(e.seen.has(t))return"skip";if(e.cursorFound&&e.affected.length>=s)return"truncate";e.seen.add(t),e.parents.set(t,n.id);let o=n.depth+1;return e.queue.push({id:t,depth:o}),e.cursorFound?(e.affected.push({id:t,distance:o,path:Yt(r,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function Ke(e,t,n,r){let i=De("graph impact",{root:e,direction:n,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(r)?r:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:Oe(t.after,i)}}function C(e,t,n){e.get(t).add(n)}function M(e){return new Map(e.map(t=>[t,new Set]))}function Ve(e){for(let t of e)t.sort();return e.sort((t,n)=>n.length-t.length||t[0].localeCompare(n[0]))}function q(e){if(Array.isArray(e))return e.map(n=>q(n));if(e===null||typeof e!="object")return e;let t=e.toJSON;return typeof t=="function"?q(t.call(e)):Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,q(r)]))}function He(e){return JSON.stringify(q(e))}function Bt(e,t,n,r){let i=[{id:e,expanded:!1}];for(;i.length>0;){let s=i.pop();if(s.expanded){r.push(s.id);continue}if(n.has(s.id))continue;n.add(s.id),i.push({id:s.id,expanded:!0});let o=[...t.get(s.id)].sort().reverse();for(let c of o)n.has(c)||i.push({id:c,expanded:!1})}}function zt(e,t){let n=new Set,r=[];for(let i of e)n.has(i)||Bt(i,t,n,r);return r}function Ht(e,t){let n=new Set,r=[];for(let i of[...e].reverse()){if(n.has(i))continue;let s=[],o=[i];for(n.add(i);o.length>0;){let c=o.pop();s.push(c);for(let a of t.get(c))n.has(a)||(n.add(a),o.push(a))}r.push(s)}return Ve(r)}function We(e,t){let n=M(e);for(let[r,i]of t)for(let s of i)C(n,s,r);return Ht(zt(e,t),n)}function Kt(e,t){let n=M(e.nodes());for(let r of e.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let s=(i.precedence??"source_before_target")==="source_before_target";C(n,s?r.source:r.target,s?r.target:r.source)}return n}function Vt(e,t){let n=new Map(e.map(s=>[s,0]));for(let s of t.values())for(let o of s)n.set(o,n.get(o)+1);let r=e.filter(s=>n.get(s)===0).sort(),i=[];for(;r.length>0;){i.push(r);let s=[];for(let o of r)for(let c of t.get(o)){let a=n.get(c)-1;n.set(c,a),a===0&&s.push(c)}r=s.sort()}return i}function Wt(e,t){let n=new Map(e.map(o=>[o,0])),r=new Map;for(let o of e)for(let c of t.get(o)){if(!n.has(c))continue;let a=n.get(o)+1,d=r.get(c);(a>n.get(c)||a===n.get(c)&&(d===void 0||o.localeCompare(d)<0))&&(n.set(c,a),r.set(c,o))}let i=[...e].sort((o,c)=>n.get(c)-n.get(o)||o.localeCompare(c))[0],s=i===void 0?[]:[i];for(;s[0]!==void 0&&r.has(s[0]);)s.unshift(r.get(s[0]));return{depth:Object.fromEntries(n),path:s}}function Yt(e,t,n){let r=[t],i=t;for(;i!==e;)i=n.get(i),r.push(i);return r.reverse()}function B(e,t={}){let n=t.registry??ve(),r=[...e.nodes()],i=Kt(e,n),s=Vt(r,i),o=s.flat(),c=o.length===r.length,a=c?[]:We(r,i).filter(l=>l.length>1||i.get(l[0]).has(l[0])),d=Wt(o,i);return{exact:!0,acyclic:c,order:o,layers:s,frontier:s[0]??[],depth:d.depth,criticalPath:d.path,criticalPathLength:Math.max(0,d.path.length-1),cycles:a,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function Xt(e,t,n){let r=M(e.nodes()),i=n===void 0?void 0:new Set(n.map(o=>e.registry().require(o).kind)),s=e.edges();for(let o of s){let c=e.registry().require(o.kind);i!==void 0&&!i.has(o.kind)&&(c.inverse===void 0||!i.has(c.inverse))||C(r,t==="incoming"?o.target:o.source,t==="incoming"?o.source:o.target)}return{adjacency:r,inspectedEdges:s.length}}function Jt(e,t,n,r,i,s){let o=U(e,t,{...n,after:void 0,direction:"incoming",limit:void 0}),c=U(e,t,{...n,after:void 0,direction:"outgoing",limit:void 0}),a=new Map,d=[...o.affected,...c.affected].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)||p.path.join("\0").localeCompare(m.path.join("\0")));for(let p of d)a.has(p.id)||a.set(p.id,p);let l=[...a.values()].sort((p,m)=>p.distance-m.distance||p.id.localeCompare(m.id)),f=r===void 0||r===t?-1:l.findIndex(p=>p.id===r);if(r!==void 0&&r!==t&&f<0)throw new TypeError(`Unknown impact cursor item: ${r}`);let u=l.slice(f+1,f+1+i),g=f+1+u.length<l.length;return{root:t,affected:u,exact:!0,truncated:o.truncated||c.truncated||g,...g?{nextCursor:se(s,u.at(-1)?.id??t)}:{},cost:{visitedNodes:o.cost.visitedNodes+c.cost.visitedNodes,inspectedEdges:o.cost.inspectedEdges+c.cost.inspectedEdges}}}function Qt(e,t,n){let r=n.direction,i=n.maxDepth??Number.POSITIVE_INFINITY,s=n.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=Ke(t,n,r,i),{adjacency:a,inspectedEdges:d}=Xt(e,r,n.kinds),l={queue:[{id:t,depth:0}],seen:new Set([t]),parents:new Map,affected:[],cursorFound:c===void 0||c===t},f=0,u=!1,g=!1;e:for(let p=0;p<l.queue.length;p+=1){n.signal?.throwIfAborted();let m=l.queue[p];f+=1;let b=[...a.get(m.id)].sort();if(m.depth>=i){b.some(w=>!l.seen.has(w))&&(u=!0);continue}for(let w of b)if(Ut(l,w,m,t,c,s)==="truncate"){u=!0,g=!0;break e}}if(!l.cursorFound)throw new TypeError(`Unknown impact cursor item: ${c}`);return{root:t,affected:l.affected,exact:!0,truncated:u,...g?{nextCursor:se(o,l.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:f,inspectedEdges:d}}}function U(e,t,n={}){let r=n.direction??"outgoing";if(r!=="both")return Qt(e,t,{...n,direction:r});let i=n.maxDepth??Number.POSITIVE_INFINITY,s=n.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=Ke(t,n,r,i);return Jt(e,t,n,c,s,o)}function Ye(e){let t=[...e.nodes()],n=M(t),r=M(t);for(let a of e.edges())C(n,a.source,a.target),C(n,a.target,a.source),C(r,a.source,a.target);let i=[],s=new Set;for(let a of t){if(s.has(a))continue;let d=[],l=[a];for(s.add(a);l.length>0;){let f=l.pop();d.push(f);for(let u of n.get(f))s.has(u)||(s.add(u),l.push(u))}i.push(d)}let o=t.map(a=>({id:a,degree:n.get(a).size})),c=Math.max(0,...o.map(({degree:a})=>a));return{components:Ve(i),stronglyConnected:We(t,r),orphans:o.filter(({degree:a})=>a===0).map(({id:a})=>a),hubs:o.filter(({degree:a})=>a>0&&a===c),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function Xr(e,t){let n=new Map(e.edges.map(i=>[He(i),i])),r=new Map(t.edges.map(i=>[He(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),removed:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),unchangedCount:[...n.keys()].filter(i=>r.has(i)).length,exact:!0}}var Zt=k.paths,en=k.visited_paths,tn=k.path_depth;function oe(e,t){if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new TypeError(`Invalid path ${e} bound: ${String(t)}`)}function z(e,t){return t.hierarchyDirection==="target_parent"?e.target:e.source}function P(e,t){return(t.precedence??"source_before_target")==="target_before_source"?e.target:e.source}function N(e,t){let n=P(e,t);return{predecessor:n,successor:n===e.source?e.target:e.source}}function nn(e,t,n){if(t===void 0)return;let r=e.registry(),i=new Set;for(let s of t){let o=r.require(s),c=o.traversal;if(c==="association")throw new TypeError(`Relationship kind ${o.kind} uses association traversal; use graph impact --direction both`);if(c!==n&&c!=="semantic"){let a=c==="hierarchy"?"graph ancestors or graph descendants":"graph predecessors or graph successors";throw new TypeError(`Relationship kind ${o.kind} uses ${c} traversal; use ${a}`)}i.add(o.kind)}return i}function rn(e,t,n,r,i){let s=e.registry(),o=e.neighborEdges(t,{direction:"both",...n===void 0?{}:{kinds:[...n]}}),c=[],a=new Set;for(let d of o.value){let l=s.require(d.edge.kind);n===void 0&&!l[r]||i(d,l,t)&&(a.has(d.id)||(a.add(d.id),c.push(d.id)))}return{neighbors:c,inspectedEdges:o.meta.inspectedEdges}}function sn(e,t,n,r,i,s){if(t>=n)return e.neighbors.some(o=>!s.seen.has(o))&&(s.truncated=!0),!1;for(let o of e.neighbors)if(!s.seen.has(o)){if(s.seen.add(o),s.queue.push({id:o,depth:t+1}),!s.resumed){o===i&&(s.resumed=!0);continue}if(s.value.length>=r)return s.truncated=!0,!0;s.value.push(o)}return!1}function H(e,t,n,r,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let s=nn(e,n.kinds,r),o=n.limit??Number.POSITIVE_INFINITY,c=n.maxDepth??Number.POSITIVE_INFINITY,a=n.after,d={seen:new Set([t]),value:[],queue:[{id:t,depth:0}],resumed:a===void 0,truncated:!1},l=0,f=0;for(let u=0;u<d.queue.length;u+=1){n.signal?.throwIfAborted();let g=d.queue[u];l+=1;let p=rn(e,g.id,s,r,i);if(f+=p.inspectedEdges,sn(p,g.depth,c,o,a,d))break}if(!d.resumed)throw new TypeError(`Traversal cursor not found in sequence: ${a}`);return{value:d.value,meta:{visitedNodes:l,inspectedEdges:f,truncated:d.truncated,nextCursor:d.value.at(-1)}}}function Xe(e,t){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`)}function Je(e,t,n,r,i){let s=e.neighborEdges(t.nodes.at(-1),{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});return i.inspectedEdges+=s.meta.inspectedEdges,s.value.filter(o=>!t.nodeSet.has(o.id))}function on(e,t,n,r,i,s,o){for(let c of Je(e,t,r,i,o)){let a=[...t.nodes,c.id],d=new Set(t.nodeSet).add(c.id),l=[...t.edges,c.edge];if(c.id===n){if(o.value.push({nodes:a,edges:l,length:l.length}),o.value.length>=s)return!0}else o.queue.push({nodes:a,nodeSet:d,edges:l})}return!1}function Qe(e,t,n={}){return H(e,t,n,"hierarchy",(r,i)=>z(r.edge,i)===r.id)}function Ze(e,t,n={}){return H(e,t,n,"hierarchy",(r,i,s)=>z(r.edge,i)===s)}function et(e,t,n={}){return H(e,t,n,"ordering",(r,i)=>P(r.edge,i)===r.id)}function tt(e,t,n={}){return H(e,t,n,"ordering",(r,i,s)=>P(r.edge,i)===s)}function cn(e,t,n,r,i,s,o,c){let a={value:[],queue:[{nodes:[t],nodeSet:new Set([t]),edges:[]}],inspectedEdges:0},d=0,l=!1,f=i+1;for(let u=0;u<a.queue.length;u+=1){if(r.signal?.throwIfAborted(),a.value.length>=f||d>=s){l=!0;break}let g=a.queue[u];if(d+=1,g.edges.length>=o){Je(e,g,r,c,a).length>0&&(l=!0);continue}if(on(e,g,n,r,c,f,a)){l=!0;break}}return{value:a.value.slice(0,i),meta:{visitedNodes:d,inspectedEdges:a.inspectedEdges,truncated:l}}}function nt(e,t,n,r={}){Xe(e,t),Xe(e,n);let i=r.maxPaths??Zt,s=r.maxVisitedPaths??en,o=r.maxDepth??tn;oe("maxPaths",i),oe("maxVisitedPaths",s),oe("maxDepth",o);let c=r.direction??"outgoing";r.signal?.throwIfAborted();for(let a of r.kinds??[])e.registry().require(a);return t===n?i===0?{value:[],meta:{visitedNodes:1,inspectedEdges:0,truncated:!0}}:{value:[{nodes:[t],edges:[],length:0}],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}}:cn(e,t,n,r,i,s,o,c)}var an=16,dn=2,ln=8;function K(e,t){if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`)}function V(e,t,n){let r=e.registry(),i=t===void 0?void 0:new Set(t.map(s=>r.require(s).kind));for(let s of e.edges()){if(s.source===s.target)continue;let o=r.require(s.kind);i!==void 0&&!(i.has(o.kind)||o.inverse!==void 0&&i.has(o.inverse))||n(s,o)}}function un(e,t){let n=new Map;V(e,t,r=>{rt(n,r.source,r.target),rt(n,r.target,r.source)});for(let r of n.values())r.sort();return n}function rt(e,t,n){let r=e.get(t);r===void 0?e.set(t,[n]):r.push(n)}function fn(e,t){let n=new Map;for(let s of e){let o=t.get(s);n.set(o,(n.get(o)??0)+1)}let r,i=0;for(let[s,o]of n)(o>i||o===i&&s<r)&&(r=s,i=o);return r}function gn(e,t){let n=new Map;for(let[i,s]of e){let o=n.get(s);o===void 0?n.set(s,[i]):o.push(i)}let r=[];for(let i of n.values())i.length<t||(i.sort(),r.push({representative:i[0],size:i.length,members:i}));return r.sort((i,s)=>s.size-i.size||i.representative.localeCompare(s.representative))}function it(e,t={}){let n=t.maxIterations??an,r=t.minSize??dn;K("maxIterations",n),K("minSize",r);let i=un(e,t.kinds),s=e.nodes(),o=new Map(s.map(f=>[f,f])),c=0,a=!1,d=0,l=0;for(;c<n&&!a;){t.signal?.throwIfAborted(),c+=1,a=!0;for(let f of s){d+=1;let u=i.get(f);if(u===void 0)continue;l+=u.length;let g=fn(u,o);g!==o.get(f)&&(o.set(f,g),a=!1)}}return{value:{communities:gn(o,r),iterations:c,converged:a},meta:{visitedNodes:d,inspectedEdges:l,truncated:!a}}}function W(e){return e.direction==="directed"&&(e.ordering||e.hierarchy)}function Y(e){return e.inverse!==void 0&&e.inverse<e.kind?e.inverse:e.kind}function ce(e,t){return(t.hierarchy?z(e,t):e.source===P(e,t)?e.target:e.source)===e.target?{from:e.source,to:e.target}:{from:e.target,to:e.source}}function pn(e,t){if(t===void 0)return;let n=e.registry(),r=new Set;for(let i of t){let s=n.require(i);if(!W(s))throw new TypeError(`Relationship kind ${s.kind} is not a directed ordering or hierarchy kind`);r.add(Y(s))}return r}function hn(e,t){let n=e.registry(),r=new Map;for(let i of e.edges()){let s=n.require(i.kind);if(!W(s))continue;let o=Y(s);if(t!==void 0&&!t.has(o))continue;let c=ce(i,s);if(c.from===c.to)continue;let a=r.get(o);a===void 0&&(a={adjacency:new Map,records:[]},r.set(o,a));let d=a.adjacency.get(c.from);d===void 0?a.adjacency.set(c.from,new Set([c.to])):d.add(c.to),a.records.push({...c,edge:i})}return r}function mn(e){let t=new Map;for(let[n,r]of e.adjacency)t.set(n,[...r].sort());return t}function _n(e,t,n,r){let i=[r];for(let s=n;s!==t;s=e.get(s))i.push(s);return i.push(t),i.reverse()}function yn(e,t,n,r,i,s){for(let o of e.get(n.id)??[])if(s.inspectedEdges+=1,!(n.depth===0&&o===t.to)&&!r.has(o)){if(r.set(o,n.id),o===t.to)return _n(r,t.from,n.id,o);i.push({id:o,depth:n.depth+1})}}function bn(e,t,n,r){let i=new Map([[t.from,t.from]]),s=[{id:t.from,depth:0}];for(let o=0;o<s.length;o+=1){let c=s[o];if(r.visitedNodes+=1,c.depth>=n)continue;let a=yn(e,t,c,i,s,r);if(a!==void 0)return a}}function A(e,t={}){let n=t.maxDepth??ln;K("maxDepth",n),t.limit!==void 0&&K("limit",t.limit);let r=t.limit??Number.POSITIVE_INFINITY,i=pn(e,t.kinds),s=hn(e,i),o=[],c={visitedNodes:0,inspectedEdges:0},a=!1;e:for(let d of[...s.keys()].sort()){let l=s.get(d),f=mn(l);for(let u of l.records){t.signal?.throwIfAborted();let g=bn(f,u,n,c);if(g!==void 0){if(o.length>=r){a=!0;break e}o.push({edge:u.edge,witness:g})}}}return{value:o,meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:a}}}function wn(e,t,n,r,i){let s=new Set,o=[];for(let c of n){if(c.id===e||s.has(c.id))continue;if(!i.seen.has(c.id)){if(t>=r){i.truncated=!0;continue}i.seen.add(c.id),i.queue.push({id:c.id,depth:t+1})}s.add(c.id),o.push(c.id);let a=i.predecessors.get(c.id);a===void 0&&(a=new Set,i.predecessors.set(c.id,a)),a.add(e)}return o}function vn(e,t,n){let r=n.direction??"outgoing",i=n.maxDepth??Number.POSITIVE_INFINITY,s=[],o=new Map,c={seen:new Set([t]),queue:[{id:t,depth:0}],predecessors:new Map,truncated:!1},a=0;for(let d=0;d<c.queue.length;d+=1){n.signal?.throwIfAborted();let{id:l,depth:f}=c.queue[d];s.push(l);let u=e.neighborEdges(l,{direction:r,...n.kinds===void 0?{}:{kinds:n.kinds}});a+=u.meta.inspectedEdges,o.set(l,wn(l,f,u.value,i,c))}return{order:s,successors:o,predecessors:c.predecessors,inspectedEdges:a,truncated:c.truncated}}function xn(e,t){let n=[],r=new Set([t]),i=[{id:t,index:0}];for(;i.length>0;){let s=i.at(-1),o=e.successors.get(s.id);if(s.index<o.length){let c=o[s.index];s.index+=1,r.has(c)||(r.add(c),i.push({id:c,index:0}))}else n.push(s.id),i.pop()}return n.reverse()}function kn(e,t,n,r){let i=e,s=t;for(;i!==s;){for(;r.get(i)>r.get(s);)i=n.get(i);for(;r.get(s)>r.get(i);)s=n.get(s)}return i}function En(e,t,n){let r;for(let i of[...e].sort())t.has(i)&&(r=r===void 0?i:kn(r,i,t,n));return r}function In(e,t,n,r,i){let s=new Map([[t,t]]),o=!0;for(;o;){o=!1;for(let c of n){if(i?.throwIfAborted(),c===t)continue;let a=En(e.predecessors.get(c),s,r);a!==void 0&&s.get(c)!==a&&(s.set(c,a),o=!0)}}return s}function st(e,t,n={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(n.maxDepth!==void 0&&(!Number.isInteger(n.maxDepth)||n.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(n.maxDepth)}`);let r=vn(e,t,n),i=xn(r,t),s=new Map(i.map((d,l)=>[d,l])),o=In(r,t,i,s,n.signal),c=new Map(i.map(d=>[d,1]));for(let d=i.length-1;d>=0;d-=1){let l=i[d];if(l===t)continue;let f=o.get(l);c.set(f,c.get(f)+c.get(l))}let a=i.filter(d=>d!==t).map(d=>({id:d,idom:o.get(d),dominatedCount:c.get(d)-1})).sort((d,l)=>l.dominatedCount-d.dominatedCount||d.id.localeCompare(l.id));return{value:{root:t,reachableCount:r.order.length,rows:a},meta:{visitedNodes:r.order.length,inspectedEdges:r.inspectedEdges,truncated:r.truncated}}}function ot(e){return Math.round(e*1e6)/1e6}function ct(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function at(e,t){let n=new Map(e.nodes().map(i=>[i,new Set]));V(e,t,i=>{n.get(i.source).add(i.target),n.get(i.target).add(i.source)});let r=new Map;for(let[i,s]of n)r.set(i,[...s].sort());return r}function Sn(e,t){let n=new Map,r=new Map;return V(e,t,(i,s)=>{if(!s.ordering)return;let{predecessor:o,successor:c}=N(i,s);ct(r,o,c),ct(n,c,o)}),{incoming:n,outgoing:r}}function Cn(e,t,n){let r=new Map([[e,0]]),i=new Map([[e,1]]),s=new Map,o=[],c=[e],a=0,d=0;for(let l=0;l<c.length;l+=1){let f=c[l];n.visitedNodes+=1,o.push(f);let u=r.get(f);f!==e&&(a+=1,d+=u);for(let g of t.get(f))if(n.inspectedEdges+=1,r.has(g)||(r.set(g,u+1),c.push(g)),r.get(g)===u+1){i.set(g,(i.get(g)??0)+i.get(f));let p=s.get(g);p===void 0?s.set(g,[f]):p.push(f)}}return{stack:o,sigma:i,predecessors:s,reachableCount:a,distanceSum:d}}function Nn(e,t,n){let r=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let s=e.stack[i],o=(1+(r.get(s)??0))/e.sigma.get(s);for(let c of e.predecessors.get(s)??[])r.set(c,(r.get(c)??0)+e.sigma.get(c)*o);s!==t&&n.set(s,(n.get(s)??0)+(r.get(s)??0))}}function An(e,t){return t<=1||e.reachableCount===0?0:e.reachableCount/(t-1)*(e.reachableCount/e.distanceSum)}function Tn(e,t,n,r,i){return{id:e,degree:t.get(e).length,inDegree:n.incoming.get(e)?.size??0,outDegree:n.outgoing.get(e)?.size??0,betweenness:ot((r.get(e)??0)/2),closeness:ot(i.get(e))}}function dt(e,t={}){let n=at(e,t.kinds),r=Sn(e,t.kinds),i=e.nodes(),s=new Map,o=new Map,c={visitedNodes:0,inspectedEdges:0};for(let l of i){t.signal?.throwIfAborted();let f=Cn(l,n,c);o.set(l,An(f,i.length)),Nn(f,l,s)}let a=0;for(let l of n.values())a+=l.length;let d=i.map(l=>Tn(l,n,r,s,o)).sort((l,f)=>f.betweenness-l.betweenness||f.degree-l.degree||l.id.localeCompare(f.id));return{value:{nodeCount:i.length,edgeCount:a/2,rows:d},meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:!1}}}function Rn(e,t){return e<=t?{source:e,target:t}:{source:t,target:e}}function Dn(e,t,n){let i=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,n.inspectedEdges+=1,i!==e.parent){if(n.discovery.has(i)){n.low.set(e.node,Math.min(n.low.get(e.node),n.discovery.get(i)));return}return e.children+=1,n.discovery.set(i,n.timer),n.low.set(i,n.timer),n.timer+=1,{node:i,parent:e.node,neighborIndex:0,children:0}}}function On(e,t,n){if(e.parent===null){e.children>1&&n.articulation.add(e.node);return}let r=e.parent,i=n.low.get(e.node);n.low.set(r,Math.min(n.low.get(r),i)),r!==t&&i>=n.discovery.get(r)&&n.articulation.add(r),i>n.discovery.get(r)&&n.bridges.push(Rn(r,e.node))}function jn(e,t,n,r){n.discovery.set(e,n.timer),n.low.set(e,n.timer),n.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){r?.throwIfAborted();let s=i.at(-1);if(s.neighborIndex<t.get(s.node).length){let o=Dn(s,t,n);o!==void 0&&i.push(o)}else On(s,e,n),i.pop()}}function X(e,t={}){let n=at(e,t.kinds),r={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())r.discovery.has(i)||jn(i,n,r,t.signal);return{value:{articulationPoints:[...r.articulation].sort(),bridges:r.bridges.sort((i,s)=>i.source.localeCompare(s.source)||i.target.localeCompare(s.target))},meta:{visitedNodes:r.discovery.size,inspectedEdges:r.inspectedEdges,truncated:!1}}}function Mn(e){let t=e.registry(),n=new Map,r=new Set;for(let i of e.edges()){let s=t.require(i.kind);if(!s.ordering)continue;let{predecessor:o,successor:c}=N(i,s);if(r.add(o),r.add(c),o===c)continue;let a=n.get(o);a===void 0?n.set(o,new Set([c])):a.add(c)}return{forward:n,participants:r}}function Pn(e,t,n,r){if(e===void 0)return r;let i=r;for(let s of e)t.has(s)&&(i=Math.min(i,n.get(s)));return i}function Ln(e,t,n){let r=n-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:n,latestFinish:n+1,slack:r,critical:r===0}}function Fn(e,t,n,r,i){let s=new Map;for(let o=e.length-1;o>=0;o-=1){let c=e[o],a=Pn(t.forward.get(c),r,s,i);s.set(c,a-1)}return e.map(o=>Ln(o,n[o],s.get(o))).sort((o,c)=>o.slack-c.slack||o.earliestStart-c.earliestStart||o.id.localeCompare(c.id))}function lt(e,t={}){t.signal?.throwIfAborted();let n=B(e,{registry:e.registry()}),r=Mn(e),i=new Set(n.order),s=n.order.filter(d=>r.participants.has(d)),o=s.reduce((d,l)=>Math.max(d,n.depth[l]+1),0),c=Fn(s,r,n.depth,i,o),a=c.length>0;return{exact:!0,acyclic:n.acyclic,makespan:o,scheduledCount:c.length,criticalPath:a?n.criticalPath:[],criticalPathLength:a?n.criticalPathLength:0,cycles:n.cycles,rows:c,provenance:{algorithm:"critical-path-method",edgeFamily:"ordering",weighting:"unit"}}}function Gn(e,t,n){for(let r=e.length-1;r>=0;r-=1){n?.throwIfAborted();let i=t.get(e[r]);for(let s of i.successors){n?.throwIfAborted();let o=t.get(s);if(o.latest===void 0||o.duration===void 0)continue;let c=o.latest-o.duration;(i.latest===void 0||c<i.latest)&&(i.latest=c,i.anchor=o.anchor)}}}function $n(e,t,n,r){let i=[],s=e;for(;s!==void 0&&i.length<n;)r?.throwIfAborted(),i.push(s),s=t.get(s).predecessor;return i.reverse(),{path:i,path_truncated:s!==void 0}}function qn(e,t,n,r,i){let s=new Map(t.map(c=>[c.id,c])),o=new Map;for(let c of e){i?.throwIfAborted();let a=s.get(c),d=a?.estimated_minutes,l=typeof d=="number"&&Number.isFinite(d)&&d>=0?d:void 0,f={item:a,duration:l,pending:0,successors:new Set,earliest:0};if(a?.deadline!==void 0){let u=Date.parse(a.deadline);Number.isFinite(u)?(f.deadline=(u-n)/6e4,f.latest=f.deadline,f.anchor=c):r(c,"invalid_deadline")}o.set(c,f)}return o}function Un(e,t,n){for(let r of e.edges()){n?.throwIfAborted();let i=e.registry().require(r.kind);if(!i.ordering)continue;let{predecessor:s,successor:o}=N(r,i),c=t.get(s);c.successors.has(o)||(c.successors.add(o),t.get(o).pending+=1)}}function Bn(e,t,n){let r=e.filter(i=>t.get(i).pending===0);for(let i=0;i<r.length;i+=1){n?.throwIfAborted();let s=r[i],o=t.get(s),c=o.earliest===null||o.duration===void 0?null:o.earliest+o.duration;for(let a of o.successors){n?.throwIfAborted();let d=t.get(a);c===null?d.earliest=null:d.earliest!==null&&(c>d.earliest||c===d.earliest&&(d.predecessor===void 0||s<d.predecessor))&&(d.earliest=c,d.predecessor=s),d.pending-=1,d.pending===0&&r.push(a)}}return r}function zn(e,t,n,r,i,s,o,c){let a=t.duration;if(t.latest!==void 0){r.scheduled_count+=1;let d=t.latest-a;r.rows.length<s?r.rows.push({id:e,deadline_id:t.anchor,latest_start:new Date(i+d*6e4).toISOString(),slack_minutes:t.earliest===null?null:d-t.earliest}):r.truncated=!0}if(t.deadline!==void 0&&t.earliest!==null&&t.earliest+a>t.deadline)if(r.overcommitted_count+=1,r.overcommitted.length<s){let d=$n(e,n,Math.min(s,o.remaining),c);o.remaining-=d.path.length,d.path_truncated&&(r.truncated=!0),r.overcommitted.push({deadline_id:e,deadline:t.item.deadline,shortfall_minutes:t.earliest+a-t.deadline,...d})}else r.truncated=!0}function Hn(e,t,n,r,i,s,o,c){let a={remaining:s};for(let d of e){c?.throwIfAborted();let l=t.get(d);if(l.pending>0){o(d,"cycle_or_gated_by_cycle");continue}if(l.duration===void 0){o(d,"unknown_estimate");continue}if(l.latest!==void 0&&!Number.isFinite(new Date(r+(l.latest-l.duration)*6e4).getTime())){o(d,"date_range_exceeded");continue}l.earliest===null&&o(d,"unknown_predecessor_estimate"),zn(d,l,t,n,r,i,a,c)}}function ut(e,t,n={}){n.signal?.throwIfAborted();let r=Date.parse(n.now??new Date().toISOString());if(!Number.isFinite(r))throw new TypeError("Invalid scheduling clock");let i=n.maxWork??1e5,s=n.limit??10;for(let[u,g]of[["maxWork",i],["limit",s]])if(!Number.isSafeInteger(g)||g<1)throw new TypeError(`Invalid scheduling ${u}`);let o={as_of:new Date(r).toISOString(),basis:"derived_elapsed_minutes",complete:!0,truncated:!1,work_limit_exceeded:!1,scheduled_count:0,residual_count:0,overcommitted_count:0,rows:[],residuals:[],overcommitted:[]},c=e.nodes(),a=e.edges();if(c.length+a.length+t.length>i)return{...o,complete:!1,work_limit_exceeded:!0};let d=(u,g)=>{o.complete=!1,o.residual_count+=1,o.residuals.length<s?o.residuals.push({id:u,reason:g}):o.truncated=!0},l=qn(c,t,r,d,n.signal);Un(e,l,n.signal);let f=Bn(c,l,n.signal);return Gn(f,l,n.signal),Hn(c,l,o,r,s,i,d,n.signal),o}function T(){return{nodes:0,isolated:0,degree_leq_one:0,semantic_nodes:0,without_semantic_edges:0,degree_histogram:{}}}function pt(e,t,n,r){let i={all:T(),active:T(),terminal:T()},s=new Map;for(let o of e.details){if(r?.throwIfAborted(),e.missingIdSet.has(o.id.toLowerCase())||o.status==="external")continue;let c=s.get(o.status)??T();s.set(o.status,c);let a=e.graph.incidentEdges(o.id),d=a.some(l=>n(l.kind));for(let l of[i.all,i[t(o.status)?"terminal":"active"],c]){l.nodes+=1,l.isolated+=+(a.length===0),a.length<=1&&(l.degree_leq_one+=1),d?l.semantic_nodes+=1:l.without_semantic_edges+=1;let f=String(a.length);l.degree_histogram[f]=(l.degree_histogram[f]??0)+1}}return{coverage_by_lifecycle:i,coverage_by_status:Object.fromEntries([...s].sort(([o],[c])=>o.localeCompare(c)))}}function ft(e){if(!J(e))return!1;let t=e;if(!["nodes","isolated","degree_leq_one","semantic_nodes","without_semantic_edges"].every(i=>Number.isSafeInteger(t[i])&&Number(t[i])>=0)||!J(t.degree_histogram))return!1;let r=Object.entries(t.degree_histogram);return r.every(([i,s])=>/^(0|[1-9]\d*)$/.test(i)&&Number.isSafeInteger(s)&&Number(s)>=0)&&r.reduce((i,[,s])=>i+Number(s),0)===t.nodes&&Number(t.isolated)<=Number(t.degree_leq_one)&&Number(t.degree_leq_one)<=Number(t.nodes)&&Number(t.semantic_nodes)+Number(t.without_semantic_edges)===t.nodes}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ht(e){for(let r of["ordering_acyclic","active_ordering_acyclic"])if(e[r]!==void 0&&typeof e[r]!="boolean")return!1;let t=e.coverage_by_lifecycle,n=e.coverage_by_status;return t===void 0&&n===void 0?!0:!J(t)||!J(n)?!1:["all","active","terminal"].every(r=>ft(t[r]))&&Object.values(n).every(ft)}function gt(e,t){return Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].sort().map(n=>{let r=Object.hasOwn(e,n)?e[n]:T(),i=Object.hasOwn(t,n)?t[n]:T(),s=Object.fromEntries([...new Set([...Object.keys(r.degree_histogram),...Object.keys(i.degree_histogram)])].sort().map(o=>[o,(i.degree_histogram[o]??0)-(r.degree_histogram[o]??0)]));return[n,{nodes:i.nodes-r.nodes,isolated:i.isolated-r.isolated,degree_leq_one:i.degree_leq_one-r.degree_leq_one,semantic_nodes:i.semantic_nodes-r.semantic_nodes,without_semantic_edges:i.without_semantic_edges-r.without_semantic_edges,degree_histogram:s}]}))}function mt(e,t){return!e.coverage_by_lifecycle||!t.coverage_by_lifecycle||!e.coverage_by_status||!t.coverage_by_status?{lifecycle_comparable:!1}:{lifecycle_comparable:!0,coverage_by_lifecycle:gt(e.coverage_by_lifecycle,t.coverage_by_lifecycle),coverage_by_status:gt(e.coverage_by_status,t.coverage_by_status)}}var R=["missing_reference_active","missing_reference_terminal","legacy_no_blocker_sentinel","ordering_cycle","legacy_ordering_cycle","ordering_storage_contradiction","legacy_ordering_storage_contradiction","hierarchy_cycle","legacy_hierarchy_cycle","hierarchy_cardinality_violation","legacy_hierarchy_cardinality_violation","hierarchy_direction_violation","legacy_hierarchy_direction_violation","duplicate_edge","legacy_duplicate_edge","duplicate_dependency_row","legacy_duplicate_dependency_row","stale_lifecycle_block","isolated_active_node","sparse_active_node"];var Kn=25,Vn="milestone",Wn="outcome milestone:",Yn=new Set(["discovered_from","incident_from","recurs_from","supersedes","verifies"]);function Q(e){return Yn.has(e)}var _t={error:0,warning:1,info:2};function yt(e){return new Set((e??[]).filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()))}function D(e,t,n,r,i,s,o,c){let a=[...i].sort((d,l)=>d.localeCompare(l));return{code:e,severity:t,policy:n,message:r(a.length),count:a.length,sample:a.slice(0,s),sample_truncated:a.length>s,remediation:o,...c===void 0?{}:{evidence:[...c].sort((d,l)=>d.localeCompare(l)).slice(0,s)}}}function Xn(e,t){return e.cycles.map(n=>D(n.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",n.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",r=>`${r} items participate in one hierarchy cycle.`,n.item_ids,t,n.legacy_terminal?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove or retype one exact hierarchy relation before continuing mutation."))}function bt(e,t,n){let r=e.cardinality_violations.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[D(n?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",n?"info":"error","Every structural child must resolve to at most one logical parent across all hierarchy spellings.",i=>`${i} child item${i===1?"":"s"} resolve to multiple hierarchy parents.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",r.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function wt(e,t,n){let r=e.divergences.filter(i=>i.legacy_terminal===n);return r.length===0?[]:[D(n?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",n?"info":"error","Scalar parent metadata and dependency-backed hierarchy rows must resolve to the same logical parent.",i=>`${i} child item${i===1?"":"s"} have divergent hierarchy storage surfaces.`,r.map(i=>i.child_id),t,n?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",r.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function Jn(e,t){let n=G(e);return n?[...Xn(n,t),...bt(n,t,!1),...bt(n,t,!0),...wt(n,t,!1),...wt(n,t,!0)]:[]}function Qn(e){let t=e.graph.registry(),n=new Map;for(let r of e.graph.edges()){let i=t.require(r.kind);if(!i.ordering)continue;let[s,o]=(i.precedence??"source_before_target")==="target_before_source"?[r.target,r.source]:[r.source,r.target],c=n.get(s);c?c.push(o):n.set(s,[o])}for(let r of n.values())r.sort((i,s)=>i.localeCompare(s));return n}function xt(e,t){t.indexes.set(e,t.nextIndex),t.lowLinks.set(e,t.nextIndex),t.nextIndex+=1,t.stack.push(e),t.onStack.add(e)}function Zn(e,t,n,r){let i=n.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let s=i[e.neighborIndex];return e.neighborIndex+=1,r.indexes.has(s)?r.onStack.has(s)&&r.lowLinks.set(e.node,Math.min(r.lowLinks.get(e.node),r.indexes.get(s))):(xt(s,r),t.push({node:s,neighborIndex:0})),!0}function er(e,t,n,r){t.pop();let i=t.at(-1);if(i&&r.lowLinks.set(i.node,Math.min(r.lowLinks.get(i.node),r.lowLinks.get(e.node))),r.lowLinks.get(e.node)!==r.indexes.get(e.node))return;let s=[];for(;;){let o=r.stack.pop();if(r.onStack.delete(o),s.push(o),o===e.node)break}(s.length>1||s.length===1&&n.get(s[0])?.includes(s[0]))&&r.components.push(s.sort((o,c)=>o.localeCompare(c)))}function tr(e){let t={indexes:new Map,lowLinks:new Map,onStack:new Set,stack:[],components:[],nextIndex:0},n=[...e.keys()].sort((r,i)=>r.localeCompare(i));for(let r of n){if(t.indexes.has(r))continue;let i=[{node:r,neighborIndex:0}];for(xt(r,t);i.length>0;){let s=i.at(-1);Zn(s,i,e,t)||er(s,i,e,t)}}return t.components.sort((r,i)=>r[0].localeCompare(i[0]))}function ae(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function y(e,t,n,r,i,s,o,c){t.length!==0&&e.push(D(r,i,s,o,t,n,c))}function nr(e,t,n){let r=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(s=>!s.no_active_blocker_sentinel);return y(r,i.filter(s=>!t(s.holder_status)).map(ae),n,"missing_reference_active","error","Active items must not reference absent targets; missing prerequisites distort scheduling.",s=>`${s} active dangling reference(s) to absent items`,"Restore or re-create the referenced item, or remove/retype the reference on the holder."),y(r,i.filter(s=>t(s.holder_status)).map(ae),n,"missing_reference_terminal","info","Terminal items may retain historical references, but absent targets remain unexplainable context.",s=>`${s} terminal dangling reference(s) to absent items`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),y(r,e.dangling.no_active_blocker_sentinels.map(ae),n,"legacy_no_blocker_sentinel","info","The pre-structured-dependency no-active-blocker sentinel is retired; real edges carry blocker state.",s=>`${s} legacy no-active-blocker sentinel reference(s)`,"Delete the sentinel reference; blocker state is derived from blocked_by edges."),r}function le(e,t){let n=t.get(e);return n?!n.terminal:!0}function kt(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function rr(e,t){let n=[],r=[];for(let s of e.orderingContradictions??[])(s.legacy_terminal?r:n).push(kt(s));let i=[];return y(i,n,t,"ordering_storage_contradiction","error","A scalar blocker and same-target structured ordering row must not assert opposite precedence.",s=>`${s} active scalar-versus-structured ordering contradiction(s)`,"Remove the structured dependency row that points the holder before its scalar blocker, or replace both representations with one unambiguous ordering edge."),y(i,r,t,"legacy_ordering_storage_contradiction","info","Terminal scalar-versus-structured ordering contradictions are exact historical storage defects with no live scheduling effect.",s=>`${s} terminal scalar-versus-structured ordering contradiction(s)`,"Remove the contradictory blocks dependency row in a dedicated changelog-safe closed-item batch; preserve the scalar blocker as the historical precedence record."),i}function ir(e,t,n,r){let i=[],s=Qn(e);for(let a of tr(s)){let d=a.some(u=>le(u,t)),l=new Set(a.map(u=>u.toLowerCase())),f=(e.orderingContradictions??[]).filter(u=>l.has(u.holder_id.toLowerCase())&&l.has(u.target_id.toLowerCase())).map(kt);i.push(d?D("ordering_cycle","error","Order-bearing relationship kinds must stay acyclic; a cycle makes every member unschedulable.",u=>`execution-order cycle across ${u} item(s)`,a,r,"Remove or retype one ordering edge inside the cycle, or split the work so precedence is linear.",f.length===0?void 0:f):D("legacy_ordering_cycle","info","Ordering cycles between exclusively terminal items are historical contradictions with no scheduling effect.",u=>`terminal-only execution-order cycle across ${u} item(s)`,a,r,"Leave as history debt, or clean up in a dedicated changelog-safe closed-item batch; never repair closed items ad hoc.",f.length===0?void 0:f))}let o=new Map;for(let[a,d]of s)for(let l of d){let f=o.get(l);f?f.push(a):o.set(l,[a])}let c=[...t.values()].filter(a=>!a.missing&&!a.terminal&&n(a.status)&&!(o.get(a.id)??[]).some(d=>{let l=t.get(d);return l===void 0||!l.terminal})).map(a=>a.id);return y(i,c,r,"stale_lifecycle_block","warning","A blocked lifecycle status must be backed by at least one open ordering predecessor.",a=>`${a} status-blocked item(s) with no open blocker edge`,'Add a local blocker edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status.'),i}function Z(e){let t=e.edges.map(n=>n.kind).sort((n,r)=>n.localeCompare(r));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function ue(e){let t=e.graph.registry(),n=new Map;for(let i of e.graph.edges()){let s=t.require(i.kind);if(!W(s))continue;let o=ce(i,s);if(o.from===o.to)continue;let c=`${Y(s)}::${o.from}::${o.to}`,a=n.get(c);a?a.edges.push(i):n.set(c,{...o,edges:[i]})}let r=[...n.values()].filter(i=>i.edges.length>=2);for(let i of r)i.edges.sort((s,o)=>s.kind.localeCompare(o.kind));return r.sort((i,s)=>i.from.localeCompare(s.from)||i.to.localeCompare(s.to))}function sr(e,t,n){let r=[],i=[];for(let o of ue(e))(le(o.from,t)||le(o.to,t)?r:i).push(Z(o));let s=[];return y(s,r,n,"duplicate_edge","info","One semantic relationship should be stored once; parallel same-family spellings (reciprocal inverse pairs included) add no information and skew degree metrics.",o=>`${o} duplicated relationship(s) between active endpoints`,"Remove all but one stored spelling of the relationship; keep the canonical direction the holder declared first."),y(s,i,n,"legacy_duplicate_edge","info","Duplicated spellings between exclusively terminal items are historical noise with no scheduling effect.",o=>`${o} duplicated relationship(s) between terminal endpoints`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),s}function or(e,t){let n=[],r=[];for(let s of e.duplicateRows??[])(s.legacy_terminal?r:n).push(`${s.holder_id} -> ${s.target_id} (${s.kind} x${s.occurrences})`);let i=[];return y(i,n,t,"duplicate_dependency_row","warning","One dependency row must be stored once per holder; identical repeated rows are a storage-layer defect invisible to the assembled graph.",s=>`${s} exactly duplicated stored dependency row(s) on active holder(s)`,"Remove the repeated rows so the dependency is stored exactly once; graph semantics are unchanged."),y(i,r,t,"legacy_duplicate_dependency_row","info","Identical repeated dependency rows on terminal holders are historical storage noise with no scheduling effect.",s=>`${s} exactly duplicated stored dependency row(s) on terminal holder(s)`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),i}function cr(e,t){let n=new Map,r={source_to_target:[],target_to_source:[],both:[]};for(let o of e.graph.registry().list())o.outcomeTraversal!==void 0&&r[o.outcomeTraversal].push(o.kind);let i={source_to_target:r.source_to_target.join(","),target_to_source:r.target_to_source.join(","),both:r.both.join(",")},s=(o,c)=>{let a=n.get(c)??new Set;a.add(o),n.set(c,a)};for(let o of e.graph.edges()){t?.throwIfAborted();let c=e.graph.registry().require(o.kind);(c.outcomeTraversal==="source_to_target"||c.outcomeTraversal==="both")&&s(o.source,o.target),(c.outcomeTraversal==="target_to_source"||c.outcomeTraversal==="both")&&s(o.target,o.source)}return{basis:i,reverse:n}}function ar(e,t,n){let r=new Set(e),i=[...e].sort();for(let s=0;s<i.length;s+=1){n?.throwIfAborted();for(let o of[...t.get(i[s])??[]].sort())r.has(o)||(r.add(o),i.push(o))}return r}function dr(e,t,n,r){let i=0,s=0,o=0,c=0;for(let g of e.values())if(r?.throwIfAborted(),!t.has(g.id)&&!(g.missing||g.status==="external")){if(g.terminal){o+=1,n.has(g.id)&&(c+=1);continue}n.has(g.id)?i+=1:s+=1}let a=i+s,d=o-c,l=i+c,f=s+d,u=l+f;return{active_outcome_reachable_nodes:i,active_outcome_unreachable_nodes:s,active_outcome_reachability_basis_points:a===0?0:Math.floor(i*1e4/a),terminal_nodes:o,terminal_outcome_reachable_nodes:c,terminal_outcome_unreachable_nodes:d,terminal_outcome_reachability_basis_points:o===0?0:Math.floor(c*1e4/o),outcome_reachable_nodes:l,outcome_unreachable_nodes:f,outcome_reachability_basis_points:u===0?0:Math.floor(l*1e4/u)}}function lr(e,t,n){let r=new Set(e.details.filter(c=>c.type?.toLowerCase()===Vn&&c.title.trim().toLowerCase().startsWith(Wn)).map(c=>c.id)),{basis:i,reverse:s}=cr(e,n),o=ar(r,s,n);return{outcome_nodes:r.size,outcome_reachability_basis:i,...dr(t,r,o,n)}}function ur(e,t,n,r,i){e.active+=1;let s=t.type??"(untyped)",o=e.byType.get(s);o||(o={active:0,isolated:0,degree_leq_one:0},e.byType.set(s,o)),o.active+=1,!(n>1)&&(e.degreeLeqOne+=1,o.degree_leq_one+=1,n===0&&(e.isolated+=1,o.isolated+=1),!(r.has(t.id.toLowerCase())||i.has(s.toLowerCase()))&&(n===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function fr(e,t,n,r,i,s,o){let c={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let h of e.graph.nodes()){o?.throwIfAborted();let _=t.get(h);if(_){if(_.missing){c.missing+=1;continue}_.terminal||ur(c,_,e.graph.incidentEdges(h).length,n,r)}}let{isolates:a,sparse:d}=c,l=[];y(l,a,i,"isolated_active_node","warning","Active work should be reachable from the graph unless explicitly declared a valid isolate.",h=>`${h} active item(s) with no relationships`,"Link the item to its parent, prerequisite, or origin \u2014 or register it as an exempt isolate."),y(l,d,i,"sparse_active_node","info","Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.",h=>`${h} active item(s) with exactly one relationship`,"Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");let f=e.graph.edges().length,u=A(e.graph,{signal:o}).value,g=new Set(u.map(({edge:h})=>`${h.source.toLowerCase()}\0${h.target.toLowerCase()}\0${h.kind}`));for(let h of e.orderingContradictions??[])g.add(`${h.holder_id.toLowerCase()}\0${h.target_id.toLowerCase()}\0${h.dependency_kind}`);let p=Object.fromEntries(Object.entries(s).sort(([h],[_])=>h.localeCompare(_))),m=Object.entries(p).reduce((h,[_,I])=>h+(Q(_)?I:0),0),b=X(e.graph,{signal:o}).value,w=lr(e,t,o);return{findings:l,profile:{nodes:e.graph.nodes().length,recorded_nodes:e.details.filter(h=>h.status!=="missing"&&h.status!=="external").length,edges:f,informative_edges:f-g.size,redundant_edges:u.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:p,edge_share_by_kind:Object.fromEntries(Object.entries(p).map(([h,_])=>[h,_/f])),semantic_edges:m,semantic_edge_share:f===0?0:m/f,active_nodes:c.active,missing_nodes:c.missing,isolated_active_nodes:c.isolated,degree_leq_one_active_nodes:c.degreeLeqOne,coverage_by_type:Object.fromEntries([...c.byType.entries()].sort(([h],[_])=>h<_?-1:1)),articulation_points:b.articulationPoints.length,bridge_edges:b.bridges.length,...w,finding_subjects_by_code:Object.fromEntries(R.map(h=>[h,0]))}}}function ee(e,t={}){let n=t.isTerminal??(u=>u==="closed"||u==="canceled"),r=t.isBlocked??(u=>u==="blocked"),i=t.maxSampleSize??Kn;if(!Number.isInteger(i)||i<1)throw new TypeError(`Invalid audit sample bound: ${String(t.maxSampleSize)}`);let s=yt(t.exemptIsolates),o=yt(t.isolateExemptTypes),c=new Map(e.details.map(u=>[u.id,{id:u.id,status:u.status,missing:e.missingIdSet.has(u.id.toLowerCase()),terminal:n(u.status),...u.type===void 0?{}:{type:u.type}}]));t.signal?.throwIfAborted();let a={};for(let u of e.graph.edges())a[u.kind]=(a[u.kind]??0)+1;let d=nr(e,n,i);d.push(...Jn(e,i)),t.signal?.throwIfAborted(),d.push(...rr(e,i)),t.signal?.throwIfAborted(),d.push(...ir(e,c,r,i)),t.signal?.throwIfAborted(),d.push(...sr(e,c,i),...or(e,i)),t.signal?.throwIfAborted();let l=fr(e,c,s,o,i,a,t.signal);d.push(...l.findings),d.sort((u,g)=>_t[u.severity]-_t[g.severity]||u.code.localeCompare(g.code)||u.sample[0].localeCompare(g.sample[0]));let f=l.profile.finding_subjects_by_code;for(let u of d)f[u.code]+=u.count;return{findings:d,profile:{...l.profile,...pt(e,n,Q,t.signal),ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"||u.code==="legacy_ordering_cycle"),active_ordering_acyclic:!d.some(u=>u.code==="ordering_cycle"),finding_subjects_by_code:f}}}function de(e,t){let n=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),r={};for(let i of n){let s=(t[i]??0)-(e[i]??0);s!==0&&(r[i]=s)}return r}function vt(e){return e.profile.coverage_by_type??{}}function gr(e,t){let n={},r=vt(e),i=vt(t),s=[...new Set([...Object.keys(r),...Object.keys(i)])].sort();for(let o of s){let c=Object.assign({active:0,isolated:0,degree_leq_one:0},r[o]),a=Object.assign({active:0,isolated:0,degree_leq_one:0},i[o]),d={active:a.active-c.active,isolated:a.isolated-c.isolated,degree_leq_one:a.degree_leq_one-c.degree_leq_one};Object.values(d).some(l=>l!==0)&&(n[o]=d)}return n}function Et(e,t){let n=gr(e,t),{edge_share_by_kind:r={},semantic_edges:i=0,semantic_edge_share:s=0}=e.profile,{edge_share_by_kind:o={},semantic_edges:c=0,semantic_edge_share:a=0}=t.profile,d=e.profile.recorded_nodes??e.profile.nodes,l=t.profile.recorded_nodes??t.profile.nodes,f=e.profile.informative_edges??e.profile.edges,u=t.profile.informative_edges??t.profile.edges,g=e.profile.redundant_edges??0,p=t.profile.redundant_edges??0,m=e.profile.ordering_contradiction_edges??0,b=t.profile.ordering_contradiction_edges??0;return{baseline_saved_at:e.saved_at,same_snapshot:e.fingerprint===t.fingerprint,affected_subjects_by_code:de(e.affected_subjects_by_code,t.affected_subjects_by_code),profile:{nodes:t.profile.nodes-e.profile.nodes,recorded_nodes:l-d,edges:t.profile.edges-e.profile.edges,informative_edges:u-f,redundant_edges:p-g,ordering_contradiction_edges:b-m,active_nodes:t.profile.active_nodes-e.profile.active_nodes,missing_nodes:t.profile.missing_nodes-e.profile.missing_nodes,isolated_active_nodes:t.profile.isolated_active_nodes-e.profile.isolated_active_nodes,degree_leq_one_active_nodes:t.profile.degree_leq_one_active_nodes-e.profile.degree_leq_one_active_nodes,edges_by_kind:de(e.profile.edges_by_kind,t.profile.edges_by_kind),edge_share_by_kind:de(r,o),semantic_edges:c-i,semantic_edge_share:a-s,coverage_by_type:n,...mt(e.profile,t.profile)}}}import It from"node:path";var St=2,fe=500,pr=64,hr="graph-durable-cache";function Ct(e){return Ae(e,hr,30,`graph-cache:${process.pid}`,!1,!1,3e3)}function F(e){return It.join(e,"runtime","graph-cache.json")}function Nt(e){return It.join(e,"runtime","graph-audit-baseline.json")}function ge(e){if(e!==null)try{let t=JSON.parse(e);return typeof t!="object"||t===null||t.version!==St||typeof t.fingerprint!="string"||typeof t.saved_at!="string"||typeof t.results!="object"||t.results===null||Array.isArray(t.results)?void 0:t}catch{return}}async function pe(e,t){let n=await j(F(e)),r=ge(n),i=r?.fingerprint===t;return{exists:n!==null,fresh:i,results:i?r.results:{}}}async function he(e,t,n,r,i){let s=await Ct(e);try{let o=ge(await j(F(e))),c=o?.fingerprint===t?o.results:{};delete c[r],c[r]=i;let a=Object.keys(c);for(let d of a.slice(0,Math.max(0,a.length-pr)))delete c[d];await re(F(e),JSON.stringify({version:St,fingerprint:t,saved_at:new Date().toISOString(),results:c})),n.results=c}finally{await s()}}async function me(e){let t=await Ct(e);try{await ke(F(e))}finally{await t()}}async function At(e,t){let n=F(e),r=await j(n),i=ge(r);return i===void 0?{exists:r!==null,fresh:!1,entry_count:0}:{exists:!0,fresh:i.fingerprint===t,entry_count:Object.keys(i.results).length,fingerprint:i.fingerprint.slice(0,12),saved_at:i.saved_at,bytes:Buffer.byteLength(r,"utf8")}}function _e(e,t){return t||e>=fe}function te(e){return O(e)&&Object.values(e).every(E)}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function E(e){return Number.isInteger(e)&&Number(e)>=0}function Tt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function L(e,t){return e===void 0||t(e)}function mr(e){return O(e)&&Object.values(e).every(Tt)}function _r(e){return O(e)?Object.values(e).every(t=>O(t)&&[t.active,t.isolated,t.degree_leq_one].every(E)):!1}function yr(e,t,n){let r=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=r.filter(o=>e[o]!==void 0).length;if(i!==0&&i!==r.length||!r.every(o=>L(e[o],E)))return;let s={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??n,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return s.recorded_nodes<=t&&s.informative_edges<=n&&s.redundant_edges<=n&&s.ordering_contradiction_edges<=n?s:void 0}function br(e,t,n){let r=[...t,...n,"finding_subjects_by_code"],i=r.filter(s=>e[s]!==void 0).length;return i!==0&&i!==r.length?!1:t.every(s=>L(e[s],E))&&n.every(s=>L(e[s],E)&&(e[s]===void 0||Number(e[s])<=1e4))&&L(e.finding_subjects_by_code,te)}function wr(e,t,n,r){let i=yr(e,n,r);if(i===void 0)return;let s=["articulation_points","bridge_edges","outcome_nodes","active_outcome_reachable_nodes","active_outcome_unreachable_nodes","terminal_nodes","terminal_outcome_reachable_nodes","terminal_outcome_unreachable_nodes","outcome_reachable_nodes","outcome_unreachable_nodes"],o=["active_outcome_reachability_basis_points","terminal_outcome_reachability_basis_points","outcome_reachability_basis_points"];if(!br(e,s,o)||e.edge_basis!==void 0&&e.edge_basis!=="deduplicated_directed")return;let c=te(e.finding_subjects_by_code)?e.finding_subjects_by_code:{};return{edge_basis:"deduplicated_directed",...i,...Object.fromEntries(s.map(a=>[a,e[a]??0])),...Object.fromEntries(o.map(a=>[a,e[a]??0])),finding_subjects_by_code:Object.fromEntries(R.map(a=>[a,c[a]??t[a]??0]))}}function vr(e,t,n,r,i){let s=[n,r,i],o=s.filter(d=>d!==void 0).length;if(o===0)return{edge_share_by_kind:{},semantic_edges:0,semantic_edge_share:0};if(o!==s.length||!mr(n)||!E(r)||!Tt(i))return;let c=Object.entries(t);if(c.reduce((d,[,l])=>d+l,0)!==e||Object.keys(n).length!==c.length||c.some(([d,l])=>n[d]!==(e===0?0:l/e)))return;let a=c.reduce((d,[l,f])=>d+(Q(l)?f:0),0);if(!(r!==a||i!==(e===0?0:a/e)))return{edge_share_by_kind:n,semantic_edges:r,semantic_edge_share:i}}function xr(e){if(e!==null)try{let t=JSON.parse(e);if(!O(t))return;let n=t,r=n.profile;if(typeof n.saved_at!="string"||typeof n.fingerprint!="string")return;let i=n.affected_subjects_by_code;if(!te(i)||!O(r)||!ht(r)||![r.nodes,r.edges,r.active_nodes,r.missing_nodes,r.isolated_active_nodes,r.degree_leq_one_active_nodes].every(E)||!te(r.edges_by_kind)||!L(r.coverage_by_type,_r))return;let s=vr(r.edges,r.edges_by_kind,r.edge_share_by_kind,r.semantic_edges,r.semantic_edge_share);if(s===void 0)return;let o=wr(r,i,r.nodes,r.edges);if(o===void 0)return;let{coverage_by_type:c={}}=r;return{...n,profile:{...r,...s,...o,coverage_by_type:c}}}catch{return}}async function Rt(e){return xr(await j(Nt(e)))}async function Dt(e,t){await re(Nt(e),JSON.stringify(t))}var kr={missing_reference_active:{op:"investigate",confidence:"medium",rationale:"Restore or re-create the referenced item, or remove/retype the reference on the active holder; the correct fix depends on why the target is absent."},missing_reference_terminal:{op:"waive",confidence:"high",rationale:"Terminal-holder reference to an absent item is historical debt; waive it or clean it up only in a dedicated changelog-safe closed-item batch."},legacy_no_blocker_sentinel:{op:"remove",confidence:"high",rationale:"The pre-structured-dependency no-active-blocker sentinel is retired and carries no information; blocker state derives from blocked_by edges."},ordering_cycle:{op:"investigate",confidence:"low",rationale:"Every cycle member is unschedulable until one ordering edge is removed or retyped; the planner never chooses which edge to cut."},legacy_ordering_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only ordering cycles have no scheduling effect; repairing them would mutate closed history (changelog drag)."},ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The structured ordering row asserts the opposite precedence from the same-target scalar blocker; remove that exact dependency row or replace both representations with one unambiguous edge."},legacy_ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The terminal holder contains a proven contradictory structured ordering row; remove it in a dedicated changelog-safe batch while preserving the scalar blocker as history."},hierarchy_cycle:{op:"investigate",confidence:"low",rationale:"Cut or retype one exact structural relation in the cycle; the planner preserves every evidence row because intent determines the correct parent."},legacy_hierarchy_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only hierarchy cycles are historical debt; waive them unless an explicit closed-history repair is approved."},hierarchy_cardinality_violation:{op:"investigate",confidence:"medium",rationale:"Choose the canonical parent and remove or retype the exact surplus hierarchy rows; the planner cannot infer ownership intent."},legacy_hierarchy_cardinality_violation:{op:"waive",confidence:"high",rationale:"Multiple parents confined to terminal items are historical debt; waive them unless a dedicated history repair is approved."},hierarchy_direction_violation:{op:"investigate",confidence:"medium",rationale:"Align the scalar parent and dependency-backed hierarchy rows to the intended canonical parent."},legacy_hierarchy_direction_violation:{op:"waive",confidence:"high",rationale:"Divergent hierarchy storage confined to terminal items is historical debt; waive it unless a dedicated history repair is approved."},duplicate_edge:{op:"remove",confidence:"high",rationale:"Parallel same-family spellings state one relationship twice; remove all but one stored spelling, keeping the holder's canonical direction."},legacy_duplicate_edge:{op:"waive",confidence:"high",rationale:"Duplicated spellings between terminal items are historical noise; waive or batch changelog-safe cleanup."},duplicate_dependency_row:{op:"remove",confidence:"high",rationale:"The identical dependency row is stored more than once on the holder; drop the repeats so the row exists exactly once \u2014 graph semantics are unchanged."},legacy_duplicate_dependency_row:{op:"waive",confidence:"high",rationale:"Repeated identical rows on terminal holders are storage noise; waive or clean up only in a changelog-safe closed-item batch."},stale_lifecycle_block:{op:"investigate",confidence:"medium",rationale:`Add a local ordering edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status; only the holder's owner knows which is true.`},isolated_active_node:{op:"investigate",confidence:"medium",rationale:"Link the item to its parent, prerequisite, or origin \u2014 or register it as an explicitly exempt isolate; the audit never fabricates an edge."},sparse_active_node:{op:"investigate",confidence:"low",rationale:"Investigate for an honest second edge (story-to-task, defect family, cross-epic complement); sparse is not automatically defective."}};function Ot(e){return`${e.source} -${e.kind}-> ${e.target}`}function Er(e){let[t,...n]=e.edges;return n.map(r=>({op:"remove",code:"duplicate_edge",subject:Ot(r),rationale:"This stored spelling restates the kept canonical edge of the same semantic family; removing it leaves the relationship stated exactly once.",evidence:[`keep: ${Ot(t)}`,`group: ${Z(e)}`],confidence:"high"}))}function Ir(e,t){if(e.code==="duplicate_edge")return e.sample.flatMap(r=>Er(t.get(r)));let n=kr[e.code];return e.sample.map(r=>({op:n.op,code:e.code,subject:r,rationale:n.rationale,evidence:[e.policy],confidence:n.confidence}))}function jt(e,t={}){let{redundancyLimit:n,...r}=t,i=ee(e,r),s=new Map(ue(e).map(d=>[Z(d),d])),o=i.findings.flatMap(d=>Ir(d,s)),c=i.findings.some(d=>d.sample_truncated);t.signal?.throwIfAborted();let a=A(e.graph,{limit:n??t.maxSampleSize??25,...t.signal===void 0?{}:{signal:t.signal}});for(let d of a.value)o.push({op:"remove",code:"redundant_edge",subject:`${d.edge.source} -> ${d.edge.target} (${d.edge.kind})`,rationale:"The stored edge is implied by a longer same-family witness path; shortcut edges are sometimes deliberate emphasis, so confirm intent before removing.",evidence:[`witness: ${d.witness.join(" -> ")}`],confidence:"medium"});return c=c||a.meta.truncated,{steps:o,report:i,truncated:c,cost:{visitedNodes:a.meta.visitedNodes,inspectedEdges:a.meta.inspectedEdges}}}var Ft=new Set(["ancestors","descendants","predecessors","successors","paths","impact","dominators"]);function Mt(e,t,n){let r=e;if(t&&e.subcommand==="audit"){let{nodes:i,recorded_nodes:s,edges:o,active_nodes:c,terminal_nodes:a,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:f,coverage_by_lifecycle:u}=e.profile,g=Object.fromEntries(Object.entries(u).map(([p,m])=>{let{degree_histogram:b,...w}=m;return[p,w]}));r={...e,profile:{nodes:i,recorded_nodes:s,edges:o,active_nodes:c,terminal_nodes:a,missing_nodes:d,ordering_acyclic:l,active_ordering_acyclic:f,coverage_by_lifecycle:g}}}return{...r,projection:{mode:t?"summary":"full",declared_field_groups:n===void 0?[]:[{name:n,restore_with:"--full"}],included_field_groups:n===void 0||t?[]:[n]}}}function Sr(e,t,n,r){return{assembly:t,...n===void 0?{}:{kinds:n},maxDepth:Ue(r.maxDepth),limit:e==="impact"&&Number(r.limit)===0?0:$(r.limit,"limit")??(r.full===!0?Number.MAX_SAFE_INTEGER:k.rows),after:r.after?.trim()||void 0,direction:Be(r.direction),maxPaths:$(r.maxPaths,"max-paths"),sample:$(r.sample,"sample")??k.samples,exemptIsolates:Pt(r.exemptIsolate),exemptIsolateTypes:Pt(r.exemptIsolateType),saveBaseline:r.saveBaseline===!0,summary:r.summary===!0,unbounded:r.full===!0}}function Pt(e){return e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",")).map(t=>t.trim()).filter(t=>t.length>0)}function Cr(e,t,n){let r=e.trim().toLowerCase();if(!ie.includes(r))throw je({command_path:"graph",token:r||"<empty>",allowed:ie});let i=r;if(Ft.has(i)&&!t?.trim())throw new x(`graph ${i} requires an item id.`,v.USAGE);if(i==="paths"&&!n?.trim())throw new x("graph paths requires a source and a target item id.",v.USAGE);return i}function ye(e){throw e instanceof TypeError?new x(e.message,v.USAGE):e}function be(e){return{truncated:e.truncated,cost:{visited_nodes:e.visitedNodes,inspected_edges:e.inspectedEdges}}}function Lt(e,t){let n=t.trim().toLowerCase();for(let r of e.details)if(r.id.trim().toLowerCase()===n&&!e.missingIdSet.has(r.id.toLowerCase()))return r.id;throw new x(`Item ${t} not found`,v.NOT_FOUND)}function Nr(e,t,n){let r={ancestors:Qe,descendants:Ze,predecessors:et,successors:tt}[e],i;try{i=r(n.assembly.graph,t,{...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},limit:n.limit,...n.after===void 0?{}:{after:n.after}})}catch(o){ye(o)}let s=be(i.meta);return{subcommand:e,root:t,count:i.value.length,...s,...i.meta.nextCursor===void 0?{}:{next_cursor:i.meta.nextCursor},...n.summary?{}:{ids:i.value}}}function Ar(e,t,n){let r=nt(n.assembly.graph,e,t,{direction:n.direction,...n.kinds===void 0?{}:{kinds:n.kinds},...n.maxDepth===void 0?{}:{maxDepth:n.maxDepth},...n.maxPaths===void 0?{}:{maxPaths:n.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:n.direction,count:r.value.length,...be(r.meta),...n.summary?{}:{paths:r.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(s=>s.kind),length:i.length}))}}}function Tr(e,t){let n;try{n=U(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth},...t.unbounded?{}:{limit:t.limit},...t.after===void 0?{}:{after:t.after}})}catch(r){ye(r)}return{subcommand:"impact",root:e,direction:t.direction,count:n.affected.length,truncated:n.truncated,...n.nextCursor===void 0?{}:{next_cursor:n.nextCursor},cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...t.summary?{}:{affected:n.affected}}}function Rr(e,t,n){return{acyclic:e.acyclic,ordered_node_count:e.order.length,layer_count:e.layers.length,frontier_count:e.frontier.length,critical_path_length:e.criticalPathLength,cycle_count:e.cycles.length,...t?{}:{frontier:e.frontier.slice(0,n),critical_path:e.criticalPath.slice(0,n),cycles:e.cycles.slice(0,n)}}}function Dr(e,t,n){return{component_count:e.components.length,largest_component_size:e.components[0]?.length??0,orphan_count:e.orphans.length,...t?{}:{orphans:e.orphans.slice(0,n),hubs:e.hubs.slice(0,n)}}}function Or(e,t,n){let r=0,i=0,s=0;for(let o of e.cycles)r+=Number(o.legacy_terminal);for(let o of e.cardinality_violations)i+=Number(o.legacy_terminal);for(let o of e.divergences)s+=Number(o.legacy_terminal);return{acyclic:e.cycles.length===0,relation_count:e.relations.length,cycle_count:e.cycles.length,active_cycle_count:e.cycles.length-r,legacy_cycle_count:r,cardinality_violation_count:e.cardinality_violations.length,active_cardinality_violation_count:e.cardinality_violations.length-i,legacy_cardinality_violation_count:i,parent_divergence_count:e.divergences.length,active_parent_divergence_count:e.divergences.length-s,legacy_parent_divergence_count:s,...t?{}:{cycles:e.cycles.slice(0,n).map(o=>o.item_ids)}}}function jr(e){let t=e.assembly.graph,n=e.limit,r=B(t,{registry:t.registry()}),i=Ye(t);return{subcommand:"analyze",node_count:t.nodes().length,edge_count:t.edges().length,edge_basis:"deduplicated_directed",sample_limit:n,execution:Rr(r,e.summary,n),knowledge:Dr(i,e.summary,n),hierarchy:Or(G(e.assembly),e.summary,n)}}function Mr(e,t){let n=ee(e.assembly,{isTerminal:t,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),r={},i={},s={},o={};for(let d of n.findings)r[d.severity]=(r[d.severity]??0)+1,i[d.code]=(i[d.code]??0)+1,s[d.severity]=(s[d.severity]??0)+d.count,o[d.code]=(o[d.code]??0)+d.count;let{finding_subjects_by_code:c,...a}=n.profile;return{subcommand:"audit",truncated:n.findings.length>e.limit,finding_count:n.findings.length,findings_by_severity:r,findings_by_code:i,affected_subjects_by_severity:s,affected_subjects_by_code:o,profile:e.summary?a:n.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:n.findings.slice(0,e.limit)}}}function Pr(e){let t=e.limit,n={};e.kinds!==void 0&&(n.kinds=e.kinds);let r=it(e.assembly.graph,n),i=r.value;return{subcommand:"communities",community_count:i.communities.length,largest_community_size:i.communities[0]?.size??0,iterations:i.iterations,converged:i.converged,truncated:!i.converged||i.communities.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{communities:i.communities.slice(0,t).map(s=>({representative:s.representative,size:s.size,members:s.members.slice(0,t)}))}}}function Lr(e){let t;try{t=A(e.assembly.graph,{...e.kinds===void 0?{}:{kinds:e.kinds},...e.maxDepth===void 0?{}:{maxDepth:e.maxDepth},limit:e.limit})}catch(n){ye(n)}return{subcommand:"redundancy",redundant_count:t.value.length,...be(t.meta),...e.summary?{}:{redundant:t.value.map(n=>({source:n.edge.source,target:n.edge.target,kind:n.edge.kind,witness:n.witness}))}}}function Fr(e,t){let n=t.limit,r=st(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=r.value.rows.filter(s=>s.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:r.value.reachableCount,bottleneck_count:i.length,truncated:r.meta.truncated||i.length>n,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,n).map(s=>({id:s.id,idom:s.idom,dominated_count:s.dominatedCount}))}}}function Gr(e){let t=e.limit,n=lt(e.assembly.graph),r=n.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:n.acyclic,makespan:n.makespan,scheduled_count:n.scheduledCount,critical_count:r,critical_path_length:n.criticalPathLength,cycle_count:n.cycles.length,truncated:n.rows.length>t,...e.summary?{}:{critical_path:n.criticalPath.slice(0,t),rows:n.rows.slice(0,t).map(i=>({id:i.id,earliest_start:i.earliestStart,latest_start:i.latestStart,slack:i.slack,critical:i.critical}))}}}function $r(e){let t=e.limit,n=dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),r=n.value;return{subcommand:"centrality",node_count:r.nodeCount,edge_count:r.edgeCount,edge_basis:"simple_undirected",truncated:r.rows.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{rows:r.rows.slice(0,t).map(i=>({id:i.id,degree:i.degree,in_degree:i.inDegree,out_degree:i.outDegree,betweenness:i.betweenness,closeness:i.closeness}))}}}function qr(e){let t=e.limit,n=X(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:r,bridges:i}=n.value;return{subcommand:"articulation",articulation_count:r.length,bridge_count:i.length,truncated:r.length>t||i.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{articulation_points:r.slice(0,t),bridges:i.slice(0,t)}}}function Ur(e,t){let n=e.limit,r=jt(e.assembly,{isTerminal:t,redundancyLimit:n,maxSampleSize:e.sample,...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},s={};for(let o of r.steps)i[o.op]=(i[o.op]??0)+1,s[o.code]=(s[o.code]??0)+1;return{subcommand:"plan",step_count:r.steps.length,steps_by_op:i,steps_by_code:s,finding_count:r.report.findings.length,truncated:r.truncated||r.steps.length>n,cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...e.summary?{}:{steps:r.steps.slice(0,n)}}}function Gt(e,t,n,r){return JSON.stringify({projection_version:2,subcommand:e,root:t??null,target:n??null,kinds:r.kinds??null,maxDepth:r.maxDepth??null,limit:r.limit,after:r.after??null,direction:r.direction,maxPaths:r.maxPaths??null,sample:r.sample,exemptIsolates:[...new Set(r.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(r.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:r.summary,unbounded:r.unbounded})}function $t(e,t,n,r,i){return e==="analyze"?jr(r):e==="audit"?Mr(r,i):e==="plan"?Ur(r,i):e==="communities"?Pr(r):e==="redundancy"?Lr(r):e==="dominators"?Fr(t,r):e==="slack"?Gr(r):e==="centrality"?$r(r):e==="articulation"?qr(r):e==="paths"?Ar(t,n,r):e==="impact"?Tr(t,r):Nr(e,t,r)}function Br(e,t){if(e!=="index"&&(t.rebuild===!0||t.clear===!0))throw new x("--rebuild and --clear apply only to graph index.",v.USAGE);if(e!=="audit"&&t.saveBaseline===!0)throw new x("--save-baseline applies only to graph audit.",v.USAGE);if(e==="slack"&&t.kind!==void 0)throw new x("graph slack analyzes every ordering kind; --kind is not supported.",v.USAGE);if(t.rebuild===!0&&t.clear===!0)throw new x("graph index accepts either --rebuild or --clear, not both.",v.USAGE);if(t.full===!0&&t.limit!==void 0)throw new x(`graph ${e} accepts either --full or --limit, not both.`,v.USAGE)}async function zr(e,t,n,r,i,s){let o="status";if(s.clear===!0&&(await me(e),o="cleared"),s.rebuild===!0){await me(e);let a=await pe(e,t),d={assembly:n.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,limit:k.rows,sample:k.samples,unbounded:!1};for(let l of["analyze","audit"])await he(e,t,a,Gt(l,void 0,void 0,d),$t(l,void 0,void 0,d,i));o="rebuilt"}let c=await At(e,t);return{subcommand:"index",action:o,state:c.exists?c.fresh?"fresh":"stale":"absent",entry_count:c.entry_count,item_count:r,min_items_threshold:fe,persist_enabled:_e(r,c.exists),current_fingerprint:t.slice(0,12),...c.saved_at===void 0?{}:{saved_at:c.saved_at},...c.bytes===void 0?{}:{bytes:c.bytes}}}async function Hr(e,t,n,r){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:n.affected_subjects_by_code,profile:{...n.profile,finding_subjects_by_code:Object.fromEntries(R.map(o=>[o,n.affected_subjects_by_code[o]??0]))}},s=await Rt(e);return r&&await Dt(e,i),s===void 0?n:{...n,baseline:Et(s,i)}}async function Kr(e,t,n,r,i){try{await he(e,t,n,r,i)}catch{}}function Vr(e,t,n,r){if(e.subcommand!=="slack")return;let i=new Set(t.assembly.details.filter(u=>r(u.status)).map(u=>u.id)),s=t.assembly.graph,o=new xe(s.nodes().filter(u=>!i.has(u)),s.edges().filter(u=>!i.has(u.source)&&!i.has(u.target)),s.registry()),c=ut(o,n.filter(u=>!i.has(u.id)),{now:Ce(),limit:t.limit}),{rows:a,residuals:d,overcommitted:l,...f}=c;e.deadline_schedule={population:"active",...f,...t.summary?{}:{rows:a,residuals:d,overcommitted:l}}}async function rs(e,t,n,r,i){let s=Cr(e,t,n);Re(r.summary===!0,r.full===!0,"--summary");let o=Ie(process.cwd(),i.path);await Pe(o);let c=await Me(o),a=Ee(c,Te()),d=await Le(o,c.item_format,a.type_to_folder,void 0,c.schema),l=Se(c.schema),f=qt=>Ne(qt,l);Br(s,r);let u=Fe(),g=ze(r.kind,u),p=qe().lookup(o,$e(d,f,u),()=>Ge(d,f,u)),m=Sr(s,p.assembly,g,r);if(s==="index")return Mt(await zr(o,p.fingerprint,m,d.length,f,r),!1);let b=Ft.has(s)?Lt(m.assembly,t):void 0,w=s==="paths"?Lt(m.assembly,n):void 0,h=Gt(s,b,w,m),_=await pe(o,p.fingerprint),I=_.results[h],S=p.memoize(h,()=>I!==void 0?structuredClone(I):$t(s,b,w,m,f)),we=_e(d.length,_.exists);!S.reused&&I===void 0&&we&&await Kr(o,p.fingerprint,_,h,S.value);let ne=S.value.subcommand==="audit"?await Hr(o,p.fingerprint,S.value,m.saveBaseline):S.value;return ne.cache={fingerprint:p.fingerprint.slice(0,12),assembly:p.assemblyReused?"hit":"miss",result:S.reused?"hit":"miss",durable:I!==void 0?"hit":we?"miss":"off"},Vr(ne,m,d,f),Mt(ne,m.summary,"result_rows")}export{B as a,U as b,Ye as c,Xr as d,Qe as e,Ze as f,et as g,tt as h,nt as i,V as j,it as k,A as l,st as m,dt as n,X as o,lt as p,ut as q,tr as r,kt as s,Z as t,ue as u,ee as v,Et as w,St as x,fe as y,F as z,Nt as A,pe as B,he as C,me as D,At as E,_e as F,Rt as G,Dt as H,jt as I,Cr as J,rs as K};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
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-C2HW7BSE.js";import{L as Le,e as je}from"./chunk-ZZYJS74B.js";import{s as Me,y as Pe}from"./chunk-SXWUKNTY.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-HGJ4MILN.js";import{u as Ce}from"./chunk-YPOATPTX.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-3QRMY6KF.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as A,j as g,k as fe,l as pe,m as me}from"./chunk-
|
|
1
|
+
import{f as A,j as g,k as fe,l as pe,m as me}from"./chunk-GUAT4OAC.js";import{a as h,b as le,c as ce,d as ue,g as he,i as ge,j as _e,k as ke}from"./chunk-I4GY7HAP.js";import{_ as ye,a as ee,b as te}from"./chunk-REORRDPH.js";import{c as y,f as se,g as ie,i as ae}from"./chunk-52PHSTGP.js";import{B as ne,F as re,gb as oe}from"./chunk-AL47ODFZ.js";import{E,Xa as Z,Ya as L,Za as F,_a as $,h as x}from"./chunk-HGJ4MILN.js";import{b as Q,m as C}from"./chunk-YPOATPTX.js";import{C as k,H as de,a as H,z as J}from"./chunk-OCKKIECS.js";import{A as p,a as U,e as V,f as G,g as X,i as Y,z as f}from"./chunk-NGFDPEP7.js";var Kt=U,Wt=V,Bt=Y,Ut=G,Vt=X;function we(e,t,n,r){let o=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),s=n.has(o);return{long:t,...r?{short:r}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:s?"string":"boolean",...s?{value_name:e.value_name??"value"}:{}}}function be(e,t=[]){let n=new Set(t.flatMap(o=>o.keys)),r=[];for(let o of ne(e.map(s=>({...s})))){r.push(we(o,o.flag,n,o.short));for(let s of o.aliases??[])r.push(we(o,s,n))}return r}var Gt=be(re,ee),Xt=be(oe,te);var w=["agile","ops","research"],R={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:A.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
|
|
2
2
|
|
|
3
3
|
## I want
|
|
4
4
|
|
|
@@ -23,4 +23,4 @@ import{f as A,j as g,k as fe,l as pe,m as me}from"./chunk-BOIMP2AR.js";import{a
|
|
|
23
23
|
|
|
24
24
|
## Conclusion
|
|
25
25
|
`}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function ze(e){if(e===void 0)return;let t=m(e);if(t.length===0)throw new Error("Profile name must not be empty.");if(w.includes(t))return t;throw new Error(`Invalid profile "${e}". Allowed: ${w.join(", ")}.`)}function Jt(e){let t=ze(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${w.join(", ")}.`);return R[t]}function Qt(){return w.map(e=>R[e])}function m(e){return e.trim().toLowerCase().replaceAll("-","_")}function ve(e){return e.map(t=>t.definition.name).join(", ")}function Ke(e=[]){let t=w.map(s=>({definition:R[s],source:"builtin"})),n=new Set(w.map(s=>m(s))),r=new Set(n),o=[];for(let s of e){let i=m(s.profile.name);if(n.has(i)){o.push(`Extension "${s.name}" profile "${s.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(r.has(i)){o.push(`Profile "${s.profile.name}" from extension "${s.name}" duplicates an already-registered profile and was ignored.`);continue}r.add(i),t.push({definition:s.profile,source:"extension",package:s.name})}return{profiles:t,warnings:o}}function Zt(e,t=[]){let{profiles:n,warnings:r}=Ke(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${ve(n)}.`);let o=m(e),s=n.find(i=>m(i.definition.name)===o);if(s===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${ve(n)}.`);return{resolved:s,warnings:r}}function We(e){return{types:e.types.length,statuses:e.statuses.length,fields:e.fields.length,workflows:e.workflows.length,config:e.config.length,templates:e.templates.length,packages:e.packages.length}}function on(e){return{name:e.name,title:e.title,summary:e.summary,composition:We(e),types:e.types.map(t=>D(()=>y(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>D(()=>g(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>D(()=>h(t).key,()=>String(t.key??""))),workflows:e.workflows.map(t=>t.type),config:e.config.map(t=>`${t.key}=${t.value}`),templates:e.templates.map(t=>t.name),packages:e.packages.map(t=>({spec:t.spec,reason:t.reason}))}}function D(e,t){try{return e()}catch{return t()}}var Be=[{key:"context_default_depth",path:"context.default_depth",kind:"string",choices:J,summary:"Default context depth."},{key:"context_activity_limit",path:"context.activity_limit",kind:"integer",min:1,max:Number.MAX_SAFE_INTEGER,decimal_only:!0,summary:"Default context activity row limit; positive decimal integer."},{key:"context_stale_threshold_days",path:"context.stale_threshold_days",kind:"integer",min:1,max:Number.MAX_SAFE_INTEGER,decimal_only:!0,summary:"Days before context marks an item stale; positive decimal integer."},...["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"].map(e=>({key:`context_sections_${e}`,path:`context.sections.${e}`,kind:"boolean",summary:`Include ${e} in default context output.`})),{key:"context_next_ranking_policy",path:"context.next_ranking_policy",kind:"string",choices:["priority_floor","weighted"],summary:"Ready-queue order for pm next with the built-in scorer: priority_floor (resume in-progress work, then priority tiers, relevance within a tier) or weighted (blended relevance order). An extension context_relevance scorer keeps its own order."},{key:"search_provider",path:"search.provider",kind:"string",summary:"Search embedding provider name (e.g. openai, ollama, or an extension provider)."},{key:"search_default_mode",path:"search.default_mode",kind:"string",choices:["auto","keyword","semantic","hybrid"],summary:"Mode a bare pm search runs in: auto (hybrid when semantic search is explicitly configured and runnable, else keyword), or a pinned keyword, semantic, or hybrid."},{key:"search_mutation_refresh_policy",path:"search.mutation_refresh_policy",kind:"string",choices:["cache_only","semantic_configured","semantic_auto"],summary:"Mutation-time search refresh policy: cache_only, semantic_configured, or semantic_auto."},{key:"search_query_expansion_enabled",path:"search.query_expansion.enabled",kind:"boolean",summary:"Enable or disable query expansion for semantic/hybrid search."},{key:"search_query_expansion_provider",path:"search.query_expansion.provider",kind:"string",summary:"Query expansion provider name (built-in openai/ollama or extension provider)."},{key:"search_rerank_enabled",path:"search.rerank.enabled",kind:"boolean",summary:"Enable or disable post-retrieval reranking for hybrid search."},{key:"search_rerank_model",path:"search.rerank.model",kind:"string",summary:"Rerank model name override used by built-in providers."},{key:"search_rerank_top_k",path:"search.rerank.top_k",kind:"integer",min:1,summary:"Number of top hybrid candidates to rerank when rerank is enabled."},{key:"search_embedding_model",path:"search.embedding_model",kind:"string",summary:"Default embedding model name (overrides provider-specific model when set)."},{key:"search_embedding_corpus_max_characters",path:"search.embedding_corpus_max_characters",kind:"integer",min:1,summary:"Maximum semantic corpus characters per item before truncation."},{key:"search_embedding_batch_size",path:"search.embedding_batch_size",kind:"integer",min:1,summary:"Number of items embedded per request batch."},{key:"search_embedding_timeout_ms",path:"search.embedding_timeout_ms",kind:"integer",min:1,summary:"Per-request embedding timeout in milliseconds."},{key:"search_score_threshold",path:"search.score_threshold",kind:"number",summary:"Minimum score for a hit to be returned (0 keeps all matches)."},{key:"search_hybrid_semantic_weight",path:"search.hybrid_semantic_weight",kind:"ratio",summary:"Hybrid mode semantic weight in [0, 1] (1-weight goes to keyword)."},{key:"search_max_results",path:"search.max_results",kind:"integer",min:1,summary:"Default upper bound on search hits when --limit is not supplied."},{key:"search_bm25_k1",path:"search.bm25.k1",kind:"number",min:0,summary:"Offline BM25 term-frequency saturation (k1); higher saturates repeated terms slower (default 1.2)."},{key:"search_bm25_b",path:"search.bm25.b",kind:"ratio",summary:"Offline BM25 document-length normalization (b) in [0, 1]; 0 disables, 1 fully normalizes (default 0.75)."},{key:"openai_base_url",path:"providers.openai.base_url",kind:"string",summary:"OpenAI-compatible API base URL (LM Studio/vLLM also use this)."},{key:"openai_api_key",path:"providers.openai.api_key",kind:"string",summary:"OpenAI-compatible API key."},{key:"openai_model",path:"providers.openai.model",kind:"string",summary:"OpenAI-compatible embedding model name."},{key:"ollama_base_url",path:"providers.ollama.base_url",kind:"string",summary:"Ollama API base URL (typically http://localhost:11434)."},{key:"ollama_model",path:"providers.ollama.model",kind:"string",summary:"Ollama embedding model name (e.g. nomic-embed-text)."},{key:"vector_store_adapter",path:"vector_store.adapter",kind:"string",summary:"Vector store adapter name (lancedb, qdrant, or an extension adapter)."},{key:"vector_store_collection_name",path:"vector_store.collection_name",kind:"string",non_empty:!0,summary:"Vector collection/table name shared by Qdrant and LanceDB adapters."},{key:"qdrant_url",path:"vector_store.qdrant.url",kind:"string",summary:"Qdrant HTTP API URL."},{key:"qdrant_api_key",path:"vector_store.qdrant.api_key",kind:"string",summary:"Qdrant API key (empty if running unauthenticated)."},{key:"lancedb_path",path:"vector_store.lancedb.path",kind:"string",summary:"LanceDB storage path (relative to pm root or absolute)."},{key:"id_prefix",path:"id_prefix",kind:"string",non_empty:!0,summary:'Prefix for generated item IDs (e.g. "pm" produces pm-xxxx).'},{key:"author_default",path:"author_default",kind:"string",non_empty:!0,summary:"Default author recorded on mutations when --author is not supplied."},{key:"agent_identity_probes_enabled",path:"agent_identity.probes_enabled",kind:"boolean",summary:"Allow privacy-bounded local harness provenance probes; no network or subprocess access is permitted."},{key:"mutation_guard_require_attributed_author",path:"mutation_guard.require_attributed_author",kind:"boolean",summary:"Reject mutations whose effective author resolves to unknown."},{key:"mutation_guard_secret_guard",path:"mutation_guard.secret_guard",kind:"string",choices:["off","advise","block"],summary:"Detect credential-shaped mutation content: off, advise, or block."},{key:"mutation_guard_stale_in_progress_hours",path:"mutation_guard.stale_in_progress_hours",kind:"integer",min:1,summary:"Age threshold for unclaimed in-progress work surfaced by health."},{key:"governance_duplicate_detection_mode",path:"governance.duplicate_detection_mode",kind:"string",choices:["off","advisory","strict"],summary:"Create/copy duplicate governance: off, advisory, or strict explicit-bypass enforcement."},{key:"governance_duplicate_detection_threshold",path:"governance.duplicate_detection_threshold",kind:"ratio",summary:"Minimum shared similarity score in [0, 1] for create/copy duplicate governance."},{key:"governance_duplicate_detection_limit",path:"governance.duplicate_detection_limit",kind:"integer",min:0,max:20,summary:"Maximum likely duplicates returned by create/copy governance (0-20)."},{key:"output_default_format",path:"output.default_format",kind:"string",choices:["toon","json"],summary:"Default output format for commands that support it: toon or json."},{key:"ux_deprecation_hints",path:"ux.deprecation_hints",kind:"boolean",summary:"Emit one stderr migration hint for deprecated command aliases."},{key:"locks_ttl_seconds",path:"locks.ttl_seconds",kind:"integer",min:1,summary:"Claim/lock time-to-live in seconds before a stale lock can be reclaimed."},{key:"locks_wait_ms",path:"locks.wait_ms",kind:"integer",min:0,summary:"Wait budget in milliseconds before a contended lock fails with lock_conflict; item-store mutations, restore and the hierarchy lock treat it as a no-progress window that each observed owner handoff restarts (120 s total cap), other locks as a fixed total; 0 fails fast. PM_LOCK_WAIT_MS overrides per invocation."},{key:"ids_token_length",path:"ids.token_length",kind:"integer",min:4,max:12,summary:"Random base36 token length for newly minted item ids (4-12, default 4). Raise it to shrink cross-branch id collision odds in concurrent multi-agent workflows (pm-pibw)."},{key:"checkpoints_retention_days",path:"checkpoints.retention_days",kind:"integer",min:1,summary:"Age in days above which pm gc --scope checkpoints prunes bulk-mutation rollback checkpoints."},{key:"schema_unknown_field_policy",path:"schema.unknown_field_policy",kind:"string",choices:["allow","warn","reject"],summary:"How item I/O handles metadata keys not in the field registry: allow, warn, or reject."},{key:"history_compact_policy_enabled",path:"history.compact_policy.enabled",kind:"boolean",summary:"Enable the history-compaction advisory: pm health warns on over-threshold streams."},{key:"history_compact_policy_max_entries",path:"history.compact_policy.max_entries",kind:"integer",min:1,summary:"Entry count above which a history stream is flagged (and the default pm history-compact --all-over threshold)."},{key:"history_compact_policy_trigger",path:"history.compact_policy.trigger",kind:"string",choices:["health_warn","auto"],summary:"History-compaction policy intent: health_warn (advisory only) or auto (scheduled sweeps expected)."}],Ue=new Map(Be.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function N(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return Ue.get(t)}function Ve(e,t){let n=t.trim().toLowerCase();return n==="true"||n==="1"||n==="yes"||n==="on"?{ok:!0,parsed:{descriptor:e,value:!0}}:n==="false"||n==="0"||n==="no"||n==="off"?{ok:!0,parsed:{descriptor:e,value:!1}}:{ok:!1,error:{message:`Config set ${e.key} requires a boolean value (true|false), got "${t}"`}}}function Ge(e,t,n){return e.key==="context_default_depth"&&(n=n.toLowerCase()),e.non_empty===!0&&n.length===0?{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}}:e.choices&&!e.choices.includes(n)?{ok:!1,error:{message:`Config set ${e.key} must be one of ${e.choices.join("|")}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function Se(e,t){let n=[e.min===void 0?"":`minimum ${e.min}`,e.max===void 0?"":`maximum ${e.max}`].filter(Boolean).join(", ");return{message:`Config set ${e.key} requires non-empty decimal integer digits${n?` (${n})`:""}, got "${t}"`}}function Xe(e,t,n){if(e.decimal_only&&!/^\d+$/u.test(n))return{ok:!1,error:Se(e,t)};if(n.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let r=Number(n);return Number.isFinite(r)?{ok:!0,value:r}:{ok:!1,error:e.decimal_only?Se(e,t):{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function Ye(e,t,n){return!Number.isInteger(n)||n<0?{ok:!1,error:{message:`Config set ${e.key} requires a non-negative integer, got "${t}"`}}:e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires an integer >= ${e.min}, got "${t}" (the runtime silently ignores 0 here and falls back to the default)`}}:e.max!==void 0&&n>e.max?{ok:!1,error:{message:`Config set ${e.key} requires an integer <= ${e.max}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function He(e,t,n){return n<0||n>1?{ok:!1,error:{message:`Config set ${e.key} requires a number in [0, 1], got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function Je(e,t,n){return e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires a number >= ${e.min}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function I(e,t){if(typeof t!="string")return{ok:!1,error:{message:`Config set ${e.key} requires a string value`}};let n=t.trim();if(e.kind==="boolean")return Ve(e,t);if(e.kind==="string")return Ge(e,t,n);let r=Xe(e,t,n);return r.ok?e.kind==="integer"?Ye(e,t,r.value):e.kind==="ratio"?He(e,t,r.value):Je(e,t,r.value):{ok:!1,error:r.error}}function Oe(e,t){let n=t.path.split("."),r=e;for(let o of n){if(typeof r!="object"||r===null)return null;let s=Object.getOwnPropertyDescriptor(r,o);if(!s||!Object.hasOwn(s,"value"))return null;r=s.value}return typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:null}function ln(e,t,n){let r=t.path.split(".");if(r.some(a=>a.length===0||["__proto__","constructor","prototype"].includes(a)))throw new Error("Unsafe settings path");let o=e;for(let a=0;a<r.length-1;a+=1){let u=r[a],c=Object.getOwnPropertyDescriptor(o,u)?.value;if(typeof c!="object"||c===null||Array.isArray(c)){let l={};Object.defineProperty(o,u,{value:l,writable:!0,enumerable:!0,configurable:!0}),o=l}else o=c}let s=r[r.length-1];return Object.getOwnPropertyDescriptor(o,s)?.value===n?!1:(Object.defineProperty(o,s,{value:n,writable:!0,enumerable:!0,configurable:!0}),!0)}var bn=["profile","types","statuses","fields","workflows","config","templates","packages"],vn=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","field_flag_invalid","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],Qe=new Set(de.flatMap(e=>[k(e.id),...(e.aliases??[]).map(t=>k(t))]).filter(e=>e.length>0)),xe=new Set(H.map(e=>e.toLowerCase()));function Ze(e,t){e.name.trim().length===0?t.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):e.name!==m(e.name)&&t.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:e.name,message:`Profile name "${e.name}" is not in canonical form; resolution folds it to "${m(e.name)}" (lowercase, hyphens as underscores).`}),e.title.trim().length===0&&t.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),e.summary.trim().length===0&&t.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function et(e,t){let n=new Set,r=new Set;for(let[o,s]of e.types.entries()){let i;try{i=y(s).name}catch(u){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof s.name=="string"?s.name:`#${o}`,message:E(u)});continue}let a=i.toLowerCase();if(r.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:i,message:`Item type "${i}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(a),n.add(a)}return n}function tt(e,t){let n=new Set,r=new Set;for(let[o,s]of e.statuses.entries()){let i;try{i=g(s)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof s.id=="string"?s.id:`#${o}`,message:E(a)});continue}if(r.has(i.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:i.id,message:`Status "${i.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(i.id),n.add(i.id);for(let a of i.aliases??[])n.add(k(a))}return n}function nt(e,t){let n=new Set;for(let[r,o]of e.fields.entries()){let s,i;try{i=h(o),s=i.key}catch(l){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof o.key=="string"?o.key:`#${r}`,message:E(l)});continue}if(n.has(s)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:s,message:`Field "${s}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}n.add(s);let a=ge(i);a.length>0&&t.push({severity:"error",code:"field_flag_invalid",dimension:"fields",target:s,message:`Field "${s}" declares a flag that is not one option spelling: ${a.map(_e).join("; ")}. Pass one spelling per alias.`});let u=he(i);u.length>0&&t.push({severity:"error",code:"field_option_collision",dimension:"fields",target:s,message:`Field "${s}" would disable a built-in option: ${u.map(ke).join("; ")}. Rename the field or narrow its commands.`});let c=ye(s);c&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:s,message:`Field "${s}" collides with canonical MCP property "${c.property}" owned by ${c.owner}; callers must pass the custom value through ${c.nested_path}.`})}}function rt(e,t,n,r){let o=new Set;for(let[s,i]of e.workflows.entries()){let a=i.type.trim().toLowerCase();if(a.length===0){r.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${s}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}let u=o.has(a);o.add(a),u?r.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:i.type,message:`Workflow type "${i.type}" is declared more than once; the later transition set wins.`}):!xe.has(a)&&!t.has(a)&&r.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:i.type,message:`Workflow governs type "${i.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let c=new Set;for(let l of i.allowed_transitions){let d=k(l[0]),B=k(l[1]);if(d.length===0||B.length===0){r.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:i.type,message:`Workflow "${i.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(let _ of[d,B])Qe.has(_)||n.has(_)||c.has(_)||(c.add(_),r.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:_,message:`Workflow "${i.type}" references status "${_}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function ot(e,t){let n=new Set;for(let r of e.config){let o=N(r.key);if(o===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:r.key,message:`Config knob "${r.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(o.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:o.key,message:`Config knob "${o.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(o.key);let s=I(o,r.value);s.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:r.key,message:s.error.message})}}function st(e,t,n){for(let r of e.templates){let o=r.options.type;if(typeof o!="string"||o.trim().length===0)continue;let s=o.trim().toLowerCase();!xe.has(s)&&!t.has(s)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:r.name,message:`Template "${r.name}" creates type "${o}" which is neither a built-in type nor declared by this profile.`})}}function it(e,t){for(let[n,r]of e.packages.entries())r.spec.trim().length===0&&t.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${n}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function Sn(e){let t=[];Ze(e,t);let n=et(e,t),r=tt(e,t);nt(e,t),rt(e,n,r,t),ot(e,t),st(e,n,t),it(e,t);let o=t.filter(i=>i.severity==="error").length,s=t.length-o;return{profile:e.name,ok:o===0,findings:t,errorCount:o,warningCount:s}}function M(e,t,n,r,o){let s=e,i=[];for(let a of t){let u=r(s),c=o(s,a),l=r(c.file);s=c.file;let d=u===l?"unchanged":c.replaced?"update":"add";i.push({key:n(a),status:d})}return{file:s,changes:i,changed:i.some(a=>a.status!=="unchanged")}}function Ee(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function at(e,t){let n=e.map(o=>({...o})),r=[];for(let o of t){let s=n.findIndex(a=>a.type===o.type),i={type:o.type,allowed_transitions:o.allowed_transitions};s<0?(n.push(i),r.push({type:o.type,status:"add"})):Ee(n[s].allowed_transitions)===Ee(o.allowed_transitions)?r.push({type:o.type,status:"unchanged"}):(n[s]=i,r.push({type:o.type,status:"update"}))}return{changes:r,result:n,changed:r.some(o=>o.status!=="unchanged")}}function lt(e,t){let n=[];for(let r of e.config){let o=N(r.key);if(o===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${r.key}".`);let s=I(o,r.value);if(!s.ok)throw new Error(`Profile "${e.name}" config ${r.key}: ${s.error.message}`);let i=Oe(t,o),a=i===null?"add":i===s.parsed.value?"unchanged":"update";n.push({key:o.key,path:o.path,value:s.parsed.value,status:a})}return{changes:n,changed:n.some(r=>r.status!=="unchanged")}}function $e(e){let t=Object.entries(e).sort(([n],[r])=>n.localeCompare(r));return JSON.stringify(t)}function ct(e,t){let n=[];for(let r of e.templates){let o=t.get(r.name),s;o===void 0?s="add":$e(o)===$e(r.options)?s="unchanged":s="update",n.push({name:r.name,options:r.options,status:s})}return{changes:n,changed:n.some(r=>r.status!=="unchanged")}}function Nn(e,t){let n=M(se(t.typesRaw),e.types,l=>y(l).name,ae,(l,d)=>ie(l,y(d))),r=M(fe(t.statusesRaw),e.statuses,l=>g(l).id,pe,(l,d)=>me(l,g(d))),o=M(le(t.fieldsRaw),e.fields,l=>h(l).key,ce,(l,d)=>ue(l,h(d))),s=at(t.workflows,e.workflows),i=lt(e,t.settings),a=ct(e,t.templates),u=e.packages.map(l=>({spec:l.spec,reason:l.reason,status:t.installedPackages.has(l.spec)?"installed":"recommended"})),c=n.changed||r.changed||o.changed||s.changed||i.changed||a.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:r,fields:o,workflows:s,config:i,templates:a,packages:u,changed:c}}import{isDeepStrictEqual as ut}from"node:util";var dt=new Set(["__proto__","prototype","constructor"]),Ce=Symbol("looseOptionOccurrences");function b(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,r)=>r.toUpperCase())}function j(e){return dt.has(e)}function Le(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Z(t)}function Fe(e){let t=[],n=x(e.long)??"",r=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let o=b(n.slice(2));o.length>0&&!j(o)&&t.push(o)}if(r.startsWith("-")&&!r.startsWith("--")){let o=b(r.slice(1));o.length>0&&!j(o)&&t.push(o)}return[...new Set(t)]}function S(e){let t=x(e.long)??"";if(t.startsWith("--")){let n=b(t.slice(2));if(n.length>0&&!j(n))return n}return Fe(e)[0]??null}function O(e){let t=x(e.long)??"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function ft(e,t){return[...(t.definitions??e).map(r=>O(r)).filter(r=>r!==null),...t.inheritedFlags??[]]}function pt(e,t,n,r){let o=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new p(`Unknown option '${e}' for extension command '${n}'.${o}`,f.USAGE,{code:"unknown_option",flag:t,required:`Use a flag the command accepts; run pm contracts --command ${n} --flags-only --json to list them.`})}function mt(e,t){throw new p(`Option '${e}' is disabled for extension command '${t}'.`,f.USAGE,{code:"extension_option_disabled",flag:e,required:`Remove ${e}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${t} --help`],nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function yt(e,t,n,r){let o=L(e),s=o.value_arity==="none"?n:o.value_arity==="optional"?`${n} [${o.value_name}]`:`${n} <${o.value_name}>`;throw new p(`Missing required option '${n}' for extension command '${r}'.`,f.USAGE,{code:"missing_required_option",flag:n,field:t,required:`Pass ${s}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${r} ${s}`],nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[n]}})}function ht(e){return typeof e=="string"||e==null?e:String(e)}function gt(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function Re(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var _t={string:ht,number:gt,boolean:Re};function v(e,t){return Array.isArray(e)?e.map(n=>v(n,t)):_t[t](e)}function P(e,t,n){let r=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(o=>o!=null&&o!==""):F(e);return t?r.map(o=>v(o,t)):r}function kt(e,t){return P(t,null,e.repeatable===!0).length>0}function wt(e,t,n,r){return n?P(e,t,r):t?v(e,t):e}function bt(e,t,n){let r=Me(e,t);return r.length===0?n:r.map(o=>o.value)}function De(e){return L(e).value_arity==="none"}function z(e,t,n,r,o){let s=O(e),i=o?` for extension command '${o}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new p(`Option '${s}'${i} expects ${r}; received ${a}.`,f.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${s}.`,`Run pm ${o??"<command>"} --help to review the declared flag contract.`]})}function K(e,t){return e.value_validation==="strict"&&t!=="string"}function Me(e,t){let n=e[Ce];if(!n)return[];let r=new Set(t);return n.filter(o=>r.has(o.key))}function vt(e,t,n,r){if(De(e))for(let o of Me(n,t)){if(o.attached!==!0)continue;let s=e.list===!0&&e.repeatable!==!0?F(o.value):[o.value];for(let i of s){let a=$(v(i,"boolean"),"boolean");a!==null&&z(e,"boolean",i,a.expected,r)}}}function St(e,t,n,r,o){let s=Array.isArray(n)?n.flat(1/0):[n],i=r?s:s.flatMap(a=>typeof a=="string"?a.split(","):[a]);for(let a of i)if(typeof a=="string"&&a.trim().length===0){let u=$(a,t);z(e,t,a,u.expected,o)}}function W(e,t,n,r){if(!K(e,n))return t;let o=n==="boolean"&&De(e),s=i=>{let a=$(i,n);return a===null?i:o&&typeof i=="string"?!0:z(e,n,i,a.expected,r)};return Array.isArray(t)?t.map(s):s(t)}function Ot(e,t,n,r){for(let o of n)if(!(o===t||!Object.hasOwn(e,o))){if(Object.hasOwn(e,t)){if(r){let s=e[t],i=e[o];e[t]=[...Array.isArray(s)?s:[s],...Array.isArray(i)?i:[i]].filter(a=>a!=null)}delete e[o];continue}e[t]=e[o],delete e[o]}}function je(e,t,n=e,r){if(t.length===0)return e;let o=Object.create(null);for(let[i,a]of Object.entries(e))o[i]=a;let s=new Set(t.map(i=>S(i)).filter(i=>i!==null));for(let i of t){let a=S(i);if(a){let u=Fe(i).filter(c=>c===a||!s.has(c));xt(o,i,a,u,n,r)}}return o}function xt(e,t,n,r,o,s){let i=t.list===!0,a=Le(t);a&&!i&&Et(e,t,n,r,a,s),Ot(e,n,r,i);let u=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=wt(t.default,a,i,u));return}if(a==="boolean"&&K(t,a)&&vt(t,r,o,s),i){e[n]=$t(t,r,o,e[n],a,u,s);return}a&&(e[n]=W(t,v(e[n],a),a,s))}function Et(e,t,n,r,o,s){for(let i of r)i!==n&&Object.hasOwn(e,i)&&W(t,v(e[i],o),o,s)}function $t(e,t,n,r,o,s,i){let a=bt(n,t,r);o&&K(e,o)&&St(e,o,a,s,i);let u=P(a,o,s);return o?W(e,u,o,i):u}function Rn(e){return S(e)}function Ae(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function Dn(e,t){let n=Ae(t);if(n.length===0)return[];let r=C(n);return e.flags.filter(o=>C(Ae(o.target_command))===r).flatMap(o=>[...o.flags])}function At(e,t,n,r){let o=O(e),[s,i]=n;throw new p(`Options '${s}' and '${i}' both set ${o} for extension command '${r}' with different values.`,f.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${o} once, under the handler key '${t}'.`,why:`'${s}' and '${i}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${i}' and pass one value as '${t}'.`,`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`]})}function Mn(e,t,n,r={}){if(t.length===0)return e;let o=t.map(l=>l.repeatable===!0&&l.list!==!0?{...l,list:!0}:l),s=Ct(o),i=Rt(e,s,n),a=new Set([...s.long.values()].map(({handlerKey:l})=>l)),u=Object.create(null),c=Object.create(null);for(let[l,d]of Object.entries(i))a.has(l)?u[l]=d:d===void 0||r.undeclaredKeys==="pass"||It(l)?c[l]=d:pt(l,Tt(l),n,ft(o,{}));return Pe(u,o,n),Object.assign(c,je(u,o,qe(u,s),n))}function qe(e,t){let n=new Set([...t.long.values()].map(({handlerKey:s})=>s)),r=Object.entries(e).filter(([s])=>n.has(s)).flatMap(([s,i])=>(Array.isArray(i)?i.flat(1/0):[i]).map(a=>({consumed:1,key:s,value:a,attached:!0}))),o=Object.create(null);return Object.defineProperty(o,Ce,{value:r}),o}function Pe(e,t,n){for(let r of t){let o=S(r);if(o===null)continue;let s=O(r),i=e[o],a=Object.hasOwn(e,o);r.enabled===!1&&a&&mt(s,n);let u=a&&(r.list!==!0||kt(r,i));r.required===!0&&r.enabled!==!1&&!u&&yt(r,o,s,n),r.list!==!0&&Array.isArray(i)&&Nt(s,n)}}function Nt(e,t){throw new p(`Option '${e}' for extension command '${t}' takes one value; received an array.`,f.USAGE,{code:"extension_flag_value_invalid",flag:e,required:`Pass one value for ${e}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${t} --flags-only --json to read each flag's value contract.`]})}var Ne=new Set([...[...Q].flatMap(e=>{let t=e.replace(/^--/u,"");return[t,...t.startsWith("no-")?[t.slice(3)]:[]].flatMap(r=>[b(r),r.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function It(e){return Ne.has(e)||Ne.has(b(e.replace(/^-{1,2}/u,"")))}function Tt(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function Ct(e){let t={long:new Map,short:new Map},n=(r,o,s)=>{o.length>0&&!r.has(o)&&r.set(o,s)};for(let r of e){let o=S(r);if(o===null)continue;let s={handlerKey:o,definition:r};n(t.long,o,s);let i=typeof r.short=="string"?r.short.trim():"";i.startsWith("-")&&!i.startsWith("--")&&n(t.short,i.slice(1),s)}return t}function q(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(b(t.replace(/^-{1,2}/u,"")))}function Lt(e,t,n,r){let o=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(o===void 0||q(e,t)!==void 0)return{spelling:t,value:n};let s=q(e,o);return s===void 0||Le(s.definition)!=="boolean"?{spelling:t,value:n}:(s.definition.list===!0||s.definition.repeatable===!0)&&Array.isArray(n)?{spelling:o,value:n.flat(1/0).map(i=>Ie(t,s.definition,i,r))}:s.definition.list===!0&&n!==void 0?{spelling:o,value:Ie(t,s.definition,n,r)}:{spelling:o,value:n===void 0?n:T(t,s.definition,n,r)}}function Ie(e,t,n,r){let o=s=>s.trim().length===0?s:String(T(e,t,s.trim(),r));return n==null?n:typeof n!="string"?T(e,t,n,r):n.trim().length===0?n:t.repeatable===!0||!n.includes(",")?T(e,t,n,r):n.split(",").map(o).join(",")}function T(e,t,n,r){let o=Re(n);return typeof o=="boolean"?!o:Ft(e,t,n,r)}function Ft(e,t,n,r){let o=O(t);throw new p(`Option '${e}' for extension command '${r}' negates ${o} and expects true, false, 1, or 0; received ${JSON.stringify(n)}.`,f.USAGE,{code:"extension_flag_value_invalid",flag:o,required:`Pass ${o} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${o}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's value contract.`]})}function Rt(e,t,n){let r=Object.create(null),o=new Map;for(let[s,i]of Object.entries(e)){let{spelling:a,value:u}=Lt(t,s,i,n),c=q(t,a);if(c===void 0)r[a]=u;else if(u!==void 0){let l=o.get(c.handlerKey);l===void 0?(o.set(c.handlerKey,a),r[c.handlerKey]=u):ut(Te(c.definition,c.handlerKey,r[c.handlerKey],t,n),Te(c.definition,c.handlerKey,u,t,n))||At(c.definition,c.handlerKey,[l,a],n)}}return r}function Te(e,t,n,r,o){let s={[t]:n};return Pe(s,[e],o),je(s,[e],qe(s,r),o)[t]}export{Kt as a,Wt as b,Bt as c,Ut as d,Vt as e,be as f,Gt as g,Xt as h,w as i,R as j,ze as k,Jt as l,Qt as m,Ke as n,Zt as o,We as p,on as q,Be as r,N as s,I as t,Oe as u,ln as v,bn as w,vn as x,Sn as y,Nn as z,Rn as A,Dn as B,Mn as C};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-4HLZOOZI.js.map
|