@unbrained/pm-cli 2026.10.31 → 2026.11.1

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 (135) hide show
  1. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/AGENTS.md +3 -3
  4. package/CHANGELOG.md +9 -0
  5. package/README.md +1 -1
  6. package/dist/cli/register-operations.d.ts +3 -3
  7. package/dist/cli/register-operations.js +1 -1
  8. package/dist/cli-bundle/bundle-manifest.json +1 -1
  9. package/dist/cli-bundle/chunks/{chunk-6PSDQ7T7.js → chunk-2GK2IVU5.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-U7JXZMU5.js → chunk-5KW4WUAK.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-WRXQAW7Q.js → chunk-5WVE7XBS.js} +45 -45
  12. package/dist/cli-bundle/chunks/{chunk-24J6TNYE.js → chunk-6PKWKVS6.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-ZTJVOBDU.js → chunk-E74BORFX.js} +3 -3
  14. package/dist/cli-bundle/chunks/chunk-F3ECOBKA.js +2 -0
  15. package/dist/cli-bundle/chunks/{chunk-43R7UTWV.js → chunk-ICT6E4IW.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-HSBTITO4.js → chunk-MP2DQJH2.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-BS2KXT24.js → chunk-MTRIGD7M.js} +42 -42
  18. package/dist/cli-bundle/chunks/{chunk-PT7TS6E7.js → chunk-N45IXPCA.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-35Q2B2GJ.js → chunk-NILQ2ZMV.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-V6EWBTNH.js → chunk-O56O7NIE.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-WNF6FOL7.js → chunk-O6TFUV6M.js} +31 -31
  22. package/dist/cli-bundle/chunks/{chunk-GMBDZID5.js → chunk-TMPO4CTZ.js} +3 -3
  23. package/dist/cli-bundle/chunks/{chunk-XDDPSWIW.js → chunk-TYERATXH.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-2AHSPMKJ.js → chunk-UEEG47TU.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-VC7TA67O.js → chunk-UUN3WNMQ.js} +19 -19
  26. package/dist/cli-bundle/chunks/{chunk-P3LNMWL2.js → chunk-WFBYKDB2.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-TL3O5GZA.js → chunk-Y7CKVU56.js} +4 -4
  28. package/dist/cli-bundle/chunks/item-transaction-Q5S5YLEJ.js +2 -0
  29. package/dist/cli-bundle/chunks/{mutation-admission-I4RHIT3Q.js → mutation-admission-BOOCJPCU.js} +2 -2
  30. package/dist/cli-bundle/chunks/{register-list-query-MVDL5EXG.js → register-list-query-23OX36Q3.js} +2 -2
  31. package/dist/cli-bundle/chunks/{register-mutation-GAF7LXRB.js → register-mutation-JPJ5YNDX.js} +2 -2
  32. package/dist/cli-bundle/chunks/register-operations-IGR7ERY5.js +2 -0
  33. package/dist/cli-bundle/chunks/{register-setup-MZN6ONB3.js → register-setup-BMIFKZZP.js} +2 -2
  34. package/dist/cli-bundle/chunks/{stage-2ZORTOF6.js → stage-ON7CYYPM.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-NRBUMDLF.js → chunk-2Y77HWIX.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-QFMJGQGO.js → chunk-3NYWMUX3.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-3Z53POXU.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/{chunk-4QPGJO2G.js → chunk-5TWS5KOM.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-EA65HVBO.js → chunk-5WCQFH6D.js} +12 -12
  40. package/dist/cli-bundle/focused-chunks/{chunk-2J7T2UCH.js → chunk-6GMYW42K.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-HPWT3RBG.js → chunk-6OKPYCLU.js} +4 -4
  42. package/dist/cli-bundle/focused-chunks/{chunk-NOKG4RFN.js → chunk-7WJDRZOR.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-PC3R5CJV.js → chunk-AL7SOFUL.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-CIQ6YWCW.js +26 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-PFBQOZPK.js → chunk-GE755ODZ.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-5MCGYBOQ.js → chunk-JCR32IAO.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-Y6UYRMVG.js → chunk-LVA76N27.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-57HPXGOQ.js → chunk-M22TI7LP.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/{chunk-KKRIFBSL.js → chunk-PAT6QF63.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-SFQKCA5K.js → chunk-RPUDOJVB.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-SXZM4PSS.js +44 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-HSAEEWSI.js → chunk-UQIBGLDR.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-MW77Q3AQ.js → chunk-VFQAZLKO.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-KH5QJXY7.js → chunk-VS2ZFPXD.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-JNKRUCVZ.js → chunk-WX2RVS2Y.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-6F6APBCX.js → chunk-Z7GIVH6B.js} +3 -3
  57. package/dist/cli-bundle/focused-chunks/{item-transaction-LU75EG7D.js → item-transaction-7VLPA2SU.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{mutation-admission-KDJ7SCPA.js → mutation-admission-2DH27R5Y.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{stage-R4KEBO37.js → stage-FYOBWQA7.js} +2 -2
  60. package/dist/cli-bundle/main.js +2 -2
  61. package/dist/cli-bundle/sdk-authoring.js +1 -1
  62. package/dist/cli-bundle/sdk-contracts.js +4 -4
  63. package/dist/cli-bundle/sdk-core.js +1 -1
  64. package/dist/cli-bundle/sdk-governance.js +1 -1
  65. package/dist/cli-bundle/sdk-graph.js +1 -1
  66. package/dist/cli-bundle/sdk-merge.js +52 -52
  67. package/dist/cli-bundle/sdk-query.js +1 -1
  68. package/dist/cli-bundle/sdk-runtime.js +1 -1
  69. package/dist/cli-bundle/sdk-testing.js +1 -1
  70. package/dist/cli-bundle/sdk.js +9 -9
  71. package/dist/core/output/mutation-projection.js +1 -1
  72. package/dist/core/output/output.js +2 -2
  73. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  74. package/dist/sdk/context-intent-contracts.d.ts +17 -0
  75. package/dist/sdk/context-intent-contracts.js +1 -1
  76. package/dist/sdk/core.d.ts +1 -1
  77. package/dist/sdk/core.js +1 -1
  78. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  79. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  80. package/dist/sdk/index.d.ts +1 -1
  81. package/dist/sdk/index.js +1 -1
  82. package/dist/sdk/init-agent-guidance.js +2 -2
  83. package/dist/sdk/lifecycle/claim.d.ts +27 -0
  84. package/dist/sdk/lifecycle/claim.js +1 -1
  85. package/dist/sdk/lifecycle/mcp-actions.d.ts +1 -1
  86. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  87. package/dist/sdk/lifecycle/task-composition.js +1 -1
  88. package/dist/sdk/output/list-envelope.d.ts +8 -0
  89. package/dist/sdk/output/list-envelope.js +1 -1
  90. package/dist/sdk/output.d.ts +1 -1
  91. package/dist/sdk/output.js +2 -2
  92. package/dist/sdk/public-surface.json +1 -1
  93. package/dist/sdk/query/context.js +2 -2
  94. package/dist/sdk/runtime/actions.js +1 -1
  95. package/dist/sdk/runtime-input.js +1 -1
  96. package/dist/sdk/runtime-public-contracts.d.ts +2 -0
  97. package/dist/sdk/runtime.d.ts +2 -2
  98. package/dist/sdk/runtime.js +1 -1
  99. package/dist/sdk/start-task-status.d.ts +1 -1
  100. package/dist/sdk/start-task-status.js +1 -1
  101. package/docs/AGENT_GUIDE.md +3 -3
  102. package/docs/COMMANDS.md +1 -0
  103. package/docs/COMMAND_NAMESPACES.md +1 -1
  104. package/docs/LIFECYCLE_COMMANDS.md +19 -4
  105. package/docs/SDK.md +9 -1
  106. package/docs/SDK_ACTION_CONFORMANCE.md +21 -0
  107. package/docs/agent-task-token-baseline.json +1 -1
  108. package/docs/agent-task-transcripts.json +1 -1
  109. package/marketplace.json +1 -1
  110. package/package.json +1 -1
  111. package/packages/pm-beads/package.json +1 -1
  112. package/packages/pm-calendar/package.json +1 -1
  113. package/packages/pm-command-kit/package.json +1 -1
  114. package/packages/pm-digital-twin/package.json +1 -1
  115. package/packages/pm-governance-audit/package.json +1 -1
  116. package/packages/pm-guide-shell/package.json +1 -1
  117. package/packages/pm-kanban/package.json +1 -1
  118. package/packages/pm-lifecycle-hooks/package.json +1 -1
  119. package/packages/pm-linked-test-adapters/package.json +1 -1
  120. package/packages/pm-search-advanced/package.json +1 -1
  121. package/packages/pm-templates/package.json +1 -1
  122. package/packages/pm-todos/package.json +1 -1
  123. package/packages/pm-vcs/package.json +1 -1
  124. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  125. package/plugins/pm-claude/package.json +1 -1
  126. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  127. package/plugins/pm-codex/package.json +1 -1
  128. package/plugins/pm-codex/plugin.json +1 -1
  129. package/runtime-dependencies.json +1 -1
  130. package/dist/cli-bundle/chunks/chunk-YT5D5HNG.js +0 -2
  131. package/dist/cli-bundle/chunks/item-transaction-UWV6UNSV.js +0 -2
  132. package/dist/cli-bundle/chunks/register-operations-JLFRL36Q.js +0 -2
  133. package/dist/cli-bundle/focused-chunks/chunk-AFVN2KCP.js +0 -44
  134. package/dist/cli-bundle/focused-chunks/chunk-GP2WU43K.js +0 -26
  135. package/dist/cli-bundle/focused-chunks/chunk-WHIE2C6Q.js +0 -2
@@ -1,3 +1,3 @@
1
- import{a as c}from"./chunk-MW77Q3AQ.js";import{g as d,oa as w,pa as u}from"./chunk-GP2WU43K.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]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();var _=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function y(e){return _.get(e.trim().toLowerCase())}function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function b(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let i=n.toLowerCase();t.has(i)||t.set(i,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function S(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=y(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),i=e.defaultStatus?.trim(),r=e.folder?.trim(),a=r&&r.length>0?u(r):void 0,s=b(e.aliases??[]);for(let l of s){g(l,"Alias");let f=y(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:i&&i.length>0?i:void 0,folder:a,aliases:s}}function x(e,t){let o=e.name.toLowerCase(),n=new Map;for(let r of t.definitions){if(typeof r.name!="string")continue;let a=r.name.trim();if(!(a.length===0||a.toLowerCase()===o)){n.set(a.toLowerCase(),a);for(let s of A(r.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),a)}}let i=n.get(o);if(i)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${i}".`);for(let r of e.aliases){let a=n.get(r.toLowerCase());if(a)throw new Error(`Alias "${r}" already maps to existing item type "${a}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),i=h(e.name,e.folder),r=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${i}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===i&&r(l)}let a=o?.get(i);a!==void 0&&a.toLowerCase()!==n&&r(a)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.name!="string"||i.name.trim().length===0||o.push(i)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function z(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),i=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),r=i>=0?n[i]:void 0,a=b([...A(r?.aliases),...t.aliases]),s={...r,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),a.length>0?s.aliases=a:s.aliases!==void 0&&delete s.aliases,T(s,"description",t.description),T(s,"default_status",t.defaultStatus),i>=0?n[i]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:i>=0,...r&&typeof r.name=="string"?{previousName:r.name}:{}}}function F(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=y(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let i=o.toLowerCase(),r=e.definitions.slice(),a=r.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===i);if(a<0)return{file:{definitions:r},removed:!1};let[s]=r.splice(a,1);return{file:{definitions:r},removed:!0,definition:s}}function T(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function M(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
1
+ import{a as c}from"./chunk-VFQAZLKO.js";import{g as d,oa as w,pa as u}from"./chunk-CIQ6YWCW.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]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();var _=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function y(e){return _.get(e.trim().toLowerCase())}function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function b(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let i=n.toLowerCase();t.has(i)||t.set(i,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function S(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=y(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),i=e.defaultStatus?.trim(),r=e.folder?.trim(),a=r&&r.length>0?u(r):void 0,s=b(e.aliases??[]);for(let l of s){g(l,"Alias");let f=y(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:i&&i.length>0?i:void 0,folder:a,aliases:s}}function x(e,t){let o=e.name.toLowerCase(),n=new Map;for(let r of t.definitions){if(typeof r.name!="string")continue;let a=r.name.trim();if(!(a.length===0||a.toLowerCase()===o)){n.set(a.toLowerCase(),a);for(let s of A(r.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),a)}}let i=n.get(o);if(i)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${i}".`);for(let r of e.aliases){let a=n.get(r.toLowerCase());if(a)throw new Error(`Alias "${r}" already maps to existing item type "${a}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),i=h(e.name,e.folder),r=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${i}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===i&&r(l)}let a=o?.get(i);a!==void 0&&a.toLowerCase()!==n&&r(a)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.name!="string"||i.name.trim().length===0||o.push(i)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function z(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),i=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),r=i>=0?n[i]:void 0,a=b([...A(r?.aliases),...t.aliases]),s={...r,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),a.length>0?s.aliases=a:s.aliases!==void 0&&delete s.aliases,T(s,"description",t.description),T(s,"default_status",t.defaultStatus),i>=0?n[i]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:i>=0,...r&&typeof r.name=="string"?{previousName:r.name}:{}}}function F(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=y(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let i=o.toLowerCase(),r=e.definitions.slice(),a=r.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===i);if(a<0)return{file:{definitions:r},removed:!1};let[s]=r.splice(a,1);return{file:{definitions:r},removed:!0,definition:s}}function T(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function M(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
2
2
  `}function E(e,t){let o=e.trim().length>0?e.trim():e,n=t?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${I(o)}" (writes ${n}).`}function O(e,t,o){return`Invalid type value "${e}". Allowed: ${t.join(", ")}. ${E(e,o)}`}(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]="77a7b77a-907c-541d-ac55-e06174dbbf11")}catch{}})();function v(e){return typeof e=="string"?e.trim().toLowerCase():""}function m(e,t){let o=c(e);return o.length===0?"":t?.alias_to_id?.get(o)??o}function U(e){let t=Array.isArray(e?.type_workflows)?e.type_workflows:[],o=new Map;for(let n of t){let i=v(n?.type);if(i.length===0||!Array.isArray(n?.allowed_transitions))continue;let r=n.allowed_transitions,a=o.get(i)??{pairs:[],denyAll:!1};r.length===0&&(a.denyAll=!0);for(let s of r){if(!Array.isArray(s)||s.length!==2)continue;let l=c(s[0]),f=c(s[1]);l.length===0||f.length===0||a.pairs.some(p=>p[0]===l&&p[1]===f)||a.pairs.push([l,f])}o.set(i,a)}return[...o.entries()].filter(([,n])=>n.pairs.length>0||n.denyAll).map(([n,i])=>({type:n,allowed_transitions:i.pairs})).sort((n,i)=>n.type.localeCompare(i.type))}function J(e){let t=v(e.typeName),o=e.typeWorkflows.find(r=>r.type===t);if(!o)return{allowed:!0,hasRule:!1,allowedTransitions:[]};let n=m(e.fromStatus,e.statusRegistry),i=m(e.toStatus,e.statusRegistry);return n.length>0&&n===i?{allowed:!0,hasRule:!0,allowedTransitions:o.allowed_transitions}:{allowed:o.allowed_transitions.some(r=>{let a=m(r[0],e.statusRegistry),s=m(r[1],e.statusRegistry);return a===n&&s===i}),hasRule:!0,allowedTransitions:o.allowed_transitions}}function W(e){return e.length===0?"(no transitions allowed)":e.map(t=>`${t[0]} -> ${t[1]}`).join(", ")}export{y as a,I as b,S as c,x as d,D as e,j as f,z as g,F as h,M as i,O as j,U as k,J as l,W as m};
3
- //# sourceMappingURL=chunk-2J7T2UCH.js.map
3
+ //# sourceMappingURL=chunk-6GMYW42K.js.map
@@ -1,4 +1,4 @@
1
- import{c as St,d as dn,e as ln,f as un,g as Nl,j as jl}from"./chunk-QFMJGQGO.js";import{a as Ll}from"./chunk-DFUTCKUF.js";import{i as Q,m as Za,x as Cl}from"./chunk-JNKRUCVZ.js";import{a as ja,c as zi,d as Wi,e as ed,g as td,h as Ua,i as nd,j as Kt,k as Yt,l as id,m as rd,n as Ha,o as sd,p as Xt,q as Zt,r as cd,s as dd,t as za}from"./chunk-Y6UYRMVG.js";import{a as qa}from"./chunk-SVOOGGAK.js";import{B as bd,C as Vi,D as kd,E as Wa,G as Ed,H as Sd,J as xd,K as Id,L as Ki,U as Yi}from"./chunk-6F6APBCX.js";import{K as Ml}from"./chunk-SFQKCA5K.js";import{A as Pl,I as eo,w as Dl,y as Qa,z as Ol}from"./chunk-PFBQOZPK.js";import{A as Cd,Aa as Ya,Ba as cn,Ca as kl,Da as El,Ea as Sl,Fa as Xa,H as Td,L as $d,M as Dd,N as Od,Q as dr,Sa as xl,Ta as Il,Xa as Rl,Ya as Al,ea as ur,fa as tl,ga as Va,ha as Bn,ja as Ka,k as Xi,na as pl,o as Hn,oa as fl,p as Rd,pa as hl,q as Ad,qa as _l,r as zn,ra as fr,ta as gl,ua as yl,va as wl,wa as Mt,xa as vl,ya as sn,za as bl}from"./chunk-NOKG4RFN.js";import{a as Yc,b as Vt,c as Fa,d as Xc,e as Zc,f as it,g as qi,h as Qc,i as wt}from"./chunk-2J7T2UCH.js";import{m as Jn,o as hr,v as Tl,y as $l}from"./chunk-KKRIFBSL.js";import{C as mr,E as ll,F as ge,G as ye,H as ul,I as pr,J as rt,K as at,O as ml,P as ot,a as Zi,c as Yd,j as nl,k as il,m as rl,n as al,o as Et,p as ol,q as sl,w as cl,x as dl}from"./chunk-5MCGYBOQ.js";import{$a as T,Aa as tn,Ba as Vd,Da as or,Ea as sr,Fa as qn,Ga as kt,Ha as Gn,Ia as Kd,Ja as cr,Ka as Nt,La as te,Ma as nn,Na as Xd,Oa as Ja,Pa as rn,Qa as an,Ra as on,Ta as Zd,Ua as Qd,Xa as je,_a as el,a as Pd,ab as lr,ba as z,ca as Hd,d as Re,da as Me,e as Ga,ea as zd,eb as ne,f as Ld,k as Qi,ka as Wd,l as Wn,la as Ba,m as Nd,ma as ir,n as er,na as en,o as Md,pa as rr,q as tr,qa as qd,r as nr,ra as Gd,t as jd,ta as Bd,u as $e,va as Jd,x as bt,y as Fd,ya as ar,z as Ud}from"./chunk-57HPXGOQ.js";import{b as Gt}from"./chunk-PC3R5CJV.js";import{a as se,c as Te,e as Ie,f as Ke,j as fe,k as ad,l as Gi,n as od}from"./chunk-MW77Q3AQ.js";import{$d as vd,Ac as Ji,Ba as Mc,Bb as Bc,Ca as Ot,Cb as Jc,Ea as jc,Fa as A,Ga as Fc,Ha as xe,Hc as hd,Ja as Hi,Ka as Uc,Kb as Vc,La as Pa,Lb as Pt,Ma as La,Mc as _d,Na,Nb as Ma,Nc as le,O as $c,Ob as Kc,Od as $,Pa as Hc,Pb as Jt,Pd as gd,Qa as zc,Qd as Qt,R as Dc,Rb as Je,Rd as vt,Sd as Lt,T as Oa,Ta as Wc,Tb as Ve,Xd as yd,Y as me,Z as Ge,_ as Oc,_d as wd,a as Ec,aa as Y,ae as re,bb as qc,d as Sc,da as Pc,e as xc,ec as ld,gc as Bi,hc as ud,ic as md,kb as Gc,kc as pd,o as Da,oa as Lc,pa as Nc,qa as H,sc as F,va as Un,wa as M,wc as K,xa as Be,ya as Ui,yc as Ne,za as Bt,zc as fd}from"./chunk-GP2WU43K.js";import{a as _r,b as Vn}from"./chunk-EGN2HFRU.js";import{A as g,B as Fn,C as D,D as yt,E as j,F as B,I as Z,a as Mi,d as ji,p as Ic,r as Rc,t as Ac,v as Cc,w as Fi,x as Tc,z as y}from"./chunk-JLXGRDTG.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 L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},we=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Ye=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 mn(e){try{return await e()}catch(t){throw t instanceof L?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function to(e){try{return await e()}catch(t){throw t instanceof we?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as gg}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 pn=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]="eaede7d4-43ae-5551-915e-19befefc29d0")}catch{}})();var Ul=1,jt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],no=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],wg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],vg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,gr=30,yr=5e3,Hl=4,bg=50;function st(e,t){if(!vg.test(e))throw new L(`${t} must be a stable lowercase id`)}function kg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function Kn(e){let t=wg.filter(r=>e[r]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],i=e[n];return{polarity:n,value:n==="zero"?0:i}}function ro(e,t){return A(e)===A(t)}function zl(e,t){if(t.polarity==="equals")return ro(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let i=t.value;return e.every(r=>i.includes(r))}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 Wl(e){let t=Kn(e),n=e.negative_control.cases;return n.some(i=>i.expected==="pass")&&n.some(i=>i.expected==="fail")&&n.every(i=>zl(i.observed,t)===(i.expected==="pass"))}function Eg(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,i=t.value;return!Array.isArray(n)||!Array.isArray(i)||i.some(r=>!n.includes(r))}return!ro(e.value,t.value)}function Sg(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},i=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return Eg(Kn(e),Kn(t))||n[t.enforcement]<n[e.enforcement]||i}function xg(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,i=Number(t)+Number(n);if(e.field!==void 0&&i!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&i!==0)throw new L("items source equals/state requires field")}function Ig(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(t=>t!==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 Rg(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 ao(e){st(e.id,"measurement.id"),e.max_cost!==void 0&&kg(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 ${no.join(", ")}`);let n=Reflect.get(t,"kind");if(!no.includes(n))throw new L(`measurement.source.kind must be one of ${no.join(", ")}`);let i=t;if(i.kind==="items"&&xg(i),i.kind==="dependency_kind"&&Ig(i),i.kind==="prose_edge_gap"&&Rg(i),(i.kind==="graph"||i.kind==="validate"||i.kind==="health")&&(typeof i.field!="string"||i.field.trim().length===0))throw new L(`${i.kind} source requires field`);return i.kind==="provider"&&(st(i.provider,"provider source provider"),st(i.key,"provider source key")),e}function oo(e){if(st(e.id,"assertion.id"),st(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=Kn(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"&&st(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(i=>i.expected==="pass")||!n.some(i=>i.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!Wl(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Ag(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)st(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(!jt.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 ql(e){if(st(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)st(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${jt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!jt.includes(t))throw new L(`gate trigger must be one of ${jt.join(", ")}`);return e.provider_policy&&Ag(e.provider_policy),e}function fn(e){if(e.version!==Ul)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let i of e.measurements){if(ao(i),t.has(`measurement:${i.id}`))throw new L(`duplicate measurement ${i.id}`);t.add(`measurement:${i.id}`)}for(let i of e.assertions){if(oo(i),t.has(`assertion:${i.id}`))throw new L(`duplicate assertion ${i.id}`);t.add(`assertion:${i.id}`)}for(let i of e.gates){ql(i);let r=i.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(r.length>0)throw new L(`gate ${i.id} references missing assertions: ${r.join(", ")}`);if(t.has(`gate:${i.id}`))throw new L(`duplicate gate ${i.id}`);t.add(`gate:${i.id}`)}let n=new Set(e.measurements.map(i=>i.id));for(let[i,r]of Gl(e))if(!n.has(i))throw new L(`${r.join(", ")} references missing measurement ${i}`);return e}function so(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)so(n,t)}function Gl(e){let t=new Map,n=(i,r)=>{let a=t.get(i)??[];a.push(r),t.set(i,a)};for(let i of e.assertions)n(i.measurement_id,`assertion ${i.id}`),i.scope.kind==="filter"&&n(i.scope.measurement_id,`assertion ${i.id} scope`);for(let i of e.measurements){if(i.source.kind!=="derived")continue;let r=[];so(i.source.expression,r);for(let a of r)n(a,`derived measurement ${i.id}`)}return t}function Cg(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]:[]]}),i=new Set,r=new Set;for(;n.length>0;){let a=n.pop();if(i.has(a))continue;i.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?r.add(o.source.provider):o.source.kind==="derived"&&so(o.source.expression,n)}return r}function Yn(){return{version:Ul,measurements:[],assertions:[],gates:[]}}function Tg(e,t){let n=t.items.filter(i=>(e.statuses===void 0||e.statuses.includes(i.status))&&(e.types===void 0||e.types.includes(i.type))&&(e.tags===void 0||e.tags.every(r=>i.tags?.includes(r)))&&(e.field===void 0||(()=>{let r=i[e.field];if(e.state!==void 0){let a=r==null||r===""||Array.isArray(r)&&r.length===0;return e.state==="missing"?a:!a}return ro(r,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function $g(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 Dg(e,t){let n=[],i=Oa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let r of t.items)for(let a of r.dependencies??[]){let o=Oa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===i&&$g(e,s)&&n.push(`${r.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function Og(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 i=e[n];if(Array.isArray(i)){for(let r of i)if(typeof r=="string")t.push(r);else if(typeof r=="object"&&r!==null){let a=Reflect.get(r,"text");typeof a=="string"&&t.push(a)}}}return t}function Pg(e,t,n,i){return e.some(r=>r.holder_id.trim().toLowerCase()===t.toLowerCase()&&(r.target_id===void 0||r.target_id.trim().toLowerCase()===n.toLowerCase())&&(r.text_contains===void 0||i.toLowerCase().includes(r.text_contains.trim().toLowerCase())))}function io(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function Lg(e){let t=new Map,n=new Set,i=[],r=/(?<![\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(io(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(io(o.id,s));for(let s of Og(o)){let c=[...s.matchAll(r)].map(d=>d[0]);a+=c.length,i.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:i,mention_count:a}}function Ng(e,t){let n=Lg(t.items),i=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=io(o.holder_id,d);if(n.linked_pairs.has(l)||Pg(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);i.get(l)?.explicit===!0&&!u||i.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let r=[...i.values()],a=r.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:r.filter(o=>o.explicit).length,implicit_subject:r.filter(o=>!o.explicit).length}}}function Mg(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 jg(e,t){let n=t.items.filter(i=>{let r=i[e.link],a=Array.isArray(r)&&r.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function Fg(e,t){let n=e.source;return n.kind==="items"?Tg(n,t):n.kind==="dependency_kind"?Dg(n,t):n.kind==="prose_edge_gap"?Ng(n,t):n.kind==="history"?Mg(n,t):n.kind==="links"?jg(n,t):null}function Bl(e,t){return e.reduce((n,i)=>({units:n.units+i.units,items_scanned:n.items_scanned+i.items_scanned,history_entries:n.history_entries+i.history_entries,provider_calls:n.provider_calls+i.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function Ug(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,i)=>n+i,0);if(e==="subtract")return t.slice(1).reduce((n,i)=>n-i,t[0]);if(e==="multiply")return t.reduce((n,i)=>n*i,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,i)=>n/i,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function Jl(e,t,n){let i=new Array(e.length),r=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;r<e.length;){let o=r;r+=1,i[o]=await n(e[o],o)}});return await Promise.all(a),i}async function Vl(e,t,n,i,r){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 Kl(o,t,n,i,r);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=r.charged.has(o.id)?[]:[s.cost];return r.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await Jl(e.operands,Hl,o=>Vl(o,t,n,i,r));return{value:Ug(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 Hg(e,t,n,i,r){ao(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await Vl(e.source.expression,t,n,[...i,e.id],r);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=Fg(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=Bl([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new we(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${gg("sha256").update(A(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function Kl(e,t,n,i,r){if(i.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...i,e.id].join(" -> ")}`);let a=r.cache.get(e.id);if(a)return a;let o=Hg(e,t,n,i,r).catch(s=>{if(s instanceof Ye&&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 Ye(s.message,c);throw d.cause=s,d}throw s});return r.cache.set(e.id,o),o}async function co(e,t,n=[e]){return Kl(e,t,n,[],{cache:new Map,charged:new Set})}function zg(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 Wg(e,t,n={}){oo(e);let i=Kn(e),r=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:i,distance:zg(t.value,i),verdict:r?"retired":zl(t.value,i)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:Wl(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function qg(e,t,n,i){let r=Cg(e,t);if(r.size===0)return;let a=e.provider_policy,o=a?.triggers[i];if(!a||!o)throw new we(`assurance gate ${e.id} refuses provider execution at trigger ${i} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of r){if(!s.has(d))throw new we(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new we(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new we(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${i}`);if(l.network&&!o.allow_network)throw new we(`assurance gate ${e.id} refuses network provider ${d} at trigger ${i}`)}}async function Fl(e,t,n,i,r){try{return await co(n,i,r)}catch(a){if(a instanceof Ye){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new we(`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 Yl(e,t,n,i){fn(t);let r=t.gates.find(c=>c.id===e);if(!r)throw new we(`assurance gate ${e} not found`);if(!r.triggers.includes(i.trigger))throw new we(`assurance gate ${e} does not declare trigger ${i.trigger}`);qg(r,t,n,i.trigger);let a=await Jl(r.assertion_ids,Hl,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 Fl(r.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 Wg(d,await Fl(r.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:r.id,tree_id:n.tree_id,trigger:i.trigger,dry_run:i.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:Bl(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function wr(e){return yg.join(e,"assurance.json")}async function Xl(e){let t=await B(wr(e));return t===null?Yn():vr(t)}function vr(e){try{return fn(JSON.parse(e))}catch(t){throw new g("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",y.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 br(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Gg(e,t){e==="measurement"?ao(t):e==="assertion"?oo(t):ql(t)}async function Xn(e,t){let n=structuredClone(br(await Xl(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function Zl(e,t,n){let i=br(await Xl(e),t).find(r=>r.id===n);if(!i)throw new we(`assurance ${t} ${n} not found`);return structuredClone(i)}async function kr(e,t,n,i={}){Gg(t,n);let r=await T(e),a=z(i.author,r.author_default),o=await an({pmRoot:e,filePath:wr(e),op:`assurance:${t}:put`,author:a,message:i.message,lockTtlSeconds:gr,lockWaitMs:yr,mutate:s=>{let c=s===null?Yn():vr(s),d=br(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&Sg(d[l],n)){let m=n.authorization_decision;if(!m||!i.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),fn(c),{raw:`${JSON.stringify(c,null,2)}
1
+ import{c as St,d as dn,e as ln,f as un,g as Nl,j as jl}from"./chunk-3NYWMUX3.js";import{a as Ll}from"./chunk-DFUTCKUF.js";import{i as Q,m as Za,x as Cl}from"./chunk-WX2RVS2Y.js";import{a as ja,c as zi,d as Wi,e as ed,g as td,h as Ua,i as nd,j as Kt,k as Yt,l as id,m as rd,n as Ha,o as sd,p as Xt,q as Zt,r as cd,s as dd,t as za}from"./chunk-LVA76N27.js";import{a as qa}from"./chunk-SVOOGGAK.js";import{B as bd,C as Vi,D as kd,E as Wa,G as Ed,H as Sd,J as xd,K as Id,L as Ki,U as Yi}from"./chunk-Z7GIVH6B.js";import{K as Ml}from"./chunk-RPUDOJVB.js";import{A as Pl,I as eo,w as Dl,y as Qa,z as Ol}from"./chunk-GE755ODZ.js";import{A as Cd,Aa as Ya,Ba as cn,Ca as kl,Da as El,Ea as Sl,Fa as Xa,H as Td,L as $d,M as Dd,N as Od,Q as dr,Sa as xl,Ta as Il,Xa as Rl,Ya as Al,ea as ur,fa as tl,ga as Va,ha as Bn,ja as Ka,k as Xi,na as pl,o as Hn,oa as fl,p as Rd,pa as hl,q as Ad,qa as _l,r as zn,ra as fr,ta as gl,ua as yl,va as wl,wa as Mt,xa as vl,ya as sn,za as bl}from"./chunk-7WJDRZOR.js";import{a as Yc,b as Vt,c as Fa,d as Xc,e as Zc,f as it,g as qi,h as Qc,i as wt}from"./chunk-6GMYW42K.js";import{m as Jn,o as hr,v as Tl,y as $l}from"./chunk-PAT6QF63.js";import{C as mr,E as ll,F as ge,G as ye,H as ul,I as pr,J as rt,K as at,O as ml,P as ot,a as Zi,c as Yd,j as nl,k as il,m as rl,n as al,o as Et,p as ol,q as sl,w as cl,x as dl}from"./chunk-JCR32IAO.js";import{$a as T,Aa as tn,Ba as Vd,Da as or,Ea as sr,Fa as qn,Ga as kt,Ha as Gn,Ia as Kd,Ja as cr,Ka as Nt,La as te,Ma as nn,Na as Xd,Oa as Ja,Pa as rn,Qa as an,Ra as on,Ta as Zd,Ua as Qd,Xa as je,_a as el,a as Pd,ab as lr,ba as z,ca as Hd,d as Re,da as Me,e as Ga,ea as zd,eb as ne,f as Ld,k as Qi,ka as Wd,l as Wn,la as Ba,m as Nd,ma as ir,n as er,na as en,o as Md,pa as rr,q as tr,qa as qd,r as nr,ra as Gd,t as jd,ta as Bd,u as $e,va as Jd,x as bt,y as Fd,ya as ar,z as Ud}from"./chunk-M22TI7LP.js";import{b as Gt}from"./chunk-AL7SOFUL.js";import{a as se,c as Te,e as Ie,f as Ke,j as fe,k as ad,l as Gi,n as od}from"./chunk-VFQAZLKO.js";import{$d as vd,Ac as Ji,Ba as Mc,Bb as Bc,Ca as Ot,Cb as Jc,Ea as jc,Fa as A,Ga as Fc,Ha as xe,Hc as hd,Ja as Hi,Ka as Uc,Kb as Vc,La as Pa,Lb as Pt,Ma as La,Mc as _d,Na,Nb as Ma,Nc as le,O as $c,Ob as Kc,Od as $,Pa as Hc,Pb as Jt,Pd as gd,Qa as zc,Qd as Qt,R as Dc,Rb as Je,Rd as vt,Sd as Lt,T as Oa,Ta as Wc,Tb as Ve,Xd as yd,Y as me,Z as Ge,_ as Oc,_d as wd,a as Ec,aa as Y,ae as re,bb as qc,d as Sc,da as Pc,e as xc,ec as ld,gc as Bi,hc as ud,ic as md,kb as Gc,kc as pd,o as Da,oa as Lc,pa as Nc,qa as H,sc as F,va as Un,wa as M,wc as K,xa as Be,ya as Ui,yc as Ne,za as Bt,zc as fd}from"./chunk-CIQ6YWCW.js";import{a as _r,b as Vn}from"./chunk-EGN2HFRU.js";import{A as g,B as Fn,C as D,D as yt,E as j,F as B,I as Z,a as Mi,d as ji,p as Ic,r as Rc,t as Ac,v as Cc,w as Fi,x as Tc,z as y}from"./chunk-JLXGRDTG.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 L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},we=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Ye=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 mn(e){try{return await e()}catch(t){throw t instanceof L?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function to(e){try{return await e()}catch(t){throw t instanceof we?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as gg}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 pn=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]="eaede7d4-43ae-5551-915e-19befefc29d0")}catch{}})();var Ul=1,jt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],no=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],wg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],vg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,gr=30,yr=5e3,Hl=4,bg=50;function st(e,t){if(!vg.test(e))throw new L(`${t} must be a stable lowercase id`)}function kg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function Kn(e){let t=wg.filter(r=>e[r]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],i=e[n];return{polarity:n,value:n==="zero"?0:i}}function ro(e,t){return A(e)===A(t)}function zl(e,t){if(t.polarity==="equals")return ro(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let i=t.value;return e.every(r=>i.includes(r))}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 Wl(e){let t=Kn(e),n=e.negative_control.cases;return n.some(i=>i.expected==="pass")&&n.some(i=>i.expected==="fail")&&n.every(i=>zl(i.observed,t)===(i.expected==="pass"))}function Eg(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,i=t.value;return!Array.isArray(n)||!Array.isArray(i)||i.some(r=>!n.includes(r))}return!ro(e.value,t.value)}function Sg(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},i=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return Eg(Kn(e),Kn(t))||n[t.enforcement]<n[e.enforcement]||i}function xg(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,i=Number(t)+Number(n);if(e.field!==void 0&&i!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&i!==0)throw new L("items source equals/state requires field")}function Ig(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(t=>t!==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 Rg(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 ao(e){st(e.id,"measurement.id"),e.max_cost!==void 0&&kg(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 ${no.join(", ")}`);let n=Reflect.get(t,"kind");if(!no.includes(n))throw new L(`measurement.source.kind must be one of ${no.join(", ")}`);let i=t;if(i.kind==="items"&&xg(i),i.kind==="dependency_kind"&&Ig(i),i.kind==="prose_edge_gap"&&Rg(i),(i.kind==="graph"||i.kind==="validate"||i.kind==="health")&&(typeof i.field!="string"||i.field.trim().length===0))throw new L(`${i.kind} source requires field`);return i.kind==="provider"&&(st(i.provider,"provider source provider"),st(i.key,"provider source key")),e}function oo(e){if(st(e.id,"assertion.id"),st(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=Kn(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"&&st(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(i=>i.expected==="pass")||!n.some(i=>i.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!Wl(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Ag(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)st(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(!jt.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 ql(e){if(st(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)st(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${jt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!jt.includes(t))throw new L(`gate trigger must be one of ${jt.join(", ")}`);return e.provider_policy&&Ag(e.provider_policy),e}function fn(e){if(e.version!==Ul)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let i of e.measurements){if(ao(i),t.has(`measurement:${i.id}`))throw new L(`duplicate measurement ${i.id}`);t.add(`measurement:${i.id}`)}for(let i of e.assertions){if(oo(i),t.has(`assertion:${i.id}`))throw new L(`duplicate assertion ${i.id}`);t.add(`assertion:${i.id}`)}for(let i of e.gates){ql(i);let r=i.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(r.length>0)throw new L(`gate ${i.id} references missing assertions: ${r.join(", ")}`);if(t.has(`gate:${i.id}`))throw new L(`duplicate gate ${i.id}`);t.add(`gate:${i.id}`)}let n=new Set(e.measurements.map(i=>i.id));for(let[i,r]of Gl(e))if(!n.has(i))throw new L(`${r.join(", ")} references missing measurement ${i}`);return e}function so(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)so(n,t)}function Gl(e){let t=new Map,n=(i,r)=>{let a=t.get(i)??[];a.push(r),t.set(i,a)};for(let i of e.assertions)n(i.measurement_id,`assertion ${i.id}`),i.scope.kind==="filter"&&n(i.scope.measurement_id,`assertion ${i.id} scope`);for(let i of e.measurements){if(i.source.kind!=="derived")continue;let r=[];so(i.source.expression,r);for(let a of r)n(a,`derived measurement ${i.id}`)}return t}function Cg(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]:[]]}),i=new Set,r=new Set;for(;n.length>0;){let a=n.pop();if(i.has(a))continue;i.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?r.add(o.source.provider):o.source.kind==="derived"&&so(o.source.expression,n)}return r}function Yn(){return{version:Ul,measurements:[],assertions:[],gates:[]}}function Tg(e,t){let n=t.items.filter(i=>(e.statuses===void 0||e.statuses.includes(i.status))&&(e.types===void 0||e.types.includes(i.type))&&(e.tags===void 0||e.tags.every(r=>i.tags?.includes(r)))&&(e.field===void 0||(()=>{let r=i[e.field];if(e.state!==void 0){let a=r==null||r===""||Array.isArray(r)&&r.length===0;return e.state==="missing"?a:!a}return ro(r,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function $g(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 Dg(e,t){let n=[],i=Oa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let r of t.items)for(let a of r.dependencies??[]){let o=Oa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===i&&$g(e,s)&&n.push(`${r.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function Og(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 i=e[n];if(Array.isArray(i)){for(let r of i)if(typeof r=="string")t.push(r);else if(typeof r=="object"&&r!==null){let a=Reflect.get(r,"text");typeof a=="string"&&t.push(a)}}}return t}function Pg(e,t,n,i){return e.some(r=>r.holder_id.trim().toLowerCase()===t.toLowerCase()&&(r.target_id===void 0||r.target_id.trim().toLowerCase()===n.toLowerCase())&&(r.text_contains===void 0||i.toLowerCase().includes(r.text_contains.trim().toLowerCase())))}function io(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function Lg(e){let t=new Map,n=new Set,i=[],r=/(?<![\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(io(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(io(o.id,s));for(let s of Og(o)){let c=[...s.matchAll(r)].map(d=>d[0]);a+=c.length,i.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:i,mention_count:a}}function Ng(e,t){let n=Lg(t.items),i=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=io(o.holder_id,d);if(n.linked_pairs.has(l)||Pg(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);i.get(l)?.explicit===!0&&!u||i.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let r=[...i.values()],a=r.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:r.filter(o=>o.explicit).length,implicit_subject:r.filter(o=>!o.explicit).length}}}function Mg(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 jg(e,t){let n=t.items.filter(i=>{let r=i[e.link],a=Array.isArray(r)&&r.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function Fg(e,t){let n=e.source;return n.kind==="items"?Tg(n,t):n.kind==="dependency_kind"?Dg(n,t):n.kind==="prose_edge_gap"?Ng(n,t):n.kind==="history"?Mg(n,t):n.kind==="links"?jg(n,t):null}function Bl(e,t){return e.reduce((n,i)=>({units:n.units+i.units,items_scanned:n.items_scanned+i.items_scanned,history_entries:n.history_entries+i.history_entries,provider_calls:n.provider_calls+i.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function Ug(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,i)=>n+i,0);if(e==="subtract")return t.slice(1).reduce((n,i)=>n-i,t[0]);if(e==="multiply")return t.reduce((n,i)=>n*i,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,i)=>n/i,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function Jl(e,t,n){let i=new Array(e.length),r=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;r<e.length;){let o=r;r+=1,i[o]=await n(e[o],o)}});return await Promise.all(a),i}async function Vl(e,t,n,i,r){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 Kl(o,t,n,i,r);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=r.charged.has(o.id)?[]:[s.cost];return r.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await Jl(e.operands,Hl,o=>Vl(o,t,n,i,r));return{value:Ug(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 Hg(e,t,n,i,r){ao(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await Vl(e.source.expression,t,n,[...i,e.id],r);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=Fg(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=Bl([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new we(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${gg("sha256").update(A(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function Kl(e,t,n,i,r){if(i.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...i,e.id].join(" -> ")}`);let a=r.cache.get(e.id);if(a)return a;let o=Hg(e,t,n,i,r).catch(s=>{if(s instanceof Ye&&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 Ye(s.message,c);throw d.cause=s,d}throw s});return r.cache.set(e.id,o),o}async function co(e,t,n=[e]){return Kl(e,t,n,[],{cache:new Map,charged:new Set})}function zg(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 Wg(e,t,n={}){oo(e);let i=Kn(e),r=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:i,distance:zg(t.value,i),verdict:r?"retired":zl(t.value,i)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:Wl(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function qg(e,t,n,i){let r=Cg(e,t);if(r.size===0)return;let a=e.provider_policy,o=a?.triggers[i];if(!a||!o)throw new we(`assurance gate ${e.id} refuses provider execution at trigger ${i} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of r){if(!s.has(d))throw new we(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new we(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new we(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${i}`);if(l.network&&!o.allow_network)throw new we(`assurance gate ${e.id} refuses network provider ${d} at trigger ${i}`)}}async function Fl(e,t,n,i,r){try{return await co(n,i,r)}catch(a){if(a instanceof Ye){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new we(`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 Yl(e,t,n,i){fn(t);let r=t.gates.find(c=>c.id===e);if(!r)throw new we(`assurance gate ${e} not found`);if(!r.triggers.includes(i.trigger))throw new we(`assurance gate ${e} does not declare trigger ${i.trigger}`);qg(r,t,n,i.trigger);let a=await Jl(r.assertion_ids,Hl,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 Fl(r.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 Wg(d,await Fl(r.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:r.id,tree_id:n.tree_id,trigger:i.trigger,dry_run:i.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:Bl(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function wr(e){return yg.join(e,"assurance.json")}async function Xl(e){let t=await B(wr(e));return t===null?Yn():vr(t)}function vr(e){try{return fn(JSON.parse(e))}catch(t){throw new g("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",y.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 br(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Gg(e,t){e==="measurement"?ao(t):e==="assertion"?oo(t):ql(t)}async function Xn(e,t){let n=structuredClone(br(await Xl(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function Zl(e,t,n){let i=br(await Xl(e),t).find(r=>r.id===n);if(!i)throw new we(`assurance ${t} ${n} not found`);return structuredClone(i)}async function kr(e,t,n,i={}){Gg(t,n);let r=await T(e),a=z(i.author,r.author_default),o=await an({pmRoot:e,filePath:wr(e),op:`assurance:${t}:put`,author:a,message:i.message,lockTtlSeconds:gr,lockWaitMs:yr,mutate:s=>{let c=s===null?Yn():vr(s),d=br(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&Sg(d[l],n)){let m=n.authorization_decision;if(!m||!i.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),fn(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 lo(e,t,n={}){let i=Yn();i.measurements=structuredClone(t.measurements),i.assertions=structuredClone(t.assertions),i.gates=structuredClone(t.gates),fn(i);let r=await T(e),a=z(n.author,r.author_default),o=await an({pmRoot:e,filePath:wr(e),op:"assurance:bundle:apply",author:a,message:n.message,lockTtlSeconds:gr,lockWaitMs:yr,mutate:s=>{let c=s===null?Yn():vr(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(A(_)!==A(h))throw new L(`assurance bundle refuses to replace divergent ${p} ${h.id}`);l.push(`${p}:${h.id}`)}};return u(c.measurements,i.measurements,"measurement"),u(c.assertions,i.assertions,"assertion"),u(c.gates,i.gates,"gate"),fn(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 Ql(e,t,n,i={}){let r=await T(e),a=z(i.author,r.author_default),o=await an({pmRoot:e,filePath:wr(e),op:`assurance:${t}:remove`,author:a,message:i.message,lockTtlSeconds:gr,lockWaitMs:yr,mutate:s=>{let c=s===null?Yn():vr(s);if(t==="measurement"){let u=Gl(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 d=br(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new L(`assurance ${t} ${n} not found`);return d.splice(l,1),fn(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 eu(e,t,n={}){if(t.dry_run)throw new TypeError("dry-run assurance verdicts are not persisted");let i=await T(e);await rn({pmRoot:e,op:"assurance:gate:verdict",author:z(n.author,i.author_default),context:{assurance_verdict:t},message:n.message??`Assurance gate ${t.gate_id} returned ${t.verdict}`,lockTtlSeconds:gr,lockWaitMs:yr})}async function tu(e,t={}){let n=t.limit??bg;if(!Number.isInteger(n)||n<1||n>pn)throw new TypeError(`assurance verdict limit must be an integer from 1 through ${pn}`);return(await Me(nn(e),te)).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)}import{mkdir as Bg,readFile as Jg}from"node:fs/promises";import iu from"node:path";import{createHash as Vg}from"node:crypto";(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]="a8daf042-f74c-5f51-b7e8-f8ff4fb8fe8e")}catch{}})();var uo=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},ru="sdk-workspace-transaction",au=/^[a-zA-Z0-9._-]+$/,ou=30,su=3e3;function _o(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!au.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function mo(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function go(e){return{pmRoot:mo(e.pmRoot,"Transaction pmRoot"),transactionId:_o(e.transactionId,"Transaction id"),author:mo(e.author,"Transaction author")}}function Sr(e,t,n){let i=e??t;if(!Number.isInteger(i)||i<=0)throw new TypeError(`${n} must be a positive integer`);return i}function cu(e,t){return iu.join(e,"transactions","sdk",`${t}.json`)}async function Xe(e,t){t.updatedAt=$();let n=cu(e,t.transactionId);await Bg(iu.dirname(n),{recursive:!0}),await Z(n,`${JSON.stringify(t,null,2)}
@@ -8,12 +8,12 @@ import{c as St,d as dn,e as ln,f as un,g as Nl,j as jl}from"./chunk-QFMJGQGO.js"
8
8
  `)){let i=/^([0-9a-f^]{40,64}) \d+ \d+(?: \d+)?$/u.exec(n)?.[1];i&&t.set(i,(t.get(i)??0)+1)}return t}function Sy(e){let t=e.split("\0"),n=new Map;for(let i=0;i+1<t.length;i+=2){let r=t[i]?.trim();if(!r)continue;let a=[...new Set(t[i+1]?.match(/\bpm-[a-z0-9][a-z0-9-]{2,63}\b/gu)??[])].sort((o,s)=>o.localeCompare(s));n.set(r,a)}return n}async function xy(e){let t=xu.relative(e.workspaceRoot,xu.resolve(e.workspaceRoot,e.sourcePath)),n=await Iu(e.workspaceRoot,["blame","--line-porcelain","-L",`${e.lineRange.start},${e.lineRange.end}`,"--",t]),i=await Iu(e.workspaceRoot,["log","-n","256","--format=%H%x00%B%x00","--",t]);return{commitLines:Ey(n),commitItems:Sy(i),available:!0}}function Iy(e){let t=e.current.nodes.at(-1),n=e.current.kinds.length+1,i;for(let r of e.graph.incidentEdges(t)){let a=r.source===t,o=a?r.target:r.source;if((e.visitedDepth.get(o)??Number.POSITIVE_INFINITY)<n)continue;e.visitedDepth.set(o,n);let s=e.graph.registry().require(r.kind),c={nodes:[...e.current.nodes,o],kinds:[...e.current.kinds,a?r.kind:s.inverse??r.kind]};e.details.get(o)?.type?.toLowerCase()==="decision"?(i=n,e.found.push(c)):e.queue.push(c)}return i}function Ry(e){let t=[{nodes:[e.itemId],kinds:[]}],n=new Map([[e.itemId,0]]),i=[],r;for(;t.length>0;){let a=t.shift(),o=a.kinds.length;r!==void 0&&o>=r||o>=e.maxDepth||(r=Iy({current:a,graph:e.graph,details:e.details,visitedDepth:n,queue:t,found:i})??r)}return i.sort((a,o)=>a.nodes.join("\0").localeCompare(o.nodes.join("\0"))),i}function Ay(e,t,n){let i=$l(t);if(!i.graph.hasNode(e))return{status:"not_found",nodes:[],kinds:[],alternative_decision_ids:[]};let r=Ry({itemId:e,maxDepth:n,graph:i.graph,details:new Map(i.details.map(s=>[s.id,s]))}),a=r[0];if(!a)return{status:"not_found",nodes:[],kinds:[],alternative_decision_ids:[]};let o=[...new Set(r.map(s=>s.nodes.at(-1)))];return{status:o.length===1?"found":"ambiguous",nodes:a.nodes,kinds:a.kinds,alternative_decision_ids:o.slice(1)}}async function Cy(e){if(!e.lineRange)return{commitLines:new Map,commitItems:new Map,available:!0};try{return await xy({workspaceRoot:e.workspaceRoot,sourcePath:e.paths[0],lineRange:e.lineRange})}catch{return{commitLines:new Map,commitItems:new Map,available:!1}}}function Ty(e){let t=[];return e.hasLineRange&&!e.attributionAvailable&&t.push("git_attribution_unavailable"),e.hasLineRange&&e.contributionLines===0&&t.push("line_attribution_unmapped"),e.decisionStatus==="ambiguous"&&t.push("multiple_governing_decisions"),e.decisionStatus==="not_found"&&t.push("governing_decision_not_found"),t}function $y(e){return[...e.commitLines.keys()].filter(t=>(e.commitItems.get(t)?.length??0)>0)}async function Au(e){Ru(e.lineRange);let t=e.decisionDepth??8;if(!Number.isSafeInteger(t)||t<1||t>32)throw new RangeError("Decision path depth must be an integer from 1 to 32.");let n=await Cy(e),i=$y(n),r=new Map;for(let a of e.candidates){let o=[...n.commitLines.entries()].filter(([l])=>n.commitItems.get(l)?.includes(a.item.id)),s=o.reduce((l,[,u])=>l+u,0),c=Ay(a.item.id,e.corpus,t),d=Ty({hasLineRange:e.lineRange!==void 0,attributionAvailable:n.available,contributionLines:s,decisionStatus:c.status});r.set(a.item.id,{score:s*100+a.files.length*10+Math.max(0,9-Math.floor((Date.now()-Date.parse(a.item.updated_at))/(720*60*60*1e3))),contribution_lines:s,evidence:[...a.files.map(l=>({kind:"linked_file",reference:l.path})),...o.map(([l,u])=>({kind:"git_commit",reference:l.slice(0,12),contribution_lines:u}))],rationale:{value:a.item.value?.trim()||null,why_now:a.item.why_now?.trim()||null,outcome:a.item.outcome?.trim()||null,objective:a.item.objective?.trim()||null},decision_path:c,ambiguities:d})}return{explanations:r,receipt:{line_range:e.lineRange??null,blamed_commit_count:n.commitLines.size,mapped_commit_count:i.length,unmapped_commit_count:n.commitLines.size-i.length,decision_depth:t}}}(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]="bee6d15d-ca4a-538c-bb70-fd3dc7e2a8ec")}catch{}})();var ni=["software-delivery","research","agent-evaluation","operations"];function Cu(e,t,n,i,r){return{id:e,measurement_id:t,owner_item_id:n,scope:{kind:"active"},ceiling:i,lifetime:"hold",enforcement:r,negative_control:{cases:[{observed:i,expected:"pass"},{observed:i+1,expected:"fail"}]}}}function Rr(e,t,n,i,r){let a=`preset-${e}`,o=r.map(c=>({id:`${a}-missing-${c}`,description:`Active items missing ${c} evidence.`,source:{kind:"links",link:c,state:"missing"}})),s=o.map(c=>Cu(`${c.id}-zero`,c.id,i,0,"warn"));return{id:e,title:t,description:n,declarations:{measurements:o,assertions:s,gates:[{id:`${a}-readiness`,description:n,assertion_ids:s.map(c=>c.id),triggers:["ci","scheduled"]}]}}}function Ar(e,t){return e==="software-delivery"?Rr(e,"Software delivery","Warn when active delivery work lacks executable tests or documentation.",t,["tests","docs"]):e==="research"?Rr(e,"Research","Warn when active research work lacks reproducibility files or documentation.",t,["files","docs"]):e==="agent-evaluation"?Rr(e,"Agent evaluation","Warn when active evaluation work lacks executable scenarios or recorded artifacts.",t,["tests","files"]):Rr(e,"Operations","Warn when active operational work lacks runbook documentation or repair evidence.",t,["docs","files"])}function Tu(e,t,n,i={}){return lo(e,Ar(t,n).declarations,i)}async function $u(e,t){let n=new Set(e.terminal_statuses??["closed","canceled"]),i={...e,items:e.items.filter(r=>!n.has(r.status))};return await Promise.all(["files","tests","docs"].map(async r=>{let a={id:`derived-active-missing-${r}`,description:`Observed active items missing ${r} evidence.`,source:{kind:"links",link:r,state:"missing"}},o=(await co(a,i)).value,s=Cu(`${a.id}-ceiling`,a.id,t,o,"observe"),c=`active-missing-${r}`;return{id:c,population_size:i.items.length,scope:{kind:"active"},observed:o,declarations:{measurements:[a],assertions:[s],gates:[{id:`derived-${c}`,description:`Observe the accepted ${r} evidence baseline.`,assertion_ids:[s.id],triggers:["ci","scheduled"]}]}}}))}function Du(e,t,n={}){return lo(e,{measurements:t.flatMap(i=>i.declarations.measurements),assertions:t.flatMap(i=>i.declarations.assertions),gates:t.flatMap(i=>i.declarations.gates)},n)}async function Ou(e,t,n,i={}){let r=t.enforcement==="observe"?"warn":"block";if(t.enforcement==="block"||n!==r)throw new TypeError(`assurance assertion ${t.id} promotion must be ${t.enforcement} -> ${r}`);return kr(e,"assertion",{...t,enforcement:n},{...i,message:i.message??`Promote assurance assertion ${t.id} from ${t.enforcement} to ${n}`})}import Nu from"node:fs/promises";import{createRequire as Dy}from"node:module";import Ae 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]="32adaa7c-f0aa-5aff-8d88-d7c0ccfbd971")}catch{}})();function Pu(e,t){let n=Ae.relative(t,e);if(n.length>0&&n!==".."&&!n.startsWith(`..${Ae.sep}`)&&!Ae.isAbsolute(n))return n.split(Ae.sep).join("/");let i=Ae.resolve(e),r=0xcbf29ce484222325n;for(let a=0;a<i.length;a+=1)r^=BigInt(i.charCodeAt(a)),r=BigInt.asUintN(64,r*0x100000001b3n);return`<external>/${r.toString(16).padStart(16,"0")}/${Ae.basename(Ae.dirname(e))}/package.json`}function Oy(e){return e.includes(`${Ae.sep}.pnpm${Ae.sep}`)?"pnpm":e.includes(`${Ae.sep}node_modules${Ae.sep}`)?"npm":"other"}async function Lu(e){try{let t=JSON.parse(await Nu.readFile(e,"utf8"));return t.name==="@unbrained/pm-cli"&&typeof t.version=="string"&&t.version.trim().length>0?t.version.trim():void 0}catch{return}}async function wo(e){try{return await Nu.realpath(e)}catch{return Ae.resolve(e)}}async function Mu(e,t,n=Ge(import.meta.url,["../../.."])){let i=await wo(t),r=await wo(Ae.join(n,"package.json")),a=await Lu(r),o=new Map;a!==void 0&&o.set(r,{version:a,path:Pu(r,i),layout:"host",consumers:["pm-cli-host"]});for(let d of e)try{let l=Dy(d.entry_path).resolve("@unbrained/pm-cli/package.json"),u=await wo(l),m=await Lu(u);if(m===void 0)continue;let f=u,p=o.get(f);if(p){p.consumers.includes(d.name)||(p.consumers.push(d.name),p.consumers.sort((h,_)=>h.localeCompare(_)));continue}o.set(f,{version:m,path:Pu(u,i),layout:Oy(u),consumers:[d.name]})}catch{}let s=[...o.values()].sort((d,l)=>d.path.localeCompare(l.path)),c=a===void 0?[]:s.filter(d=>d.version!==a);return{host_version:a??null,copies:s,mismatches:c,warnings:c.map(d=>`extension_host_pm_cli_version_skew:${a}:${d.version}:${d.consumers.join("+")}`)}}import vo from"node:fs/promises";import bo 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]="069e2e60-11d9-5a37-a966-9073944d32a2")}catch{}})();var ju=8388608,Py=new Set(["resolved","failed"]),Ly=[{kind:"boolean",matches:e=>typeof e=="boolean"||typeof e=="string"&&/^(?:true|false)$/iu.test(e.trim())},{kind:"single_digit",matches:e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=9||typeof e=="string"&&/^\d$/u.test(e.trim())}];function Ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ko(e){return Ly.find(t=>t.matches(e))?.kind}function Fu(e){let t=new Map,n=0,i=0;return{entries:e.map(r=>{let a=Ze(r.agent_provenance)?r.agent_provenance:void 0;if(a===void 0||!qd(r).ok)return r;let o={},s=!1;for(let[d,l]of Object.entries(a)){let u=Ze(l)?ko(l.value):void 0;if(u===void 0){o[d]=l;continue}s=!0,i+=1;let m=r.agent_harness??"unknown",f=`${m}\0${d}\0${u}`,p=t.get(f)??{harness:m,dimension:d,kind:u,count:0};p.count+=1,t.set(f,p)}if(!s)return r;n+=1;let c={...r};return Object.keys(o).length===0?delete c.agent_provenance:c.agent_provenance=o,Gd(r,c,{retainPriorRecord:!0,retainPriorRecordHash:!1})}),receipt:{changed:n>0,events_changed:n,observations_removed:i,invalid_values:[...t.values()].sort((r,a)=>r.harness.localeCompare(a.harness)||r.dimension.localeCompare(a.dimension)||r.kind.localeCompare(a.kind))}}}async function Uu(e){let t=[];for(let n of await Hu(e)??[])try{let i=await vo.readFile(bo.join(e,"history",n),"utf8");for(let r of i.split(`
9
9
  `)){if(r.trim().length===0)continue;let a=zu(r);if(!(a===null||!Ze(a.agent_provenance))&&Object.values(a.agent_provenance).some(o=>Ze(o)&&ko(o.value)!==void 0)){t.push(n.slice(0,-6));break}}}catch{}return t}async function Hu(e){try{return(await vo.readdir(bo.join(e,"history"))).filter(t=>t.endsWith(".jsonl")).sort()}catch{return null}}async function Ny(e,t,n){let i;try{i=await vo.open(bo.join(e,"history",t),"r");let r=(await i.stat()).size,a=Math.min(r,Math.max(0,n)),o=Buffer.alloc(a),{bytesRead:s}=await i.read(o,0,a,0),c=o.subarray(0,s).toString("utf8"),d=s>=r,l=c.lastIndexOf(`
10
10
  `),u=c;return d||(u=l===-1?"":c.slice(0,l+1)),{content:u,bytesRead:s,complete:d}}catch{return null}finally{await i?.close()}}function zu(e){try{let t=JSON.parse(e);return Ze(t)?t:null}catch{return null}}function My(e,t,n){let i=typeof e.agent_harness=="string"?e.agent_harness:void 0;if(i===void 0)return;let r=Ze(e.agent_provenance)?e.agent_provenance:{};if(Object.entries(r).forEach(([o,s])=>{if(!Ze(s))return;let c=ko(s.value);if(!c)return;let d=`${i}\0${o}\0${c}`,l=n.get(d)??{harness:i,dimension:o,kind:c,count:0};l.count+=1,n.set(d,l)}),!Ze(e.context))return;let a=e.context.agent_provenance_outcomes;Ze(a)&&Object.entries(a).forEach(([o,s])=>{if(!Ze(s)||typeof s.resolver!="string"||!Py.has(String(s.status)))return;let c=`${i}\0${o}\0${s.resolver}`,d=t.get(c)??{harness:i,dimension:o,resolver:s.resolver,attempts:0,successes:0};d.attempts+=1,s.status==="resolved"&&(d.successes+=1),t.set(c,d)})}function jy(e,t,n,i,r,a){let o=r;for(let s of e.split(`
11
- `)){if(s.trim().length===0)continue;if(o>=i)return{eventsRead:o,truncated:!0};o+=1;let c=zu(s);if(c===null){a.malformed_events+=1;continue}if(typeof c.ts=="string"&&vt(c.ts)){let d=new Date(c.ts).toISOString();(a.earliest_event_at===null||d<a.earliest_event_at)&&(a.earliest_event_at=d),(a.latest_event_at===null||d>a.latest_event_at)&&(a.latest_event_at=d)}My(c,t,n)}return{eventsRead:o,truncated:!1}}function Fy(e,t,n){return n?[...e.filter(i=>i.attempts>0&&i.successes===0).map(i=>`provenance_resolver_zero_success:${i.harness}:${i.dimension}:${i.resolver}:${String(i.attempts)}`),...t.map(i=>`provenance_value_domain_invalid:${i.harness}:${i.dimension}:${i.kind}:${String(i.count)}`)]:[]}async function Wu(e,t=1e4){if(!Number.isSafeInteger(t)||t<0)throw new RangeError("Provenance event limit must be a non-negative safe integer.");let n={scope:"history_prefix",event_limit:t,byte_limit:ju,bytes_read:0,events_read:0,truncated:!1,unreadable_sources:0,malformed_events:0,earliest_event_at:null,latest_event_at:null,complete:!1},i=new Map,r=new Map,a=0,o=0,s=!1,c=await Hu(e);c===null&&(n.unreadable_sources+=1);for(let u of c??[]){let m=await Ny(e,u,Math.max(0,ju-o));if(m===null){n.unreadable_sources+=1;continue}o+=m.bytesRead;let f=jy(m.content,i,r,t,a,n);if(a=f.eventsRead,f.truncated){s=!0;break}if(!m.complete){s=!0;break}}let d=[...i.values()].sort((u,m)=>u.harness.localeCompare(m.harness)||u.dimension.localeCompare(m.dimension)||u.resolver.localeCompare(m.resolver)),l=[...r.values()].sort((u,m)=>u.harness.localeCompare(m.harness)||u.dimension.localeCompare(m.dimension)||u.kind.localeCompare(m.kind));return n.bytes_read=o,n.events_read=a,n.truncated=s,n.complete=!s&&n.unreadable_sources===0&&n.malformed_events===0,{outcomes:d,sample:n,invalid_values:l,warnings:Fy(d,l,n.complete),events_read:a,truncated:s}}import Uy from"node:fs/promises";(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]="eeaf2318-5964-5d98-ad90-9faa7fc69975")}catch{}})();function Eo(e){if(!e.itemDocument)return[];let t=e.itemDocument.metadata?.assignee?.trim();if(!t||t===e.author||e.force)return[];let n=je(e.settings);if(n.ownership_enforcement==="strict")throw new g(`Item ${e.subjectId} is assigned to ${t}. Use --force to override.`,y.CONFLICT);return n.ownership_enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.subjectId}:${t}`]:[]}async function Hy(e){let t=await B(e.subject.historyPath);if(t!==e.historyRawBeforeLock)throw new g(`History for ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,y.CONFLICT);let n=await ge(e.pmRoot,e.subject.id,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder),i=n?e.readItem?await e.readItem(n):await ye(n,{schema:e.settings.schema}):null;if((i?.raw??null)!==(e.currentItemRawBeforeLock??null))throw new g(`Item ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,y.CONFLICT);return{historyRawUnderLock:t,locatedUnderLock:n,loadedItemUnderLock:i}}async function Cr(e){let t=e.writeHistoryRaw??Z;try{await t(e.historyPath,e.nextHistoryRaw),await Ba(e.historyPath)}catch(n){try{e.historyRawUnderLock===null?await Uy.rm(e.historyPath,{force:!0}):await t(e.historyPath,e.historyRawUnderLock),await Ba(e.historyPath)}catch(i){throw new AggregateError([n,i],`History rewrite failed and rollback also failed: ${String(n)}`)}throw n}}async function qu(e){let t=[...Eo({itemDocument:e.itemDocument,subjectId:e.subject.id,author:e.author,force:e.force,settings:e.settings})],n=await re(e.pmRoot,e.subject.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms);try{let i=await Hy({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItemRawBeforeLock,operation:e.operation});return await e.applyRewrite(i),e.applyPostRewrite&&t.push(...await e.applyPostRewrite(i)),t}finally{await 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]="6283ef18-f75e-5e8c-a65f-0ba05858bc2b")}catch{}})();async function Gu(e){let{subject:t,settings:n,operation:i,options:r}=e,a=await Hd(t.historyPath,t.id);if(a.raw===null)throw new g(`No history stream exists for ${t.id}.`,y.NOT_FOUND);if(a.entries.length===0)throw new g(`No history entries exist for ${t.id}; nothing to ${i.slice(8)}.`,y.USAGE);let o=t.located?await ye(t.located,{schema:n.schema}):null,s=z(r.author,n.author_default),c=await e.transform({raw:a.raw,entries:a.entries,verification:Gn(a.entries),loadedItem:o,author:s}),d=Gn(c.rewrittenEntries);if(!d.ok)throw new g(`${i} produced an invalid rewritten chain (${d.errors.join(", ")}).`,y.GENERIC_FAILURE);let l=c.changed&&!r.dryRun?await qu({pmRoot:e.pmRoot,subject:t,settings:n,typeRegistry:e.typeRegistry,historyRawBeforeLock:a.raw,currentItemRawBeforeLock:o?.raw??null,operation:i,author:s,force:r.force,itemDocument:o?.document??null,applyRewrite:async u=>{await c.beforeWrite?.(),c.applyRewrite?await c.applyRewrite(u):await Cr({historyPath:t.historyPath,nextHistoryRaw:Nt(c.rewrittenEntries),historyRawUnderLock:u.historyRawUnderLock})},applyPostRewrite:c.afterWrite??(async()=>K({path:t.historyPath,scope:"project",op:`${i.replace("-","_")}:history`}))}):[];return c.report({verification:d,warnings:l})}(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]="d8f1968e-a030-5a3c-b766-60a409163745")}catch{}})();function Tr(e,t,n=25){let i=e.definitions.filter(o=>o.roles.length===0).map(o=>o.id).sort((o,s)=>o.localeCompare(s)),r=new Set(i),a=t.filter(o=>{let s=ad(o.status,e);return s!==void 0&&r.has(s)}).map(o=>o.id).sort((o,s)=>o.localeCompare(s));return{roleless_status_count:i.length,roleless_statuses:i.slice(0,n),roleless_statuses_truncated:i.length>n,affected_item_count:a.length,affected_item_ids:a.slice(0,n),affected_item_ids_truncated:a.length>n}}function $r(e){return e.roleless_status_count===0?[]:[`schema_status_missing_lifecycle_role:${e.roleless_status_count}`]}(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]="717434ef-3c62-50a8-8887-e2bbc3851eff")}catch{}})();var Ju=8,So=100;function Vu(e,t){return e.length<=t?{values:e,truncated:!1}:{values:e.slice(0,t),truncated:!0}}function Fe(e,t){return Array.isArray(e)?{count:e.length,sample:e.slice(0,t),truncated:e.length>t}:{count:0,sample:[],truncated:!1}}function zy(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let t=e;return{layer:t.layer,directory:t.directory,name:t.name,version:t.version,enabled:t.enabled,status:t.status,has_activate:t.has_activate,capabilities:t.capabilities}}function ii(e,t){let n=Fe(e,t);return{...n,sample:n.sample.map(i=>zy(i))}}function W(e,t){if(!Array.isArray(e))return{count:0,sample:[],truncated:!1};let n=e.filter(i=>typeof i=="string");return{count:n.length,sample:n.slice(0,t),truncated:n.length>t}}function Wy(e){if(typeof e!="object"||e===null)return null;let t=e;return{applied_count:t.applied_count,pending_count:t.pending_count,failed_count:t.failed_count}}var qy={settings:(e,t)=>({version:e.version,id_prefix:e.id_prefix,locks_ttl_seconds:e.locks_ttl_seconds,warnings:W(e.warnings,t)}),directories:(e,t)=>({required_count:Array.isArray(e.required)?e.required.length:0,optional_count:Array.isArray(e.optional)?e.optional.length:0,missing_required:W(e.missing_required,t),missing_optional:W(e.missing_optional,t),missing:W(e.missing,t),strict_directories:e.strict_directories}),settings_values:(e,t)=>({warnings:W(e.warnings,t)}),telemetry:e=>({enabled:e.enabled,capture_level:e.capture_level,endpoint:e.endpoint,queue_exists:e.queue_exists,queue_entries:e.queue_entries,queue_draining:e.queue_draining,queue_invalid_rows:e.queue_invalid_rows,queue_rows_total:e.queue_rows_total,last_successful_flush_at:e.last_successful_flush_at,last_failed_flush_at:e.last_failed_flush_at,endpoint_probe:e.endpoint_probe,env_overrides:e.env_overrides}),extensions:(e,t)=>{let n=typeof e.activation=="object"&&e.activation!==null?e.activation:{};return{disabled_by_flag:e.disabled_by_flag,discovered:ii(e.discovered,t),effective:ii(e.effective,t),loaded:ii(e.loaded,t),failed:Fe(e.failed,t),warnings:W(e.warnings,t),activation:{failed:Fe(n.failed,t),warnings:W(n.warnings,t),hook_counts:n.hook_counts,command_handler_count:n.command_handler_count,service_override_count:n.service_override_count,renderer_override_count:n.renderer_override_count,registration_counts:n.registration_counts,migration_status:Wy(n.migration_status)},author_manifest:e.author_manifest,triage:e.triage,capability_contract:e.capability_contract,capability_guidance:Fe(e.capability_guidance,t),host_version_census:e.host_version_census}},storage:(e,t)=>{let n=typeof e.author_attribution=="object"&&e.author_attribution!==null?e.author_attribution:void 0;return{...e,...n?{author_attribution:{...n,affected_item_ids:W(n.affected_item_ids,t),samples:Fe(n.samples,t)}}:{}}},locks:e=>({active_lock_count:e.active_lock_count,stale_lock_count:e.stale_lock_count,unreadable_lock_count:e.unreadable_lock_count,unparseable_lock_count:e.unparseable_lock_count}),integrity:(e,t)=>{let n=typeof e.tracked_runtime_cache=="object"&&e.tracked_runtime_cache!==null?e.tracked_runtime_cache:void 0;return{checked_item_files:e.checked_item_files,checked_history_streams:e.checked_history_streams,counts:e.counts,item_unreadable:W(e.item_unreadable,t),item_conflict_markers:Fe(e.item_conflict_markers,t),item_parse_failures:W(e.item_parse_failures,t),tracked_runtime_cache:n===void 0?e.tracked_runtime_cache:{...n,tracked_paths:W(n.tracked_paths,t)},history_unreadable:W(e.history_unreadable,t),history_conflict_markers:Fe(e.history_conflict_markers,t),history_invalid_json:Fe(e.history_invalid_json,t),skipped:e.skipped}},history_drift:(e,t)=>{let n=typeof e.cache_confirmation=="object"&&e.cache_confirmation!==null?e.cache_confirmation:void 0;return{checked_items:e.checked_items,cache_hit_verification:e.cache_hit_verification,cache_confirmation:n===void 0?e.cache_confirmation:{...n,candidate_items:W(n.candidate_items,t),confirmed_items:W(n.confirmed_items,t),resolved_false_positive_items:W(n.resolved_false_positive_items,t)},counts:e.counts,drifted_items:W(e.drifted_items,t),merge_receipt_attributed_items:W(e.merge_receipt_attributed_items,t),missing_streams:W(e.missing_streams,t),unreadable_streams:W(e.unreadable_streams,t),hash_mismatches:W(e.hash_mismatches,t),chain_mismatches:W(e.chain_mismatches,t),version_skews:W(e.version_skews,t),workspace_state_mismatches:W(e.workspace_state_mismatches,t),workspace_state_missing:W(e.workspace_state_missing,t),workspace_state_unreadable:W(e.workspace_state_unreadable,t),skipped:e.skipped}},vectorization:(e,t)=>({semantic_runtime_available:e.semantic_runtime_available,compatibility_mode_auto_defaults:e.compatibility_mode_auto_defaults,auto_ollama_defaults_applied:e.auto_ollama_defaults_applied,auto_ollama_defaults_skipped_reason:e.auto_ollama_defaults_skipped_reason,auto_ollama_defaults_remediation:e.auto_ollama_defaults_remediation,refresh_policy:e.refresh_policy,provider_active:e.provider_active,vector_store_active:e.vector_store_active,items:e.items,ledger_entries_before:e.ledger_entries_before,stale_items_before_total:e.stale_items_before_total,stale_items_before:W(e.stale_items_before,t),refresh_attempted:e.refresh_attempted,refresh_skipped_reason:e.refresh_skipped_reason,refresh_result:e.refresh_result,ledger_entries_after:e.ledger_entries_after,stale_items_after_total:e.stale_items_after_total,stale_items_after:W(e.stale_items_after,t),skipped:e.skipped})};function xo(e,t){let n=qy[e.name];return n?n(e.details,t):e.details}function Ku(e){return{disabled_by_flag:e.details.disabled_by_flag,loaded_count:Array.isArray(e.details.loaded)?e.details.loaded.length:0,failed_count:0,warning_count:0,restore_with:"pm health --full"}}function Gy(e){if(e.name==="extensions"&&e.status==="ok")return Ku(e);let t=xo(e,8);return Buffer.byteLength(JSON.stringify(t))<Buffer.byteLength(JSON.stringify(e.details))?t:e.details}function Io(e,t){let n=new Set([...t,...e.failed_because]);return(e.findings??[]).filter(i=>n.has(i.warning))}function By(e){let t=W(e.warnings,8);return{ok:e.ok,...e.verdict?{verdict:e.verdict}:{},checks:e.checks.map(n=>({name:n.name,status:n.status,ok:n.ok,details:Gy(n)})),warnings:t.sample,findings:Io(e,t.sample),failed_because:e.failed_because,projection:{mode:"brief",warning_count:t.count,warnings_truncated:t.truncated,detail_limit:8},generated_at:e.generated_at}}function Bu(e){return e.details.skipped===!0}function Jy(e){let t=W(e.warnings,8),n=e.checks.filter(Bu).map(i=>i.name);return{ok:e.ok,...e.verdict?{verdict:e.verdict}:{},checks:e.checks.filter(i=>!Bu(i)).map(i=>({name:i.name,status:i.status,ok:i.ok,details:{}})),warning_count:t.count,warnings:t.sample,findings:Io(e,t.sample),failed_because:e.failed_because,projection:{mode:"summary",warning_count:t.count,warnings_truncated:t.truncated,detail_limit:8,omitted_checks:n},generated_at:e.generated_at}}function Vy(e,t,n){return t.full===!0?e:n?Jy(e):t.brief===!0?By(e):{...e,checks:e.checks.map(i=>i.name==="extensions"&&i.status==="ok"?{...i,details:Ku(i)}:i),projection:{mode:"standard",warning_count:e.warning_count,warnings_truncated:e.warnings_truncated===!0,detail_limit:8}}}function Ro(e,t,n){let i=e.warning_count??e.warnings.length,r=e.warnings.slice(0,100),a={...e,warning_count:i,warning_limit:100,warnings_truncated:i>100,warnings:r,findings:Io(e,r)},o=Vy(a,t,n);return{...o,warning_count:i,warning_limit:100,warnings_truncated:i>o.warnings.length,...o.projection?{projection:{...o.projection,warning_count:i,warnings_truncated:i>o.warnings.length}}:{}}}import Co from"node:fs/promises";import ce from"node:path";import Ky from"node:readline/promises";import{stdin as Yy,stdout as Dr}from"node:process";(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]="f3a0706e-7162-5cde-9f48-c5de9b2fbd8e")}catch{}})();var I$=["ask","add","skip","status"],Xy=["AGENTS.md","CLAUDE.md"],Zy=["pm init","pm context","pm search","pm create","pm claim","pm files","pm docs","pm test --run","pm close","pm release","pm_author"],Qy=8,To=1,ew="<!-- pm-cli:agent-guidance:start:",tw=`<!-- pm-cli:agent-guidance:start:v${To} -->`,Ao="<!-- pm-cli:agent-guidance:end -->",ai="Add workflow guidance later: pm init --agent-guidance add";var nw=()=>Ky.createInterface({input:Yy,output:Dr});function hn(e,t){let n=ce.relative(e,t);return n.length===0?ce.basename(t):n.split(ce.sep).join("/")}function Yu(e){return e.endsWith(`
11
+ `)){if(s.trim().length===0)continue;if(o>=i)return{eventsRead:o,truncated:!0};o+=1;let c=zu(s);if(c===null){a.malformed_events+=1;continue}if(typeof c.ts=="string"&&vt(c.ts)){let d=new Date(c.ts).toISOString();(a.earliest_event_at===null||d<a.earliest_event_at)&&(a.earliest_event_at=d),(a.latest_event_at===null||d>a.latest_event_at)&&(a.latest_event_at=d)}My(c,t,n)}return{eventsRead:o,truncated:!1}}function Fy(e,t,n){return n?[...e.filter(i=>i.attempts>0&&i.successes===0).map(i=>`provenance_resolver_zero_success:${i.harness}:${i.dimension}:${i.resolver}:${String(i.attempts)}`),...t.map(i=>`provenance_value_domain_invalid:${i.harness}:${i.dimension}:${i.kind}:${String(i.count)}`)]:[]}async function Wu(e,t=1e4){if(!Number.isSafeInteger(t)||t<0)throw new RangeError("Provenance event limit must be a non-negative safe integer.");let n={scope:"history_prefix",event_limit:t,byte_limit:ju,bytes_read:0,events_read:0,truncated:!1,unreadable_sources:0,malformed_events:0,earliest_event_at:null,latest_event_at:null,complete:!1},i=new Map,r=new Map,a=0,o=0,s=!1,c=await Hu(e);c===null&&(n.unreadable_sources+=1);for(let u of c??[]){let m=await Ny(e,u,Math.max(0,ju-o));if(m===null){n.unreadable_sources+=1;continue}o+=m.bytesRead;let f=jy(m.content,i,r,t,a,n);if(a=f.eventsRead,f.truncated){s=!0;break}if(!m.complete){s=!0;break}}let d=[...i.values()].sort((u,m)=>u.harness.localeCompare(m.harness)||u.dimension.localeCompare(m.dimension)||u.resolver.localeCompare(m.resolver)),l=[...r.values()].sort((u,m)=>u.harness.localeCompare(m.harness)||u.dimension.localeCompare(m.dimension)||u.kind.localeCompare(m.kind));return n.bytes_read=o,n.events_read=a,n.truncated=s,n.complete=!s&&n.unreadable_sources===0&&n.malformed_events===0,{outcomes:d,sample:n,invalid_values:l,warnings:Fy(d,l,n.complete),events_read:a,truncated:s}}import Uy from"node:fs/promises";(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]="eeaf2318-5964-5d98-ad90-9faa7fc69975")}catch{}})();function Eo(e){if(!e.itemDocument)return[];let t=e.itemDocument.metadata?.assignee?.trim();if(!t||t===e.author||e.force)return[];let n=je(e.settings);if(n.ownership_enforcement==="strict")throw new g(`Item ${e.subjectId} is assigned to ${t}. Use --force to override.`,y.CONFLICT);return n.ownership_enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.subjectId}:${t}`]:[]}async function Hy(e){let t=await B(e.subject.historyPath);if(t!==e.historyRawBeforeLock)throw new g(`History for ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,y.CONFLICT);let n=await ge(e.pmRoot,e.subject.id,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder),i=n?e.readItem?await e.readItem(n):await ye(n,{schema:e.settings.schema}):null;if((i?.raw??null)!==(e.currentItemRawBeforeLock??null))throw new g(`Item ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,y.CONFLICT);return{historyRawUnderLock:t,locatedUnderLock:n,loadedItemUnderLock:i}}async function Cr(e){let t=e.writeHistoryRaw??Z;try{await t(e.historyPath,e.nextHistoryRaw),await Ba(e.historyPath)}catch(n){try{e.historyRawUnderLock===null?await Uy.rm(e.historyPath,{force:!0}):await t(e.historyPath,e.historyRawUnderLock),await Ba(e.historyPath)}catch(i){throw new AggregateError([n,i],`History rewrite failed and rollback also failed: ${String(n)}`)}throw n}}async function qu(e){let t=[...Eo({itemDocument:e.itemDocument,subjectId:e.subject.id,author:e.author,force:e.force,settings:e.settings})],n=await re(e.pmRoot,e.subject.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms);try{let i=await Hy({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItemRawBeforeLock,operation:e.operation});return await e.applyRewrite(i),e.applyPostRewrite&&t.push(...await e.applyPostRewrite(i)),t}finally{await 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]="6283ef18-f75e-5e8c-a65f-0ba05858bc2b")}catch{}})();async function Gu(e){let{subject:t,settings:n,operation:i,options:r}=e,a=await Hd(t.historyPath,t.id);if(a.raw===null)throw new g(`No history stream exists for ${t.id}.`,y.NOT_FOUND);if(a.entries.length===0)throw new g(`No history entries exist for ${t.id}; nothing to ${i.slice(8)}.`,y.USAGE);let o=t.located?await ye(t.located,{schema:n.schema}):null,s=z(r.author,n.author_default),c=await e.transform({raw:a.raw,entries:a.entries,verification:Gn(a.entries),loadedItem:o,author:s}),d=Gn(c.rewrittenEntries);if(!d.ok)throw new g(`${i} produced an invalid rewritten chain (${d.errors.join(", ")}).`,y.GENERIC_FAILURE);let l=c.changed&&!r.dryRun?await qu({pmRoot:e.pmRoot,subject:t,settings:n,typeRegistry:e.typeRegistry,historyRawBeforeLock:a.raw,currentItemRawBeforeLock:o?.raw??null,operation:i,author:s,force:r.force,itemDocument:o?.document??null,applyRewrite:async u=>{await c.beforeWrite?.(),c.applyRewrite?await c.applyRewrite(u):await Cr({historyPath:t.historyPath,nextHistoryRaw:Nt(c.rewrittenEntries),historyRawUnderLock:u.historyRawUnderLock})},applyPostRewrite:c.afterWrite??(async()=>K({path:t.historyPath,scope:"project",op:`${i.replace("-","_")}:history`}))}):[];return c.report({verification:d,warnings:l})}(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]="d8f1968e-a030-5a3c-b766-60a409163745")}catch{}})();function Tr(e,t,n=25){let i=e.definitions.filter(o=>o.roles.length===0).map(o=>o.id).sort((o,s)=>o.localeCompare(s)),r=new Set(i),a=t.filter(o=>{let s=ad(o.status,e);return s!==void 0&&r.has(s)}).map(o=>o.id).sort((o,s)=>o.localeCompare(s));return{roleless_status_count:i.length,roleless_statuses:i.slice(0,n),roleless_statuses_truncated:i.length>n,affected_item_count:a.length,affected_item_ids:a.slice(0,n),affected_item_ids_truncated:a.length>n}}function $r(e){return e.roleless_status_count===0?[]:[`schema_status_missing_lifecycle_role:${e.roleless_status_count}`]}(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]="717434ef-3c62-50a8-8887-e2bbc3851eff")}catch{}})();var Ju=8,So=100;function Vu(e,t){return e.length<=t?{values:e,truncated:!1}:{values:e.slice(0,t),truncated:!0}}function Fe(e,t){return Array.isArray(e)?{count:e.length,sample:e.slice(0,t),truncated:e.length>t}:{count:0,sample:[],truncated:!1}}function zy(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let t=e;return{layer:t.layer,directory:t.directory,name:t.name,version:t.version,enabled:t.enabled,status:t.status,has_activate:t.has_activate,capabilities:t.capabilities}}function ii(e,t){let n=Fe(e,t);return{...n,sample:n.sample.map(i=>zy(i))}}function W(e,t){if(!Array.isArray(e))return{count:0,sample:[],truncated:!1};let n=e.filter(i=>typeof i=="string");return{count:n.length,sample:n.slice(0,t),truncated:n.length>t}}function Wy(e){if(typeof e!="object"||e===null)return null;let t=e;return{applied_count:t.applied_count,pending_count:t.pending_count,failed_count:t.failed_count}}var qy={settings:(e,t)=>({version:e.version,id_prefix:e.id_prefix,locks_ttl_seconds:e.locks_ttl_seconds,warnings:W(e.warnings,t)}),directories:(e,t)=>({required_count:Array.isArray(e.required)?e.required.length:0,optional_count:Array.isArray(e.optional)?e.optional.length:0,missing_required:W(e.missing_required,t),missing_optional:W(e.missing_optional,t),missing:W(e.missing,t),strict_directories:e.strict_directories}),settings_values:(e,t)=>({warnings:W(e.warnings,t)}),telemetry:e=>({enabled:e.enabled,capture_level:e.capture_level,endpoint:e.endpoint,queue_exists:e.queue_exists,queue_entries:e.queue_entries,queue_draining:e.queue_draining,queue_invalid_rows:e.queue_invalid_rows,queue_rows_total:e.queue_rows_total,last_successful_flush_at:e.last_successful_flush_at,last_failed_flush_at:e.last_failed_flush_at,endpoint_probe:e.endpoint_probe,env_overrides:e.env_overrides}),extensions:(e,t)=>{let n=typeof e.activation=="object"&&e.activation!==null?e.activation:{};return{disabled_by_flag:e.disabled_by_flag,discovered:ii(e.discovered,t),effective:ii(e.effective,t),loaded:ii(e.loaded,t),failed:Fe(e.failed,t),warnings:W(e.warnings,t),activation:{failed:Fe(n.failed,t),warnings:W(n.warnings,t),hook_counts:n.hook_counts,command_handler_count:n.command_handler_count,service_override_count:n.service_override_count,renderer_override_count:n.renderer_override_count,registration_counts:n.registration_counts,migration_status:Wy(n.migration_status)},author_manifest:e.author_manifest,triage:e.triage,capability_contract:e.capability_contract,capability_guidance:Fe(e.capability_guidance,t),host_version_census:e.host_version_census}},storage:(e,t)=>{let n=typeof e.author_attribution=="object"&&e.author_attribution!==null?e.author_attribution:void 0;return{...e,...n?{author_attribution:{...n,affected_item_ids:W(n.affected_item_ids,t),samples:Fe(n.samples,t)}}:{}}},locks:e=>({active_lock_count:e.active_lock_count,stale_lock_count:e.stale_lock_count,unreadable_lock_count:e.unreadable_lock_count,unparseable_lock_count:e.unparseable_lock_count}),integrity:(e,t)=>{let n=typeof e.tracked_runtime_cache=="object"&&e.tracked_runtime_cache!==null?e.tracked_runtime_cache:void 0;return{checked_item_files:e.checked_item_files,checked_history_streams:e.checked_history_streams,counts:e.counts,item_unreadable:W(e.item_unreadable,t),item_conflict_markers:Fe(e.item_conflict_markers,t),item_parse_failures:W(e.item_parse_failures,t),tracked_runtime_cache:n===void 0?e.tracked_runtime_cache:{...n,tracked_paths:W(n.tracked_paths,t)},history_unreadable:W(e.history_unreadable,t),history_conflict_markers:Fe(e.history_conflict_markers,t),history_invalid_json:Fe(e.history_invalid_json,t),skipped:e.skipped}},history_drift:(e,t)=>{let n=typeof e.cache_confirmation=="object"&&e.cache_confirmation!==null?e.cache_confirmation:void 0;return{checked_items:e.checked_items,cache_hit_verification:e.cache_hit_verification,cache_confirmation:n===void 0?e.cache_confirmation:{...n,candidate_items:W(n.candidate_items,t),confirmed_items:W(n.confirmed_items,t),resolved_false_positive_items:W(n.resolved_false_positive_items,t)},counts:e.counts,drifted_items:W(e.drifted_items,t),merge_receipt_attributed_items:W(e.merge_receipt_attributed_items,t),missing_streams:W(e.missing_streams,t),unreadable_streams:W(e.unreadable_streams,t),hash_mismatches:W(e.hash_mismatches,t),chain_mismatches:W(e.chain_mismatches,t),version_skews:W(e.version_skews,t),workspace_state_mismatches:W(e.workspace_state_mismatches,t),workspace_state_missing:W(e.workspace_state_missing,t),workspace_state_unreadable:W(e.workspace_state_unreadable,t),skipped:e.skipped}},vectorization:(e,t)=>({semantic_runtime_available:e.semantic_runtime_available,compatibility_mode_auto_defaults:e.compatibility_mode_auto_defaults,auto_ollama_defaults_applied:e.auto_ollama_defaults_applied,auto_ollama_defaults_skipped_reason:e.auto_ollama_defaults_skipped_reason,auto_ollama_defaults_remediation:e.auto_ollama_defaults_remediation,refresh_policy:e.refresh_policy,provider_active:e.provider_active,vector_store_active:e.vector_store_active,items:e.items,ledger_entries_before:e.ledger_entries_before,stale_items_before_total:e.stale_items_before_total,stale_items_before:W(e.stale_items_before,t),refresh_attempted:e.refresh_attempted,refresh_skipped_reason:e.refresh_skipped_reason,refresh_result:e.refresh_result,ledger_entries_after:e.ledger_entries_after,stale_items_after_total:e.stale_items_after_total,stale_items_after:W(e.stale_items_after,t),skipped:e.skipped})};function xo(e,t){let n=qy[e.name];return n?n(e.details,t):e.details}function Ku(e){return{disabled_by_flag:e.details.disabled_by_flag,loaded_count:Array.isArray(e.details.loaded)?e.details.loaded.length:0,failed_count:0,warning_count:0,restore_with:"pm health --full"}}function Gy(e){if(e.name==="extensions"&&e.status==="ok")return Ku(e);let t=xo(e,8);return Buffer.byteLength(JSON.stringify(t))<Buffer.byteLength(JSON.stringify(e.details))?t:e.details}function Io(e,t){let n=new Set([...t,...e.failed_because]);return(e.findings??[]).filter(i=>n.has(i.warning))}function By(e){let t=W(e.warnings,8);return{ok:e.ok,...e.verdict?{verdict:e.verdict}:{},checks:e.checks.map(n=>({name:n.name,status:n.status,ok:n.ok,details:Gy(n)})),warnings:t.sample,findings:Io(e,t.sample),failed_because:e.failed_because,projection:{mode:"brief",warning_count:t.count,warnings_truncated:t.truncated,detail_limit:8},generated_at:e.generated_at}}function Bu(e){return e.details.skipped===!0}function Jy(e){let t=W(e.warnings,8),n=e.checks.filter(Bu).map(i=>i.name);return{ok:e.ok,...e.verdict?{verdict:e.verdict}:{},checks:e.checks.filter(i=>!Bu(i)).map(i=>({name:i.name,status:i.status,ok:i.ok,details:{}})),warning_count:t.count,warnings:t.sample,findings:Io(e,t.sample),failed_because:e.failed_because,projection:{mode:"summary",warning_count:t.count,warnings_truncated:t.truncated,detail_limit:8,omitted_checks:n},generated_at:e.generated_at}}function Vy(e,t,n){return t.full===!0?e:n?Jy(e):t.brief===!0?By(e):{...e,checks:e.checks.map(i=>i.name==="extensions"&&i.status==="ok"?{...i,details:Ku(i)}:i),projection:{mode:"standard",warning_count:e.warning_count,warnings_truncated:e.warnings_truncated===!0,detail_limit:8}}}function Ro(e,t,n){let i=e.warning_count??e.warnings.length,r=e.warnings.slice(0,100),a={...e,warning_count:i,warning_limit:100,warnings_truncated:i>100,warnings:r,findings:Io(e,r)},o=Vy(a,t,n);return{...o,warning_count:i,warning_limit:100,warnings_truncated:i>o.warnings.length,...o.projection?{projection:{...o.projection,warning_count:i,warnings_truncated:i>o.warnings.length}}:{}}}import Co from"node:fs/promises";import ce from"node:path";import Ky from"node:readline/promises";import{stdin as Yy,stdout as Dr}from"node:process";(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]="bb8a4985-8bc0-5290-a6f9-310d940cf4d7")}catch{}})();var I$=["ask","add","skip","status"],Xy=["AGENTS.md","CLAUDE.md"],Zy=["pm init","pm context","pm search","pm create","pm claim","pm files","pm docs","pm test --run","pm close","pm release","pm_author"],Qy=8,To=1,ew="<!-- pm-cli:agent-guidance:start:",tw=`<!-- pm-cli:agent-guidance:start:v${To} -->`,Ao="<!-- pm-cli:agent-guidance:end -->",ai="Add workflow guidance later: pm init --agent-guidance add";var nw=()=>Ky.createInterface({input:Yy,output:Dr});function hn(e,t){let n=ce.relative(e,t);return n.length===0?ce.basename(t):n.split(ce.sep).join("/")}function Yu(e){return e.endsWith(`
12
12
  `)?e:`${e}
13
13
  `}function iw(e){return e.includes(`\r
14
14
  `)?`\r
15
15
  `:`
16
- `}function Xu(e){let t=e.indexOf(ew);if(t===-1)return null;let n=e.indexOf(Ao,t);return n===-1?null:{start_index:t,end_index:n+Ao.length}}function rw(e){return Xu(e)!==null}function aw(e,t="<your project test command>"){return[tw,"## pm Workflow (Agent Quickstart)","",'- Cold start with the measured canonical orientation: `pm context --limit 10 --for orient`; before item mutation, also run `pm search "<keywords>" --limit 10`, `pm list --status open --limit 20`, and `pm list --status in_progress --limit 20`.',"- Claim and start atomically: `pm claim <id> --start`.",`- Link evidence while coding: \`pm files <id> --add ...\`, \`pm docs <id> --add ...\`, \`pm test <id> --add command="${t}"\`.`,'- Verify and close: `pm test <id> --run --progress`, then atomically record closure evidence with `pm close <id> "<reason>" --resolution "<what changed>" --expected "<expected outcome>" --actual "<observed outcome>" --validate-close warn`, then `pm release <id>`.',"- Author identity is automatic for supported agent harnesses; use `--author` only for an explicit override.","",Ao,""].join(e)}function Zu(e,t="<your project test command>"){let n=iw(e),i=aw(n,t),r=Xu(e);if(r){let s=e.slice(r.end_index),c=s.startsWith(`\r
16
+ `}function Xu(e){let t=e.indexOf(ew);if(t===-1)return null;let n=e.indexOf(Ao,t);return n===-1?null:{start_index:t,end_index:n+Ao.length}}function rw(e){return Xu(e)!==null}function aw(e,t="<your project test command>"){return[tw,"## pm Workflow (Agent Quickstart)","",'- Cold start with the measured canonical orientation: `pm context --for orient`; before item mutation, also run `pm search "<keywords>" --limit 10`, `pm list --status open --limit 20`, and `pm list --status in_progress --limit 20`.',"- Claim and start: `pm claim <id> --start`, or `pm claim --next --start` to take the next available item in one write.",`- Link evidence while coding: \`pm files <id> --add ...\`, \`pm docs <id> --add ...\`, \`pm test <id> --add command="${t}"\`.`,'- Verify and close: `pm test <id> --run --progress`, then atomically record closure evidence with `pm close <id> "<reason>" --resolution "<what changed>" --expected "<expected outcome>" --actual "<observed outcome>" --validate-close warn`, then `pm release <id>`.',"- Author identity is automatic for supported agent harnesses; use `--author` only for an explicit override.","",Ao,""].join(e)}function Zu(e,t="<your project test command>"){let n=iw(e),i=aw(n,t),r=Xu(e);if(r){let s=e.slice(r.end_index),c=s.startsWith(`\r
17
17
  `)?s.slice(2):s.startsWith(`
18
18
  `)?s.slice(1):s,d=Yu(`${e.slice(0,r.start_index)}${i}${c}`);return{next_content:d,changed:d!==e}}let a=e.length===0?"":e.endsWith(`
19
19
  `)?`
@@ -62,4 +62,4 @@ ${a}`,y.GENERIC_FAILURE)}}function Ca(e){return typeof e.tag=="string"&&e.tag.tr
62
62
  `);oe(e.progressEnabled,"writing keyword artifacts"),await Z(t,`${JSON.stringify(e.manifest,null,2)}
63
63
  `),await Z(n,`${r}
64
64
  `);let a=[];if(e.mode!=="keyword")try{oe(e.progressEnabled,"writing vectorization status ledger"),await kl(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 OW(e,t){let n=oC(e.mode),i=aC(e),r=e.full===!0;oe(i,`start mode=${n}`);let a=M(process.cwd(),t.path);await ne(a);let o=ur(await T(a)).settings,s=null;try{s=await re(a,tl,o.locks.ttl_seconds,z(void 0,"pm-reindex"),!1,o.governance.force_required_for_stale_lock,o.locks.wait_ms)}catch(c){throw c instanceof g&&c.exitCode===y.CONFLICT?new g("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",y.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=dC(o),d=lC(o),l=_C({requestedMode:n,pmRoot:a,settings:o,extensionEmbedding:c,extensionVectorAdapter:d}),u=n;oe(i,"loading item corpus");let m=await gC({pmRoot:a,settings:o}),f=m.warnings,{documentCandidates:p,metadataDocuments:h}=m;oe(i,`loaded_items=${h.length}`);let _=$(),w=hC(u,_,h),v=Oi.join(a,wc),E=Oi.join(a,vc),k=u==="keyword"?await kc(a,p,o.schema,f):h,I=[],C={},S=null,b=fC(u);if(u==="keyword"&&await yC({pmRoot:a,settings:o,forceFullSemantic:r,extensionEmbedding:c,reindexWarnings:f}),u!=="keyword"){let x=await xC({pmRoot:a,settings:o,requestedMode:n,activeEmbeddingProvider:l.activeEmbeddingProvider,activeVectorStore:l.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:d,documentCandidates:p,metadataDocuments:h,documentsForKeywordArtifacts:k,forceFullSemantic:r,reindexWarnings:f,semanticWarnings:I,semanticSummary:b,progressEnabled:i});k=x.documentsForKeywordArtifacts,C=x.vectorizationLedgerEntries,S=x.vectorizationEmbeddingMetadata}let O=await IC({pmRoot:a,mode:u,manifest:w,documentsForKeywordArtifacts:k,settings:o,vectorizationLedgerEntries:C,vectorizationEmbeddingMetadata:S,progressEnabled:i}),P=[...await K({path:v,scope:"project",op:"reindex:manifest"}),...await K({path:E,scope:"project",op:"reindex:embeddings"}),...await Ji({mode:u,total_items:h.length})];return oe(i,"done"),{ok:!0,mode:u,total_items:h.length,semantic:b,artifacts:{manifest:wc,embeddings:vc},warnings:[...f,...I,...O,...P],generated_at:_}}finally{await s?.()}}export{L as a,we as b,Ye as c,mn as d,to as e,Ul as f,jt as g,no as h,Sg as i,ao as j,oo as k,ql as l,fn as m,Yn as n,co as o,Wg as p,Yl as q,Xn as r,Zl as s,kr as t,lo as u,Ql as v,eu as w,tu as x,go as y,uu as z,YC as A,iy as B,XC as C,ay as D,eT as E,hu as F,cy as G,vT as H,dv as I,BD as J,KD as K,YD as L,ci as M,XD as N,ZD as O,QD as P,eO as Q,tO as R,nO as S,iO as T,rO as U,aO as V,oO as W,sO as X,ns as Y,ls as Z,I$ as _,rm as $,my as aa,bu as ba,DT as ca,ti as da,OT as ea,wy as fa,vy as ga,PT as ha,by as ia,qh as ja,FT as ka,Au as la,Bh as ma,KF as na,YF as oa,ni as pa,Ar as qa,Tu as ra,$u as sa,Du as ta,Ou as ua,Mu as va,Fu as wa,Uu as xa,Wu as ya,At as za,rM as Aa,aM as Ba,oM as Ca,sM as Da,hM as Ea,Lf as Fa,ca as Ga,FM as Ha,ft as Ia,qf as Ja,UM as Ka,HM as La,t0 as Ma,a0 as Na,Kf as Oa,Hy as Pa,Gu as Qa,xs as Ra,P1 as Sa,L1 as Ta,Tr as Ua,$r as Va,yh as Wa,Lj as Xa,wh as Ya,bh as Za,kh as _a,xh as $a,Rh as ab,SI as bb,xI as cb,eU as db,tU as eb,nU as fb,iU as gb,RI as hb,AI as ib,CI as jb,rU as kb,Kh as lb,$I as mb,Yh as nb,Gs as ob,Zh as pb,DI as qb,OI as rb,PI as sb,Ks as tb,Ys as ub,hU as vb,_U as wb,gU as xb,uR as yb,AH as zb,F_ as Ab,Ti as Bb,z_ as Cb,W_ as Db,q_ as Eb,uc as Fb,wA as Gb,uz as Hb,Pz as Ib,zz as Jb,ig as Kb,rg as Lb,ag as Mb,mW as Nb,xW as Ob,IW as Pb,RW as Qb,OW as Rb};
65
- //# sourceMappingURL=chunk-HPWT3RBG.js.map
65
+ //# sourceMappingURL=chunk-6OKPYCLU.js.map
@@ -1,4 +1,4 @@
1
- import{F as rt,G as ot,f as he}from"./chunk-5MCGYBOQ.js";import{$a as te,Fa as Zt,Ua as en,Va as nt,Wa as tn,_a as ge,ab as ye,da as tt,g as Qe,h as Jt,r as Ze,x as _e,y as et,ya as Qt}from"./chunk-57HPXGOQ.js";import{b as Gt}from"./chunk-MW77Q3AQ.js";import{$ as E,Aa as Ke,Ba as Yt,Ec as fe,Ga as Xe,Ja as Wt,Nc as Xt,Od as D,a as Be,ae as pe,ba as Z,ca as K,da as b,fa as Bt,jc as Kt,qa as We,sc as Je,wc as me,ya as ee,za as Ge}from"./chunk-GP2WU43K.js";import{A as m,C as W,E as G,F as T,I as v,K as ue,t as Ye,z as l}from"./chunk-JLXGRDTG.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]="cef883fa-81be-5092-a07b-7a5ca961fbc7")}catch{}})();var Ee=new WeakSet,it=new WeakMap,nn=new WeakSet;function rn(e){return nn.add(e),e}function st(e){return nn.has(e)}function ne(e){Ee.add(e);for(let[t,n]of Object.entries(e)){if(!Array.isArray(n))continue;let r=[...n];Reflect.set(e,t,r),Ee.add(r)}return e}function Pr(e,t){return Ee.has(e)||t!==void 0&&it.get(e)?.has(t)===!0}function $r(e,t){let n=new Set(t);it.set(e,n);for(let r of n){let o=Reflect.get(e,r);if(!Array.isArray(o))continue;let i=[...o];Reflect.set(e,r,i),Ee.add(i)}return e}function on(e,t){if(st(e)&&rn(t),Pr(e))return ne(t);let n=it.get(e);return n?$r(t,n):t}(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]="b2ae2a38-678e-5f49-9f86-6e1ea4210b34")}catch{}})();var O="-",an=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function cn(e,t){if(e.startsWith("```")||e.includes(`
1
+ import{F as rt,G as ot,f as he}from"./chunk-JCR32IAO.js";import{$a as te,Fa as Zt,Ua as en,Va as nt,Wa as tn,_a as ge,ab as ye,da as tt,g as Qe,h as Jt,r as Ze,x as _e,y as et,ya as Qt}from"./chunk-M22TI7LP.js";import{b as Gt}from"./chunk-VFQAZLKO.js";import{$ as E,Aa as Ke,Ba as Yt,Ec as fe,Ga as Xe,Ja as Wt,Nc as Xt,Od as D,a as Be,ae as pe,ba as Z,ca as K,da as b,fa as Bt,jc as Kt,qa as We,sc as Je,wc as me,ya as ee,za as Ge}from"./chunk-CIQ6YWCW.js";import{A as m,C as W,E as G,F as T,I as v,K as ue,t as Ye,z as l}from"./chunk-JLXGRDTG.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]="cef883fa-81be-5092-a07b-7a5ca961fbc7")}catch{}})();var Ee=new WeakSet,it=new WeakMap,nn=new WeakSet;function rn(e){return nn.add(e),e}function st(e){return nn.has(e)}function ne(e){Ee.add(e);for(let[t,n]of Object.entries(e)){if(!Array.isArray(n))continue;let r=[...n];Reflect.set(e,t,r),Ee.add(r)}return e}function Pr(e,t){return Ee.has(e)||t!==void 0&&it.get(e)?.has(t)===!0}function $r(e,t){let n=new Set(t);it.set(e,n);for(let r of n){let o=Reflect.get(e,r);if(!Array.isArray(o))continue;let i=[...o];Reflect.set(e,r,i),Ee.add(i)}return e}function on(e,t){if(st(e)&&rn(t),Pr(e))return ne(t);let n=it.get(e);return n?$r(t,n):t}(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]="b2ae2a38-678e-5f49-9f86-6e1ea4210b34")}catch{}})();var O="-",an=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function cn(e,t){if(e.startsWith("```")||e.includes(`
2
2
  `))return!0;let n=t.map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${n})\\s*[:=]`,"i").test(e)}function dn(e){let t=e.trim();if(t==="")return[];let n=(jr(t)??t.split(",")).map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase());return Array.from(new Set(n)).sort((r,o)=>r.localeCompare(o))}function ln(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n of e)if(typeof n=="string")for(let r of dn(n))t.push(r);return Array.from(new Set(t)).sort((n,r)=>n.localeCompare(r))}function un(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function zr(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function Fr(e,t,n){let r=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new m('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',l.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});a.length>0&&!r.includes(a)&&r.push(a)}let o=[],i=r;for(let s of n??[]){let a=s.trim();if(a.length!==0){if(!i.includes(a)){o.push(a);continue}i=i.filter(c=>c!==a)}}return{criteria:i,unmatchedRemovals:o}}function Ur(e,t){let n=un(e);if(!t||t.length===0)return Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i));let r=new Set(n);for(let o of ln(t))r.add(o);return Array.from(r).sort((o,i)=>o.localeCompare(i))}function Vr(e,t){let n=Array.from(new Set(un(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return n;let r=new Set(ln(t));return r.size===0?n:n.filter(o=>!r.has(o))}function jr(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):"").filter(n=>n.length>0)}function at(e){return e.replace(/\r\n/g,`
3
3
  `)}function mn(e){let t=at(e).trim();if(!t.startsWith("```"))return e;let n=t.split(`
4
4
  `);return n.length<2||n.at(-1)?.trim()!=="```"?e:n.slice(1,-1).join(`
@@ -19,4 +19,4 @@ ${i}`;continue}return null}return n}function pn(e,t){let n=mn(e).trim();if(!n)th
19
19
  `)){let r=n.trim();if(r.length!==0)try{let o=JSON.parse(r);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=Ha(o)),t.push(o))}catch{}}return t}function Ba(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let n=Date.parse(e.enqueued_at);return Number.isNaN(n)?!1:n<t}function qt(e,t){let n=Rr(t),r=[],o=0;for(let i of e){if(JSON.stringify(i).length>pr||Ba(i,n)||i.attempts>=_r){o+=1;continue}r.push(i)}if(r.length>ar){let i=r.length-ar;return o+=i,{entries:r.slice(i),prunedCount:o}}return{entries:r,prunedCount:o}}async function Ya(e,t){let n=t.map(o=>JSON.stringify(o)).join(`
20
20
  `),r=n.length>0?`${n}
21
21
  `:"";for(let o=0;;o+=1)try{await v(Ve(e),r,{createParentDirectories:!H(process.env[q])});return}catch(i){let s=hr[o];if(s===void 0||!Or(i))throw i;await Mr(s)}}async function ur(e,t,n,r){return le(async()=>{let o=await T(Ve(e)),i=o===null?[]:jt(o),s=[];for(let c of i){if(n.has(c.id))continue;let d=r.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=qt(s,t);return await Ya(e,a),a.length},e)}async function Wa(e,t){let n=await T(Ve(e));if(n===null||n.trim().length===0){await R(e,{pending_otel_spans:0});return}let r=jt(n),{entries:o,prunedCount:i}=qt(r,t),s=o.filter(g=>Vt(g.next_attempt_after)).slice(0,ha);if(s.length===0){let g=i>0?await ur(e,t,new Set,new Map):o.length;await R(e,{pending_otel_spans:g});return}let a=D(),c=new Set,d=new Map,u=0,p;await Promise.all(s.map(async g=>{try{let h=await Ar(g.endpoint,{"content-type":"application/json"},JSON.stringify(g.payload));if(h<200||h>=300)throw new Error(`local_otel_export_http_${h}`);c.add(g.id),u+=1}catch(h){p=h instanceof Error?zt(h.message,"redacted"):"local_otel_export_failed";let y=g.attempts+1;d.set(g.id,{attempts:y,next_attempt_after:xr(y)})}}));let _=await ur(e,t,c,d),f={pending_otel_spans:_,last_otel_attempt_at:a};u>0&&(f.last_otel_success_at=a),p!==void 0?(f.last_otel_failure_at=a,f.last_otel_failure_error=p):_===0&&(f.last_otel_failure_at=void 0,f.last_otel_failure_error=void 0),await R(e,f)}async function Ga(e,t,n){try{await Ja(e,t,n)}catch{}try{await Wa(e,n)}catch{}}async function Ka(e,t=va){try{let n=Da(e),r=await la(n,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(r.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=A.join(n,i.name);(await fr(s)).mtimeMs<o&&await Ut(s,{force:!0})}))}catch{}}async function le(e,t=ee(process.cwd()),n=5e3){let r=dr.catch(()=>{}).then(()=>Kt(async()=>{let o=await pe(t,"telemetry-queue",60,"telemetry",!1,!1,n,{createParentDirectories:!H(process.env[q])});try{return en(t),await e()}finally{await o()}}));return dr=r.catch(()=>{}),r}async function qe(e){let t=await T(Ue(e));return t===null||t.trim().length===0?[]:Cr(t)}async function $t(e,t,n){return le(async()=>{let r=await qe(e),{entries:o}=je(r,n),i=o.filter(s=>!t.has(s.event.event_id));return await Lr(e,i),i},e)}async function Xa(e,t,n,r){return le(async()=>{let o=await qe(e),{entries:i}=je(o,r),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:n,next_attempt_after:xr(c)}});return await Lr(e,s),s},e)}async function Ja(e,t,n){await Ka(e);let r=t.trim();if(r.length===0)return;let o=await T(Ue(e));if(o===null||o.trim().length===0){await R(e,{endpoint:r,queue_entries:0});return}let i=Cr(o);if(i.length===0){await R(e,{endpoint:r,queue_entries:0});return}let{entries:s,prunedCount:a}=je(i,n);if(s.length===0){let f=await $t(e,new Set,n);await R(e,{endpoint:r,queue_entries:f.length});return}let c=s.filter(f=>kr(f)).slice(0,ya);if(c.length===0){let f=a>0?await $t(e,new Set,n):s;await R(e,{endpoint:r,queue_entries:f.length});return}let d=new Set(c.map(f=>f.event.event_id)),u=D(),p={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(p["x-pm-telemetry-key"]=_);try{let f=await Ar(r,p,JSON.stringify({schema_version:ga,events:c.map(g=>g.event)}));if(f<200||f>=300)throw new Error(`telemetry_flush_http_${f}`)}catch(f){let g=await Xa(e,d,u,n),h=f instanceof Error?zt(f.message,"redacted"):"telemetry_flush_failed";await R(e,{endpoint:r,queue_entries:g.length,last_attempted_flush_at:u,last_failed_flush_at:u,last_failed_flush_error:h});return}try{let f=await $t(e,d,n);await R(e,{endpoint:r,queue_entries:f.length,last_attempted_flush_at:u,last_successful_flush_at:u,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(f){let g=f instanceof Error?zt(f.message,"redacted"):"telemetry_flush_failed",h=await qe(e).catch(()=>s);await R(e,{endpoint:r,queue_entries:h.length,last_attempted_flush_at:u,last_failed_flush_at:u,last_failed_flush_error:g})}}async function Qa(e){let t=Er(e);H(process.env[q])||await Pt(A.dirname(t),{recursive:!0});try{return await Pt(t),!0}catch(n){if(typeof n!="object"||n===null||!("code"in n)||n.code!=="EEXIST")throw n}try{let n=await fr(t);return Date.now()-n.mtimeMs<Ia?!1:(await Ut(t,{recursive:!0,force:!0}),await Pt(t),!0)}catch{return!1}}function Za(e){try{da(e,{recursive:!0,force:!0})}catch{}}function ec(e){Za(Na(e))}async function tc(e,t,n){let r=await Qa(e);if(ec(e),!r)return!1;try{await Ga(e,t,n)}finally{try{await Ut(Er(e),{recursive:!0,force:!0})}catch{}}return!0}async function mr(e,t){let n=new Set;try{let{entries:r}=je(await qe(e),t);for(let o of r.filter(kr))n.add(`event:${o.event.event_id}`)}catch{}try{let r=await T(Ve(e));if(r!==null)for(let o of qt(jt(r),t).entries)Vt(o.next_attempt_after)&&n.add(`span:${o.id}`)}catch{}return n}async function fm(e=ee(process.cwd())){if(!de().telemetry_disabled)try{await nt(e,async()=>{let t=H(process.env[q]),n=!0;for(;n;){if(!(await te(e)).telemetry.enabled)return;let r=await le(()=>ja(e),e);if(!r)return;let o=t?await mr(e,r.retentionDays):new Set;if(!await tc(e,r.endpoint,r.retentionDays)||!t)return;let i=await mr(e,r.retentionDays);n=i.size>0&&(i.size!==o.size||[...i].some(s=>!o.has(s)))}},()=>H(process.env[q]))}catch{}}(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]="f7513c8b-4ae1-50ef-8e22-5f743be36db6")}catch{}})();export{eu as a,_d as b,pi as c,hi as d,yi as e,Ei as f,st as g,Pr as h,cn as i,dn as j,zr as k,Fr as l,Ur as m,Vr as n,pn as o,Kr as p,sc as q,Xr as r,ac as s,re as t,Qr as u,be as v,cc as w,Zr as x,we as y,dc as z,Se as A,to as B,no as C,Li as D,si as E,Gc as F,kn as G,Kc as H,Ce as I,Xc as J,mi as K,gd as L,wi as M,bi as N,yt as O,Ti as P,Et as Q,vi as R,Od as S,Ai as T,Dn as U,Ci as V,xi as W,Ri as X,jd as Y,Di as Z,Gd as _,zi as $,Ui as aa,ro as ba,Vi as ca,ji as da,Re as ea,us as fa,yc as ga,ct as ha,yn as ia,dt as ja,go as ka,yo as la,bc as ma,En as na,X as oa,lt as pa,mt as qa,xt as ra,gl as sa,kt as ta,Ne as ua,Wn as va,Pe as wa,Rt as xa,Lt as ya,Ot as za,Mt as Aa,Zn as Ba,er as Ca,zl as Da,Dt as Ea,de as Fa,Wo as Ga,In as Ha,Ko as Ia,Xo as Ja,Jo as Ka,Oc as La,ht as Ma,Cn as Na,An as Oa,ei as Pa,ti as Qa,xn as Ra,oi as Sa,Zs as Ta,ra as Ua,ia as Va,sa as Wa,ga as Xa,_r as Ya,le as Za,fm as _a};
22
- //# sourceMappingURL=chunk-NOKG4RFN.js.map
22
+ //# sourceMappingURL=chunk-7WJDRZOR.js.map
@@ -1,2 +1,2 @@
1
- import{G as h}from"./chunk-GP2WU43K.js";import{A as f,m as b,z as l}from"./chunk-JLXGRDTG.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]="300b6741-40eb-5bb1-bb0a-bb144d15946e")}catch{}})();var d=new Set(b),u=Object.freeze({get size(){return d.size},has(e){return d.has(e)},entries(){return d.entries()},keys(){return d.keys()},values(){return d.values()},forEach(e,t){d.forEach(n=>e.call(t,n,n,u))},[Symbol.iterator](){return d.values()}});function g(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function w(e){return typeof e!="string"?null:h(e)}function E(e){try{return structuredClone(e)}catch{return e}}function x(e){let t=e.trim(),n=t.indexOf("=");if(n<=0)throw new f(`--field entries must use name=value syntax, received: ${e}`,l.USAGE);let i=t.slice(0,n).trim(),r=t.slice(n+1);return{key:i,value:r}}function S(e,t,n){try{let i=JSON.parse(e);if(n==="array"&&Array.isArray(i)||n==="object"&&typeof i=="object"&&i!==null&&!Array.isArray(i))return i}catch{}throw new f(`--field ${t}=... must be valid JSON ${n}`,l.USAGE)}function F(e,t,n){if(t==="string")return n;if(t==="number"){let i=n.trim();if(i.length===0)throw new f(`--field ${e}=... must be a number`,l.USAGE);let r=Number(i);if(!Number.isFinite(r))throw new f(`--field ${e}=... must be a number`,l.USAGE);return r}if(t==="boolean"){let i=n.trim().toLowerCase();if(i==="true"||i==="1"||i==="yes")return!0;if(i==="false"||i==="0"||i==="no")return!1;throw new f(`--field ${e}=... must be one of true|false|1|0|yes|no`,l.USAGE)}return t==="string_array"?n.split(/[\n,|]/u).map(i=>i.trim()).filter(i=>i.length>0):S(n,e,t)}function y(e){let t=new Map;if(!e)return t;for(let n of e.item_fields)for(let i of n.fields){let r=g(i.name),s=w(i.type);if(!r||!s)continue;let o=t.get(r);if(o&&o.type!==s)throw new f(`Extension item field "${r}" is declared with conflicting types: ${o.type}, ${s}`,l.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(r,{name:r,type:s})}return t}function A(e){if(u.has(e))throw new f(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...u].sort((t,n)=>t.localeCompare(n)).join(", ")}.`,l.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function D(e){return[...y(e).keys()].sort((t,n)=>t.localeCompare(n))}function U(e,t,n){if(!e||e.length===0)return{};let i=y(t),r={};for(let s of e){let{key:o,value:c}=x(s),a=i.get(o);if(!a){if(u.has(o)){let m=n?.(o)??{recovery:{provided_fields:[o]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};throw new f(`--field ${o} is a core item field, not an extension field`,l.USAGE,{code:"core_item_field_requires_dedicated_flag",field:o,...m})}let p=[...i.keys()].sort((m,_)=>m.localeCompare(_));throw new f(`--field ${o} is not declared by an active extension item-field registration`,l.USAGE,{code:"extension_item_field_unknown",field:o,recovery:{provided_fields:[o]},nextSteps:p.length>0?[`Use one of the declared fields: ${p.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}A(a.name),r[a.name]=F(a.name,a.type,c)}return r}function I(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(n=>typeof n=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e,t){return!t||t.length===0?!0:t.some(n=>Object.is(n,e))}function G(e,t,n={}){if(t){y(t);for(let i of t.item_fields)for(let r of i.fields){let s=g(r.name);if(!s)continue;A(s),!(s in e)&&!n.skipDefaultFields?.has(s)&&Object.prototype.hasOwnProperty.call(r,"default")&&(e[s]=E(r.default));let o=e[s];if(o===void 0)continue;let c=w(r.type);if(c&&!I(o,c))throw new TypeError(`Item field "${s}" must be of type ${c}`);let a=Array.isArray(r.values)?r.values:void 0;if(!$(o,a))throw new TypeError(`Item field "${s}" must match one of the configured allowed values`)}}}export{u as a,D as b,U as c,G as d};
2
- //# sourceMappingURL=chunk-PC3R5CJV.js.map
1
+ import{G as h}from"./chunk-CIQ6YWCW.js";import{A as f,m as b,z as l}from"./chunk-JLXGRDTG.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]="300b6741-40eb-5bb1-bb0a-bb144d15946e")}catch{}})();var d=new Set(b),u=Object.freeze({get size(){return d.size},has(e){return d.has(e)},entries(){return d.entries()},keys(){return d.keys()},values(){return d.values()},forEach(e,t){d.forEach(n=>e.call(t,n,n,u))},[Symbol.iterator](){return d.values()}});function g(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function w(e){return typeof e!="string"?null:h(e)}function E(e){try{return structuredClone(e)}catch{return e}}function x(e){let t=e.trim(),n=t.indexOf("=");if(n<=0)throw new f(`--field entries must use name=value syntax, received: ${e}`,l.USAGE);let i=t.slice(0,n).trim(),r=t.slice(n+1);return{key:i,value:r}}function S(e,t,n){try{let i=JSON.parse(e);if(n==="array"&&Array.isArray(i)||n==="object"&&typeof i=="object"&&i!==null&&!Array.isArray(i))return i}catch{}throw new f(`--field ${t}=... must be valid JSON ${n}`,l.USAGE)}function F(e,t,n){if(t==="string")return n;if(t==="number"){let i=n.trim();if(i.length===0)throw new f(`--field ${e}=... must be a number`,l.USAGE);let r=Number(i);if(!Number.isFinite(r))throw new f(`--field ${e}=... must be a number`,l.USAGE);return r}if(t==="boolean"){let i=n.trim().toLowerCase();if(i==="true"||i==="1"||i==="yes")return!0;if(i==="false"||i==="0"||i==="no")return!1;throw new f(`--field ${e}=... must be one of true|false|1|0|yes|no`,l.USAGE)}return t==="string_array"?n.split(/[\n,|]/u).map(i=>i.trim()).filter(i=>i.length>0):S(n,e,t)}function y(e){let t=new Map;if(!e)return t;for(let n of e.item_fields)for(let i of n.fields){let r=g(i.name),s=w(i.type);if(!r||!s)continue;let o=t.get(r);if(o&&o.type!==s)throw new f(`Extension item field "${r}" is declared with conflicting types: ${o.type}, ${s}`,l.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(r,{name:r,type:s})}return t}function A(e){if(u.has(e))throw new f(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...u].sort((t,n)=>t.localeCompare(n)).join(", ")}.`,l.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function D(e){return[...y(e).keys()].sort((t,n)=>t.localeCompare(n))}function U(e,t,n){if(!e||e.length===0)return{};let i=y(t),r={};for(let s of e){let{key:o,value:c}=x(s),a=i.get(o);if(!a){if(u.has(o)){let m=n?.(o)??{recovery:{provided_fields:[o]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};throw new f(`--field ${o} is a core item field, not an extension field`,l.USAGE,{code:"core_item_field_requires_dedicated_flag",field:o,...m})}let p=[...i.keys()].sort((m,_)=>m.localeCompare(_));throw new f(`--field ${o} is not declared by an active extension item-field registration`,l.USAGE,{code:"extension_item_field_unknown",field:o,recovery:{provided_fields:[o]},nextSteps:p.length>0?[`Use one of the declared fields: ${p.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}A(a.name),r[a.name]=F(a.name,a.type,c)}return r}function I(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(n=>typeof n=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e,t){return!t||t.length===0?!0:t.some(n=>Object.is(n,e))}function G(e,t,n={}){if(t){y(t);for(let i of t.item_fields)for(let r of i.fields){let s=g(r.name);if(!s)continue;A(s),!(s in e)&&!n.skipDefaultFields?.has(s)&&Object.prototype.hasOwnProperty.call(r,"default")&&(e[s]=E(r.default));let o=e[s];if(o===void 0)continue;let c=w(r.type);if(c&&!I(o,c))throw new TypeError(`Item field "${s}" must be of type ${c}`);let a=Array.isArray(r.values)?r.values:void 0;if(!$(o,a))throw new TypeError(`Item field "${s}" must match one of the configured allowed values`)}}}export{u as a,D as b,U as c,G as d};
2
+ //# sourceMappingURL=chunk-AL7SOFUL.js.map