@unbrained/pm-cli 2026.11.27 → 2026.11.29
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 +4 -4
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/linked-resource-value-list.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3AZOATC2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-3E53F7QY.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-5CMR4R5V.js → chunk-3TK2YOVB.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-O23KTJL6.js → chunk-3US5T6B2.js} +63 -63
- package/dist/cli-bundle/chunks/chunk-4EBHZBM2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-MGJMQSN4.js → chunk-4QA5O64H.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-5EFS7K7Y.js +1 -0
- package/dist/cli-bundle/chunks/chunk-CNZOC6JD.js +2 -0
- package/dist/cli-bundle/chunks/chunk-CV2B4JUB.js +3 -0
- package/dist/cli-bundle/chunks/chunk-DBASKWBO.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZGV4ZXDS.js → chunk-EYEQC3L2.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-FRYNDVLN.js +8 -0
- package/dist/cli-bundle/chunks/chunk-GSLOAEY2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-KS47NGMQ.js → chunk-JFPCL45G.js} +14 -14
- package/dist/cli-bundle/chunks/chunk-JQHLOSSS.js +4 -0
- package/dist/cli-bundle/chunks/chunk-JV7LREUF.js +3 -0
- package/dist/cli-bundle/chunks/chunk-K3MVVDLN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-6OIHST4I.js → chunk-K672XXGQ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-KP75JTTO.js → chunk-KCR4NF2A.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-L7HON3BE.js +23 -0
- package/dist/cli-bundle/chunks/chunk-LQEB6GSY.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-W7SPEGSP.js → chunk-NLHNB2L3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-63AVXDZS.js → chunk-NRCGGNOE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KHFUHGL3.js → chunk-OGVSGXQX.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-PY6A7ULK.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-6NJ3BONB.js → chunk-Q6GIFUCW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X6TE47CS.js → chunk-R6M5OGJH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-RWHS77ME.js +113 -0
- package/dist/cli-bundle/chunks/chunk-SV27NNXQ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-TE6FBDHP.js +4 -0
- package/dist/cli-bundle/chunks/chunk-VI3A7UZ2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WLZ5KVM2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WNB62BGK.js +10 -0
- package/dist/cli-bundle/chunks/chunk-X5D5YUHR.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZK4CY24V.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZSBPE36C.js +2 -0
- package/dist/cli-bundle/chunks/field-definition-losses-XKE4DRUA.js +2 -0
- package/dist/cli-bundle/chunks/field-option-collisions-OZE43TOH.js +2 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-H3MMNXXG.js → indexed-receipt-blobs-DR3FDHND.js} +2 -2
- package/dist/cli-bundle/{focused-chunks/item-revision-NOHVIOQQ.js → chunks/item-revision-3WXNNFLP.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-DJ5GAITL.js +2 -0
- package/dist/cli-bundle/chunks/linked-resource-value-list-2655COY2.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-QOKPDYM4.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-JNJHB3E6.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-Q7UW2EPV.js → register-list-query-YGVUE4YZ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-YNW7E3T4.js → register-mutation-3JVZQDHH.js} +2 -2
- package/dist/cli-bundle/chunks/register-operations-LCHUHKRA.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-IJ7M3VUK.js +2 -0
- package/dist/cli-bundle/chunks/runtime-schema-OAIUNQRL.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-ESAAEBRM.js → settlement-hook-BIVNGBZF.js} +2 -2
- package/dist/cli-bundle/chunks/stage-7BD7U2BX.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-26P6C6OO.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-2CQFGJQ6.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-42SU4LK3.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-5NSWNLFE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4HLZOOZI.js → chunk-ACTBMSCH.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-BPBKHY6H.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UGQ2EXTU.js → chunk-BPOU2S44.js} +57 -57
- package/dist/cli-bundle/focused-chunks/chunk-BZ3PUUPG.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-CWQLW4ZO.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-N7ZAMULP.js → chunk-EUDAUT6T.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-GTUPHXKR.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NGFDPEP7.js → chunk-IRYNVGKH.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-JFICNN4T.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-AL47ODFZ.js → chunk-KLOHZNJ4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KPASZGBL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-24W63UPP.js → chunk-KWKPX36T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-HSWL6L2O.js → chunk-LKTRICZR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7FKGIJEB.js → chunk-LSVRZ4KQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MYWUMVCZ.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-NNLENKU7.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-NO5MUY4I.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-52PHSTGP.js → chunk-NZA2LP4Y.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GUAT4OAC.js → chunk-PPCBCPIZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QTV6UE2Q.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-REORRDPH.js → chunk-S4AC7OMI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7GZMOLQY.js → chunk-S5VG7RFY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-TSZVCALS.js +91 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YPOATPTX.js → chunk-TX24L7RQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WJAUHPXD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4SX2BN4V.js → chunk-XR6MLUVW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/field-definition-losses-GGA6FUHD.js +2 -0
- package/dist/cli-bundle/focused-chunks/field-option-collisions-HABQYZMQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-PG2VJ3MB.js → indexed-receipt-blobs-EUYZJR5R.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-YH5R7YPW.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-YZ2PUPGM.js +2 -0
- package/dist/cli-bundle/{chunks/mutation-actor-SFYTD2ZB.js → focused-chunks/mutation-actor-DJ2VRLKG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-3SECKVKY.js +2 -0
- package/dist/cli-bundle/focused-chunks/runtime-schema-IDRXWCC4.js +2 -0
- package/dist/cli-bundle/focused-chunks/{settlement-hook-4MGRERCT.js → settlement-hook-Q6MJQKIE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/stage-FEJT2UCG.js +2 -0
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +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 +2 -2
- package/dist/core/extensions/item-fields.d.ts +33 -2
- package/dist/core/extensions/item-fields.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/fs/fs-utils.d.ts +8 -0
- package/dist/core/fs/fs-utils.js +2 -2
- package/dist/core/item/item-type-inspection.js +2 -0
- package/dist/core/item/type-registry.js +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/schema/runtime-schema.d.ts +39 -1
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/store/settings.d.ts +7 -0
- package/dist/core/store/settings.js +5 -5
- package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
- package/dist/sdk/extension/command-options.d.ts +8 -0
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/update.js +2 -2
- package/dist/sdk/profile.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/schema/field-definition-losses.js +2 -0
- package/dist/sdk/schema/field-option-collisions.js +1 -1
- package/dist/sdk/schema/schema-file-entry-losses.js +2 -0
- package/dist/sdk/schema.js +2 -2
- package/dist/sdk/test/execution.d.ts +9 -1
- package/dist/sdk/test/execution.js +4 -4
- package/docs/COMMANDS.md +3 -1
- package/docs/CONFIGURATION.md +2 -0
- package/docs/EXTENSIONS.md +1 -1
- package/docs/SDK_AUDITED_MUTATIONS.md +21 -3
- package/marketplace.json +1 -1
- package/node_modules/fast-json-patch/README.md +2 -2
- package/node_modules/fast-json-patch/dist/fast-json-patch.js +604 -818
- package/node_modules/fast-json-patch/dist/fast-json-patch.min.js +4 -8
- package/node_modules/fast-json-patch/package.json +14 -17
- package/package.json +2 -2
- 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-5M7UTO2G.js +0 -2
- package/dist/cli-bundle/chunks/chunk-66TNCHHG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-AVHRMUXJ.js +0 -3
- package/dist/cli-bundle/chunks/chunk-HTT52JL3.js +0 -125
- package/dist/cli-bundle/chunks/chunk-J25DZRYJ.js +0 -31
- package/dist/cli-bundle/chunks/chunk-J6TFG34A.js +0 -4
- package/dist/cli-bundle/chunks/chunk-JX475QVU.js +0 -3
- package/dist/cli-bundle/chunks/chunk-OFX2VA5Z.js +0 -2
- package/dist/cli-bundle/chunks/chunk-QVDEZBSV.js +0 -8
- package/dist/cli-bundle/chunks/chunk-SIRZ4VMT.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SX76UGEY.js +0 -3
- package/dist/cli-bundle/chunks/chunk-VC4BJIA7.js +0 -9
- package/dist/cli-bundle/chunks/chunk-WY7467RY.js +0 -3
- package/dist/cli-bundle/chunks/chunk-XB6QEVUK.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XYX4CXFR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-Y5U7QCNX.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YGK6SA7P.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZILIHDDY.js +0 -113
- package/dist/cli-bundle/chunks/field-option-collisions-UL6BIPAK.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-WNUDY5DM.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-ER3OWOPV.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-AVOOT3KH.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-DAUTQCIO.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-VSURGF7V.js +0 -2
- package/dist/cli-bundle/chunks/runtime-schema-Y4SHTEXL.js +0 -2
- package/dist/cli-bundle/chunks/stage-N5GDBS5A.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2XGHBYDA.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-3QRMY6KF.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AN4NFFLL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-B2HJI6KA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-C2HW7BSE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-GISZWMBS.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-H4JBS477.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HGJ4MILN.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-I4GY7HAP.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-KMG4O2IU.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-OCKKIECS.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-SXWUKNTY.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-ZZYJS74B.js +0 -91
- package/dist/cli-bundle/focused-chunks/field-option-collisions-BP7ILGQK.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-O26COBOJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-HVJV5S76.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-JRICEVYN.js +0 -2
- package/dist/cli-bundle/focused-chunks/runtime-schema-YXPYDD2C.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-NSX6ASBZ.js +0 -2
- package/node_modules/fast-json-patch/webpack.config.js +0 -63
|
@@ -1,2 +0,0 @@
|
|
|
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,2 +0,0 @@
|
|
|
1
|
-
import{ua as l}from"./chunk-HGJ4MILN.js";import{k as y,m,n as f,o as h}from"./chunk-YPOATPTX.js";import{z as a}from"./chunk-NGFDPEP7.js";var R=[{exit_code:a.SUCCESS,outcome:"effect",success:!0,meaning:"The requested operation completed with its intended effect."},{exit_code:a.GENERIC_FAILURE,outcome:"internal_failure",success:!1,meaning:"An unexpected runtime or internal failure prevented completion."},{exit_code:a.USAGE,outcome:"refused_input",success:!1,meaning:"The invocation was refused because its input or composition was invalid."},{exit_code:a.NOT_FOUND,outcome:"refused_tracker_state",success:!1,meaning:"The requested tracker, item, or resource was not present."},{exit_code:a.CONFLICT,outcome:"conflict",success:!1,meaning:"Current state or concurrency prevented the requested effect."},{exit_code:a.DEPENDENCY_FAILED,outcome:"dependency_failed",success:!1,meaning:"A required dependency operation failed."},{exit_code:a.NO_EFFECT,outcome:"no_effect",success:!0,meaning:"The request was valid and completed, but matched nothing to change."},{exit_code:a.PARTIAL_EFFECT,outcome:"partial_effect",success:!0,meaning:"The request completed and changed some, but not all, selected targets."}],b=[a.SUCCESS,a.GENERIC_FAILURE,a.USAGE,a.NOT_FOUND,a.CONFLICT,a.DEPENDENCY_FAILED],I=new Set(["close-many","update-many"]),w=l.map(t=>({command:t,exit_codes:I.has(t)?[...b,a.NO_EFFECT,a.PARTIAL_EFFECT]:[...b]})),v=new Map(w.map(t=>[t.command,t])),D=[a.SUCCESS,a.NO_EFFECT,a.PARTIAL_EFFECT];function Ee(t){return D.includes(t)}function Ae(t){return R.some(e=>e.exit_code===t)}function Oe(t){let e=t.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(" ");return v.get(e)??v.get(e.split(" ")[0])}function Te(t,e=l,s=w){let o=new Map(s.map(r=>[r.command,r])),i=e.filter(r=>!o.has(r)),n=t.filter(r=>{let _=o.get(r.command)??o.get(r.command.split(" ")[0]);return _===void 0||!_.exit_codes.includes(r.exit_code)}),d=new Set(t.map(r=>r.exit_code)),c=[...new Set(s.flatMap(r=>r.exit_codes))].filter(r=>!d.has(r)).sort((r,_)=>r-_);return{ok:i.length===0&&n.length===0&&c.length===0,missing_commands:i,undeclared_observations:n,unreachable_exit_codes:c}}function Se(t){return t.applied===0&&t.failed>0?{outcome:"dependency_failed",exit_code:a.DEPENDENCY_FAILED}:t.applied===0?{outcome:"no_effect",exit_code:a.NO_EFFECT}:t.skipped>0||t.failed>0||t.unmatched>0?{outcome:"partial_effect",exit_code:a.PARTIAL_EFFECT}:{outcome:"effect",exit_code:a.SUCCESS}}var g=[{exit_code:1,class:"generic_failure"},{exit_code:2,class:"usage"},{exit_code:3,class:"not_found"},{exit_code:4,class:"conflict"},{exit_code:5,class:"dependency_failed"}],q=new Map(g.map(t=>[t.exit_code,t.class]));function x(t){return[...new Set(t.map(e=>e.trim()).filter(Boolean))].sort()}function L(t){if(!t)return[];let e=new Set,s=new Set;return t.map(o=>{let i=o.state.trim(),n=o.probe_id.trim(),d=x(o.entrypoints);if(!/^[a-z][a-z0-9_]*$/.test(i)||!/^[a-z][a-z0-9-]*$/.test(n)||d.length===0||e.has(i)||s.has(n))throw new TypeError("Invalid pm refusal state contract");return e.add(i),s.add(n),{state:i,probe_id:n,entrypoints:d,expected_exit_class:o.expected_exit_class}}).sort((o,i)=>o.state.localeCompare(i.state))}function j(t,e,s,o,i){return![[1,2,3,4,5].includes(t.exit_code),t.meaning.trim().length>0,t.recovery.trim().length>0,e.length>0,s.length>0,/^[a-z][a-z0-9_]*$/.test(o),i.every(n=>/^[a-z][a-z0-9_]*$/.test(n)),q.get(t.exit_code)===t.class].includes(!1)}function F(t,e){let s=t,o=new Set;for(;s.canonical_code!==s.code;){if(o.has(s.code))throw new TypeError(`Alias cycle in pm error code catalog: ${t.code}`);o.add(s.code);let i=e.get(s.canonical_code);if(!i)throw new TypeError(`Invalid pm error code contract: ${t.code}`);s=i}return s}function $(t){let e=new Map(t.map(s=>[s.code,s]));for(let s of t){let o=F(s,e);if(o.exit_code!==s.exit_code||o.class!==s.class)throw new TypeError(`Alias transport mismatch for pm error code: ${s.code}`);let i=t.filter(n=>n.code!==o.code&&n.canonical_code===o.code).map(n=>n.code).sort();if(s.code===o.code?JSON.stringify(s.aliases)!==JSON.stringify(i):s.aliases.length>0)throw new TypeError(`Invalid pm error code contract: ${s.code}`)}}function E(t){let e=new Set,s=t.map(o=>{let i=o.code.trim();if(!/^[a-z][a-z0-9_]*$/.test(i))throw new TypeError(`Invalid pm error code: ${JSON.stringify(o.code)}`);if(e.has(i))throw new TypeError(`Duplicate pm error code: ${i}`);e.add(i);let n=x(o.sources),d=x(o.emitting_commands),u=(o.canonical_code??i).trim(),c=x(o.aliases??[]),r=L(o.owned_states);if(!j(o,n,d,u,c))throw new TypeError(`Invalid pm error code contract: ${i}`);if(r.some(_=>_.expected_exit_class!==o.class))throw new TypeError(`Invalid pm refusal state exit class: ${i}`);return Object.freeze({...o,code:i,meaning:o.meaning.trim(),recovery:o.recovery.trim(),sources:n,emitting_commands:d,canonical_code:u,aliases:c,owned_states:r})});return $(s),Object.freeze(s.sort((o,i)=>o.code.localeCompare(i.code)))}function Ne(t,e){let s=C(t,e);return C(s.canonical_code??s.code,e)}function C(t,e){let s=t.trim(),o=e.find(i=>i.code===s);if(!o)throw new TypeError(`Unknown pm error code "${s}"`);return o}var z="Inspect the structured error guidance, then retry the suggested command when one is present.",U=new Map(g.map(t=>[t.exit_code,t.class]));function A(t){return t.map(e=>{let s=`${e.code.replaceAll("_"," ")} condition.`,o={code:e.code,meaning:`${s.charAt(0).toUpperCase()}${s.slice(1)}`,stability:e.stable?"stable":"provisional",exit_code:e.exit_code,class:U.get(e.exit_code),recovery:z,sources:e.sources,emitting_commands:e.emitting_commands??["*"],canonical_code:e.canonical_code??e.code,aliases:e.aliases??[]};return e.owned_states&&(o.owned_states=e.owned_states),o})}var O=[{code:"acceptance_criteria_mutation_conflict",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_remove_unmatched",exit_code:3,sources:["sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_semicolon_forbidden",exit_code:2,stable:!0,sources:["core/item/parse.ts"]},{code:"accepted_rejected_value",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"alias_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"alias_target_missing",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"already_claimed_by",exit_code:4,stable:!0,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"ambiguous_option_combination",exit_code:2,stable:!0,sources:["sdk/lifecycle/claim.ts","sdk/lifecycle/plan.ts"],emitting_commands:["claim","plan"]},{code:"annotation_alias_conflict",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"annotation_entry_mismatch",exit_code:4,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_invalid",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_without_target",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_flag_like_value",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_if_absent_without_append",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_message_without_text",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_text_compacted",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_text_source_conflict",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"annotation_transposed_subcommand",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"append_empty_body",exit_code:2,stable:!0,sources:["sdk/lifecycle/append.ts"],emitting_commands:["append"]},{code:"assurance_registry_invalid",exit_code:1,sources:["sdk/governance/assurance.ts"]},{code:"bare_comma_entry_ambiguous",exit_code:2,sources:["core/item/parse.ts"]},{code:"blocker_identity_read_failed",exit_code:1,sources:["sdk/query/declared-blockers.ts"]},{code:"body_file_conflicts_with_body",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_missing_path",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_unreadable",exit_code:3,stable:!0,sources:["core/io/body-file.ts"]},{code:"budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"bulk_create_route",exit_code:2,sources:["cli/register-mutation.ts"]},{code:"bulk_ids_input_empty",exit_code:2,sources:["core/io/bulk-ids-input.ts","sdk/history-compact.ts","sdk/history-mcp.ts"],owned_states:[{state:"bulk_ids_stdin_contains_no_nonempty_ids",probe_id:"bulk-ids-stdin-empty",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_missing_path",exit_code:2,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_token_omits_its_path",probe_id:"bulk-ids-file-path-missing",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_unreadable",exit_code:3,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_path_cannot_be_read",probe_id:"bulk-ids-file-unreadable",entrypoints:["update-many"],expected_exit_class:"not_found"}]},{code:"bundle_integrity_torn_install",exit_code:1,stable:!0,sources:["cli/bundle-integrity.ts"]},{code:"capability_undeclared",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"capability_unused",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"child_projection_item_bound_exceeded",exit_code:1,stable:!0,sources:["sdk/item-children.ts"]},{code:"close_reason_required",exit_code:2,stable:!0,sources:["sdk/lifecycle-policy.ts","sdk/lifecycle/close-many.ts"],emitting_commands:["*","close-many"]},{code:"close_through_update",exit_code:1,stable:!0,sources:["core/telemetry/observability.ts"]},{code:"close_validation_deferred_fields",exit_code:2,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"close_validation_missing_fields",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"collected_zero_items",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"collection_transposed_subcommand",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"command_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"command_namespace",exit_code:2,stable:!0,sources:["sdk/cli-contracts/runtime-contracts.ts"]},{code:"command_override_conflict",exit_code:4,stable:!0,sources:["sdk/compose.ts"]},{code:"config_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_key_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts","sdk/config.ts"]},{code:"config_value_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"conflicting_lifecycle_owner",exit_code:2,stable:!0,sources:["cli/register-operations.ts"]},{code:"context_evaluation_read_incomplete",exit_code:2,sources:["sdk/context-relevance.ts"]},{code:"context_signal_store_invalid",exit_code:2,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_stale",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_write_failed",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_takes_no_item_argument",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"core_item_field_requires_dedicated_flag",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"create_deferral_conflict",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_field_unsupported",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_fields_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_reason_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_positional_type_without_title",exit_code:2,stable:!0,sources:["cli/register-mutation.ts"]},{code:"dependency_cardinality_created",exit_code:2,sources:["sdk/graph/cardinality-integrity.ts"]},{code:"dependency_edge_not_allowed",exit_code:2,stable:!0,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_flag_value_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_remove_no_match",exit_code:3,sources:["sdk/lifecycle/dependency-removal.ts"],emitting_commands:["update"]},{code:"dependency_target_not_found",exit_code:3,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_temporal_order_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"duplicate_canonical_flag",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"duplicate_command",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"duplicate_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"duplicate_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"duplicate_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"duplicate_probe",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"duplicate_sweep_cost_limit",exit_code:4,stable:!0,sources:["sdk/query/duplicate-candidates.ts"],emitting_commands:["duplicate-candidates"]},{code:"duplicate_target_circular",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_is_duplicate",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_missing",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_self",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"empty_corpus",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"empty_surface",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"event_cursor_query_mismatch",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"event_history_integrity_failed",exit_code:1,sources:["core/history/event-index.ts"]},{code:"event_index_unavailable",exit_code:1,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"exit_code_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"expect_hash_background_unsupported",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invalid",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invocation_rewritten",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_requires_mutation",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_target_required",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expected_revision_duplicate",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"expected_revision_scope_conflict",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"extension_command_activation_failed",exit_code:1,stable:!0,sources:["cli/commander-usage.ts"]},{code:"extension_dependency_name_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_spec_invalid",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_version_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_flag_value_invalid",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_install_incomplete_source_scan",exit_code:2,sources:["sdk/extension/install-plan.ts"]},{code:"extension_install_rollback_failed",exit_code:1,sources:["sdk/extension/install-snapshot.ts"]},{code:"extension_install_soft_failed",exit_code:1,stable:!0,sources:["cli/register-setup.ts"]},{code:"extension_install_source_contains_destination",exit_code:2,stable:!0,sources:["sdk/extension/install-runtime.ts"]},{code:"extension_item_field_reserved",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_type_conflict",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_unknown",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_mutation_guard_failed",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_decision",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_denial",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_timed_out",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_option_disabled",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_option_spelling_conflict",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_read_output_invalid",exit_code:2,sources:["sdk/read-output/extension.ts"]},{code:"extension_update_health_partial_coverage",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"extensions_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"field_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_flag_invalid",exit_code:2,sources:["core/profile/profile-lint.ts"]},{code:"field_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_mcp_input_collision",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_option_collision",exit_code:1,sources:["core/profile/profile-lint.ts"]},{code:"finalization_invalid_document",exit_code:2,sources:["sdk/transactions/item-finalization.ts"]},{code:"github_source_entry_unbuilt",exit_code:2,stable:!0,sources:["sdk/extension/shared.ts"]},{code:"hierarchy_cardinality_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_cycle_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_parent_divergence_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"history_append_only_repair_unavailable",exit_code:4,sources:["sdk/history/append-only-repair.ts"]},{code:"history_author_acknowledge_plan_conflict",exit_code:4,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_plan_fingerprint_required",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_preview_limit_invalid",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_required_values_missing",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_conflict",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_required",exit_code:2,stable:!0,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_not_actionable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_unreadable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_baseline_unavailable",exit_code:1,sources:["core/history/projection.ts"]},{code:"history_compact_boundary_bridged",exit_code:2,sources:["sdk/history-compact.ts"]},{code:"history_drift_chain_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_chain_mismatches"]},{code:"history_drift_chain_unbridgeable",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_hash_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_hash_mismatches"]},{code:"history_drift_merge_receipt",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_missing_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_missing_streams"]},{code:"history_drift_unreadable_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_unreadable_streams"]},{code:"history_drift_unrepairable_stream",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_version_skew",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_version_skews"]},{code:"history_json_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/history/read.ts"],canonical_code:"merge_conflict_markers_detected"},{code:"history_record_integrity_invalid",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_record_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_record_version_unsupported",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_redact_bridge_unlocated",exit_code:1,sources:["sdk/history-redact.ts"]},{code:"history_replay_invalid",exit_code:1,sources:["core/history/projection.ts","core/history/tombstone.ts"]},{code:"history_salvage_refused",exit_code:4,sources:["sdk/history/salvage.ts"]},{code:"history_stream_over_compact_threshold",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"history_target_out_of_range",exit_code:1,stable:!0,sources:["core/history/projection.ts"]},{code:"history_timestamp_invalid",exit_code:1,sources:["core/history/event-index.ts","core/history/history.ts"]},{code:"history_union_rebase_conflict",exit_code:4,sources:["sdk/merge/history-scalar-rebase.ts"]},{code:"history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_unknown_author_events"]},{code:"history_version_mapping_unavailable",exit_code:2,sources:["core/history/version-address.ts"]},{code:"history_version_pruned",exit_code:2,sources:["core/history/projection.ts"]},{code:"history_version_unreconstructable",exit_code:2,sources:["core/history/projection.ts"]},{code:"host_environment_capacity_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_operation_invalid",exit_code:2,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_permission_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_resource_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"improvement_metric_contract_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"improvement_observation_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"in_progress_idle",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"in_progress_unowned",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"incomplete_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"inconsistent_concept_kind",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"init_existing_settings_requires_force",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_gitignore_unwritable",exit_code:1,stable:!0,sources:["sdk/workspace.ts"]},{code:"init_id_prefix_conflict",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_id_prefix_path_like",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"integrity_history_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_history_conflict_markers"]},{code:"integrity_history_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_history_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_ahead_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_ahead_items"]},{code:"integrity_item_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_outdated_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_outdated_items"]},{code:"integrity_item_parse_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"invalid_argument_value",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/item/priority.ts","core/shared/url-credentials.ts","core/telemetry/observability.ts","sdk/config.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/extension/listing-fields.ts","sdk/extension/static-inventory.ts","sdk/governance/assurance-mutation-error.ts","sdk/history-redact.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/linked-artifacts.ts","sdk/query/next.ts","sdk/runtime-input.ts","sdk/runtime.ts","sdk/runtime/mutation-admission.ts","sdk/runtime/mutation-value-validation.ts","sdk/runtime/schema-preview.ts","sdk/test/run-phases.ts","sdk/workspace.ts"],emitting_commands:["*","create","next","task-composition","update","update-many"]},{code:"invalid_command_usage",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"invalid_event_cursor",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_cursor_mode",exit_code:2,sources:["cli/register-list-query.ts","sdk/mutation-events.ts","sdk/runtime-extended-actions.ts"]},{code:"invalid_event_follow_interval",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_limit",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_since",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_history_analytics_limit",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_minimum_sample",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_since",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_improvement_ledger",exit_code:1,sources:["sdk/improvement-ledger-validation.ts"]},{code:"invalid_improvement_metric",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_limit",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_timestamp",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_provenance_predicate",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"invalid_query_cursor",exit_code:2,stable:!0,sources:["sdk/pagination.ts","sdk/query/window-pagination.ts"]},{code:"invalid_read_output_session",exit_code:2,sources:["sdk/read-output-session.ts"]},{code:"invalid_reproducible_process_environment",exit_code:2,sources:["sdk/reproducibility/process.ts"]},{code:"invalid_workspace_snapshot_target",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"item_already_active",exit_code:4,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"item_already_exists",exit_code:4,stable:!0,sources:["sdk/lifecycle/create.ts"],emitting_commands:["create"]},{code:"item_deleted",exit_code:3,sources:["core/history/tombstone.ts"]},{code:"item_document_encoding_invalid",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_document_invalid",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_document_roundtrip_failed",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_format_version_unsupported",exit_code:4,sources:["core/item/item-format.ts"]},{code:"item_id_collision",exit_code:4,stable:!0,sources:["sdk/lifecycle/copy.ts"],emitting_commands:["copy"]},{code:"item_identity_ambiguous",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_identity_conflict",exit_code:4,sources:["sdk/governance/validate-history-drift.ts","sdk/lifecycle/item-revision.ts","sdk/merge/three-way.ts","sdk/query/declared-blockers.ts"]},{code:"item_identity_reserved",exit_code:4,sources:["core/history/history.ts"]},{code:"item_not_found",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/item-store.ts","core/telemetry/observability.ts","sdk/governance/validate-history-drift.ts"]},{code:"item_revision_conflict",exit_code:4,sources:["core/store/item-mutation-precondition.ts"]},{code:"likely_duplicate",exit_code:4,stable:!0,sources:["sdk/similarity.ts"]},{code:"linked_artifact_mutation_conflict",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_conflict",exit_code:4,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_key_misread",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_resource_positional_value",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_test_command_immutable",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_command_not_executable",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_context_invalid",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_patch_fields_unsupported",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_remove_no_match",exit_code:3,sources:["sdk/test/execution.ts"]},{code:"linked_test_update_ambiguous",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_update_no_match",exit_code:3,sources:["sdk/test/update.ts"]},{code:"linked_test_value_not_quoted",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"list_source_incomplete",exit_code:1,stable:!0,sources:["sdk/query/list.ts"],emitting_commands:["list"]},{code:"local_package_archive_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"local_source_not_found_bare_name",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"lock_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/lock/lock.ts","core/telemetry/observability.ts"]},{code:"lock_lost",exit_code:4,sources:["core/lock/lock.ts"]},{code:"lock_path_unsafe",exit_code:4,sources:["core/lock/lock-confinement.ts"]},{code:"locks_stale_count",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"locks_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"malformed_plan_step_evidence",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"managed_state_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"managed_state_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_capabilities_absent",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"manifest_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_unknown_key",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_declares_an_unknown_top_level_key",probe_id:"author-manifest-unknown-key",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"manifest_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"mcp_annotation_file_unavailable",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"mcp_stdin_unavailable",exit_code:2,sources:["sdk/annotations.ts"]},{code:"mcp_task_not_found_or_not_authorized",exit_code:3,sources:["sdk/mcp/tasks.ts"]},{code:"merge_artifacts_ignored",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_bun_launcher_unavailable",exit_code:5,sources:["sdk/merge/install.ts"]},{code:"merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/item/item-format.ts"],aliases:["history_merge_conflict_markers_detected"]},{code:"merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]}];var T=[{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]},{code:"merge_receipt_history_reference_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_receipt_not_portable",exit_code:4,sources:["sdk/merge/receipts.ts"]},{code:"merge_receipts_pending",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_reconcile_receipt_evidence_untrusted",exit_code:4,sources:["sdk/history-repair.ts"]},{code:"merge_root_not_found",exit_code:3,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_settlement_hook_conflict",exit_code:4,sources:["sdk/merge/settlement-hook.ts"]},{code:"merge_settlement_review_required",exit_code:4,sources:["sdk/merge/ignored-artifacts.ts","sdk/merge/reconcile.ts","sdk/merge/stage.ts"]},{code:"missing_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"missing_cli_flag",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_directory",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"missing_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_lifecycle_target",exit_code:2,stable:!0,sources:["sdk/extension.ts"]},{code:"missing_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"missing_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_parameter_alias",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_positive_execution_receipt",exit_code:1,sources:["sdk/test/execution.ts"]},{code:"missing_probe",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_required_argument",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/main.ts","cli/register-mutation.ts","cli/schema/registration.ts","core/telemetry/observability.ts","sdk/governance/assurance-action.ts","sdk/history-redact.ts","sdk/invocation-author.ts","sdk/lifecycle/claim.ts","sdk/linked-artifacts.ts"],emitting_commands:["*","claim"]},{code:"missing_required_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/context-intent-contracts.ts","sdk/extension/command-options.ts","sdk/lifecycle/create.ts","sdk/lifecycle/plan.ts"],emitting_commands:["*","create","plan"]},{code:"missing_suggested_retry",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_suggested_retry_args",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"module_import_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"multi_target_github_install_ambiguous",exit_code:2,stable:!0,sources:["cli/register-setup.ts"]},{code:"mutation_author_required",exit_code:2,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"mutation_document_unreadable",exit_code:2,sources:["cli/register-structured-mutation.ts"]},{code:"mutation_option_value_invalid",exit_code:2,sources:["sdk/lifecycle/mutation-option-validation.ts"],emitting_commands:["item mutate"]},{code:"mutation_secret_guard_blocked",exit_code:4,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"no_matching_tests",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_projects_matched_filters",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_test_files_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_tests_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_update_fields",exit_code:1,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"no_version_bounds_declared",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_omits_canonical_pm_version_bounds",probe_id:"author-manifest-version-bounds-missing",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"non_refusal_exit",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"npm_pack_json_shape_unsupported",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_missing",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_unsafe",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_not_found",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"npm_source_shorthand_ambiguous",exit_code:2,sources:["sdk/extension/install-sources.ts"]},{code:"output_budget_exceeded",exit_code:2,sources:["sdk/testing.ts"]},{code:"ownership_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/annotations.ts"]},{code:"ownership_dependency_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"ownership_metadata_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"package_spec_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"package_upgrade_modes_mutually_exclusive",exit_code:2,sources:["sdk/governance/upgrade.ts"]},{code:"positional_shape_budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"positional_signature_mismatch",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"profile_name_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_name_not_normalized",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_summary_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_title_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"project_runtime_history_epoch_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_item_format_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_mutation",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_read",exit_code:1,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_schema_field_requires_declared_flag",exit_code:2,sources:["core/extensions/item-fields.ts"]},{code:"projection_options_mutually_exclusive",exit_code:2,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"provenance_value_domain_invalid",exit_code:2,sources:["core/diagnostics/remediation.ts"]},{code:"read_output_cursor_command_mismatch",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_invalid",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_stale",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_mutation_conflict",exit_code:2,sources:["sdk/read-output-contracts.ts"]},{code:"read_output_surface_unsupported",exit_code:2,sources:["sdk/extension/static-inventory.ts","sdk/read-output-contracts.ts"]},{code:"recovery_kind_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"redundant_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"refusal_allowed_values_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_exit_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_mutated_state",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_probe_missing",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_recovery_failed",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"reindex_already_running",exit_code:4,stable:!0,sources:["sdk/governance/reindex.ts"]},{code:"removed_canonical_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"removed_compatibility_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"reopen_reason_required",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reopen_receipt_missing",exit_code:1,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"reopen_target_status_invalid",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reported_zero_passes",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reported_zero_tests",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reserved_item_field",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"retry_failed",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"schema_field_flag_invalid",exit_code:2,sources:["sdk/schema/field-option-collisions.ts"]},{code:"schema_field_option_collision",exit_code:2,sources:["sdk/schema/field-option-collisions.ts"]},{code:"schema_migration_input_required",exit_code:2,stable:!0,sources:["cli/migration-gates.ts"]},{code:"semantic_spelling_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"settings_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_read_fs_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_schema",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_merge_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_section_document_malformed",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_document_missing",exit_code:3,sources:["core/store/settings-sections.ts"]},{code:"settings_section_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_name_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_reserved",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_revision_conflict",exit_code:4,sources:["core/store/settings-sections.ts"]},{code:"settings_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_write_assigned_path_invalid",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_json",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_schema",exit_code:2,sources:["core/store/settings.ts"]},{code:"stale_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"stale_claim_takeover_refused",exit_code:4,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"stale_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_in_progress_items",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"stale_lock_requires_override",exit_code:4,sources:["core/lock/lock.ts"]},{code:"stale_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_revision",exit_code:4,sources:["core/store/item-store.ts"]},{code:"start_blocked_by_open_dependency",exit_code:4,sources:["sdk/lifecycle/start-blockers.ts"],emitting_commands:["claim","start-task","update"]},{code:"status_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_lifecycle_role_required",exit_code:2,sources:["sdk/schema.ts"]},{code:"stdin_json_invalid",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"stdin_json_persisted_annotation_changed",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"stdin_json_unknown_key",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"structured_entry_key_repeated",exit_code:2,sources:["core/item/parse.ts"]},{code:"structured_event_immutable",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"structured_event_input_conflict",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_empty",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_since_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"suggested_retry_args_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"telemetry_endpoint_probe_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_endpoint_probe_http_status",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_otel_export_failing",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_high_retries",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_invalid_rows",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_pending",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_schema_version_behind",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_state_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"template_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"terminal_plan_mutation",exit_code:4,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"terminal_state_conflict",exit_code:4,stable:!0,sources:["core/telemetry/observability.ts","sdk/lifecycle/claim.ts"],emitting_commands:["*","claim"]},{code:"test_measure_requires_execution",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"test_measure_requires_run",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"text_unpaired_surrogate",exit_code:2,sources:["core/item/item-format.ts","core/shared/output-unicode.ts"]},{code:"tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_tracked_runtime_cache_files"]},{code:"tracker_not_initialized",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/tracker-preflight.ts","core/telemetry/observability.ts"],owned_states:[{state:"selected_tracker_root_exists_without_settings",probe_id:"tracker-root-settings-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_missing",exit_code:3,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_does_not_exist",probe_id:"tracker-root-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_not_directory",exit_code:2,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_a_regular_file",probe_id:"tracker-root-not-directory",entrypoints:["list"],expected_exit_class:"usage"}]},{code:"tracker_root_unreadable",exit_code:1,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_not_readable",probe_id:"tracker-root-unreadable",entrypoints:["list"],expected_exit_class:"generic_failure"}]},{code:"transaction_abandoned",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_committed",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_create_compensated",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_journal_invalid",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_partial_mutation",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_plan_mismatch",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_preview_external_schema",exit_code:2,sources:["sdk/item-transaction.ts"]},{code:"transaction_preview_non_regular_file",exit_code:2,sources:["core/fs/fs-utils.ts"]},{code:"transaction_preview_snapshot_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_recovery_plan_missing",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"type_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"type_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"undeclared_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"unexpected_refusal_probe",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"unknown_command",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/cli-contracts/runtime-contracts.ts"]},{code:"unknown_context_intent",exit_code:2,stable:!0,sources:["sdk/context-intent-contracts.ts"]},{code:"unknown_error",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"unknown_field",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_field_projection",exit_code:2,stable:!0,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"unknown_item_type",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_lifecycle_action",exit_code:2,stable:!0,sources:["sdk/agent/subcommand-recovery.ts"],canonical_code:"unknown_subcommand"},{code:"unknown_noun",exit_code:2,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"unknown_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/runtime/invocation-options.ts","core/telemetry/observability.ts","sdk/extension/command-options.ts"],owned_states:[{state:"declared_option_is_rejected_on_the_selected_command_path",probe_id:"cross-command-unknown-option",entrypoints:["deps"],expected_exit_class:"usage"}]},{code:"unknown_plan_template",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"unknown_provenance_dimension",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"unknown_status",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_subcommand",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","sdk/agent/subcommand-recovery.ts"],aliases:["unknown_lifecycle_action"],owned_states:[{state:"config_action_token_is_not_declared",probe_id:"config-unknown-action",entrypoints:["config"],expected_exit_class:"usage"},{state:"graph_command_token_is_not_declared",probe_id:"graph-unknown-subcommand",entrypoints:["graph"],expected_exit_class:"usage"},{state:"nested_command_token_is_not_declared_by_its_family",probe_id:"schema-unknown-subcommand",entrypoints:["schema"],expected_exit_class:"usage"},{state:"package_lifecycle_token_is_not_declared",probe_id:"package-unknown-action",entrypoints:["package"],expected_exit_class:"usage"}]},{code:"unsafe_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"unsupported_update_option",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"upsert_key_ambiguous",exit_code:4,sources:["sdk/structured-mutations.ts"]},{code:"upsert_key_conflict",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"upsert_key_duplicate",exit_code:2,sources:["sdk/item-transaction.ts","sdk/structured-mutations.ts"]},{code:"upsert_key_missing",exit_code:2,sources:["sdk/structured-mutations.ts"]},{code:"upsert_match_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"validate_command_references_stale_pm_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_missing_linked_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_orphaned_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_tracked_all_strict_forces_pm_internals",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_format_version_ahead_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_ahead_format_version"},{code:"validate_format_version_outdated_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_outdated_format_version"},{code:"validate_hierarchy_parent_cycle",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_hierarchy_parent_cycle_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_history_drift_chain_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_chain_mismatch"},{code:"validate_history_drift_hash_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_hash_mismatch"},{code:"validate_history_drift_missing_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_missing_stream"},{code:"validate_history_drift_unreadable_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_unreadable_stream"},{code:"validate_history_drift_version_skews",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_version_skew"},{code:"validate_history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_unknown_author_events"},{code:"validate_lifecycle_active_closure_like_metadata",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_active_terminal_parent",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_stale_blockers",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_driver_configuration",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_fence_drift",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_custom_profile_missing_required_fields",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_duplicate_issue_codes",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_acceptance_criteria",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_close_reason",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_closed_at",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_confidence",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_estimate",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_release",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_reviewer",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_risk",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_sprint",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_resolution_missing_fields",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_schema_field_option_collision",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_duplicate_item_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_history_conflict_markers",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_history_conflict_marker"},{code:"validate_storage_resurrected_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"tracked_runtime_cache_files"},{code:"validate_storage_unparseable_config",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unparseable_history",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unreadable_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_embedding_identity_changed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_stale_items_remaining",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"visible_surface_ceiling_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"workflow_duplicate_type",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_policy_approval_history_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_audit_failed",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_input_unreadable",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_invalid",exit_code:2,sources:["core/policy/workflow-policy.ts"]},{code:"workflow_policy_refused",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_registry_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_status_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_transition_malformed",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workspace_history_chain_invalid",exit_code:4,sources:["core/history/workspace-history.ts"]},{code:"workspace_history_state_conflict",exit_code:4,stable:!0,sources:["core/history/workspace-history.ts"]},{code:"workspace_root_pm_path",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"workspace_snapshot_force_required",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_manifest_mismatch",exit_code:4,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_name_reserved_fingerprint",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_not_found",exit_code:3,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_permission_denied",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_resource_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_storage_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"wrong_item_type",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]}];var ze=E(A([...O,...T]));var G=Object.freeze({"--body":"Set the item body.","--body-file":"Read the item body from a file, or from stdin when set to -.","--description":"Set the item description.","--stdin":"Read the value from stdin.","--stdin-json":"Read a complete JSON document from stdin."}),B=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),V=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),Y=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),X=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),W=["--allow-","--check-","--dry-run","--explain","--fail-","--fix-","--full","--has-","--include-","--json","--no-","--prune-","--quiet","--refresh-","--require-","--runtime-only","--schema-only","--skip-","--stream","--strict-","--summary","--today","--verbose"],H=new Set(["--activate","--active-only","--adopt","--adopt-all","--all","--all-actionable","--all-affected-ids","--all-day","--all-streams","--acknowledge-linked-tests","--append-stable","--auto-fix","--auto-pm-context","--availability-only","--background","--brief","--by-assignee","--by-priority","--by-tag","--catalog","--claim","--clear","--clear-comments","--clear-criteria","--clear-deps","--clear-docs","--clear-events","--clear-files","--clear-learnings","--clear-notes","--clear-reminders","--clear-tests","--clear-type-options","--cli-only","--closed","--compact","--completion","--count","--counts","--deactivate","--declarative","--defaults","--describe","--diff","--doctor","--empty-body","--explore","--field-utilization","--filter-empty-body","--flags-only","--follow","--force","--global","--highlight","--hybrid","--id-only","--if-available","--ignore-global","--include_unparented","--infer","--init","--install","--isolated","--lean","--list","--local","--manage","--markdown","--metadata-coverage","--next","--normalize-provenance","--only","--only-last","--output-row-contract","--override-linked-pm-context","--override-linked-workspace-context","--packages-only","--past","--phrase-exact","--profile","--progress","--project","--promote-to-item-dep","--provenance","--provenance-summary","--raw","--ready-only","--ready_only","--rebuild","--recent","--reload","--repair","--replace-deps","--replace-docs","--replace-files","--replace-tests","--required","--required-on-create","--run","--runtime-probe","--save-baseline","--scaffold","--semantic","--shared-host-safe","--storage","--takeover-stale","--title-exact","--token-accounting","--trace","--tree","--unbounded","--uninstall","--validate-paths","--verify","--watch","--with-packages"]),J=new Set(["--only-index"]),K=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),Q=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),Z=new Set(["--regression"]);function ee(t,e){return e==="--stdin"||e==="--stdin-json"?["stdin"]:Y.has(`${t}:${e}`)?["argv","file","stdin"]:e.endsWith("-file")?["argv","file"]:B.has(e)&&V.has(t)?["argv","stdin"]:["argv"]}function te(t,e){let s=K.has(`${t}:${e.flag}`)||e.value_name!==void 0||e.value_type==="string"||e.value_type==="number"||e.list===!0||e.repeatable===!0,o=e.value_type==="boolean"||e.flag==="--stdin"||e.flag==="--stdin-json"||e.flag.startsWith("--filter-")&&(e.flag.endsWith("-missing")||e.flag.startsWith("--filter-has-")||e.flag.startsWith("--filter-no-"))||W.some(i=>e.flag.startsWith(i));return s||J.has(e.flag)||!H.has(e.flag)&&!o}function se(t,e){return e.value_arity!==void 0?e.value_arity:te(t,e)?Z.has(e.flag)||Q.has(`${t}:${e.flag}`)?"optional":"required":"none"}function oe(t,e){let s=f(t),o=se(s,e),i=o!=="none",n=ee(s,e.flag),d=e.description??G[e.flag]??`${i?"Set":"Enable"} ${e.flag.slice(2).replaceAll("-"," ")}.`;return{...e,description:d,takes_value:i,value_required:o==="required",...i?{value_name:e.value_name??"value"}:{},value_type:i?e.value_type??"string":"boolean",required:e.required===!0,repeatable:e.repeatable===!0||e.list===!0,input_sources:n,...n.includes("stdin")&&e.flag!=="--stdin"&&e.flag!=="--stdin-json"?{stdin_token:"-"}:{},...X.has(`${s}:${e.flag}`)?{file_token_prefix:"@"}:{}}}function Be(t,e){return e.map(s=>oe(t,s))}function Ve(t,e,s){let o=t.trim().toLowerCase(),i=[],n=new Map,d=0;for(let c of s)if(c.command.trim().toLowerCase()===o){if(d+=1,n.has(c.flag)){i.push({code:"duplicate_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} was observed more than once.`});continue}n.set(c.flag,c)}let u=new Set(e.map(({flag:c})=>c));for(let c of e){let r=n.get(c.flag);if(!r){i.push({code:"missing_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} has no executable option observation.`});continue}for(let[_,P]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[_]!==r[_]&&i.push({code:P,command:o,flag:c.flag,detail:`${o} ${c.flag} declares ${_}=${String(c[_])} but the executable option reports ${String(r[_])}.`})}for(let c of n.values())u.has(c.flag)||i.push({code:"undeclared_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,r)=>c.flag.localeCompare(r.flag)||c.code.localeCompare(r.code)),{ok:i.length===0,declared_count:e.length,observed_count:d,findings:i}}var ie=["mutation_receipt","entity","collection","diagnostic","stream"],ce=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),re=new Set(["close-many","update-many"]),ne=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),ae=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function p(t){if(t.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!ie.includes(t.kind))throw new TypeError(`Unsupported output envelope kind: ${t.kind}`);return t}function S(t){let e=t.trim().replace(/\s+/gu," "),[s=e]=e.split(" ");return re.has(s)?p({command:e,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):ce.has(s)?p({command:e,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):ne.has(s)?p({command:e,kind:"collection",wrapper_key:s==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):ae.has(s)?p({command:e,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):p({command:e,kind:s==="get"?"entity":"diagnostic",wrapper_key:s==="get"?"item":null,cardinality:s==="get"?"one":"none",format_flag:"--json"})}var de=l.map(t=>S(t)),_e=new Map(de.map(t=>[t.command,t]));function He(t){let e=t.trim().replace(/\s+/gu," ");if(e.length===0)throw new TypeError("command must be a non-empty command path");let[s=e]=f(e).split(" "),o=_e.get(s);return o?{...o,command:e}:S(e)}function le(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ue(t){return le(t)&&typeof t.id=="string"&&t.id.length>0&&typeof t.status=="string"&&t.status.length>0&&Number.isSafeInteger(t.changed_field_count)&&Number(t.changed_field_count)>=0&&(t.close_reason===void 0||typeof t.close_reason=="string")&&(t.deleted===void 0||typeof t.deleted=="boolean")&&(t.previous_status===void 0||typeof t.previous_status=="string")&&(t.warnings===void 0||Array.isArray(t.warnings))}function Je(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new TypeError(`Mutation receipt must be valid JSON: ${String(s)}`,{cause:s})}if(!ue(e))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:e.id,status:e.status,changedFieldCount:e.changed_field_count,...typeof e.close_reason=="string"?{closeReason:e.close_reason}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previousStatus:e.previous_status}:{},...Array.isArray(e.warnings)?{warnings:e.warnings}:{}}}var me=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),pe=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]),fe=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])}),xe=new Set(["extension","install","package","packages","upgrade"]);function ge(t){let e=m(t.trim().toLowerCase());if(e==="ops")return"quality";for(let[s,o]of Object.entries(fe))if(o.has(e))return s;return xe.has(e)?"extensions":"internal"}var k=Object.freeze([...l.flatMap(t=>t==="item"?["item","item-reopen"]:[t,...y.filter(e=>e.alias===t).map(e=>e.canonical)]).map(t=>({command:t,tier:me.has(m(t))?"core":pe.has(m(t))?"standard":"full",family:ge(t)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]),ke=k,et=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),tt=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);var M={core:0,standard:1,full:2,internal:3},N=new Map(ke.map(({command:t,tier:e})=>[t,e]));function st(t,e="standard"){return N.get(t.trim().toLowerCase())??N.get(m(t.trim().toLowerCase()))??e}function ot(t){return ye(t,k)}function ye(t,e){let s=M[t];return e.filter(o=>o.tier!=="internal"&&M[o.tier]<=s).map(o=>o.command)}function he(t,e){return e.filter(s=>s.family===t).map(s=>s.command)}var be=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],ve=new Set([...h.filter(t=>t.hidden).map(t=>t.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function it(t=k){return be.map(e=>({family:e,commands:he(e,t).filter(s=>t.find(o=>o.command===s)?.tier!=="internal"&&!ve.has(s))})).filter(({commands:e})=>e.length>0)}var ct=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});var rt=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]),nt=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:!0},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:!1}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0},{name:"evidence",description:"Exact verification and outcome evidence.",required:!0}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);export{R as a,w as b,D as c,Ee as d,Ae as e,Oe as f,Te as g,Se as h,g as i,E as j,Ne as k,C as l,ze as m,oe as n,Be as o,Ve as p,k as q,st as r,ot as s,it as t,ie as u,p as v,de as w,He as x,ue as y,Je as z};
|
|
2
|
-
//# sourceMappingURL=chunk-AN4NFFLL.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as N,f as P}from"./chunk-H4JBS477.js";import{H as m,I as R,X as L,i as p,j as x}from"./chunk-ZZYJS74B.js";import{s as v,y as E}from"./chunk-SXWUKNTY.js";import{a as g,b as C}from"./chunk-X6CXWWNB.js";import{Q as w,W as _,aa as l,je as k,s as f}from"./chunk-HGJ4MILN.js";import{O as b}from"./chunk-OCKKIECS.js";import{A as s,C as I,z as c}from"./chunk-NGFDPEP7.js";async function X(t){let i=_(process.cwd(),t);await E(i);let r=await v(i),a=w(r,k());return{pmRoot:i,settings:r,typeRegistry:a}}async function j(t,i,r,a){l(t,p(i));let e=await m(t,i,r.id_prefix,r.item_format,a);if(e)return{id:e.id,historyPath:l(t,e.id),located:e};let o=x(i,r.id_prefix),n=p(i),d=o===n?[o]:[o,n];for(let u of d){let h=l(t,u);if(await I(h))return{id:u,historyPath:h,located:null}}throw new s(`Item ${i} not found`,c.NOT_FOUND)}import{readdir as T}from"node:fs/promises";import y from"node:path";function B(t,i){let r=new Map;for(let a of t){let e=a.external?a.id:i.get(a.id.toLowerCase())?.id??a.id;r.set(a.external?`external:${e}`:`local:${e.toLowerCase()}`,{...a,id:e})}return[...r.values()]}async function D(t,i){let r=y.basename(t),e=(await T(y.dirname(t)).catch(o=>{throw L("Cannot verify the blocker's physical file identity",{exitCode:c.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:o})})).filter(o=>o.toLowerCase()===r.toLowerCase()).sort((o,n)=>+(n===r)-+(o===r)||o.localeCompare(n)).map(o=>y.parse(o).name)[0];if(e===void 0)throw new s(`Blocker canonical file disappeared during identity verification: ${i}`,c.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return e}async function te(t){let i=N(t.metadata);if(i.length===0)return[];let r=new Map([t.metadata.blocked_by,...(t.metadata.dependencies??[]).filter(e=>f(e.kind)==="blocked_by").map(e=>e.id)].filter(e=>typeof e=="string").map(e=>[e.trim().toLowerCase(),e.trim()])),a=new Map;for(let e of i){if(g(e)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(e)||t.metadata.dependencies?.some(d=>d.id.trim()===e&&f(d.kind)==="blocked_by"&&C(d.source_kind)))continue;let o=await m(t.pmRoot,r.get(e),t.settings.id_prefix,t.settings.item_format,t.typeToFolder);if(o===null)continue;let n=await R(o,{schema:t.settings.schema});if(o.id=await D(o.itemPath,o.id),n.document.metadata.id!==o.id)throw new s(`Blocker identity differs from its canonical file: ${o.id}`,c.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});a.set(e.toLowerCase(),n.document.metadata)}return B(P({blocked_by:t.metadata.blocked_by,dependencies:t.metadata.dependencies,updated_at:t.metadata.updated_at},a,b(t.settings.schema)),a)}export{X as a,j as b,D as c,te as d};
|
|
2
|
-
//# sourceMappingURL=chunk-B2HJI6KA.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{H as Ie,I as Te,L as Le,X as Se,j as Ee}from"./chunk-ZZYJS74B.js";import{s as be,y as Re}from"./chunk-SXWUKNTY.js";import{a as N,b as R}from"./chunk-X6CXWWNB.js";import{Cf as ye,Df as ke,Gb as G,Hf as we,Q as ae,Qe as A,W as ue,cf as me,dg as xe,eg as ve,hf as ge,je as z,jg as Ce,ke as fe,q as E,qf as he,v as de,vf as _e,ze as Y}from"./chunk-HGJ4MILN.js";import{C as F,c as le}from"./chunk-YPOATPTX.js";import{O as pe}from"./chunk-OCKKIECS.js";import{A as w,z as x}from"./chunk-NGFDPEP7.js";function v(){let e=E();for(let n of z()?.relationship_kinds??[])for(let o of n.definitions)e.register(o);return e}function M(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();return n.length>0?n:void 0}function K(e){return[e.parent_id,e.child_id,e.source,e.kind,e.holder_id,e.target_id??""].join("\0")}function Qe(e,n){let o=new Set,t=[];for(let r of[...e].sort()){if(o.has(r))continue;o.add(r);let i=[{nodeId:r,children:[...n.get(r)??[]].sort(),nextChild:0}];for(;i.length>0;){let s=i.at(-1),c=s.children[s.nextChild];c===void 0?(t.push(s.nodeId),i.pop()):(s.nextChild+=1,o.has(c)||(o.add(c),i.push({nodeId:c,children:[...n.get(c)??[]].sort(),nextChild:0})))}}return t}function Ze(e,n){let o=[...e].sort(),t=Qe(o,n),r=new Set,i=et(o,n),s=[];for(let c of t.reverse()){if(r.has(c))continue;let d=tt(c,i,r);(d.length>1||n.get(d[0])?.has(d[0]))&&s.push(d)}return s.sort((c,d)=>c.join("\0").localeCompare(d.join("\0")))}function et(e,n){let o=new Map(e.map(t=>[t,new Set]));for(let[t,r]of n)for(let i of r)o.get(i)?.add(t);return o}function tt(e,n,o){let t=[],r=[e];for(o.add(e);r.length>0;){let i=r.pop();t.push(i);for(let s of[...n.get(i)].sort())o.has(s)||(o.add(s),r.push(s))}return t.sort()}function Oe(e){let n=new Map;for(let o of e){let t=M(o?.id);t&&!n.has(t)&&n.set(t,o)}return n}function nt(e,n,o){let t=M(n.parent);if(!(!t||!o.has(t)))return{parent_id:t,child_id:e,source:"scalar_parent",kind:"parent",holder_id:e,child_cardinality:"one"}}function ot(e,n,o,t){let r=M(n?.id),i=t.resolve(n?.kind);if(!r||!o.has(r)||!i?.hierarchy)return;let s=i.hierarchyDirection==="source_parent";return{parent_id:s?e:r,child_id:s?r:e,source:"dependency",kind:i.kind,holder_id:e,target_id:r,child_cardinality:s?i.incoming:i.outgoing}}function De(e,n){let o=new Map;for(let[t,r]of e){let i=nt(t,r,e);i&&o.set(K(i),i);for(let s of r.dependencies??[]){let c=ot(t,s,e,n);c&&o.set(K(c),c)}}return[...o.values()].sort((t,r)=>K(t).localeCompare(K(r)))}function un(e,n=v()){return De(Oe(e),n)}function rt(e,n,o){let t=new Set(e.filter(r=>r.child_cardinality==="one").map(r=>r.child_id));return[...n].filter(([r,i])=>i.length>1&&t.has(r)).map(([r,i])=>({child_id:r,parent_ids:[...i],legacy_terminal:o.has(r)&&i.every(s=>o.has(s))})).sort((r,i)=>r.child_id.localeCompare(i.child_id))}function it(e,n,o){let t=new Map;for(let i of n){if(i.source!=="dependency")continue;let s=t.get(i.child_id)??new Set;s.add(i.parent_id),t.set(i.child_id,s)}let r=[];for(let[i,s]of e){let c=M(s.parent);if(!c||!e.has(c))continue;let d=[...t.get(i)??[]].filter(u=>u!==c).sort();d.length!==0&&r.push({child_id:i,scalar_parent_id:c,dependency_parent_ids:d,legacy_terminal:o.has(i)&&o.has(c)&&d.every(u=>o.has(u))})}return r.sort((i,s)=>i.child_id.localeCompare(s.child_id))}function H(e,n=t=>t==="closed"||t==="canceled",o=v()){let t=Oe(e),r=De(t,o),i=st(r),s=new Set([...t].filter(([,d])=>n(d.status)).map(([d])=>d)),c=Ze([...t.keys()],new Map([...i.children_by_parent].map(([d,u])=>[d,new Set(u)]))).map(d=>({item_ids:d,legacy_terminal:d.every(u=>s.has(u))}));return{relations:r,cycles:c,cardinality_violations:rt(r,i.parents_by_child,s),divergences:it(t,r,s)}}function ln(e){return e.source==="scalar_parent"?`${e.parent_id} -> ${e.child_id} (scalar parent on ${e.holder_id})`:`${e.parent_id} -> ${e.child_id} (${e.kind} dependency on ${e.holder_id})`}function st(e){let n=new Map,o=new Map;for(let t of e){let r=n.get(t.child_id)??new Set;r.add(t.parent_id),n.set(t.child_id,r);let i=o.get(t.parent_id)??new Set;i.add(t.child_id),o.set(t.parent_id,i)}return{parents_by_child:new Map([...n].map(([t,r])=>[t,[...r].sort()])),children_by_parent:new Map([...o].map(([t,r])=>[t,[...r].sort()]))}}function J(e,n){let o=new Set(n);return e.every(t=>o.has(t))}function pn(e,n,o,t,r){let i=M(o);if(!i)return;let s=H(e,t,r),c=H(n,t,r),d=c.divergences.find(a=>!s.divergences.some(p=>p.child_id===a.child_id&&p.scalar_parent_id===a.scalar_parent_id&&J(a.dependency_parent_ids,p.dependency_parent_ids)));if(d){let a=[d.scalar_parent_id,...d.dependency_parent_ids].sort();throw new w(`Hierarchy mutation would assign ${d.child_id} to multiple parents: ${a.join(", ")}.`,x.CONFLICT,{code:"hierarchy_parent_divergence_created",source_id:i,target_id:d.child_id,verification_errors:a})}let u=c.cardinality_violations.find(a=>(a.child_id===i||a.parent_ids.includes(i))&&!s.cardinality_violations.some(p=>p.child_id===a.child_id&&J(a.parent_ids,p.parent_ids)));if(u)throw new w(`Hierarchy mutation would assign ${u.child_id} to multiple parents: ${u.parent_ids.join(", ")}.`,x.CONFLICT,{code:"hierarchy_cardinality_created",source_id:i,target_id:u.child_id,verification_errors:u.parent_ids});let l=c.cycles.find(a=>a.item_ids.includes(i)&&!s.cycles.some(p=>J(a.item_ids,p.item_ids)));if(l)throw new w(`Hierarchy mutation would create a cycle: ${l.item_ids.join(" -> ")}.`,x.CONFLICT,{code:"hierarchy_cycle_created",source_id:i,verification_errors:l.item_ids})}var ct="global";function hn(e){let n=e?.trim();if(n)return R(n)?ct:n}function _n(e,n,o){return dt(e,n,o)}function dt(e,n,o){let t=e.trim();return R(o)||N(t)?t:Ee(t,n)}function L(e){if(typeof e!="string")return;let n=e.trim();if(!(!n||["none","null","n/a","na"].includes(n.toLowerCase())))return n}function $(e){let n=L(e);return n?.toLowerCase()==="no-active-blocker"?void 0:n}function B(e,n,o=!0){let t=L(e);return o&&(R(n)||t!==void 0&&N(t))}function Q(e,n){return B(e,n)?`external\0${e}`:`local\0${e.toLowerCase()}`}function Ae(e,n,o,t){return B(e,n)?t.get(e):o.get(e.toLowerCase())}function T(e,n){let o=e.toLowerCase(),t=n.toLowerCase();return o!==t?o<t?-1:1:e!==n?e<n?-1:1:0}function at(e){let n=new Map;for(let o of e.dependencies??[]){if(typeof o!="object"||o===null)continue;let t=o,r=L(t.id);if(!r)continue;let i=typeof t.kind=="string"?t.kind:"related",s=`${i}\0${Q(r,t.source_kind)}`,c=n.get(s);c?c.count+=1:n.set(s,{target_id:r,kind:i,count:1})}return n}function ut(e,n=o=>o==="closed"||o==="canceled"){let o=[];for(let t of e)if(!(typeof t?.id!="string"||t.id.trim().length===0))for(let r of at(t).values())r.count<2||o.push({holder_id:t.id.trim(),target_id:r.target_id,kind:r.kind,occurrences:r.count,holder_status:t.status,legacy_terminal:n(t.status)});return o.sort((t,r)=>{let i=T(t.holder_id,r.holder_id);if(i!==0)return i;let s=T(t.target_id,r.target_id);return s!==0?s:T(t.kind,r.kind)})}function lt(e,n,o,t,r){if(typeof o!="object"||o===null)return;let i=L(o.id);if(!i||Q(i,o.source_kind)!==Q(n))return;let s=r.resolve(typeof o.kind=="string"?o.kind:"related");if(!(s?.ordering!==!0||(s.precedence??"source_before_target")!=="source_before_target"))return{holder_id:e.id.trim(),target_id:i,dependency_kind:s.kind,holder_status:e.status,legacy_terminal:t(e.status)}}function pt(e,n=t=>t==="closed"||t==="canceled",o=v()){let t=new Map;for(let r of e){if(typeof r?.id!="string"||r.id.trim().length===0)continue;let i=L(r.blocked_by);if(i)for(let s of r.dependencies??[]){let c=lt(r,i,s,n,o);c&&t.set(`${c.holder_id.toLowerCase()}\0${c.target_id.toLowerCase()}\0${c.dependency_kind}`,c)}}return[...t.values()].sort((r,i)=>{let s=T(r.holder_id,i.holder_id);if(s!==0)return s;let c=T(r.target_id,i.target_id);return c!==0?c:T(r.dependency_kind,i.dependency_kind)})}function Z(e,n=o=>o==="closed"||o==="canceled"){let o=e.filter(d=>typeof d?.id=="string"&&d.id.trim().length>0),t=new Set(o.map(d=>d.id.trim().toLowerCase())),r=new Map,i=(d,u,l,a,p)=>{let m=L(u);if(!m||t.has(m.toLowerCase())||B(m,void 0,p))return;let f={holder_id:d.id.trim(),target_id:m,kind:l,source:a,holder_status:d.status,legacy_terminal:n(d.status),no_active_blocker_sentinel:m.toLowerCase()==="no-active-blocker"};r.set(`${f.holder_id}::${f.target_id}::${f.kind}::${f.source}`,f)};for(let d of o){i(d,d.parent,"parent","parent",!1),i(d,d.blocked_by,"blocked_by","blocked_by",!0);for(let u of d.dependencies??[]){if(typeof u!="object"||u===null)continue;let l=u;R(l.source_kind)||i(d,l.id,typeof l.kind=="string"?l.kind:"related","dependency",!0)}}let s=[...r.values()].sort((d,u)=>d.holder_id.localeCompare(u.holder_id)||d.target_id.localeCompare(u.target_id)||d.kind.localeCompare(u.kind)||d.source.localeCompare(u.source)),c=s.filter(d=>d.legacy_terminal);return{active:s.filter(d=>!d.legacy_terminal),legacy_terminal:c,no_active_blocker_sentinels:s.filter(d=>d.no_active_blocker_sentinel)}}function ft(e){let n=new Map;for(let o of[...e.active,...e.legacy_terminal]){if(o.no_active_blocker_sentinel)continue;let t=o.target_id.trim(),r=t.toLowerCase();n.has(r)||n.set(r,t)}return[...n.values()].sort((o,t)=>o.localeCompare(t))}function mt(e){let n=new Map;for(let o of e){let t=$(o.blocked_by);t&&B(t)&&!n.has(t)&&n.set(t,t);for(let r of o.dependencies??[]){if(typeof r!="object"||r===null||!B(r.id,r.source_kind))continue;let i=$(r.id);i&&!n.has(i)&&n.set(i,i)}}return[...n.values()].sort((o,t)=>o.localeCompare(t))}var Ne=new WeakMap;function En(e){return e.hierarchyIntegrity??Ne.get(e)}function gt(e,n=v()){let o={};for(let t of e)for(let r of t.dependencies??[]){if(typeof r!="object"||r===null)continue;let i=r.kind;if(typeof i!="string")continue;let s=i.trim().toLowerCase().replaceAll("-","_"),c=n.resolve(i);c&&s!==c.kind&&(o[s]=(o[s]??0)+1)}return Object.fromEntries(Object.entries(o).sort(([t],[r])=>t.localeCompare(r)))}function ee(e,n,o){let t=o??v(),r=e.filter(f=>typeof f?.id=="string"&&f.id.trim().length>0),i=new Map(r.map(f=>[f.id.trim().toLowerCase(),f.id.trim()])),s=Z(r,n),c=ft(s);for(let f of c)i.set(f.toLowerCase(),f);let d=mt(r),u=new Set(i.keys()),l=new Map;for(let f of d){let _=f;for(;u.has(_.toLowerCase());)_=`external:${_}`;l.set(f,_),u.add(_.toLowerCase())}let a=r.map(f=>{let _=$(f.parent),g=$(f.blocked_by),h=(f.dependencies??[]).flatMap(k=>{if(typeof k!="object"||k===null)return[];let y=k,C=$(y.id);return C?[{id:Ae(C,y.source_kind,i,l),kind:typeof y.kind=="string"?y.kind:"related"}]:[]});return{id:f.id.trim(),..._?{parent:i.get(_.toLowerCase())}:{},...g?{blocked_by:Ae(g,void 0,i,l)}:{},dependencies:h}}),p=H(r,n,t),m={graph:de.fromItems([...a,...c.map(f=>({id:f})),...d.map(f=>({id:l.get(f)}))],t),details:[...r.map(f=>({id:f.id.trim(),title:f.title,status:f.status,...typeof f.type=="string"&&f.type.trim().length>0?{type:f.type.trim()}:{}})),...c.map(f=>({id:f,title:`[missing] ${f}`,status:"missing"})),...d.map(f=>({id:l.get(f),title:`[external] ${f}`,status:"external"}))],missingIdSet:new Set(c.map(f=>f.toLowerCase())),dangling:s,duplicateRows:ut(r,n),orderingContradictions:pt(r,n,t),legacyAliasCounts:gt(r,t),hierarchyIntegrity:p};return Ne.set(m,p),m}import{createHash as ht}from"node:crypto";var _t=64,yt=8;function kt(e,n){let o=(e.dependencies??[]).map(t=>{if(typeof t!="object"||t===null)return"";let r=t;return`${typeof r.kind=="string"?r.kind:"related"}:${typeof r.id=="string"?r.id:""}`}).sort().join(",");return[e.id,e.title,e.status,n(e.status)?"1":"0",typeof e.type=="string"?e.type.trim():"",e.parent??"",e.blocked_by??"",o].join("\0")}function $e(e,n=t=>t==="closed"||t==="canceled",o=E()){let t=e.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0).map(i=>kt(i,n)).sort(),r=o.list().map(i=>le(i)).sort();return ht("sha256").update(t.join("")).update("").update(r.join("")).digest("hex")}function Me(e,n,o){let t=n??o;if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(n)}`);return t}var te=class{#e=new Map;#t;#n;constructor(n={}){this.#t=Me("maxResultsPerWorkspace",n.maxResultsPerWorkspace,_t),this.#n=Me("maxWorkspaces",n.maxWorkspaces,yt)}lookup(n,o,t){let r=this.#e.get(n),i=!0;(r===void 0||r.fingerprint!==o)&&(r={fingerprint:o,assembly:t(),results:new Map},i=!1,!this.#e.has(n)&&this.#e.size>=this.#n&&this.#e.delete(this.#e.keys().next().value)),this.#e.delete(n),this.#e.set(n,r);let s=r,c=this.#t;return{assembly:s.assembly,assemblyReused:i,fingerprint:o,memoize(d,u){let l=s.results.get(d);if(l!==void 0||s.results.has(d))return s.results.delete(d),s.results.set(d,l),{value:structuredClone(l),reused:!0};let a=u();return s.results.size>=c&&s.results.delete(s.results.keys().next().value),s.results.set(d,structuredClone(a)),{value:a,reused:!1}}}}clear(){this.#e.clear()}},Be=new te;function Pe(){return Be}function Sn(){Be.clear()}var U=1200,wt=["prerequisite","dependent","ancestor","descendant","provenance","related"],xt=new TextEncoder;function ne(e,n,o){let t=e??n;if(!Number.isInteger(t)||t<1)throw new TypeError(`Relationship context ${o} must be positive`);return t}function P(e){return Math.max(1,Math.ceil(xt.encode(JSON.stringify(e)).byteLength/4))}function W(e,n,o){let t=o.resolve(e.kind);if(t?.ordering){let i=(t.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return n===i?"prerequisite":"dependent"}if(t?.hierarchy){let i=t.hierarchyDirection==="source_parent"?e.source:e.target;return n===i?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function vt(e,n,o,t){let r=e.filter(i=>i.source===n&&i.target===o||i.target===n&&i.source===o).map(i=>W(i,o,t));return[...new Set(r)].sort()}function Ct(e){return wt.find(n=>e.includes(n))}function Et(e,n,o,t){let r=t.direction??"both",i=t.maxDepth??3;if(!Number.isInteger(i)||i<0)throw new TypeError("Relationship context maxDepth must be non-negative");let s=new Set([n]),c=[{id:n,distance:0}],d=[],u=0,l=!1;for(let a=0;a<c.length;a+=1){t.signal?.throwIfAborted();let p=c[a];if(p.distance>=i&&l)continue;let m=e.neighborEdges(p.id,{direction:r,kinds:t.kinds,signal:t.signal});if(u+=m.meta.inspectedEdges,p.distance>=i){m.value.some(f=>!s.has(f.id))&&(l=!0);continue}for(let{id:f,edge:_}of m.value){if(s.has(f))continue;s.add(f);let g={id:f,distance:p.distance+1,via:p.id,role:W(_,f,o)};d.push(g),c.push(g)}}return{rows:d,visitedNodes:c.length,inspectedEdges:u,depthTruncated:l}}function bt(e,n,o,t){let r={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},i=e.neighborEdges(n,{direction:t.direction??"both",kinds:t.kinds,signal:t.signal}).value;for(let{id:s,edge:c}of i)r[W(c,s,o)]+=1;return{directEdges:r,directTotal:i.length,rootEdges:i.map(({edge:s})=>s)}}function Rt(e,n,o,t){let r=new Set;for(let i of n){let s=i.source===o?i.target:i.source,c=W(i,s,t);(c==="prerequisite"||c==="ancestor")&&r.add(s)}return[...e].sort((i,s)=>Number(r.has(s.id))-Number(r.has(i.id))||i.distance-s.distance||i.id.localeCompare(s.id))}function It(e,n){let o=e.distance===1?vt(n.rootEdges,n.rootId,e.id,n.registry):[];return{...n.details.get(e.id)??{id:e.id},distance:e.distance,role:o.length>0?Ct(o):e.role,via:e.via,reasons:o.length>0?o:[`${e.role} via ${e.via} (depth ${e.distance})`]}}function Tt(e){let n=[],o=e.initialTokens,t=0;for(let r of e.candidates){if(n.length>=e.nodeLimit)break;let i=It(r,e),s=P(i);if(o+s>e.tokenBudget)break;let c=e.rootEdges.filter(d=>d.source===r.id||d.target===r.id).reduce((d,u)=>d+P(u),0);if(o+t+s+c>e.tokenBudget){if(n.length>0)break}else t+=c;n.push(i),o+=s}if(e.candidates.length>0&&n.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:n,usedTokens:o}}function Lt(e){let n=e.options.kinds?new Set(e.options.kinds.map(i=>e.registry.require(i).kind)):void 0,o=e.graph.edges().filter(i=>{if(!e.included.has(i.source)||!e.included.has(i.target))return!1;if(n===void 0||n.has(i.kind))return!0;let s=e.registry.resolve(i.kind)?.inverse;return s!==void 0&&n.has(s)}).sort((i,s)=>+(s.source===e.rootId||s.target===e.rootId)-+(i.source===e.rootId||i.target===e.rootId)),t=[],r=e.initialTokens;for(let i of o){if(t.length>=e.edgeLimit)break;let s=P(i);r+s>e.tokenBudget||(t.push(i),r+=s)}return{edges:t,usedTokens:r,candidateCount:o.length}}function Ue(e,n,o,t={}){if(!e.nodes().includes(n))throw new TypeError(`Relationship node not found: ${n}`);let r=ne(t.nodeLimit,20,"nodeLimit"),i=ne(t.edgeLimit,40,"edgeLimit"),s=ne(t.tokenBudget,U,"tokenBudget"),c=t.registry??E(),d=new Map(o.map(I=>[I.id,I])),u=d.get(n)??{id:n},{evidence:l=[],...a}=u,p=[...l],m=Et(e,n,c,t),{rootEdges:f,..._}=bt(e,n,c,t),g=Rt(m.rows,f,n,c),h=ye("relationship-context",{rootId:n,direction:t.direction??"both",kinds:[...t.kinds??[]].sort(),maxDepth:t.maxDepth??3,ordering:"required-root-evidence-first-v1"}),k=we(g,t.cursor,h,({id:I})=>I,"--cursor"),y=g.slice(k),C=P(a)+P(p);if(C>s)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");let O=Tt({candidates:y,details:d,rootEdges:f,rootId:n,registry:c,nodeLimit:r,tokenBudget:s,initialTokens:C}),{nodes:D}=O,Ve=new Set([n,...D.map(({id:I})=>I)]),ie=Lt({graph:e,rootId:n,included:Ve,options:t,registry:c,edgeLimit:i,tokenBudget:s,initialTokens:O.usedTokens}),{edges:X,usedTokens:Ye}=ie,j=k+D.length,q=j<g.length,se=D.at(-1),V=ie.candidateCount-X.length,ce=m.depthTruncated||q||V>0,Je={rootId:n,...a.status===void 0?{}:{rootStatus:a.status},..._,discoveredNodes:g.length,returnedNodes:D.length,returnedEdges:X.length,omittedNodes:g.length-j,omittedEdges:V,evidenceCount:p.length,hasMore:q};return{root:a,summary:Je,nodes:D,edges:X,evidence:p,meta:{exact:!0,truncated:ce,completeness:ce?"truncated":"complete",nodeLimit:r,edgeLimit:i,tokenBudget:s,usedTokens:Ye,visitedNodes:m.visitedNodes,inspectedEdges:m.inspectedEdges,omittedNodes:g.length-j,omittedEdges:V,...q&&se?{nextCursor:ke(h,se.id,j-1)}:{}}}}var St=["tree","graph","context"],Ot=["none","repeated"],Dt=["outgoing","incoming","both"],At=32,Nt=200,Mt=400,$t=16e3;function Bt(e){let n=e?.trim().toLowerCase()??"tree";if(St.includes(n))return n;throw new w(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,x.USAGE)}function S(e,n){if(e===void 0)return;let o=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(o)||o<1)throw new w(`Invalid --${n} value "${e}". Use a positive integer.`,x.USAGE);return o}function Fe(e){if(e===void 0)return;let n=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(n)||n<0)throw new w(`Invalid --max-depth value "${e}". Use a non-negative integer.`,x.USAGE);return n}function Pt(e){let n=e?.trim().toLowerCase()??"none";if(Ot.includes(n))return n;throw new w(`Invalid --collapse value "${e}". Use "none" or "repeated".`,x.USAGE)}function Ut(e){let n=e?.trim().toLowerCase()??"both";if(Dt.includes(n))return n;throw new w(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,x.USAGE)}function jt(e,n=E()){if(e===void 0)return;let o=(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);if(o.length===0)return;let t=new Set;for(let r of o){let i=n.resolve(r);if(!i){let s=n.list().map(c=>c.kind).join(", ");throw new w(`Invalid --kind value "${r}". Registered kinds: ${s}.`,x.USAGE)}t.add(i.kind)}return[...t].sort()}function Ft(e){if(!e||e.length===0)return[];let n=e.map(({id:t,kind:r})=>({id:t.trim(),kind:r.trim().toLowerCase()})).sort((t,r)=>{let i=t.kind.localeCompare(r.kind);return i!==0?i:t.id.localeCompare(r.id)}),o=new Map;for(let t of n){let r=`${t.kind.toLowerCase()}::${t.id.toLowerCase()}`;o.has(r)||o.set(r,{id:t.id,kind:t.kind})}return[...o.values()]}function Gt(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:Ft(e.dependencies)}}function zt(e){return A(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function Kt(e,n,o,t,r,i,s,c,d){for(let u of n.dependencies){let l=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:u.id,kind:u.kind}).length/3));if(c.nodes>=c.nodeLimit){e.truncated=!0,c.reasons.add("node_limit");break}if(c.edges>=c.edgeLimit){e.truncated=!0,c.reasons.add("edge_limit");break}if(c.estimatedTokens+l>=c.tokenBudget){e.truncated=!0,c.reasons.add("token_budget");break}c.edges+=1,c.estimatedTokens+=l,e.dependencies.push(Ge(u.id,o,t,r,i,s,c,d+1,u.kind))}}function Ht(e,n,o,t,r,i,s,c){return s.estimatedTokens>=s.tokenBudget&&n?.dependencies.length?(e.truncated=!0,s.reasons.add("token_budget"),!0):!n||e.cycle?!0:t!==void 0&&c>=t?(n.dependencies.length>0&&(e.truncated=!0,s.reasons.add("max_depth")),!0):r==="repeated"&&i.has(o)?(e.collapsed=!0,!0):!1}function Ge(e,n,o,t,r,i,s,c=0,d){let u=e.trim().toLowerCase(),l=n.get(u),a={id:l?.id??e,title:l?.title,type:l?.type,status:l?.status,via:d,missing:!l,cycle:o.has(u),dependencies:[]};if(s.nodes+=1,s.estimatedTokens+=zt(a),Ht(a,l,u,t,r,i,s,c))return a;r==="repeated"&&i.add(u);let p=new Set(o);return p.add(u),Kt(a,l,n,p,t,r,i,s,c),a}function je(e,n){return!e||e.missing&&!n.missing?n:{...e,title:e.title??n.title,type:e.type??n.type,status:e.status??n.status}}function Wt(e){let n=new Map,o=new Map,t=[e];for(;t.length>0;){let c=t.pop();n.set(c.id,je(n.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));for(let d of c.dependencies){n.set(d.id,je(n.get(d.id),{id:d.id,title:d.title,type:d.type,status:d.status,missing:d.missing}));let u=d.via??"related",l=`${c.id}::${d.id}::${u}`;o.has(l)||o.set(l,{from:c.id,to:d.id,kind:u}),d.cycle||t.push(d)}}let r=[...n.values()].sort((c,d)=>c.id.localeCompare(d.id)),i=[...o.values()].sort((c,d)=>{let u=c.from.localeCompare(d.from);if(u!==0)return u;let l=c.to.localeCompare(d.to);return l!==0?l:c.kind.localeCompare(d.kind)}),s=r.filter(c=>c.missing).map(c=>c.id);return{root_id:e.id,nodes:r,edges:i,missing_ids:s}}function ze(e,n,o){let t=new Set,r=new Set,i=new Set,s=new Set,c=[{id:e,depth:0}],d=0;for(;d<c.length;){let u=c[d++],l=u.id.trim().toLowerCase();t.add(l);let a=n.get(l);if(!a){i.add(l);continue}if(!(o!==void 0&&u.depth>=o)&&!s.has(l)){s.add(l);for(let p of a.dependencies)r.add(`${l}::${p.id.trim().toLowerCase()}::${p.kind}`),c.push({id:p.id,depth:u.depth+1})}}return{node_count:t.size,edge_count:r.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function Xt(e,n=E()){let o=Fe(e.maxDepth),t=S(e.nodeLimit,"node-limit"),r=S(e.edgeLimit,"edge-limit"),i=S(e.tokenBudget,"token-budget"),s=jt(e.kind,n);return{direction:Ut(e.direction),...s===void 0?{}:{kinds:s},...o===void 0?{}:{maxDepth:o},...t===void 0?{}:{nodeLimit:t},...r===void 0?{}:{edgeLimit:r},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function qt(e,n,o,t){return Ue(e.graph,n,e.details.map(r=>r.id===n&&t.length>0?{...r,evidence:t}:r),o)}function oe(e,n,o,t){for(let r of o.slice(0,t)){let i=r?.trim();i&&e.push(`${n}:${i}`)}}async function Vt(e,n,o,t){let r=await Ie(e,n,o.id_prefix,o.item_format,t);if(!r)return[];let{document:i}=await Te(r,{schema:o.schema}),s=i.metadata,c=s.files??[],d=s.tests??[],u=s.docs??[],l=[["files",c.length],["tests",d.length],["docs",u.length],["comments",(s.comments??[]).length],["notes",(s.notes??[]).length],["learnings",(s.learnings??[]).length]];if(l.every(([,p])=>p===0))return[];let a=[`linked:${l.map(([p,m])=>`${p}=${m}`).join(",")}`];return oe(a,"file",c.map(p=>p.path),3),oe(a,"test",d.map(p=>p.command??p.path),2),oe(a,"doc",u.map(p=>p.path),2),a}function Yt(e){let{canonicalId:n,context:o,missingCount:t,missingReferences:r,referenceLimit:i,summaryOnly:s}=e;return{id:n,format:"context",node_count:o.nodes.length+1,edge_count:o.edges.length,edge_basis:"deduplicated_directed",missing_count:t,missing_scope:"traversal",missing_reference_count:r.length,...s?{}:{missing_references:r.slice(0,i),context:o}}}function Jt(e){let{row:n,missingReachableSet:o,packetIds:t,filteredKinds:r,registry:i}=e;if(n.no_active_blocker_sentinel||!o.has(n.target_id.trim().toLowerCase())||!t.has(n.holder_id))return!1;if(r===void 0)return!0;let s=i.resolve(n.kind);return s!==void 0&&(r.has(s.kind)||s.inverse!==void 0&&r.has(s.inverse))}function Ke(e,n){let o=fe(),t=n.commandOptionsOverride??(o?.command==="deps"?o.options:n.commandOptions);return xe("deps",{...t,...n.global,resolvedOutputFormat:n.format},e)}function re(e,n){let o=Ke(e,n),t=r=>Ce(r,n.format,n.global.lean===!0);return t(n.global.tokenAccounting===!0?ve(o,t):o)}function He(e,n,o){let t;for(;;){let r=A(new TextEncoder().encode(re(e,n)).byteLength);if(r===t)return r;o(r),t=r}}function We(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function Xe(e){let{assembly:n,canonicalId:o,contextOptions:t,rootEvidence:r,summaryOnly:i,rendering:s,missingCount:c,missingReferences:d}=e,u=t.edgeLimit??40,l=Math.min(u,d.length),a=t.tokenBudget,p;for(;;){let m=qt(n,o,{...t,...a===void 0?{}:{tokenBudget:a}},r);p??=m.meta.tokenBudget,a??=p;let f=Yt({canonicalId:o,context:m,missingCount:c,missingReferences:d,referenceLimit:l,summaryOnly:i});if(i){if(A(new TextEncoder().encode(re(b(f,!0,s.legacyAliasCounts),s)).byteLength)>p)throw new TypeError("Relationship context tokenBudget cannot fit the rendered summary");return f}if(m.meta.tokenBudget=p,m.meta.usedTokens=He(b(f,!1,s.legacyAliasCounts),s,h=>{m.meta.usedTokens=h}),m.meta.usedTokens<=p)return f;if(l>0){l-=1;continue}let _=a,g=_*p/m.meta.usedTokens;a=Math.min(_-1,Math.max(1,Math.floor(g*.9)))}}function qe(e,n){let o=e.contextOptions,t={...e.rendering.global,outputFormat:e.rendering.format},r=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","context","--output-format",e.rendering.format,"--token-budget"],i=r.length;r.push(String(n));let s=new Set(["--pm-path","--format","--output-format","--token-budget"]),c={format:"context",tokenBudget:n,kind:o.kinds},d=[["--max-depth","maxDepth",o.maxDepth],["--node-limit","nodeLimit",o.nodeLimit],["--edge-limit","edgeLimit",o.edgeLimit],["--direction","direction",o.direction],["--cursor","cursor",o.cursor],["--output-include","outputInclude",t.outputInclude],["--output-limit","outputLimit",t.outputLimit],["--output-budget","outputBudget",t.outputBudget],["--output-session","outputSession",t.outputSession],["--output-cursor","outputCursor",t.outputCursor]];for(let[a,p,m]of d)m!==void 0&&(r.push(a,String(m)),s.add(a),c[p]=m);for(let a of o.kinds??[])r.push("--kind",a),s.add("--kind");let u=[["--summary","summary",e.summaryOnly],["--full","full",e.rendering.commandOptions.full],["--json","json",t.json],["--lean","lean",t.lean],["--output-row-contract","outputRowContract",t.outputRowContract],["--token-accounting","tokenAccounting",t.tokenAccounting],["--no-extensions","noExtensions",t.noExtensions],["--no-pager","noPager",t.noPager]];for(let[a,p,m]of u)m===!0&&(r.push(a),s.add(a),c[p]=!0);let l=ge.find(a=>a.command==="deps");return Reflect.set(c,me,{canonical_include_modes:[],cli_invocation_observed:!0,explicit_legacy_aliases:Object.values(l.dimensions).flatMap(a=>a.legacy_aliases.flatMap(p=>s.has(p.flag)?[p.flag]:[]))}),he("deps",c),Y(c.summary===!0,c.full===!0,"--summary"),t.outputInclude=c.outputInclude,{args:r,budgetIndex:i,summaryOnly:c.summary===!0,rendering:{...e.rendering,global:t,commandOptionsOverride:c}}}function Qt(e,n,o){let t={...n.rendering,commandOptionsOverride:{...n.rendering.commandOptionsOverride,tokenBudget:o}},r;try{r=Xe({...e,contextOptions:{...e.contextOptions,tokenBudget:o},summaryOnly:n.summaryOnly,rootEvidence:n.summaryOnly?[]:e.rootEvidence,rendering:t})}catch(s){if(!We(s))throw s;return"native_floor"}let i=Ke(b(r,n.summaryOnly,t.legacyAliasCounts),t);return _e(i)?"output_constraints":"fits"}async function Zt(e,n){let o=e.contextOptions.tokenBudget??U,t=qe(e,o),i=(t.summaryOnly?1:1+Math.min(e.contextOptions.edgeLimit??40,e.missingReferences.length))*(e.assembly.details.reduce((p,m)=>p+m.id.length+m.title.length+m.status.length+(m.type?.length??0),e.assembly.graph.edges().length+e.missingReferences.length)+(t.summaryOnly?[]:e.rootEvidence).reduce((p,m)=>p+m.length,0)),{findContextBudgetRecovery:s}=await import("./context-budget-recovery-CSJV3TY3.js"),c=s({requested:o,initialBudget:U,workUnits:i,probe:p=>Qt(e,t,p)}),d=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","tree","--summary"],u=F(d),l=c.feasible_tokens===null?d:[...t.args];c.feasible_tokens!==null&&(l[t.budgetIndex]=String(c.feasible_tokens));let a=F(l);return Se("Relationship context tokenBudget cannot fit the required rendered packet",{exitCode:x.USAGE,cause:n,context:{code:"invalid_argument_value",field:"tokenBudget",value:String(o),required:c.feasible_tokens===null?"Inspect the compact summary and review the output constraints.":"Retry the preserved context query with --token-budget "+c.feasible_tokens+".",why:"Budget advice is verified against the current query. A minimum is reported only after every smaller positive budget is checked.",examples:[a,u],nextSteps:[a],recovery:{recovery_mode:"compact",suggested_flags:["--token-budget"],token_budget:c,suggested_retry_args:l,suggested_retry:a,next_best_command:u,fallback_candidates:[{source:"relationship_summary",command:u,reason:"Inspect bounded counts separately from context rows."}]}}})}async function en(e){let{pmRoot:n,assembly:o,canonicalId:t,options:r,rootEvidence:i,summaryOnly:s,rendering:c}=e,d=Xt(r,o.graph.registry()),u=o.graph.closure(t,{direction:d.direction,...d.kinds===void 0?{}:{kinds:d.kinds},maxDepth:d.maxDepth??3}),l=u.value.filter(h=>o.missingIdSet.has(h.toLowerCase())),a=new Set(l.map(h=>h.toLowerCase())),p=o.graph.registry(),m=d.kinds?new Set(d.kinds.map(h=>p.require(h).kind)):void 0,f=new Set([t,...u.value]),_=[...o.dangling.active,...o.dangling.legacy_terminal].filter(h=>Jt({row:h,missingReachableSet:a,packetIds:f,filteredKinds:m,registry:p})),g={pmRoot:n,assembly:o,canonicalId:t,contextOptions:d,rootEvidence:i,summaryOnly:s,rendering:c,missingCount:l.length,missingReferences:_};try{return Xe(g)}catch(h){if(h instanceof w&&h.code==="invalid_query_cursor"){let k=qe({...g,contextOptions:{...d,cursor:void 0},rendering:{...c,global:{...c.global,outputCursor:void 0}}},d.tokenBudget??U),y=F(k.args);throw new w(h.message,h.exitCode,{...h.context,nextSteps:[...h.context.nextSteps,y],recovery:{suggested_retry:y,suggested_retry_args:k.args}})}throw We(h)?await Zt(g,h):h}}function tn(e){let n=[e],o;for(;n.length>0;){let t=n.pop();t.dependencies.length>0&&(o=t,n.push(...t.dependencies))}return o?(o.dependencies.pop(),o.truncated=!0,!0):!1}function nn(e,n,o,t,r,i,s){let c=r??At,d=S(o.nodeLimit,"node-limit")??Nt,u=S(o.edgeLimit,"edge-limit")??Mt,l=S(o.tokenBudget,"token-budget")??$t,a={nodeLimit:d,edgeLimit:u,tokenBudget:l,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},p=Ge(e,t,new Set,c,n==="graph"?"repeated":i,new Set,a),m=ze(e,t,void 0),f;for(;;){let _=Wt(p),g=a.reasons.size===0?void 0:{reasons:[...a.reasons].sort(),limits:{max_depth:c,node_limit:d,edge_limit:u,token_budget:l},estimated_tokens:0,total_node_count:m.node_count,total_edge_count:m.edge_count,omitted_node_count:Math.max(0,m.node_count-_.nodes.length),omitted_edge_count:Math.max(0,m.edge_count-_.edges.length)},h={id:e,format:n,node_count:_.nodes.length,edge_count:_.edges.length,edge_basis:"deduplicated_directed",missing_count:_.missing_ids.length,...g?{truncation:g}:{}};if(f=n==="tree"?{...h,tree:p}:{...h,graph:_},(f.truncation===void 0?A(new TextEncoder().encode(re(b(f,!1,s.legacyAliasCounts),s)).byteLength):He(b(f,!1,s.legacyAliasCounts),s,y=>{f.truncation.estimated_tokens=y}))<=l)return f;if(!tn(p))return a.reasons.add("token_budget"),f;a.reasons.add("token_budget")}}function b(e,n,o={}){let t={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"},r=e.context?.meta.truncated?[{name:"relationship_context_bounds",restore_with:"--token-budget <n> --node-limit <n> --edge-limit <n> --max-depth <n>"}]:[];return{...e,legacy_alias_counts:o,projection:{mode:n?"summary":"full",declared_field_groups:[t,...r],included_field_groups:n?[]:[t.name]}}}async function ro(e,n,o){let t=ue(process.cwd(),o.path);await Re(t);let r=Bt(n.format),i=Fe(n.maxDepth),s=Pt(n.collapse);Y(n.summary===!0,n.full===!0,"--summary");let c=n.summary===!0,d=await be(t),u=ae(d,z()),l=await Le(t,d.item_format,u.type_to_folder,void 0,d.schema),a=pe(d.schema),p=new Map(l.map(g=>[g.id.trim().toLowerCase(),Gt(g)])),m=Z(l,g=>G(g,a));for(let g of[...m.active,...m.legacy_terminal]){let h=p.get(g.holder_id.trim().toLowerCase()),k=g.kind.trim().toLowerCase();h&&!h.dependencies.some(y=>y.id.trim().toLowerCase()===g.target_id.trim().toLowerCase()&&y.kind===k)&&h.dependencies.push({id:g.target_id,kind:k})}if(!p.has(e.trim().toLowerCase()))throw new w(`Item ${e} not found`,x.NOT_FOUND);let f=o.outputFormat??(o.json===!0||o.json===void 0&&o.defaultOutputFormat==="json"?"json":"toon");if(r==="context"){let g=p.get(e.trim().toLowerCase()).id,h=c?[]:await Vt(t,g,d,u.type_to_folder),k=O=>G(O,a),y=v(),C=Pe().lookup(t,$e(l,k,y),()=>ee(l,k,y));return b(await en({pmRoot:t,assembly:C.assembly,canonicalId:g,options:n,rootEvidence:h,summaryOnly:c,rendering:{format:f,global:o,commandOptions:n,legacyAliasCounts:C.assembly.legacyAliasCounts}}),c,C.assembly.legacyAliasCounts)}let _=Object.fromEntries(Object.entries(ee(l,g=>G(g,a)).legacyAliasCounts));return c?b({id:e,format:r,...ze(e,p,i)},!0,_):b(nn(e,r,n,p,i,s,{format:f,global:o,commandOptions:n,legacyAliasCounts:_}),!1,_)}export{hn as a,_n as b,dt as c,v as d,un as e,H as f,ln as g,st as h,pn as i,$ as j,ut as k,pt as l,Z as m,ft as n,En as o,ee as p,$e as q,te as r,Pe as s,Sn as t,U as u,Ue as v,S as w,Fe as x,Ut as y,jt as z,ro as A};
|
|
2
|
-
//# sourceMappingURL=chunk-C2HW7BSE.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as W,c as j}from"./chunk-B2HJI6KA.js";import{jb as V}from"./chunk-52PHSTGP.js";import{H as $,I as D,O as q,Y as G}from"./chunk-ZZYJS74B.js";import{s as F}from"./chunk-SXWUKNTY.js";import{Ba as R,Dd as f,Ed as T,Fd as _,Gd as b,Hd as N,Ka as y,Kd as O,Lc as S,Ld as k,Md as H,Nd as L,Od as M,Pd as P,Q as v,Qd as l,W as w,aa as I,je as U,xd as A}from"./chunk-HGJ4MILN.js";import{D as E,E as C}from"./chunk-YPOATPTX.js";import{A as d,y as g,z as m}from"./chunk-NGFDPEP7.js";var B="item_revision_conflict",ee=10,J=/^[0-9a-f]{64}$/u;function p(e,n){return new d(`Invalid expected revision ${JSON.stringify(e)}: ${n}.`,m.USAGE,{code:"expect_hash_invalid",value:e,required:"Pass the 64-character item_hash from pm get <id> --json, optionally as <id>=<item_hash>.",examples:["--expect-hash <item_hash>","--expect-hash pm-a1b2=<item_hash>"]})}function K(e){let n=typeof e=="string"?e.trim().toLowerCase():"";if(!J.test(n))throw p(String(e),"the revision is not a 64-character hexadecimal item_hash");return n}function te(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw p(String(t),"expected a string");let i=t.split(",").map(o=>o.trim()).filter(o=>o.length>0);if(i.length===0)throw p(t,"the value is empty");let r=o=>C(t)===t?o:E;return i.map(o=>{let c=o.lastIndexOf("="),s=c===-1?void 0:o.slice(0,c).trim();if(s!==void 0&&s.length===0)throw p(r(o),"the item id before = is empty");let a=c===-1?o:o.slice(c+1);if(!J.test(a.trim().toLowerCase()))throw p(r(a),"the revision is not a 64-character hexadecimal item_hash");let h=K(a);return s===void 0?{itemHash:h}:{id:s,itemHash:h}})})}async function X(e,n){let t=await F(e),i=v(t,U()).type_to_folder,r=await $(e,n,t.id_prefix,t.item_format,i);if(r){let{document:o}=await D(r,{schema:t.schema});if(o.metadata.id!==await j(r.itemPath,r.id))throw new d(`Item file ${r.id} embeds the id ${o.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,m.CONFLICT,{code:"item_identity_conflict",item_id:r.id,required:`Repair ${r.id}'s identity first (pm validate reports it; pm restore ${r.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:o.metadata.id,document:o}}try{return{id:(await W(e,n,t,i)).id,document:g}}catch{throw await q(e,n,t.id_prefix,i)}}function x(e){return w(e.cwd??process.cwd(),e.pmRoot)}async function Te(e,n={}){let t=await X(x(n),e);return{id:t.id,item_hash:A(t.document)}}async function Y(e,n,t){let i=[];for(let r of n){let o=r.id??t;if(o===void 0||o.trim().length===0)throw new d("A bare expected revision needs an item to bind to.",m.USAGE,{code:"expect_hash_target_required",required:"This command has no single item argument; name each target as --expect-hash <id>=<item_hash>.",examples:["--expect-hash pm-a1b2=<item_hash>"]});i.push({id:(await X(e,o)).id,itemHash:r.itemHash})}return i}function ie(e){return[...new Set(e.patch.map(n=>{let t=n.path.split("/");return String(t[1]==="metadata"?t[2]:t[1])}))].sort()}async function ne(e,n,t){let i;try{i=await S(I(e,n),n)}catch{return}let r=-1;for(let s=i.length-1;s>=0;s-=1){let a=i[s];if(a.after_hash===t){r=s+1;break}if(a.before_hash===t){r=s;break}}if(r===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};let o=i.slice(r),c=o.slice(-ee);return{expected_revision_recorded:!0,changes_since:c.map(s=>({ts:s.ts,op:s.op,author:s.author,fields:ie(s)})),changes_since_omitted:o.length-c.length}}async function be(e,n){if(!u(e))return{};let t=await Q(e,n);return{error_code:B,expected_revision:String(t.context.expected_revision),current_revision:String(t.context.current_revision),details:t.context.details}}function u(e){return G(e)&&e.context.code===B}function Ne(e){let n=e.find(t=>u(t));if(n!==void 0)throw n}function Oe(){return new d("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",m.USAGE,{code:"expect_hash_invocation_rewritten",required:"Run the command without the rewriting extension (--no-extensions), or drop --expect-hash.",why:"An extension parser or preflight override changed this invocation's tracker or arguments, and final dispatch, the extension SDK client and the guard do not share one rewritten view."})}function oe(e,n){if(n===void 0||!u(e)||typeof e.context.item_id!="string"||M(e))return e;let t=e.context.reason===k;if(!t&&e.context.reason!==O)return e;let i=P(l(e,new d(e.message,e.exitCode,{...e.context,...H(e.context.item_id,t,n)})));return i.stack=e.stack,i}async function Q(e,n,t){if(!L(e,n))return e;let i=oe(e,t);if(!u(i)||i.context.details!==void 0)return i;let r=i.context.item_id,o=i.context.expected_revision;if(typeof r!="string"||typeof o!="string")return i;let c;try{c=await ne(n,r,o)}catch{return i}if(c===void 0)return i;let s={expected_revision_recorded:c.expected_revision_recorded,changes_since:c.changes_since.map(h=>({ts:h.ts,op:h.op,author:h.author,fields:[...h.fields]})),changes_since_omitted:c.changes_since_omitted},a=l(i,new d(i.message,i.exitCode,{...i.context,details:s}));return a.stack=i.stack,a}async function Z(e,n,t){try{return{result:await T(e,n),...b(e)}}catch(i){throw e.pmRoot===void 0?i:await Q(i,e.pmRoot,t)}}function re(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",x(e)]}}async function ke(e,n,t={}){return Z(await se(e,t),n,re(t))}async function se(e,n={}){let t=x(n),i=e.map(({id:o,itemHash:c})=>({id:o,itemHash:K(c)})),r=f();return _(r,t,await Y(t,i)),r}function He(e){let n=N(e);return n===void 0||n.length>0}function ce(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}var z=new Set(R);function ae(e,n={}){let t=e.trim().replace(/\s+/gu,"-"),i=z.has(t)?t:e;if(z.has(i)&&(!V(i)||i==="deps")&&!y.has(i))throw de(i);if((i==="test"||i==="test-all")&&n.background===!0)throw new d(`--expect-hash cannot guard ${i} --background: the worker runs in another process.`,m.USAGE,{code:"expect_hash_background_unsupported",required:`Run ${i} in the foreground to guard its result recording, or drop --expect-hash for a background run.`})}function de(e){return new d(`--expect-hash guards item writes, and ${e} is not a mutation.`,m.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function he(e,n){if(n.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;let t=e,i=Array.isArray(t.warnings)?t.warnings:[];return{...t,warnings:[...i,...n.map(ce)]}}async function Le(e){let n=e.expectHash;if(n!==void 0&&typeof n!="string"&&!(Array.isArray(n)&&n.every(o=>typeof o=="string")))throw p(JSON.stringify(n)??String(n),"expected a string or an array of strings");let t=te(n);if(t.length===0)return e.run();ae(e.action,{background:e.background===!0||e.options?.background===!0});let i=f();_(i,e.pmRoot,await Y(e.pmRoot,t,e.defaultId));let r=await Z(i,e.run,e.invocation);return he(r.result,r.unchecked)}export{B as a,ee as b,K as c,te as d,Te as e,Y as f,ne as g,be as h,u as i,Ne as j,Oe as k,oe as l,Q as m,Z as n,ke as o,se as p,He as q,ce as r,ae as s,de as t,Le as u};
|
|
2
|
-
//# sourceMappingURL=chunk-GISZWMBS.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as B,b as v}from"./chunk-X6CXWWNB.js";import{Fb as I,Gb as h,K as T,S as A,s as m}from"./chunk-HGJ4MILN.js";function E(e,n){return(n===void 0?void 0:A(e,n))?.execution_role??T[e.trim().toLowerCase()]??"agent"}var g="blocked_by",L="blocks",G=Object.freeze([g,L]),x="no-active-blocker";function l(e){return e.trim().toLowerCase()}function b(e,n){return n?`external:${e}`:`local:${l(e)}`}function k(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&l(t)!==x){let o=B(t);n.set(b(t,o),o?t:l(t))}for(let o of e.dependencies??[]){let c=typeof o.id=="string"?o.id.trim():"";if(m(o.kind)===g&&c.length>0&&l(c)!==x){let s=B(c)||v(o.source_kind);n.set(b(c,s),s?c:l(c))}}return[...n.values()].sort((o,c)=>o.localeCompare(c))}function _(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(k(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=m(c.kind)===L&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===x)continue;let i=n.get(s)??new Set;i.add(o),n.set(s,i)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function M(e,n){let t=l(e.id);return t.length>0?_(n).get(t)??k(e):k(e)}function S(e,n,t,o){let c=e,s=typeof c.id=="string"?o?.get(l(c.id))??M(c,[...n.values()]):k(e),i=new Set((e.dependencies??[]).filter(r=>m(r.kind)===g&&v(r.source_kind)&&typeof r.id=="string"&&r.id.trim().length>0).map(r=>b(r.id.trim(),!0)));return s.map(r=>{if(B(r)||i.has(b(r,!0)))return{id:r,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let d=n.get(l(r));return d?{id:r,title:d.title,status:d.status,resolved:h(d.status,t)}:{id:r,title:null,status:null,resolved:!1}})}function R(e,n,t){return S(e,n,t)}function U(e,n){let t=new Map(e.map(i=>[l(i.id),i])),o=_(e),c=new Set([...z(n),...n.blocked_statuses]),s=new Set;for(let i of e){let r=I(i.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||S(i,t,n,o).some(f=>!f.resolved))&&s.add(l(i.id))}return s}function W(e,n,t={},o){let c=[...e.ready,...e.decisions,...e.gates];t.includeContainers===!0&&c.push(...e.containers.filter(i=>i.open_blockers.length===0&&!n.blocked_statuses.has(I(i.item.status,n))));let s={ready:[],decisions:[],gates:[]};for(let i of c){let r=E(i.item.type,o);r==="human"&&t.includeDecisions!==!0?s.decisions.push(i):r==="gate"&&t.includeGates!==!0?s.gates.push(i):s.ready.push(i)}return s}function z(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function $(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let i of n.get(s)??[]){if(!h(i.status,t))return!0;o.push(l(i.id))}}}return!1}function j(e){let n=new Map,t=new Map,o=new Map,c=_(e);for(let s of e){n.set(l(s.id),s);let i=typeof s.parent=="string"?s.parent.trim():"";if(i.length>0){let r=l(i),d=t.get(r)??[];d.push(s),t.set(r,d)}for(let r of c.get(l(s.id))){let d=l(r),f=o.get(d)??[];f.push(s.id),o.set(d,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function V(e,n,t,o){let{itemsById:c,childrenByParent:s,blockedByReverse:i,blockerIdsByItem:r}=j(n),d=new Set([...z(t),...t.blocked_statuses]),f=new Set(n.filter(a=>!h(a.status,t)).map(a=>l(a.id))),C=[],w=[],y=[],D=[],N=[],K=0;for(let a of e){if(!d.has(I(a.status,t)))continue;K+=1;let O=S(a,c,t,r).filter(u=>!u.resolved),Y=(i.get(l(a.id))??[]).filter(u=>f.has(l(u))).sort((u,F)=>u.localeCompare(F)),p={item:a,open_blockers:O,unblocks:Y};if($(a.id,s,t)){y.push(p);continue}let P=t.blocked_statuses.has(I(a.status,t));if(O.length===0&&!P){let u=E(a.type,o);u==="human"?D.push(p):u==="gate"?N.push(p):C.push(p)}else w.push(p)}return{ready:C,blocked:w,containers:y,decisions:D,gates:N,active_count:K,container_count:y.length}}export{E as a,G as b,k as c,_ as d,M as e,R as f,U as g,W as h,V as i};
|
|
2
|
-
//# sourceMappingURL=chunk-H4JBS477.js.map
|