@unbrained/pm-cli 2026.10.3 → 2026.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +17 -2
  3. package/dist/cli/error-guidance.js +1 -1
  4. package/dist/cli/runtime/invocation-options.js +1 -1
  5. package/dist/cli/runtime/selection.js +1 -1
  6. package/dist/cli/runtime-compatibility-boundary.d.ts +1 -1
  7. package/dist/cli/runtime-compatibility-boundary.js +3 -3
  8. package/dist/cli-bundle/bundle-manifest.json +154 -154
  9. package/dist/cli-bundle/chunks/{chunk-YCBGZF3T.js → chunk-7CE2DJMA.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-6ST3SCQ6.js → chunk-7UVXKI7K.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-H2DZW6I6.js → chunk-D7Z2ZMJL.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-44UGMMQ6.js → chunk-GZMWISWW.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-KP7NBQK3.js → chunk-J52QIRRZ.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-3AF2R3Y6.js → chunk-JDKD3WGG.js} +6 -6
  15. package/dist/cli-bundle/chunks/chunk-JQ7DW663.js +2 -0
  16. package/dist/cli-bundle/chunks/{chunk-MKXBCBAN.js → chunk-QXIDOOWT.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-5XKF5SQV.js → chunk-SMKHR6BM.js} +49 -49
  18. package/dist/cli-bundle/chunks/{chunk-FW5LJXQY.js → chunk-V3U77H3V.js} +28 -28
  19. package/dist/cli-bundle/chunks/{chunk-YDWKGUQU.js → chunk-XZDWAYJC.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-QPKQKSQU.js → chunk-Y6VRBTP3.js} +71 -71
  21. package/dist/cli-bundle/chunks/{chunk-6Z4IV2MC.js → chunk-YAAFYFS4.js} +2 -2
  22. package/dist/cli-bundle/chunks/{register-list-query-DYCGUQEW.js → register-list-query-QBGXO5JJ.js} +2 -2
  23. package/dist/cli-bundle/chunks/{register-mutation-5PT3NW3A.js → register-mutation-53ZLT4RX.js} +2 -2
  24. package/dist/cli-bundle/chunks/{register-operations-QDDQOAAV.js → register-operations-OBK2FXUU.js} +2 -2
  25. package/dist/cli-bundle/chunks/{register-setup-BBX67YMA.js → register-setup-HM3OCBH2.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/{chunk-FKK2HI3S.js → chunk-2JFYR56O.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-UTRSM3ZK.js → chunk-32EVUSS4.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-DBD4W4QP.js → chunk-467EW5RL.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-WAJNX4RN.js → chunk-5GUSO2P4.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-GMYUNHST.js → chunk-6XBRADQQ.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-EJN7DY3B.js → chunk-7O4NUJVO.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-E754JDLY.js → chunk-CURTIIQT.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-4FFPGNCJ.js → chunk-IJUWEEEB.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-XRSCIYHR.js → chunk-JCVMOSWQ.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-ZIXFMIUL.js → chunk-JMJK2L4Z.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-WCY6HRZO.js → chunk-KG3H4UZZ.js} +14 -14
  37. package/dist/cli-bundle/focused-chunks/{chunk-VVWYI2X7.js → chunk-MHQ2XICU.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-3BIYG72P.js → chunk-Q6DJ5DFQ.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-73DA7ISY.js → chunk-RJV6QVJE.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-HIA2ZF64.js → chunk-ZE2JZ7R6.js} +11 -11
  41. package/dist/cli-bundle/focused-chunks/chunk-ZLEN4HZD.js +165 -0
  42. package/dist/cli-bundle/main.js +22 -22
  43. package/dist/cli-bundle/sdk-authoring.js +1 -1
  44. package/dist/cli-bundle/sdk-contracts.js +1 -1
  45. package/dist/cli-bundle/sdk-core.js +22 -22
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-graph.js +1 -1
  48. package/dist/cli-bundle/sdk-merge.js +11 -11
  49. package/dist/cli-bundle/sdk-query.js +1 -1
  50. package/dist/cli-bundle/sdk-runtime.js +1 -1
  51. package/dist/cli-bundle/sdk-testing.js +1 -1
  52. package/dist/cli-bundle/sdk.js +1 -1
  53. package/dist/core/extensions/extension-types.d.ts +8 -1
  54. package/dist/core/extensions/extension-types.js +1 -1
  55. package/dist/core/shared/time.js +1 -1
  56. package/dist/core/store/settings.d.ts +11 -2
  57. package/dist/core/store/settings.js +2 -2
  58. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  59. package/dist/sdk/cli-bootstrap.js +1 -1
  60. package/dist/sdk/context-intent-contracts.js +1 -1
  61. package/dist/sdk/extension-command-context.js +1 -1
  62. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  63. package/dist/sdk/item-transaction.js +1 -1
  64. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  65. package/dist/sdk/lifecycle/task-composition.js +1 -1
  66. package/dist/sdk/output-projection.js +1 -1
  67. package/dist/sdk/public-surface.json +1 -1
  68. package/dist/sdk/query/get.js +1 -1
  69. package/dist/sdk/query/search-pagination.d.ts +1 -1
  70. package/dist/sdk/query/search-pagination.js +1 -1
  71. package/dist/sdk/test/workspace-snapshot.js +1 -1
  72. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +25 -0
  73. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +23 -0
  74. package/docs/SDK_AUDITED_MUTATIONS.md +35 -0
  75. package/docs/TESTING.md +8 -0
  76. package/docs/ecosystem-review-2026-09-28.json +2864 -3157
  77. package/marketplace.json +2 -2
  78. package/package.json +1 -1
  79. package/packages/pm-beads/package.json +1 -1
  80. package/packages/pm-calendar/package.json +1 -1
  81. package/packages/pm-command-kit/package.json +1 -1
  82. package/packages/pm-digital-twin/package.json +1 -1
  83. package/packages/pm-governance-audit/package.json +1 -1
  84. package/packages/pm-guide-shell/package.json +1 -1
  85. package/packages/pm-kanban/package.json +1 -1
  86. package/packages/pm-lifecycle-hooks/package.json +1 -1
  87. package/packages/pm-linked-test-adapters/package.json +1 -1
  88. package/packages/pm-search-advanced/package.json +1 -1
  89. package/packages/pm-templates/package.json +1 -1
  90. package/packages/pm-todos/package.json +1 -1
  91. package/packages/pm-vcs/package.json +1 -1
  92. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  93. package/plugins/pm-claude/package.json +2 -2
  94. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  95. package/plugins/pm-codex/package.json +2 -2
  96. package/plugins/pm-codex/plugin.json +1 -1
  97. package/dist/cli-bundle/chunks/chunk-H7CXQBGQ.js +0 -2
  98. package/dist/cli-bundle/focused-chunks/chunk-YC32ZSLS.js +0 -165
@@ -1,4 +1,4 @@
1
- import{a as zo,c as Gr,d as qr,e as pl,g as hl,h as Wo,i as _l,j as an,k as cn,l as gl,m as yl,n as Go,o as bl,p as ln,q as dn,r as kl,s as Sl,t as qo}from"./chunk-4FFPGNCJ.js";import{e as ei,f as Yo,h as Xo}from"./chunk-3BIYG72P.js";import{B as Ml,C as Xr,D as jl,E as Ko,G as Fl,H as Ul,J as zl,K as Zr,M as Qr,a as al,g as Uo,i as cl}from"./chunk-EJN7DY3B.js";import{K as Xd}from"./chunk-VVWYI2X7.js";import{D as ns,E as fi,Ha as Hd,Ia as Wd,Ma as Gd,Na as qd,T as pi,U as yd,V as rs,W as Qn,Y as is,aa as Td,ba as $d,ca as Od,da as Dd,ea as _i,f as ld,g as dd,ga as Pd,h as ud,ha as Nd,ia as Ld,ja as Gt,k as mi,ka as Md,kb as Jd,la as gn,ma as jd,mb as as,na as os,nb as Kd,o as Xn,oa as yn,ob as Yd,p as md,pa as Fd,q as fd,qa as Ud,r as Zn,ra as zd,s as pd,sa as ss,u as ts,v as hd,wb as cs,z as _d}from"./chunk-WAJNX4RN.js";import{a as dl,b as sn,c as Ho,d as ul,e as ml,f as at,g as Br,h as fl,i as St}from"./chunk-ZIXFMIUL.js";import{$ as Vl,Aa as rd,Ab as Le,Ba as id,Bb as Rd,Cb as _n,D as q,Da as pn,Db as ct,E as Hl,Ea as Yn,Eb as Wt,Fa as od,Ga as si,H as xe,Ha as Ht,Hb as Cd,I as Zo,Ia as fe,Ib as lt,Ja as ai,Ka as sd,La as es,Ma as ci,Na as hn,O as Wl,Oa as li,P as ti,Pa as ad,S as ni,Sa as Ie,T as ri,Ua as cd,V as Gl,Va as $,W as Pe,Wa as di,Wb as er,Xa as ui,Y as xt,Yb as gi,Z as ql,Za as gd,_ as Bl,aa as zt,ba as Jl,dc as Bd,eb as wd,fb as vd,ga as Kl,gc as Vd,ha as Qo,hb as bd,ia as ii,ib as kd,ja as mn,jb as It,kb as Sd,la as oi,lb as Ed,ma as Yl,na as Xl,ob as xd,pa as Zl,pb as Id,ra as Ql,ta as ed,ub as hi,va as td,wb as Ad,xa as fn,ya as nd,yb as ne,zb as Ne}from"./chunk-YC32ZSLS.js";import{b as rn,e as de,g as De,i as Ee,j as Xe,n as _e,o as wl,p as Vr,r as vl}from"./chunk-GMYUNHST.js";import{$ as g,$a as Wr,$c as Nl,Aa as he,Ac as $l,Ba as Oe,Bb as Ye,Ca as Kc,Cc as Ol,Ea as te,Ha as Yc,Kc as H,La as Xc,Lb as ll,Nc as Z,Pc as We,Qb as Jr,Qc as Dl,Ra as Zc,Rb as El,Rc as Yr,S as Hc,Sa as Qc,Sb as Bo,T as Wc,Ta as G,Tb as Vo,Ub as Jo,V as Gc,Wb as xl,Wd as T,X as qc,Xb as Il,Xd as Ll,Y as Hr,Ya as Kn,Yc as Pl,Yd as un,Z as Bc,Za as N,Zc as Ze,Zd as Et,_a as Je,_b as Al,_d as Ut,a as Ur,aa as y,ab as Mt,cb as el,d as zr,db as jt,de as ce,fb as tl,fc as Rl,gb as nl,ha as Vc,hb as rl,i as Fc,ka as Jc,l as Uc,m as zc,ma as jo,pb as il,qb as Ft,ra as Jn,rb as C,sa as O,sb as ol,ta as kt,tb as Se,ua as z,va as V,vb as Fo,w as Mo,wb as sl,wc as Cl,xa as Q,xb as on,yc as Kr,zb as Ke,zc as Tl}from"./chunk-WCY6HRZO.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="00d2200c-d308-51a6-acc4-8da90afaf6d6")}catch{}})();var L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},Ae=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Qe=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function wn(e){try{return await e()}catch(t){throw t instanceof L?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function Zd(e){try{return await e()}catch(t){throw t instanceof Ae?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Fg}from"node:crypto";import Ug from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b00dcab2-22c6-55b7-b93d-f6f5413d4b04")}catch{}})();var vn=1e3;(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="00ad9b34-4feb-5812-8755-801869cce3ad")}catch{}})();var eu=1,qt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],ls=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],zg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],Hg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,yi=30,wi=5e3,tu=4,Wg=50;function dt(e,t){if(!Hg.test(e))throw new L(`${t} must be a stable lowercase id`)}function Gg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function tr(e){let t=zg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function us(e,t){return C(e)===C(t)}function nu(e,t){if(t.polarity==="equals")return us(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function ru(e){let t=tr(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>nu(r.observed,t)===(r.expected==="pass"))}function qg(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!us(e.value,t.value)}function Bg(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||C(e.scope)!==C(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return qg(tr(e),tr(t))||n[t.enforcement]<n[e.enforcement]||r}function Vg(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new L("items source equals/state requires field")}function Jg(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function Kg(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function ms(e){dt(e.id,"measurement.id"),e.max_cost!==void 0&&Gg(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${ls.join(", ")}`);let n=Reflect.get(t,"kind");if(!ls.includes(n))throw new L(`measurement.source.kind must be one of ${ls.join(", ")}`);let r=t;if(r.kind==="items"&&Vg(r),r.kind==="dependency_kind"&&Jg(r),r.kind==="prose_edge_gap"&&Kg(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new L(`${r.kind} source requires field`);return r.kind==="provider"&&(dt(r.provider,"provider source provider"),dt(r.key,"provider source key")),e}function fs(e){if(dt(e.id,"assertion.id"),dt(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=tr(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&dt(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!ru(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Yg(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)dt(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!qt.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function iu(e){if(dt(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)dt(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${qt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!qt.includes(t))throw new L(`gate trigger must be one of ${qt.join(", ")}`);return e.provider_policy&&Yg(e.provider_policy),e}function bn(e){if(e.version!==eu)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(ms(r),t.has(`measurement:${r.id}`))throw new L(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(fs(r),t.has(`assertion:${r.id}`))throw new L(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){iu(r);let i=r.assertion_ids.filter(o=>!e.assertions.some(s=>s.id===o));if(i.length>0)throw new L(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new L(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of ou(e))if(!n.has(r))throw new L(`${i.join(", ")} references missing measurement ${r}`);return e}function ps(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)ps(n,t)}function ou(e){let t=new Map,n=(r,i)=>{let o=t.get(r)??[];o.push(i),t.set(r,o)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];ps(r.source.expression,i);for(let o of i)n(o,`derived measurement ${r.id}`)}return t}function Xg(e,t){let n=e.assertion_ids.flatMap(o=>{let s=t.assertions.find(a=>a.id===o);return[s.measurement_id,...s.scope.kind==="filter"?[s.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let o=n.pop();if(r.has(o))continue;r.add(o);let s=t.measurements.find(a=>a.id===o);s.source.kind==="provider"?i.add(s.source.provider):s.source.kind==="derived"&&ps(s.source.expression,n)}return i}function nr(){return{version:eu,measurements:[],assertions:[],gates:[]}}function Zg(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let o=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?o:!o}return us(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function Qg(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function ey(e,t){let n=[],r=jo(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let o of i.dependencies??[]){let s=jo(o.kind)??o.kind.trim().toLowerCase(),a=o.source_kind?.trim();s===r&&Qg(e,a)&&n.push(`${i.id}->${o.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function ty(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let o=Reflect.get(i,"text");typeof o=="string"&&t.push(o)}}}return t}function ny(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function ds(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function ry(e){let t=new Map,n=new Set,r=[],i=/\b[a-z][a-z0-9]*-[a-z0-9]+\b/giu,o=0;for(let s of e){t.set(s.id.toLowerCase(),s.id);for(let a of s.dependencies??[])n.add(ds(s.id,a.id));for(let a of[s.parent,s.blocked_by])typeof a=="string"&&n.add(ds(s.id,a));for(let a of ty(s)){let c=[...a.matchAll(i)].map(l=>l[0]);o+=c.length,r.push({holder_id:s.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:o}}function iy(e,t){let n=ry(t.items),r=new Map;for(let s of n.prose_mentions){let a=s.mentioned_ids.map(l=>n.canonical_ids.get(l.toLowerCase())).filter(l=>l!==void 0&&l!==s.holder_id),c=[...new Set(a)];for(let l of c){let d=ds(s.holder_id,l);if(n.linked_pairs.has(d)||ny(e.exemptions??[],s.holder_id,l,s.segment))continue;let u=c.some(m=>m!==l);r.get(d)?.explicit===!0&&!u||r.set(d,{contributor:`${s.holder_id}->${l}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],o=i.map(s=>s.contributor).sort();return{value:o.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:o.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(s=>s.explicit).length,implicit_subject:i.filter(s=>!s.explicit).length}}}function oy(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function sy(e,t){let n=t.items.filter(r=>{let i=r[e.link],o=Array.isArray(i)&&i.length>0;return e.state==="present"?o:!o});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function ay(e,t){let n=e.source;return n.kind==="items"?Zg(n,t):n.kind==="dependency_kind"?ey(n,t):n.kind==="prose_edge_gap"?iy(n,t):n.kind==="history"?oy(n,t):n.kind==="links"?sy(n,t):null}function su(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function cy(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function au(e,t,n){let r=new Array(e.length),i=0,o=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let s=i;i+=1,r[s]=await n(e[s],s)}});return await Promise.all(o),r}async function cu(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let s=n.find(l=>l.id===e.measurement);if(!s)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await lu(s,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${s.id} is not numeric`);let c=i.charged.has(s.id)?[]:[a.cost];return i.charged.add(s.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let o=await au(e.operands,tu,s=>cu(s,t,n,r,i));return{value:cy(e.operator,o.map(s=>s.value)),costs:o.flatMap(s=>s.costs),population_size:Math.max(0,...o.map(s=>s.population_size)),contributors:[...new Set(o.flatMap(s=>s.contributors))]}}async function ly(e,t,n,r,i){ms(e);let o=Date.now(),s,a=[],c=0;if(e.source.kind==="derived"){let u=await cu(e.source.expression,t,n,[...r,e.id],i);s={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=ay(e,t);u!==null?s=u:(s=await t.external(e.source),c=1)}let l={units:s.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-o},d=su([...a,l],Date.now()-o);if(e.max_cost!==void 0&&d.units>e.max_cost)throw new Ae(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${d.units}`);return{id:e.id,definition_fingerprint:`sha256:${Fg("sha256").update(C(e)).digest("hex")}`,value:s.value,population_size:s.population_size,cost:d,contributors:s.contributors??[],...s.partitions?{partitions:s.partitions}:{}}}function lu(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let o=i.cache.get(e.id);if(o)return o;let s=ly(e,t,n,r,i).catch(a=>{if(a instanceof Qe&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},l=new Qe(a.message,c);throw l.cause=a,l}throw a});return i.cache.set(e.id,s),s}async function hs(e,t,n=[e]){return lu(e,t,n,[],{cache:new Map,charged:new Set})}function dy(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function uy(e,t,n={}){fs(e);let r=tr(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:dy(t.value,r),verdict:i?"retired":nu(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:ru(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function my(e,t,n,r){let i=Xg(e,t);if(i.size===0)return;let o=e.provider_policy,s=o?.triggers[r];if(!o||!s)throw new Ae(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(o.allowed_providers),c={low:0,medium:1,high:2};for(let l of i){if(!a.has(l))throw new Ae(`assurance gate ${e.id} refuses provider ${l}`);let d=n.provider_capabilities?.[l];if(!d)throw new Ae(`assurance provider ${l} has no declared capabilities`);if(c[d.cost_class]>c[s.max_cost_class])throw new Ae(`assurance gate ${e.id} refuses ${d.cost_class}-cost provider ${l} at trigger ${r}`);if(d.network&&!s.allow_network)throw new Ae(`assurance gate ${e.id} refuses network provider ${l} at trigger ${r}`)}}async function Qd(e,t,n,r,i){try{return await hs(n,r,i)}catch(o){if(o instanceof Qe){let s=o.check?` check ${o.check}`:"",a=o.measurement_id??n.id,c=new Ae(`assurance gate ${e} assertion ${t} measurement ${a} source ${o.source_kind}${s} field ${o.field} could not resolve: ${o.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:o.source_kind,field:o.field,...o.check?{check:o.check}:{}});throw c.cause=o,c}throw o}}async function du(e,t,n,r){bn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new Ae(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new Ae(`assurance gate ${e} does not declare trigger ${r.trigger}`);my(i,t,n,r.trigger);let o=await au(i.assertion_ids,tu,async c=>{let l=t.assertions.find(p=>p.id===c),d=t.measurements.find(p=>p.id===l.measurement_id),u=n;if(l.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(_=>!p.has(_.status))}}else if(l.scope.kind==="filter"){let p=l.scope.measurement_id,_=t.measurements.find(v=>v.id===p),h=await Qd(i.id,l.id,_,n,t.measurements),w=new Set(h.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===l.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return uy(l,await Qd(i.id,l.id,d,u,t.measurements),{owner_terminal:f})}),s=o.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=o.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:s?"block":a?"warn":"pass",exit_code:s?1:0,assertions:o,assertions_total:o.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:su(o.map(c=>c.cost),Math.max(0,...o.map(c=>c.cost.duration_ms)))}}function vi(e){return Ug.join(e,"assurance.json")}async function uu(e){let t=await V(vi(e));return t===null?nr():bi(t)}function bi(e){try{return bn(JSON.parse(e))}catch(t){throw new y("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",g.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function ki(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function fy(e,t){e==="measurement"?ms(t):e==="assertion"?fs(t):iu(t)}async function rr(e,t){let n=structuredClone(ki(await uu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function _s(e,t,n){let r=ki(await uu(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Si(e,t,n,r={}){fy(t,n);let i=await $(e),o=q(r.author,i.author_default),s=await hn({pmRoot:e,filePath:vi(e),op:`assurance:${t}:put`,author:o,message:r.message,lockTtlSeconds:yi,lockWaitMs:wi,mutate:a=>{let c=a===null?nr():bi(a),l=ki(c,t),d=l.findIndex(m=>m.id===n.id),u=d<0?"created":"updated";if(t==="assertion"&&d>=0&&Bg(l[d],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return d<0?l.push(structuredClone(n)):l[d]=structuredClone(n),bn(c),{raw:`${JSON.stringify(c,null,2)}
1
+ import{a as zo,c as Gr,d as qr,e as pl,g as hl,h as Wo,i as _l,j as an,k as cn,l as gl,m as yl,n as Go,o as bl,p as ln,q as dn,r as kl,s as Sl,t as qo}from"./chunk-IJUWEEEB.js";import{e as ei,f as Yo,h as Xo}from"./chunk-Q6DJ5DFQ.js";import{B as Ml,C as Xr,D as jl,E as Ko,G as Fl,H as Ul,J as zl,K as Zr,M as Qr,a as al,g as Uo,i as cl}from"./chunk-7O4NUJVO.js";import{K as Xd}from"./chunk-MHQ2XICU.js";import{D as ns,E as fi,Ha as Hd,Ia as Wd,Ma as Gd,Na as qd,T as pi,U as yd,V as rs,W as Qn,Y as is,aa as Td,ba as $d,ca as Od,da as Dd,ea as _i,f as ld,g as dd,ga as Pd,h as ud,ha as Nd,ia as Ld,ja as Gt,k as mi,ka as Md,kb as Jd,la as gn,ma as jd,mb as as,na as os,nb as Kd,o as Xn,oa as yn,ob as Yd,p as md,pa as Fd,q as fd,qa as Ud,r as Zn,ra as zd,s as pd,sa as ss,u as ts,v as hd,wb as cs,z as _d}from"./chunk-5GUSO2P4.js";import{a as dl,b as sn,c as Ho,d as ul,e as ml,f as at,g as Br,h as fl,i as St}from"./chunk-JMJK2L4Z.js";import{$ as Vl,$a as gd,Aa as rd,Ab as ne,Ba as id,Bb as Ne,Cb as Le,D as q,Da as pn,Db as Rd,E as Hl,Ea as Yn,Eb as _n,Fa as od,Fb as ct,Ga as si,Gb as Wt,H as xe,Ha as Ht,I as Zo,Ia as fe,Ja as ai,Jb as Cd,Ka as sd,Kb as lt,La as es,Ma as ci,Na as hn,O as Wl,Oa as li,P as ti,Pa as ad,S as ni,T as ri,Ta as Ie,V as Gl,W as Pe,Wa as cd,Xa as $,Y as xt,Ya as di,Yb as er,Z as ql,Za as ui,_ as Bl,_b as gi,aa as zt,ba as Jl,fc as Bd,ga as Kl,gb as wd,ha as Qo,hb as vd,ia as ii,ic as Vd,ja as mn,jb as bd,kb as kd,la as oi,lb as It,ma as Yl,mb as Sd,na as Xl,nb as Ed,pa as Zl,qb as xd,ra as Ql,rb as Id,ta as ed,va as td,wb as hi,xa as fn,ya as nd,yb as Ad}from"./chunk-ZLEN4HZD.js";import{b as rn,e as de,g as De,i as Ee,j as Xe,n as _e,o as wl,p as Vr,r as vl}from"./chunk-6XBRADQQ.js";import{$ as g,$a as Wr,$c as Nl,Aa as he,Ac as $l,Ba as Oe,Bb as Ye,Ca as Kc,Cc as Ol,Ea as te,Ha as Yc,Kc as H,La as Xc,Lb as ll,Nc as Z,Pc as We,Qb as Jr,Qc as Dl,Ra as Zc,Rb as El,Rc as Yr,S as Hc,Sa as Qc,Sb as Bo,T as Wc,Ta as G,Tb as Vo,Ub as Jo,V as Gc,Wb as xl,Wd as T,X as qc,Xb as Il,Xd as Ll,Y as Hr,Ya as Kn,Yc as Pl,Yd as un,Z as Bc,Za as N,Zc as Ze,Zd as Et,_a as Je,_b as Al,_d as Ut,a as Ur,aa as y,ab as Mt,cb as el,d as zr,db as jt,de as ce,fb as tl,fc as Rl,gb as nl,ha as Vc,hb as rl,i as Fc,ka as Jc,l as Uc,m as zc,ma as jo,pb as il,qb as Ft,ra as Jn,rb as C,sa as O,sb as ol,ta as kt,tb as Se,ua as z,va as V,vb as Fo,w as Mo,wb as sl,wc as Cl,xa as Q,xb as on,yc as Kr,zb as Ke,zc as Tl}from"./chunk-KG3H4UZZ.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="00d2200c-d308-51a6-acc4-8da90afaf6d6")}catch{}})();var L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},Ae=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Qe=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function wn(e){try{return await e()}catch(t){throw t instanceof L?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function Zd(e){try{return await e()}catch(t){throw t instanceof Ae?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Fg}from"node:crypto";import Ug from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b00dcab2-22c6-55b7-b93d-f6f5413d4b04")}catch{}})();var vn=1e3;(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="00ad9b34-4feb-5812-8755-801869cce3ad")}catch{}})();var eu=1,qt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],ls=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],zg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],Hg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,yi=30,wi=5e3,tu=4,Wg=50;function dt(e,t){if(!Hg.test(e))throw new L(`${t} must be a stable lowercase id`)}function Gg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function tr(e){let t=zg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function us(e,t){return C(e)===C(t)}function nu(e,t){if(t.polarity==="equals")return us(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function ru(e){let t=tr(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>nu(r.observed,t)===(r.expected==="pass"))}function qg(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!us(e.value,t.value)}function Bg(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||C(e.scope)!==C(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return qg(tr(e),tr(t))||n[t.enforcement]<n[e.enforcement]||r}function Vg(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new L("items source equals/state requires field")}function Jg(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function Kg(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function ms(e){dt(e.id,"measurement.id"),e.max_cost!==void 0&&Gg(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${ls.join(", ")}`);let n=Reflect.get(t,"kind");if(!ls.includes(n))throw new L(`measurement.source.kind must be one of ${ls.join(", ")}`);let r=t;if(r.kind==="items"&&Vg(r),r.kind==="dependency_kind"&&Jg(r),r.kind==="prose_edge_gap"&&Kg(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new L(`${r.kind} source requires field`);return r.kind==="provider"&&(dt(r.provider,"provider source provider"),dt(r.key,"provider source key")),e}function fs(e){if(dt(e.id,"assertion.id"),dt(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=tr(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&dt(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!ru(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Yg(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)dt(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!qt.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function iu(e){if(dt(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)dt(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${qt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!qt.includes(t))throw new L(`gate trigger must be one of ${qt.join(", ")}`);return e.provider_policy&&Yg(e.provider_policy),e}function bn(e){if(e.version!==eu)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(ms(r),t.has(`measurement:${r.id}`))throw new L(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(fs(r),t.has(`assertion:${r.id}`))throw new L(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){iu(r);let i=r.assertion_ids.filter(o=>!e.assertions.some(s=>s.id===o));if(i.length>0)throw new L(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new L(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of ou(e))if(!n.has(r))throw new L(`${i.join(", ")} references missing measurement ${r}`);return e}function ps(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)ps(n,t)}function ou(e){let t=new Map,n=(r,i)=>{let o=t.get(r)??[];o.push(i),t.set(r,o)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];ps(r.source.expression,i);for(let o of i)n(o,`derived measurement ${r.id}`)}return t}function Xg(e,t){let n=e.assertion_ids.flatMap(o=>{let s=t.assertions.find(a=>a.id===o);return[s.measurement_id,...s.scope.kind==="filter"?[s.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let o=n.pop();if(r.has(o))continue;r.add(o);let s=t.measurements.find(a=>a.id===o);s.source.kind==="provider"?i.add(s.source.provider):s.source.kind==="derived"&&ps(s.source.expression,n)}return i}function nr(){return{version:eu,measurements:[],assertions:[],gates:[]}}function Zg(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let o=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?o:!o}return us(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function Qg(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function ey(e,t){let n=[],r=jo(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let o of i.dependencies??[]){let s=jo(o.kind)??o.kind.trim().toLowerCase(),a=o.source_kind?.trim();s===r&&Qg(e,a)&&n.push(`${i.id}->${o.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function ty(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let o=Reflect.get(i,"text");typeof o=="string"&&t.push(o)}}}return t}function ny(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function ds(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function ry(e){let t=new Map,n=new Set,r=[],i=/\b[a-z][a-z0-9]*-[a-z0-9]+\b/giu,o=0;for(let s of e){t.set(s.id.toLowerCase(),s.id);for(let a of s.dependencies??[])n.add(ds(s.id,a.id));for(let a of[s.parent,s.blocked_by])typeof a=="string"&&n.add(ds(s.id,a));for(let a of ty(s)){let c=[...a.matchAll(i)].map(l=>l[0]);o+=c.length,r.push({holder_id:s.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:o}}function iy(e,t){let n=ry(t.items),r=new Map;for(let s of n.prose_mentions){let a=s.mentioned_ids.map(l=>n.canonical_ids.get(l.toLowerCase())).filter(l=>l!==void 0&&l!==s.holder_id),c=[...new Set(a)];for(let l of c){let d=ds(s.holder_id,l);if(n.linked_pairs.has(d)||ny(e.exemptions??[],s.holder_id,l,s.segment))continue;let u=c.some(m=>m!==l);r.get(d)?.explicit===!0&&!u||r.set(d,{contributor:`${s.holder_id}->${l}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],o=i.map(s=>s.contributor).sort();return{value:o.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:o.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(s=>s.explicit).length,implicit_subject:i.filter(s=>!s.explicit).length}}}function oy(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function sy(e,t){let n=t.items.filter(r=>{let i=r[e.link],o=Array.isArray(i)&&i.length>0;return e.state==="present"?o:!o});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function ay(e,t){let n=e.source;return n.kind==="items"?Zg(n,t):n.kind==="dependency_kind"?ey(n,t):n.kind==="prose_edge_gap"?iy(n,t):n.kind==="history"?oy(n,t):n.kind==="links"?sy(n,t):null}function su(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function cy(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function au(e,t,n){let r=new Array(e.length),i=0,o=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let s=i;i+=1,r[s]=await n(e[s],s)}});return await Promise.all(o),r}async function cu(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let s=n.find(l=>l.id===e.measurement);if(!s)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await lu(s,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${s.id} is not numeric`);let c=i.charged.has(s.id)?[]:[a.cost];return i.charged.add(s.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let o=await au(e.operands,tu,s=>cu(s,t,n,r,i));return{value:cy(e.operator,o.map(s=>s.value)),costs:o.flatMap(s=>s.costs),population_size:Math.max(0,...o.map(s=>s.population_size)),contributors:[...new Set(o.flatMap(s=>s.contributors))]}}async function ly(e,t,n,r,i){ms(e);let o=Date.now(),s,a=[],c=0;if(e.source.kind==="derived"){let u=await cu(e.source.expression,t,n,[...r,e.id],i);s={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=ay(e,t);u!==null?s=u:(s=await t.external(e.source),c=1)}let l={units:s.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-o},d=su([...a,l],Date.now()-o);if(e.max_cost!==void 0&&d.units>e.max_cost)throw new Ae(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${d.units}`);return{id:e.id,definition_fingerprint:`sha256:${Fg("sha256").update(C(e)).digest("hex")}`,value:s.value,population_size:s.population_size,cost:d,contributors:s.contributors??[],...s.partitions?{partitions:s.partitions}:{}}}function lu(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let o=i.cache.get(e.id);if(o)return o;let s=ly(e,t,n,r,i).catch(a=>{if(a instanceof Qe&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},l=new Qe(a.message,c);throw l.cause=a,l}throw a});return i.cache.set(e.id,s),s}async function hs(e,t,n=[e]){return lu(e,t,n,[],{cache:new Map,charged:new Set})}function dy(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function uy(e,t,n={}){fs(e);let r=tr(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:dy(t.value,r),verdict:i?"retired":nu(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:ru(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function my(e,t,n,r){let i=Xg(e,t);if(i.size===0)return;let o=e.provider_policy,s=o?.triggers[r];if(!o||!s)throw new Ae(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(o.allowed_providers),c={low:0,medium:1,high:2};for(let l of i){if(!a.has(l))throw new Ae(`assurance gate ${e.id} refuses provider ${l}`);let d=n.provider_capabilities?.[l];if(!d)throw new Ae(`assurance provider ${l} has no declared capabilities`);if(c[d.cost_class]>c[s.max_cost_class])throw new Ae(`assurance gate ${e.id} refuses ${d.cost_class}-cost provider ${l} at trigger ${r}`);if(d.network&&!s.allow_network)throw new Ae(`assurance gate ${e.id} refuses network provider ${l} at trigger ${r}`)}}async function Qd(e,t,n,r,i){try{return await hs(n,r,i)}catch(o){if(o instanceof Qe){let s=o.check?` check ${o.check}`:"",a=o.measurement_id??n.id,c=new Ae(`assurance gate ${e} assertion ${t} measurement ${a} source ${o.source_kind}${s} field ${o.field} could not resolve: ${o.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:o.source_kind,field:o.field,...o.check?{check:o.check}:{}});throw c.cause=o,c}throw o}}async function du(e,t,n,r){bn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new Ae(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new Ae(`assurance gate ${e} does not declare trigger ${r.trigger}`);my(i,t,n,r.trigger);let o=await au(i.assertion_ids,tu,async c=>{let l=t.assertions.find(p=>p.id===c),d=t.measurements.find(p=>p.id===l.measurement_id),u=n;if(l.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(_=>!p.has(_.status))}}else if(l.scope.kind==="filter"){let p=l.scope.measurement_id,_=t.measurements.find(v=>v.id===p),h=await Qd(i.id,l.id,_,n,t.measurements),w=new Set(h.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===l.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return uy(l,await Qd(i.id,l.id,d,u,t.measurements),{owner_terminal:f})}),s=o.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=o.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:s?"block":a?"warn":"pass",exit_code:s?1:0,assertions:o,assertions_total:o.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:su(o.map(c=>c.cost),Math.max(0,...o.map(c=>c.cost.duration_ms)))}}function vi(e){return Ug.join(e,"assurance.json")}async function uu(e){let t=await V(vi(e));return t===null?nr():bi(t)}function bi(e){try{return bn(JSON.parse(e))}catch(t){throw new y("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",g.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function ki(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function fy(e,t){e==="measurement"?ms(t):e==="assertion"?fs(t):iu(t)}async function rr(e,t){let n=structuredClone(ki(await uu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function _s(e,t,n){let r=ki(await uu(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Si(e,t,n,r={}){fy(t,n);let i=await $(e),o=q(r.author,i.author_default),s=await hn({pmRoot:e,filePath:vi(e),op:`assurance:${t}:put`,author:o,message:r.message,lockTtlSeconds:yi,lockWaitMs:wi,mutate:a=>{let c=a===null?nr():bi(a),l=ki(c,t),d=l.findIndex(m=>m.id===n.id),u=d<0?"created":"updated";if(t==="assertion"&&d>=0&&Bg(l[d],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return d<0?l.push(structuredClone(n)):l[d]=structuredClone(n),bn(c),{raw:`${JSON.stringify(c,null,2)}
2
2
  `,result:{changed:!0,action:u,kind:t,id:n.id}}}});return{...s.result,changed:s.changed}}async function gs(e,t,n={}){let r=nr();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),bn(r);let i=await $(e),o=q(n.author,i.author_default),s=await hn({pmRoot:e,filePath:vi(e),op:"assurance:bundle:apply",author:o,message:n.message,lockTtlSeconds:yi,lockWaitMs:wi,mutate:a=>{let c=a===null?nr():bi(a),l=[],d=[],u=(m,f,p)=>{for(let _ of f){let h=m.find(w=>w.id===_.id);if(!h){m.push(structuredClone(_)),l.push(`${p}:${_.id}`);continue}if(C(h)!==C(_))throw new L(`assurance bundle refuses to replace divergent ${p} ${_.id}`);d.push(`${p}:${_.id}`)}};return u(c.measurements,r.measurements,"measurement"),u(c.assertions,r.assertions,"assertion"),u(c.gates,r.gates,"gate"),bn(c),{raw:`${JSON.stringify(c,null,2)}
3
3
  `,result:{changed:l.length>0,created_ids:l,unchanged_ids:d}}}});return{...s.result,changed:s.changed}}async function mu(e,t,n,r={}){let i=await $(e),o=q(r.author,i.author_default),s=await hn({pmRoot:e,filePath:vi(e),op:`assurance:${t}:remove`,author:o,message:r.message,lockTtlSeconds:yi,lockWaitMs:wi,mutate:a=>{let c=a===null?nr():bi(a);if(t==="measurement"){let u=ou(c).get(n);if(u&&u.length>0)throw new L(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new L(`assurance assertion ${n} is referenced by gate`);let l=ki(c,t),d=l.findIndex(u=>u.id===n);if(d<0)throw new L(`assurance ${t} ${n} not found`);return l.splice(d,1),bn(c),{raw:`${JSON.stringify(c,null,2)}
4
4
  `,result:{changed:!0,action:"removed",kind:t,id:n}}}});return{...s.result,changed:s.changed}}async function fu(e,t,n={}){if(t.dry_run)throw new TypeError("dry-run assurance verdicts are not persisted");let r=await $(e);await ci({pmRoot:e,op:"assurance:gate:verdict",author:q(n.author,r.author_default),context:{assurance_verdict:t},message:n.message??`Assurance gate ${t.gate_id} returned ${t.verdict}`,lockTtlSeconds:yi,lockWaitMs:wi})}async function pu(e,t={}){let n=t.limit??Wg;if(!Number.isInteger(n)||n<1||n>vn)throw new TypeError(`assurance verdict limit must be an integer from 1 through ${vn}`);return(await zt(ai(e),fe)).reverse().filter(i=>i.op==="assurance:gate:verdict").map(i=>i.context?.assurance_verdict).filter(i=>typeof i=="object"&&i!==null&&"gate_id"in i).filter(i=>t.gate_id===void 0||i.gate_id===t.gate_id).slice(0,n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0daf7c89-abc5-5c35-ba3f-9772a50408c0")}catch{}})();var ir={type:"string",minLength:1,maxLength:128,pattern:"\\S"},Ei={type:"array",minItems:1,maxItems:Bo,items:ir},hu={...Ei,items:{...ir,pattern:"^(?!(?:.*\\.)?(?:__proto__|constructor|prototype)(?:\\.|$))[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$"}},py={type:"object",additionalProperties:!1,required:["id","rule"],properties:{id:{type:"string",minLength:1,maxLength:128,pattern:"^[a-zA-Z0-9][a-zA-Z0-9._-]*$"},description:{type:"string",minLength:1,maxLength:500,pattern:"\\S"},effect:{enum:["advise","warn","refuse"]},subject:{type:"object",additionalProperties:!1,properties:{...Object.fromEntries(["types","tags","statuses","operations","parents"].map(e=>[e,Ei])),dependency:{type:"object",additionalProperties:!1,required:["kind"],properties:{kind:ir,id:ir}}}},rule:{oneOf:[{type:"object",additionalProperties:!1,required:["kind","fields"],properties:{kind:{const:"require_fields"},fields:hu}},{type:"object",additionalProperties:!1,required:["kind","authors"],properties:{kind:{const:"authors"},authors:Ei}},...["field_writers","approval"].map(e=>({type:"object",additionalProperties:!1,required:["kind","fields","authors"],properties:{kind:{const:e},fields:hu,authors:Ei}})),{type:"object",additionalProperties:!1,required:["kind","allowed"],properties:{kind:{const:"transition"},allowed:{type:"array",maxItems:Bo,items:{type:"array",minItems:2,maxItems:2,items:ir}}}}]}}},GT={$schema:"https://json-schema.org/draft/2020-12/schema",title:"pm workflow policy registry",type:"object",additionalProperties:!1,required:["version","policies"],properties:{version:{const:1},enforcement:{enum:["advise","refuse"],default:"advise"},policies:{type:"array",maxItems:El,items:py}}};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="42dee0a5-d003-5e44-8b2d-d74a23d3f2ce")}catch{}})();async function _u(e,t,n,r){let i=await It(e).catch(()=>null);return i===null?{check:{name:"completeness",status:"error",ok:!1,details:{policy_registry_readable:!1,policy_registry_path:"schema/policies.json",remediation_hint:"Repair schema/policies.json, then rerun pm validate."}},warnings:["validate_completeness_policy_registry_unreadable"]}:gu(i,t,n,r)}function hy(e,t,n){return e===0?"undeclared":t===0?"empty":n===0?"inapplicable":n===t?"covered":"partial"}function gu(e,t,n=5,r=!1){let i=[],o=new Map,s=e.policies.filter(h=>h.rule.kind==="require_fields"),a=s.filter(h=>h.subject?.operations===void 0),c=new Set,l=0,d=0,u=0,m=0,f=0,p=Al(e);for(let h of t){let w=p({operation:"",author:"",before:h,after:h,completeness_only:!0});l+=+(w.decisions.length>0),d+=w.decisions.length,w.decisions.forEach(S=>c.add(S.policy_id));let v=w.decisions.filter(S=>!S.satisfied);if(v.length===0)continue;m+=1;let k=o.get(h.type)??{items:0,violations:0,missing_fields:0};k.items+=1;for(let S of v)u+=1,k.violations+=1,k.missing_fields+=S.missing_fields.length,S.effect==="refuse"&&(f+=1),i.length<n&&i.push({id:h.id,type:h.type,status:h.status,decision:S});o.set(h.type,k)}let _=r||f>0?"error":u>0?"warn":"ok";return{check:{name:"completeness",status:_,ok:_==="ok",details:{scope:"operation_independent_require_fields",declared_requirement_count:s.length,state_requirement_count:a.length,applicable_requirement_count:c.size,requirement_application_count:d,governed_items:l,ungoverned_items:t.length-l,contract_status:hy(s.length,t.length,l),applied_policy_ids:[...c].sort().slice(0,Math.max(0,n)),applied_policy_ids_truncated:c.size>Math.max(0,n),checked_items:t.length,incomplete_items:m,violation_count:u,refused_violations:f,missing_by_type:Object.fromEntries(o),violations:i,violations_truncated:i.length<u,enforcement:e.enforcement}},warnings:[...u>0?[`validate_completeness_missing_fields:${u}`]:[],...r?["validate_completeness_source_incomplete"]:[]]}}import _y from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f54fe358-8f4c-5bf4-ae2a-9c92cd08c953")}catch{}})();function gy(){return{version:1,enforcement:"advise",policies:[...[["Epic",["goal","objective","body"]],["Story",["description","value","acceptance_criteria"]],["Decision",["body","resolution"]],["Feature",["acceptance_criteria","expected_result"]],["Task",["description"]],["Issue",["repro_steps","expected_result"]],["Chore",["description"]]].map(([t,n])=>({id:`completeness-${t.toLowerCase()}`,effect:"advise",description:`Evidence expected when ${t} work reaches completion.`,subject:{types:[t],statuses:["closed"]},rule:{kind:"require_fields",fields:[...n]}})),{id:"completeness-resolution",effect:"advise",subject:{statuses:["closed"]},rule:{kind:"require_fields",fields:["resolution","expected_result","actual_result"]}}]}}function vu(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{throw new y("Policy definition must be valid JSON.",g.USAGE)}if(typeof t!="object"||t===null||Array.isArray(t))throw new y("Policy definition must be an object.",g.USAGE);return t}async function yy(e,t){let n=N(process.cwd(),e.path);await ne(n);let r=await $(n);return{pmRoot:n,settings:r,author:q(t,r.author_default)}}function yu(e,t,n,r){if(e==="policy-mode")return Jo({...n,enforcement:t});let i=n.policies.filter(a=>a.id!==t);if(e==="policy-remove")return{...n,policies:i};let o=Vo(r.definition),s=Jo({...n,policies:[...i,o].sort((a,c)=>a.id.localeCompare(c.id))});if(Buffer.byteLength(`${JSON.stringify(s,null,2)}
@@ -72,4 +72,4 @@ ${o}`,g.GENERIC_FAILURE)}}function Po(e){return typeof e.tag=="string"&&e.tag.tr
72
72
  `);le(e.progressEnabled,"writing keyword artifacts"),await Q(t,`${JSON.stringify(e.manifest,null,2)}
73
73
  `),await Q(n,`${i}
74
74
  `);let o=[];if(e.mode!=="keyword")try{le(e.progressEnabled,"writing vectorization status ledger"),await Fd(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(s){o.push(`search_vectorization_status_ledger_write_failed:${s instanceof Error?s.message:String(s)}`)}return o}async function c2(e,t){let n=lT(e.mode),r=cT(e),i=e.full===!0;le(r,`start mode=${n}`);let o=N(process.cwd(),t.path);await ne(o);let s=pi(await $(o)).settings,a=null;try{a=await ce(o,yd,s.locks.ttl_seconds,q(void 0,"pm-reindex"),!1,s.governance.force_required_for_stale_lock,s.locks.wait_ms)}catch(c){throw c instanceof y&&c.exitCode===g.CONFLICT?new y("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",g.CONFLICT,{code:"reindex_already_running",type:"urn:pm-cli:error:reindex_already_running",why:"Semantic reindex can be expensive and duplicate runs compete for the same local embedding model and vector store.",nextSteps:["Check active pm reindex processes before starting another reindex.","Rerun with --progress when you need non-interactive visibility."]}):c}try{let c=mT(s),l=fT(s),d=wT({requestedMode:n,pmRoot:o,settings:s,extensionEmbedding:c,extensionVectorAdapter:l}),u=n;le(r,"loading item corpus");let m=await vT({pmRoot:o,settings:s}),f=m.warnings,{documentCandidates:p,metadataDocuments:_}=m;le(r,`loaded_items=${_.length}`);let h=T(),w=yT(u,h,_),v=Fr.join(o,Pc),k=Fr.join(o,Nc),S=u==="keyword"?await Mc(o,p,s.schema,f):_,x=[],R={},E=null,b=gT(u);if(u==="keyword"&&await bT({pmRoot:o,settings:s,forceFullSemantic:i,extensionEmbedding:c,reindexWarnings:f}),u!=="keyword"){let F=await RT({pmRoot:o,settings:s,requestedMode:n,activeEmbeddingProvider:d.activeEmbeddingProvider,activeVectorStore:d.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:l,documentCandidates:p,metadataDocuments:_,documentsForKeywordArtifacts:S,forceFullSemantic:i,reindexWarnings:f,semanticWarnings:x,semanticSummary:b,progressEnabled:r});S=F.documentsForKeywordArtifacts,R=F.vectorizationLedgerEntries,E=F.vectorizationEmbeddingMetadata}let j=await CT({pmRoot:o,mode:u,manifest:w,documentsForKeywordArtifacts:S,settings:s,vectorizationLedgerEntries:R,vectorizationEmbeddingMetadata:E,progressEnabled:r}),I=[...await Z({path:v,scope:"project",op:"reindex:manifest"}),...await Z({path:k,scope:"project",op:"reindex:embeddings"}),...await Yr({mode:u,total_items:_.length})];return le(r,"done"),{ok:!0,mode:u,total_items:_.length,semantic:b,artifacts:{manifest:Pc,embeddings:Nc},warnings:[...f,...x,...j,...I],generated_at:h}}finally{await a?.()}}export{L as a,Ae as b,Qe as c,wn as d,Zd as e,eu as f,qt as g,ls as h,Bg as i,ms as j,fs as k,iu as l,bn as m,nr as n,hs as o,uy as p,du as q,rr as r,_s as s,Si as t,gs as u,mu as v,fu as w,pu as x,Ym as y,CD as z,rv as A,iv as B,tt as C,cP as D,xv as E,py as F,GT as G,gu as H,gy as I,d$ as J,fb as K,mN as L,hN as M,_N as N,hr as O,gN as P,yN as Q,wN as R,vN as S,bN as T,kN as U,SN as V,EN as W,xN as X,IN as Y,AN as Z,pp as _,va as $,iD as aa,mm as ba,Ai as ca,H$ as da,D as ea,se as fa,W$ as ga,vs as ha,G$ as ia,q$ as ja,Ru as ka,B$ as la,V$ as ma,J$ as na,Py as oa,K$ as pa,Y$ as qa,bs as ra,X$ as sa,Z$ as ta,ws as ua,Q$ as va,eO as wa,Tu as xa,tO as ya,Ly as za,Du as Aa,uO as Ba,ar as Ca,mO as Da,Wy as Ea,Gy as Fa,fO as Ga,qy as Ha,f_ as Ia,yO as Ja,Uu as Ka,h_ as La,Nz as Ma,Lz as Na,cr as Oa,Ti as Pa,Hu as Qa,Wu as Ra,Gu as Sa,qu as Ta,Ku as Ua,Xu as Va,Zu as Wa,tm as Xa,Pt as Ya,Vj as Za,Jj as _a,Kj as $a,Yj as ab,aF as bb,th as cb,La as db,AF as eb,yt as fb,RF as gb,CF as hb,tI as ib,oI as jb,hh as kb,uw as lb,rm as mb,Ua as nb,k1 as ob,S1 as pb,Oi as qb,Di as rb,Uh as sb,bU as tb,zh as ub,Wh as vb,Gh as wb,Vh as xb,Kh as yb,RR as zb,CR as Ab,Uz as Bb,zz as Cb,Hz as Db,Wz as Eb,$R as Fb,OR as Gb,DR as Hb,Gz as Ib,y_ as Jb,NR as Kb,w_ as Lb,sc as Mb,b_ as Nb,LR as Ob,MR as Pb,jR as Qb,dc as Rb,uc as Sb,eH as Tb,tH as Ub,nH as Vb,p0 as Wb,oW as Xb,cg as Yb,Lr as Zb,ug as _b,mg as $b,fg as ac,Ic as bc,kC as cc,UW as dc,lG as ec,gG as fc,xg as gc,Ig as hc,Ag as ic,zG as jc,e2 as kc,t2 as lc,n2 as mc,c2 as nc};
75
- //# sourceMappingURL=chunk-73DA7ISY.js.map
75
+ //# sourceMappingURL=chunk-RJV6QVJE.js.map