@unbrained/pm-cli 2026.10.8 → 2026.10.10
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 +2 -2
- package/CHANGELOG.md +36 -0
- package/dist/cli/register-list-query.js +2 -2
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +150 -150
- package/dist/cli-bundle/chunks/{chunk-MJVRF67I.js → chunk-2JYTSTQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UGFN5NJ2.js → chunk-BXSXT5Z6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HFCIAXLP.js → chunk-ESRACL6K.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-34L2BS2Z.js → chunk-K2UTE75T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZHIMZ65M.js → chunk-KNW3RSLS.js} +30 -30
- package/dist/cli-bundle/chunks/chunk-MEWBSWE3.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-RCFZ6H2Y.js → chunk-OBLO45UM.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FOLSEOJ2.js → chunk-RBPOO46D.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TNU56MZI.js → chunk-RUT3CCAG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-K6E2FFUT.js → chunk-S445XEYT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZBVAZ7XX.js → chunk-SSY4OSJR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OG66KEOF.js → chunk-YMLF6QT7.js} +75 -79
- package/dist/cli-bundle/chunks/{chunk-L7U5FSZ5.js → chunk-ZWRLAOA4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-PYVSPGPV.js → register-list-query-T6BOR67M.js} +7 -7
- package/dist/cli-bundle/chunks/register-mutation-6NXR7SAJ.js +20 -0
- package/dist/cli-bundle/chunks/{register-operations-WL25C3NP.js → register-operations-PDOBQZUJ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-PFKYNEQI.js → register-setup-MAYFPKBX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6TKAFFEB.js → chunk-2CJWTLQG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EOUORVJA.js → chunk-52UJEHEV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-V3EPBB6V.js → chunk-AU6VJGTY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-L3CZNKZE.js → chunk-B3YW6H2I.js} +16 -20
- package/dist/cli-bundle/focused-chunks/{chunk-XT7JAVHI.js → chunk-DMSADMEU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-A3W6HFFO.js → chunk-EIOQNLBQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OLCJ2PJS.js → chunk-GVGFUD52.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2KSPGWLH.js → chunk-JGFSSR3G.js} +16 -16
- package/dist/cli-bundle/focused-chunks/{chunk-MW2TQHZ3.js → chunk-KNJR2WUO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MJQ253F3.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-F2ME5MJY.js → chunk-PBCYGO7X.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PBPPIGUL.js → chunk-PLTTMQAW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SIEGIPNT.js +165 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DRHJOG5X.js → chunk-W5AE7GKZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LZQGEVKT.js → chunk-WAOXID5J.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BDT5EALU.js → chunk-WOEZJUA2.js} +2 -2
- package/dist/cli-bundle/main.js +2 -2
- 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 +22 -22
- 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 +50 -50
- 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 +9 -9
- package/dist/core/history/event-index.d.ts +1 -2
- package/dist/core/history/event-index.js +2 -2
- package/dist/core/item/item-format.d.ts +2 -0
- package/dist/core/item/item-format.js +3 -3
- package/dist/core/output/output.d.ts +16 -14
- package/dist/core/output/output.js +6 -10
- package/dist/core/schema/runtime-field-values.d.ts +2 -2
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/store/item-format-migration.js +1 -1
- package/dist/core/store/item-metadata-query-index.d.ts +1 -2
- package/dist/core/store/item-metadata-query-index.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/sqlite-runtime.d.ts +15 -0
- package/dist/core/store/sqlite-runtime.js +2 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/governance/reliability.d.ts +74 -0
- package/dist/sdk/governance/reliability.js +2 -0
- package/dist/sdk/governance.d.ts +1 -0
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/output/table-rows.d.ts +37 -0
- package/dist/sdk/output/table-rows.js +2 -0
- package/dist/sdk/output.d.ts +1 -0
- package/dist/sdk/output.js +2 -2
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output-contracts.d.ts +3 -3
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/structured-mutations.d.ts +5 -1
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/test/workspace-snapshot.d.ts +1 -1
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/docs/AGENT_OUTPUT_ENCODINGS.md +119 -0
- package/docs/PACKAGE_GATE_ACCEPTANCE.md +56 -0
- package/docs/QUALITY_EVIDENCE.md +52 -1
- package/docs/README.md +2 -0
- package/docs/RELEASE_RELIABILITY.md +54 -3
- package/docs/SDK.md +16 -2
- package/docs/TESTING.md +47 -3
- package/docs/agent-task-token-baseline.json +15 -14
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
- package/marketplace.json +2 -2
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +2 -2
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +2 -2
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +2 -2
- package/dist/cli-bundle/chunks/chunk-JDTBPW4Y.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-WXP3YLIN.js +0 -20
- package/dist/cli-bundle/focused-chunks/chunk-OSKXYRYZ.js +0 -165
- package/dist/cli-bundle/focused-chunks/chunk-PEBOVLEG.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as za,c as Gr,d as qr,e as yd,g as wd,h as Ga,i as vd,j as sn,k as cn,l as bd,m as kd,n as qa,o as xd,p as dn,q as ln,r as Ad,s as Id,t as Ba}from"./chunk-DRHJOG5X.js";import{e as ei,f as Xa,h as Za}from"./chunk-LZQGEVKT.js";import{B as Hd,C as Xr,D as zd,E as Ya,G as Wd,H as Gd,J as qd,K as Zr,M as Qr,a as ud,g as Ha,i as md}from"./chunk-6TKAFFEB.js";import{K as tu}from"./chunk-EOUORVJA.js";import{D as ro,E as pi,Ha as Bl,Ia as Vl,Ma as Jl,Na as Kl,T as fi,U as kl,V as io,W as Kn,Y as ao,aa as Pl,ba as Nl,ca as Ll,da as Ml,ea as gi,f as pl,g as fl,ga as jl,h as hl,ha as Fl,ia as Ul,ja as qt,k as mi,ka as Hl,kb as Zl,la as hn,ma as zl,mb as co,na as oo,nb as Ql,o as Vn,oa as _n,ob as eu,p as _l,pa as Wl,q as gl,qa as Gl,r as Jn,ra as ql,s as yl,sa as so,u as no,v as wl,wb as lo,z as vl}from"./chunk-2KSPGWLH.js";import{a as fd,b as on,c as Wa,d as hd,e as _d,f as ot,g as Br,h as gd,i as xt}from"./chunk-PBPPIGUL.js";import{$ as Xd,$a as bl,Aa as sl,Ab as ne,Ba as cl,Bb as ve,Cb as be,D as G,Da as Rt,Db as Ol,E as Bd,Ea as Bn,Eb as _i,Fa as dl,Fb as ct,Ga as oi,Gb as dt,H as Ce,Ha as Gt,I as Qa,Ia as ce,Ja as si,Jb as Dl,Ka as ll,Kb as lt,La as to,Ma as ci,Na as fn,O as Vd,Oa as di,P as ti,Pa as ul,S as ni,T as ri,Ta as Te,V as Jd,W as Me,Wa as ml,Xa as T,Y as It,Ya as li,Yb as Yn,Z as Kd,Za as ui,_ as Yd,_b as yi,aa as st,ba as Zd,fc as Yl,ga as Qd,gb as Sl,ha as eo,hb as El,ia as ii,ic as Xl,ja as mn,jb as xl,kb as Al,la as ai,lb as Ct,ma as el,mb as Il,na as tl,nb as Rl,pa as nl,qb as Cl,ra as rl,rb as Tl,ta as il,va as al,wb as hi,xa as pn,ya as ol,yb as $l}from"./chunk-OSKXYRYZ.js";import{b as rn,e as le,g as Le,i as Re,j as Ke,n as ge,o as Sd,p as Vr,r as Ed}from"./chunk-F2ME5MJY.js";import{$ as g,$a as L,$c as Ye,$d as At,Ac as Kr,Ba as fe,Bb as Ve,Bc as Pd,Ca as Ne,Cc as Nd,Da as Qc,Db as Je,Ec as Ld,Fa as ee,Ia as ed,Mc as H,Na as td,Nb as pd,Pc as X,Rc as He,S as Bc,Sb as Jr,Sc as Md,T as Vc,Ta as nd,Tb as Rd,Tc as Yr,Ua as rd,Ub as Va,V as Jc,Va as W,Vb as Ja,Wb as Ka,X as Kc,Y as zr,Yb as Cd,Yd as $,Z as Yc,Zb as Td,Zd as Ud,_a as qn,_c as jd,_d as un,a as Ur,aa as y,ab as Be,ac as $d,ae as Wt,bb as Wr,bd as Fd,cb as Ut,d as Hr,eb as id,fb as Ht,fe as te,ha as Xc,hb as ad,hc as Od,i as Wc,ib as od,jb as sd,ka as Zc,l as Gc,m as qc,ma as Fa,ra as Gn,rb as cd,sa as O,sb as zt,ta as Et,tb as C,ua as F,ub as dd,va as V,vb as Ie,w as ja,xb as Ua,ya as Z,yb as ld,yc as Dd,zb as an}from"./chunk-L3CZNKZE.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]="081bf1eb-4b9a-5fa9-a272-34ae781d250c")}catch{}})();var M=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},$e=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Xe=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 gn(e){try{return await e()}catch(t){throw t instanceof M?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function nu(e){try{return await e()}catch(t){throw t instanceof $e?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Kg}from"node:crypto";import Yg 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 yn=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]="416aaf09-e4f6-5d10-aee0-eba374f1cd83")}catch{}})();var iu=1,Bt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],uo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],Xg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],Zg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,wi=30,vi=5e3,au=4,Qg=50;function ut(e,t){if(!Zg.test(e))throw new M(`${t} must be a stable lowercase id`)}function ey(e,t){if(!Number.isFinite(e)||e<0)throw new M(`${t} must be a finite non-negative number`)}function Xn(e){let t=Xg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new M(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function po(e,t){return C(e)===C(t)}function ou(e,t){if(t.polarity==="equals")return po(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 su(e){let t=Xn(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>ou(r.observed,t)===(r.expected==="pass"))}function ty(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!po(e.value,t.value)}function ny(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 ty(Xn(e),Xn(t))||n[t.enforcement]<n[e.enforcement]||r}function ry(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new M("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 M("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new M("items source equals/state requires field")}function iy(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new M("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(t=>t!==void 0).length>1)throw new M("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 M("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 M("dependency_kind source source_kind_state must be present or missing")}function ay(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new M("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 M("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 M("prose_edge_gap exemption selectors must not be empty")}}function fo(e){ut(e.id,"measurement.id"),e.max_cost!==void 0&&ey(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let n=Reflect.get(t,"kind");if(!uo.includes(n))throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let r=t;if(r.kind==="items"&&ry(r),r.kind==="dependency_kind"&&iy(r),r.kind==="prose_edge_gap"&&ay(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new M(`${r.kind} source requires field`);return r.kind==="provider"&&(ut(r.provider,"provider source provider"),ut(r.key,"provider source key")),e}function ho(e){if(ut(e.id,"assertion.id"),ut(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new M("assertion.owner_item_id is required");let t=Xn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new M(`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 M("retired assertion requires retire_reason");e.scope.kind==="filter"&&ut(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 M("assertion negative control requires pass and fail cases");if(!su(e))throw new M(`assertion ${e.id} negative control does not prove its bound`);return e}function oy(e){if(!Array.isArray(e.allowed_providers))throw new M("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)ut(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new M("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Bt.includes(t))throw new M(`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 M(`gate provider policy trigger ${t} is invalid`)}}function cu(e){if(ut(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new M("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new M("gate requires at least one assertion");for(let t of e.assertion_ids)ut(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new M(`gate.triggers is required and must be an array of ${Bt.join(", ")}`);if(e.triggers.length===0)throw new M("gate requires at least one trigger");for(let t of e.triggers)if(!Bt.includes(t))throw new M(`gate trigger must be one of ${Bt.join(", ")}`);return e.provider_policy&&oy(e.provider_policy),e}function wn(e){if(e.version!==iu)throw new M(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(fo(r),t.has(`measurement:${r.id}`))throw new M(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(ho(r),t.has(`assertion:${r.id}`))throw new M(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){cu(r);let i=r.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(i.length>0)throw new M(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new M(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of du(e))if(!n.has(r))throw new M(`${i.join(", ")} references missing measurement ${r}`);return e}function _o(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)_o(n,t)}function du(e){let t=new Map,n=(r,i)=>{let a=t.get(r)??[];a.push(i),t.set(r,a)};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=[];_o(r.source.expression,i);for(let a of i)n(a,`derived measurement ${r.id}`)}return t}function sy(e,t){let n=e.assertion_ids.flatMap(a=>{let o=t.assertions.find(s=>s.id===a);return[o.measurement_id,...o.scope.kind==="filter"?[o.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let a=n.pop();if(r.has(a))continue;r.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?i.add(o.source.provider):o.source.kind==="derived"&&_o(o.source.expression,n)}return i}function Zn(){return{version:iu,measurements:[],assertions:[],gates:[]}}function cy(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 a=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?a:!a}return po(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function dy(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 ly(e,t){let n=[],r=Fa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let a of i.dependencies??[]){let o=Fa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===r&&dy(e,s)&&n.push(`${i.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function uy(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 a=Reflect.get(i,"text");typeof a=="string"&&t.push(a)}}}return t}function my(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 mo(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function py(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,a=0;for(let o of e){t.set(o.id.toLowerCase(),o.id);for(let s of o.dependencies??[])n.add(mo(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(mo(o.id,s));for(let s of uy(o)){let c=[...s.matchAll(i)].map(d=>d[0]);a+=c.length,r.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:a}}function fy(e,t){let n=py(t.items),r=new Map;for(let o of n.prose_mentions){let s=o.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==o.holder_id),c=[...new Set(s)];for(let d of c){let l=mo(o.holder_id,d);if(n.linked_pairs.has(l)||my(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],a=i.map(o=>o.contributor).sort();return{value:a.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:a.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(o=>o.explicit).length,implicit_subject:i.filter(o=>!o.explicit).length}}}function hy(e,t){return{value:t.history.filter(n=>(e.op===void 0||n.op===e.op)&&(e.author===void 0||n.author===e.author)&&(e.harness===void 0||n.agent_harness===e.harness)&&(e.model===void 0||n.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function _y(e,t){let n=t.items.filter(r=>{let i=r[e.link],a=Array.isArray(i)&&i.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function gy(e,t){let n=e.source;return n.kind==="items"?cy(n,t):n.kind==="dependency_kind"?ly(n,t):n.kind==="prose_edge_gap"?fy(n,t):n.kind==="history"?hy(n,t):n.kind==="links"?_y(n,t):null}function lu(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 yy(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 uu(e,t,n){let r=new Array(e.length),i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let o=i;i+=1,r[o]=await n(e[o],o)}});return await Promise.all(a),r}async function mu(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let o=n.find(d=>d.id===e.measurement);if(!o)throw new TypeError(`derived measurement references missing ${e.measurement}`);let s=await pu(o,t,n,r,i);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=i.charged.has(o.id)?[]:[s.cost];return i.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await uu(e.operands,au,o=>mu(o,t,n,r,i));return{value:yy(e.operator,a.map(o=>o.value)),costs:a.flatMap(o=>o.costs),population_size:Math.max(0,...a.map(o=>o.population_size)),contributors:[...new Set(a.flatMap(o=>o.contributors))]}}async function wy(e,t,n,r,i){fo(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await mu(e.source.expression,t,n,[...r,e.id],i);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=gy(e,t);u!==null?o=u:(o=await t.external(e.source),c=1)}let d={units:o.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()-a},l=lu([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new $e(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${Kg("sha256").update(C(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function pu(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let a=i.cache.get(e.id);if(a)return a;let o=wy(e,t,n,r,i).catch(s=>{if(s instanceof Xe&&s.measurement_id===void 0){let c={measurement_id:e.id,source_kind:s.source_kind,field:s.field,...s.check?{check:s.check}:{}},d=new Xe(s.message,c);throw d.cause=s,d}throw s});return i.cache.set(e.id,o),o}async function go(e,t,n=[e]){return pu(e,t,n,[],{cache:new Map,charged:new Set})}function vy(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,e-t.value)}function by(e,t,n={}){ho(e);let r=Xn(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:vy(t.value,r),verdict:i?"retired":ou(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:su(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function ky(e,t,n,r){let i=sy(e,t);if(i.size===0)return;let a=e.provider_policy,o=a?.triggers[r];if(!a||!o)throw new $e(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!s.has(d))throw new $e(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new $e(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new $e(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!o.allow_network)throw new $e(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function ru(e,t,n,r,i){try{return await go(n,r,i)}catch(a){if(a instanceof Xe){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new $e(`assurance gate ${e} assertion ${t} measurement ${s} source ${a.source_kind}${o} field ${a.field} could not resolve: ${a.message}`,{gate_id:e,assertion_id:t,measurement_id:s,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}});throw c.cause=a,c}throw a}}async function fu(e,t,n,r){wn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new $e(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new $e(`assurance gate ${e} does not declare trigger ${r.trigger}`);ky(i,t,n,r.trigger);let a=await uu(i.assertion_ids,au,async c=>{let d=t.assertions.find(p=>p.id===c),l=t.measurements.find(p=>p.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(h=>!p.has(h.status))}}else if(d.scope.kind==="filter"){let p=d.scope.measurement_id,h=t.measurements.find(v=>v.id===p),_=await ru(i.id,d.id,h,n,t.measurements),w=new Set(_.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===d.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return by(d,await ru(i.id,d.id,l,u,t.measurements),{owner_terminal:f})}),o=a.some(c=>c.verdict==="fail"&&c.enforcement==="block"),s=a.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:o?"block":s?"warn":"pass",exit_code:o?1:0,assertions:a,assertions_total:a.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:lu(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function bi(e){return Yg.join(e,"assurance.json")}async function hu(e){let t=await V(bi(e));return t===null?Zn():ki(t)}function ki(e){try{return wn(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 Si(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Sy(e,t){e==="measurement"?fo(t):e==="assertion"?ho(t):cu(t)}async function Qn(e,t){let n=structuredClone(Si(await hu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function yo(e,t,n){let r=Si(await hu(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Ei(e,t,n,r={}){Sy(t,n);let i=await T(e),a=G(r.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:`assurance:${t}:put`,author:a,message:r.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s),d=Si(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&ny(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new M(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
1
|
+
import{a as za,c as Gr,d as qr,e as yd,g as wd,h as Ga,i as vd,j as sn,k as cn,l as bd,m as kd,n as qa,o as xd,p as dn,q as ln,r as Ad,s as Id,t as Ba}from"./chunk-W5AE7GKZ.js";import{e as ei,f as Xa,h as Za}from"./chunk-WAOXID5J.js";import{B as Hd,C as Xr,D as zd,E as Ya,G as Wd,H as Gd,J as qd,K as Zr,M as Qr,a as ud,g as Ha,i as md}from"./chunk-2CJWTLQG.js";import{K as tu}from"./chunk-52UJEHEV.js";import{D as ro,E as pi,Ha as Bl,Ia as Vl,Ma as Jl,Na as Kl,T as fi,U as kl,V as io,W as Kn,Y as ao,aa as Pl,ba as Nl,ca as Ll,da as Ml,ea as gi,f as pl,g as fl,ga as jl,h as hl,ha as Fl,ia as Ul,ja as qt,k as mi,ka as Hl,kb as Zl,la as hn,ma as zl,mb as co,na as oo,nb as Ql,o as Vn,oa as _n,ob as eu,p as _l,pa as Wl,q as gl,qa as Gl,r as Jn,ra as ql,s as yl,sa as so,u as no,v as wl,wb as lo,z as vl}from"./chunk-JGFSSR3G.js";import{a as fd,b as on,c as Wa,d as hd,e as _d,f as ot,g as Br,h as gd,i as xt}from"./chunk-PLTTMQAW.js";import{$ as Xd,$a as bl,Aa as sl,Ab as ne,Ba as cl,Bb as ve,Cb as be,D as G,Da as Rt,Db as Ol,E as Bd,Ea as Bn,Eb as _i,Fa as dl,Fb as ct,Ga as oi,Gb as dt,H as Ce,Ha as Gt,I as Qa,Ia as ce,Ja as si,Jb as Dl,Ka as ll,Kb as lt,La as to,Ma as ci,Na as fn,O as Vd,Oa as di,P as ti,Pa as ul,S as ni,T as ri,Ta as Te,V as Jd,W as Me,Wa as ml,Xa as T,Y as It,Ya as li,Yb as Yn,Z as Kd,Za as ui,_ as Yd,_b as yi,aa as st,ba as Zd,fc as Yl,ga as Qd,gb as Sl,ha as eo,hb as El,ia as ii,ic as Xl,ja as mn,jb as xl,kb as Al,la as ai,lb as Ct,ma as el,mb as Il,na as tl,nb as Rl,pa as nl,qb as Cl,ra as rl,rb as Tl,ta as il,va as al,wb as hi,xa as pn,ya as ol,yb as $l}from"./chunk-SIEGIPNT.js";import{b as rn,e as le,g as Le,i as Re,j as Ke,n as ge,o as Sd,p as Vr,r as Ed}from"./chunk-PBCYGO7X.js";import{$ as g,$a as L,$c as Ye,$d as At,Ac as Kr,Ba as fe,Bb as Ve,Bc as Pd,Ca as Ne,Cc as Nd,Da as Qc,Db as Je,Ec as Ld,Fa as ee,Ia as ed,Mc as H,Na as td,Nb as pd,Pc as X,Rc as He,S as Bc,Sb as Jr,Sc as Md,T as Vc,Ta as nd,Tb as Rd,Tc as Yr,Ua as rd,Ub as Va,V as Jc,Va as W,Vb as Ja,Wb as Ka,X as Kc,Y as zr,Yb as Cd,Yd as $,Z as Yc,Zb as Td,Zd as Ud,_a as qn,_c as jd,_d as un,a as Ur,aa as y,ab as Be,ac as $d,ae as Wt,bb as Wr,bd as Fd,cb as Ut,d as Hr,eb as id,fb as Ht,fe as te,ha as Xc,hb as ad,hc as Od,i as Wc,ib as od,jb as sd,ka as Zc,l as Gc,m as qc,ma as Fa,ra as Gn,rb as cd,sa as O,sb as zt,ta as Et,tb as C,ua as F,ub as dd,va as V,vb as Ie,w as ja,xb as Ua,ya as Z,yb as ld,yc as Dd,zb as an}from"./chunk-B3YW6H2I.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]="081bf1eb-4b9a-5fa9-a272-34ae781d250c")}catch{}})();var M=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},$e=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Xe=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 gn(e){try{return await e()}catch(t){throw t instanceof M?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function nu(e){try{return await e()}catch(t){throw t instanceof $e?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Kg}from"node:crypto";import Yg 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 yn=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]="416aaf09-e4f6-5d10-aee0-eba374f1cd83")}catch{}})();var iu=1,Bt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],uo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],Xg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],Zg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,wi=30,vi=5e3,au=4,Qg=50;function ut(e,t){if(!Zg.test(e))throw new M(`${t} must be a stable lowercase id`)}function ey(e,t){if(!Number.isFinite(e)||e<0)throw new M(`${t} must be a finite non-negative number`)}function Xn(e){let t=Xg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new M(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function po(e,t){return C(e)===C(t)}function ou(e,t){if(t.polarity==="equals")return po(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 su(e){let t=Xn(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>ou(r.observed,t)===(r.expected==="pass"))}function ty(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!po(e.value,t.value)}function ny(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 ty(Xn(e),Xn(t))||n[t.enforcement]<n[e.enforcement]||r}function ry(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new M("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 M("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new M("items source equals/state requires field")}function iy(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new M("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(t=>t!==void 0).length>1)throw new M("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 M("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 M("dependency_kind source source_kind_state must be present or missing")}function ay(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new M("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 M("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 M("prose_edge_gap exemption selectors must not be empty")}}function fo(e){ut(e.id,"measurement.id"),e.max_cost!==void 0&&ey(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let n=Reflect.get(t,"kind");if(!uo.includes(n))throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let r=t;if(r.kind==="items"&&ry(r),r.kind==="dependency_kind"&&iy(r),r.kind==="prose_edge_gap"&&ay(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new M(`${r.kind} source requires field`);return r.kind==="provider"&&(ut(r.provider,"provider source provider"),ut(r.key,"provider source key")),e}function ho(e){if(ut(e.id,"assertion.id"),ut(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new M("assertion.owner_item_id is required");let t=Xn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new M(`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 M("retired assertion requires retire_reason");e.scope.kind==="filter"&&ut(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 M("assertion negative control requires pass and fail cases");if(!su(e))throw new M(`assertion ${e.id} negative control does not prove its bound`);return e}function oy(e){if(!Array.isArray(e.allowed_providers))throw new M("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)ut(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new M("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Bt.includes(t))throw new M(`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 M(`gate provider policy trigger ${t} is invalid`)}}function cu(e){if(ut(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new M("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new M("gate requires at least one assertion");for(let t of e.assertion_ids)ut(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new M(`gate.triggers is required and must be an array of ${Bt.join(", ")}`);if(e.triggers.length===0)throw new M("gate requires at least one trigger");for(let t of e.triggers)if(!Bt.includes(t))throw new M(`gate trigger must be one of ${Bt.join(", ")}`);return e.provider_policy&&oy(e.provider_policy),e}function wn(e){if(e.version!==iu)throw new M(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(fo(r),t.has(`measurement:${r.id}`))throw new M(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(ho(r),t.has(`assertion:${r.id}`))throw new M(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){cu(r);let i=r.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(i.length>0)throw new M(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new M(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of du(e))if(!n.has(r))throw new M(`${i.join(", ")} references missing measurement ${r}`);return e}function _o(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)_o(n,t)}function du(e){let t=new Map,n=(r,i)=>{let a=t.get(r)??[];a.push(i),t.set(r,a)};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=[];_o(r.source.expression,i);for(let a of i)n(a,`derived measurement ${r.id}`)}return t}function sy(e,t){let n=e.assertion_ids.flatMap(a=>{let o=t.assertions.find(s=>s.id===a);return[o.measurement_id,...o.scope.kind==="filter"?[o.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let a=n.pop();if(r.has(a))continue;r.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?i.add(o.source.provider):o.source.kind==="derived"&&_o(o.source.expression,n)}return i}function Zn(){return{version:iu,measurements:[],assertions:[],gates:[]}}function cy(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 a=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?a:!a}return po(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function dy(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 ly(e,t){let n=[],r=Fa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let a of i.dependencies??[]){let o=Fa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===r&&dy(e,s)&&n.push(`${i.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function uy(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 a=Reflect.get(i,"text");typeof a=="string"&&t.push(a)}}}return t}function my(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 mo(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function py(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,a=0;for(let o of e){t.set(o.id.toLowerCase(),o.id);for(let s of o.dependencies??[])n.add(mo(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(mo(o.id,s));for(let s of uy(o)){let c=[...s.matchAll(i)].map(d=>d[0]);a+=c.length,r.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:a}}function fy(e,t){let n=py(t.items),r=new Map;for(let o of n.prose_mentions){let s=o.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==o.holder_id),c=[...new Set(s)];for(let d of c){let l=mo(o.holder_id,d);if(n.linked_pairs.has(l)||my(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],a=i.map(o=>o.contributor).sort();return{value:a.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:a.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(o=>o.explicit).length,implicit_subject:i.filter(o=>!o.explicit).length}}}function hy(e,t){return{value:t.history.filter(n=>(e.op===void 0||n.op===e.op)&&(e.author===void 0||n.author===e.author)&&(e.harness===void 0||n.agent_harness===e.harness)&&(e.model===void 0||n.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function _y(e,t){let n=t.items.filter(r=>{let i=r[e.link],a=Array.isArray(i)&&i.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function gy(e,t){let n=e.source;return n.kind==="items"?cy(n,t):n.kind==="dependency_kind"?ly(n,t):n.kind==="prose_edge_gap"?fy(n,t):n.kind==="history"?hy(n,t):n.kind==="links"?_y(n,t):null}function lu(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 yy(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 uu(e,t,n){let r=new Array(e.length),i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let o=i;i+=1,r[o]=await n(e[o],o)}});return await Promise.all(a),r}async function mu(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let o=n.find(d=>d.id===e.measurement);if(!o)throw new TypeError(`derived measurement references missing ${e.measurement}`);let s=await pu(o,t,n,r,i);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=i.charged.has(o.id)?[]:[s.cost];return i.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await uu(e.operands,au,o=>mu(o,t,n,r,i));return{value:yy(e.operator,a.map(o=>o.value)),costs:a.flatMap(o=>o.costs),population_size:Math.max(0,...a.map(o=>o.population_size)),contributors:[...new Set(a.flatMap(o=>o.contributors))]}}async function wy(e,t,n,r,i){fo(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await mu(e.source.expression,t,n,[...r,e.id],i);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=gy(e,t);u!==null?o=u:(o=await t.external(e.source),c=1)}let d={units:o.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()-a},l=lu([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new $e(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${Kg("sha256").update(C(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function pu(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let a=i.cache.get(e.id);if(a)return a;let o=wy(e,t,n,r,i).catch(s=>{if(s instanceof Xe&&s.measurement_id===void 0){let c={measurement_id:e.id,source_kind:s.source_kind,field:s.field,...s.check?{check:s.check}:{}},d=new Xe(s.message,c);throw d.cause=s,d}throw s});return i.cache.set(e.id,o),o}async function go(e,t,n=[e]){return pu(e,t,n,[],{cache:new Map,charged:new Set})}function vy(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,e-t.value)}function by(e,t,n={}){ho(e);let r=Xn(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:vy(t.value,r),verdict:i?"retired":ou(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:su(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function ky(e,t,n,r){let i=sy(e,t);if(i.size===0)return;let a=e.provider_policy,o=a?.triggers[r];if(!a||!o)throw new $e(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!s.has(d))throw new $e(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new $e(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new $e(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!o.allow_network)throw new $e(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function ru(e,t,n,r,i){try{return await go(n,r,i)}catch(a){if(a instanceof Xe){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new $e(`assurance gate ${e} assertion ${t} measurement ${s} source ${a.source_kind}${o} field ${a.field} could not resolve: ${a.message}`,{gate_id:e,assertion_id:t,measurement_id:s,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}});throw c.cause=a,c}throw a}}async function fu(e,t,n,r){wn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new $e(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new $e(`assurance gate ${e} does not declare trigger ${r.trigger}`);ky(i,t,n,r.trigger);let a=await uu(i.assertion_ids,au,async c=>{let d=t.assertions.find(p=>p.id===c),l=t.measurements.find(p=>p.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(h=>!p.has(h.status))}}else if(d.scope.kind==="filter"){let p=d.scope.measurement_id,h=t.measurements.find(v=>v.id===p),_=await ru(i.id,d.id,h,n,t.measurements),w=new Set(_.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===d.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return by(d,await ru(i.id,d.id,l,u,t.measurements),{owner_terminal:f})}),o=a.some(c=>c.verdict==="fail"&&c.enforcement==="block"),s=a.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:o?"block":s?"warn":"pass",exit_code:o?1:0,assertions:a,assertions_total:a.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:lu(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function bi(e){return Yg.join(e,"assurance.json")}async function hu(e){let t=await V(bi(e));return t===null?Zn():ki(t)}function ki(e){try{return wn(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 Si(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Sy(e,t){e==="measurement"?fo(t):e==="assertion"?ho(t):cu(t)}async function Qn(e,t){let n=structuredClone(Si(await hu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function yo(e,t,n){let r=Si(await hu(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Ei(e,t,n,r={}){Sy(t,n);let i=await T(e),a=G(r.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:`assurance:${t}:put`,author:a,message:r.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s),d=Si(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&ny(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new M(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
2
2
|
`,result:{changed:!0,action:u,kind:t,id:n.id}}}});return{...o.result,changed:o.changed}}async function wo(e,t,n={}){let r=Zn();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),wn(r);let i=await T(e),a=G(n.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:"assurance:bundle:apply",author:a,message:n.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s),d=[],l=[],u=(m,f,p)=>{for(let h of f){let _=m.find(w=>w.id===h.id);if(!_){m.push(structuredClone(h)),d.push(`${p}:${h.id}`);continue}if(C(_)!==C(h))throw new M(`assurance bundle refuses to replace divergent ${p} ${h.id}`);l.push(`${p}:${h.id}`)}};return u(c.measurements,r.measurements,"measurement"),u(c.assertions,r.assertions,"assertion"),u(c.gates,r.gates,"gate"),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
3
3
|
`,result:{changed:d.length>0,created_ids:d,unchanged_ids:l}}}});return{...o.result,changed:o.changed}}async function _u(e,t,n,r={}){let i=await T(e),a=G(r.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:`assurance:${t}:remove`,author:a,message:r.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s);if(t==="measurement"){let u=du(c).get(n);if(u&&u.length>0)throw new M(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new M(`assurance assertion ${n} is referenced by gate`);let d=Si(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new M(`assurance ${t} ${n} not found`);return d.splice(l,1),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
4
4
|
`,result:{changed:!0,action:"removed",kind:t,id:n}}}});return{...o.result,changed:o.changed}}async function gu(e,t,n={}){if(t.dry_run)throw new TypeError("dry-run assurance verdicts are not persisted");let r=await T(e);await ci({pmRoot:e,op:"assurance:gate:verdict",author:G(n.author,r.author_default),context:{assurance_verdict:t},message:n.message??`Assurance gate ${t.gate_id} returned ${t.verdict}`,lockTtlSeconds:wi,lockWaitMs:vi})}async function yu(e,t={}){let n=t.limit??Qg;if(!Number.isInteger(n)||n<1||n>yn)throw new TypeError(`assurance verdict limit must be an integer from 1 through ${yn}`);return(await st(si(e),ce)).reverse().filter(r=>r.op==="assurance:gate:verdict").map(r=>r.context?.assurance_verdict).filter(r=>typeof r=="object"&&r!==null&&"gate_id"in r).filter(r=>t.gate_id===void 0||r.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]="caa9f916-c7ce-5e74-a00b-dd0fc6a41b5d")}catch{}})();var er={type:"string",minLength:1,maxLength:128,pattern:"\\S"},xi={type:"array",minItems:1,maxItems:Va,items:er},wu={...xi,items:{...er,pattern:"^(?!(?:.*\\.)?(?:__proto__|constructor|prototype)(?:\\.|$))[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$"}},Ey={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,xi])),dependency:{type:"object",additionalProperties:!1,required:["kind"],properties:{kind:er,id:er}}}},rule:{oneOf:[{type:"object",additionalProperties:!1,required:["kind","fields"],properties:{kind:{const:"require_fields"},fields:wu}},{type:"object",additionalProperties:!1,required:["kind","authors"],properties:{kind:{const:"authors"},authors:xi}},...["field_writers","approval"].map(e=>({type:"object",additionalProperties:!1,required:["kind","fields","authors"],properties:{kind:{const:e},fields:wu,authors:xi}})),{type:"object",additionalProperties:!1,required:["kind","allowed"],properties:{kind:{const:"transition"},allowed:{type:"array",maxItems:Va,items:{type:"array",minItems:2,maxItems:2,items:er}}}}]}}},o$={$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:Rd,items:Ey}}};(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]="808f3bb5-cca5-5f9c-b557-7923c79ae6ce")}catch{}})();async function vu(e,t,n,r){let i=await Ct(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"]}:bu(i,t,n,r)}function xy(e,t,n){return e===0?"undeclared":t===0?"empty":n===0?"inapplicable":n===t?"covered":"partial"}function bu(e,t,n=5,r=!1){let i=[],a=new Map,o=e.policies.filter(_=>_.rule.kind==="require_fields"),s=o.filter(_=>_.subject?.operations===void 0),c=new Set,d=0,l=0,u=0,m=0,f=0,p=$d(e);for(let _ of t){let w=p({operation:"",author:"",before:_,after:_,completeness_only:!0});d+=+(w.decisions.length>0),l+=w.decisions.length,w.decisions.forEach(k=>c.add(k.policy_id));let v=w.decisions.filter(k=>!k.satisfied);if(v.length===0)continue;m+=1;let S=a.get(_.type)??{items:0,violations:0,missing_fields:0};S.items+=1;for(let k of v)u+=1,S.violations+=1,S.missing_fields+=k.missing_fields.length,k.effect==="refuse"&&(f+=1),i.length<n&&i.push({id:_.id,type:_.type,status:_.status,decision:k});a.set(_.type,S)}let h=r||f>0?"error":u>0?"warn":"ok";return{check:{name:"completeness",status:h,ok:h==="ok",details:{scope:"operation_independent_require_fields",declared_requirement_count:o.length,state_requirement_count:s.length,applicable_requirement_count:c.size,requirement_application_count:l,governed_items:d,ungoverned_items:t.length-d,contract_status:xy(o.length,t.length,d),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(a),violations:i,violations_truncated:i.length<u,enforcement:e.enforcement}},warnings:[...u>0?[`validate_completeness_missing_fields:${u}`]:[],...r?["validate_completeness_source_incomplete"]:[]]}}import Ay 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]="0c3bed4d-4a17-5004-a1c5-65f6acec2a9b")}catch{}})();function Iy(){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(([e,t])=>({id:`completeness-${e.toLowerCase()}`,effect:"advise",description:`Evidence expected when ${e} work reaches completion.`,subject:{types:[e],statuses:["closed"]},rule:{kind:"require_fields",fields:[...t]}})),{id:"completeness-resolution",effect:"advise",subject:{statuses:["closed"]},rule:{kind:"require_fields",fields:["resolution","expected_result","actual_result"]}}]}}function Eu(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 Ry(e,t){let n=L(process.cwd(),e.path);await ne(n);let r=await T(n);return{pmRoot:n,settings:r,author:G(t,r.author_default)}}function ku(e,t,n,r){if(e==="policy-mode")return Ka({...n,enforcement:t});let i=n.policies.filter(s=>s.id!==t);if(e==="policy-remove")return{...n,policies:i};let a=Ja(r.definition),o=Ka({...n,policies:[...i,a].sort((s,c)=>s.id.localeCompare(c.id))});if(Buffer.byteLength(`${JSON.stringify(o,null,2)}
|
|
@@ -73,4 +73,4 @@ ${a}`,g.GENERIC_FAILURE)}}function Na(e){return typeof e.tag=="string"&&e.tag.tr
|
|
|
73
73
|
`);de(e.progressEnabled,"writing keyword artifacts"),await Z(t,`${JSON.stringify(e.manifest,null,2)}
|
|
74
74
|
`),await Z(n,`${i}
|
|
75
75
|
`);let a=[];if(e.mode!=="keyword")try{de(e.progressEnabled,"writing vectorization status ledger"),await Wl(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(o){a.push(`search_vectorization_status_ledger_write_failed:${o instanceof Error?o.message:String(o)}`)}return a}async function Vq(e,t){let n=xT(e.mode),r=ET(e),i=e.full===!0;de(r,`start mode=${n}`);let a=L(process.cwd(),t.path);await ne(a);let o=fi(await T(a)).settings,s=null;try{s=await te(a,kl,o.locks.ttl_seconds,G(void 0,"pm-reindex"),!1,o.governance.force_required_for_stale_lock,o.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=RT(o),d=CT(o),l=NT({requestedMode:n,pmRoot:a,settings:o,extensionEmbedding:c,extensionVectorAdapter:d}),u=n;de(r,"loading item corpus");let m=await LT({pmRoot:a,settings:o}),f=m.warnings,{documentCandidates:p,metadataDocuments:h}=m;de(r,`loaded_items=${h.length}`);let _=$(),w=PT(u,_,h),v=Lr.join(a,Fc),S=Lr.join(a,Uc),k=u==="keyword"?await zc(a,p,o.schema,f):h,x=[],D={},E=null,b=DT(u);if(u==="keyword"&&await MT({pmRoot:a,settings:o,forceFullSemantic:i,extensionEmbedding:c,reindexWarnings:f}),u!=="keyword"){let R=await GT({pmRoot:a,settings:o,requestedMode:n,activeEmbeddingProvider:l.activeEmbeddingProvider,activeVectorStore:l.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:d,documentCandidates:p,metadataDocuments:h,documentsForKeywordArtifacts:k,forceFullSemantic:i,reindexWarnings:f,semanticWarnings:x,semanticSummary:b,progressEnabled:r});k=R.documentsForKeywordArtifacts,D=R.vectorizationLedgerEntries,E=R.vectorizationEmbeddingMetadata}let N=await qT({pmRoot:a,mode:u,manifest:w,documentsForKeywordArtifacts:k,settings:o,vectorizationLedgerEntries:D,vectorizationEmbeddingMetadata:E,progressEnabled:r}),A=[...await X({path:v,scope:"project",op:"reindex:manifest"}),...await X({path:S,scope:"project",op:"reindex:embeddings"}),...await Yr({mode:u,total_items:h.length})];return de(r,"done"),{ok:!0,mode:u,total_items:h.length,semantic:b,artifacts:{manifest:Fc,embeddings:Uc},warnings:[...f,...x,...N,...A],generated_at:_}}finally{await s?.()}}export{M as a,$e as b,Xe as c,gn as d,nu as e,iu as f,Bt as g,uo as h,ny as i,fo as j,ho as k,cu as l,wn as m,Zn as n,go as o,by as p,fu as q,Qn as r,yo as s,Ei as t,wo as u,_u as v,gu as w,yu as x,ip as y,qD as z,uv as A,mv as B,et as C,xP as D,Nv as E,Ey as F,o$ as G,bu as H,Iy as I,A$ as J,Sb as K,CN as L,ON as M,DN as N,ur as O,PN as P,NN as Q,LN as R,MN as S,jN as T,FN as U,UN as V,HN as W,zN as X,WN as Y,GN as Z,ws as _,Is as $,vD as aa,_m as ba,Ri as ca,iO as da,P as ea,oe as fa,aO as ga,ko as ha,oO as ia,sO as ja,Ou as ka,cO as la,dO as ma,lO as na,Gy as oa,uO as pa,mO as qa,So as ra,pO as sa,fO as ta,bo as ua,hO as va,_O as wa,Pu as xa,gO as ya,By as za,Mu as Aa,IO as Ba,rr as Ca,RO as Da,Qy as Ea,ew as Fa,CO as Ga,tw as Ha,S_ as Ia,PO as Ja,Gu as Ka,x_ as La,uz as Ma,mz as Na,ir as Oa,$i as Pa,Bu as Qa,Vu as Ra,Ju as Sa,Ku as Ta,Qu as Ua,tm as Va,nm as Wa,am as Xa,Mt as Ya,b1 as Za,k1 as _a,S1 as $a,E1 as ab,N1 as bb,mh as cb,pa as db,rF as eb,vt as fb,iF as gb,aF as hb,_x as ib,vx as jb,Ah as kb,bw as lb,sm as mb,qs as nb,ZF as ob,QF as pb,Di as qb,Pi as rb,Xh as sb,XU as tb,Zh as ub,e_ as vb,t_ as wb,i_ as xb,o_ as yb,WI as zb,GI as Ab,_z as Bb,gz as Cb,yz as Db,wz as Eb,BI as Fb,VI as Gb,JI as Hb,vz as Ib,R_ as Jb,YI as Kb,C_ as Lb,uc as Mb,$_ as Nb,XI as Ob,ZI as Pb,QI as Qb,hc as Rb,_c as Sb,Tz as Tb,$z as Ub,Oz as Vb,TR as Wb,WW as Xb,yg as Yb,Dr as Zb,bg as _b,kg as $b,Sg as ac,$c as bc,jC as cc,xG as dc,JG as ec,nq as fc,Ng as gc,Lg as hc,Mg as ic,Aq as jc,Fq as kc,Uq as lc,Hq as mc,Vq as nc};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-KNJR2WUO.js.map
|