@unbrained/pm-cli 2026.8.11 → 2026.8.13

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 (250) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +74 -21
  3. package/dist/cli/commander-usage.js +37 -11
  4. package/dist/cli/error-guidance.d.ts +2 -0
  5. package/dist/cli/error-guidance.js +82 -19
  6. package/dist/cli/main.js +35 -19
  7. package/dist/cli/register-annotations.js +56 -3
  8. package/dist/cli/register-assurance.js +28 -17
  9. package/dist/cli/register-list-query.js +10 -7
  10. package/dist/cli/register-operations.js +16 -6
  11. package/dist/cli-bundle/bundle-manifest.json +163 -163
  12. package/dist/cli-bundle/chunks/chunk-3ZMOWAFM.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-DEDU3DG7.js +196 -0
  14. package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +13 -0
  15. package/dist/cli-bundle/chunks/chunk-F7FJYGK3.js +8 -0
  16. package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +5 -0
  17. package/dist/cli-bundle/chunks/chunk-IMGIN7R6.js +2 -0
  18. package/dist/cli-bundle/chunks/{chunk-A2SJGHSI.js → chunk-Q47C67TQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-WMEZHCFI.js → chunk-QGTUPEU5.js} +62 -54
  20. package/dist/cli-bundle/chunks/chunk-TF3TPKPR.js +34 -0
  21. package/dist/cli-bundle/chunks/{chunk-ZU34C3LH.js → chunk-YLBAPY22.js} +50 -50
  22. package/dist/cli-bundle/chunks/register-list-query-4HIZ7EA3.js +10 -0
  23. package/dist/cli-bundle/chunks/register-mutation-W64FZ5HN.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-C44ET7R5.js +2 -0
  25. package/dist/cli-bundle/chunks/{register-setup-NOCOOWQY.js → register-setup-634MFRXU.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +31 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-4H5IA6AV.js → chunk-2JP7W7GO.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-2RI2FESN.js +4 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +8 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-2DL3MRTD.js → chunk-3DJSGWVB.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +5 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +155 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-TL5M2PAY.js → chunk-E3AVJ655.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-J5EKAIVD.js → chunk-HC2OL2H2.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-BKPIY34S.js → chunk-I75MANL7.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-IIS2FRKL.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-NFHFZH2Z.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +17 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-UDAZWT25.js → chunk-OOYYKQWX.js} +4 -4
  42. package/dist/cli-bundle/focused-chunks/{chunk-23FTGO3W.js → chunk-PKPOZXLL.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-QDZUABWL.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +16 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-55BIB6DV.js → chunk-TEZIXMTH.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +18 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +42 -41
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +1 -1
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +2 -2
  58. package/dist/core/checkpoint/checkpoint-gc.js +7 -12
  59. package/dist/core/extensions/activation-summary-markdown.js +5 -4
  60. package/dist/core/extensions/activation-summary.d.ts +2 -0
  61. package/dist/core/extensions/activation-summary.js +6 -2
  62. package/dist/core/extensions/capability-usage.d.ts +1 -1
  63. package/dist/core/extensions/capability-usage.js +4 -3
  64. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  65. package/dist/core/extensions/contribution-inventory.js +6 -2
  66. package/dist/core/extensions/extension-registries.js +3 -2
  67. package/dist/core/extensions/extension-types.d.ts +83 -1
  68. package/dist/core/extensions/extension-types.js +3 -2
  69. package/dist/core/extensions/loader.d.ts +2 -8
  70. package/dist/core/extensions/loader.js +53 -144
  71. package/dist/core/extensions/registration-values.d.ts +43 -0
  72. package/dist/core/extensions/registration-values.js +210 -0
  73. package/dist/core/extensions/reserved-host-flags.js +3 -2
  74. package/dist/core/extensions/runtime-registrations.d.ts +3 -1
  75. package/dist/core/extensions/runtime-registrations.js +12 -2
  76. package/dist/core/fs/fs-utils.d.ts +2 -0
  77. package/dist/core/fs/fs-utils.js +7 -3
  78. package/dist/core/history/drift-cache.js +4 -3
  79. package/dist/core/history/drift-scan.js +16 -17
  80. package/dist/core/history/history.d.ts +8 -0
  81. package/dist/core/history/history.js +57 -7
  82. package/dist/core/history/replay.d.ts +9 -1
  83. package/dist/core/history/replay.js +48 -13
  84. package/dist/core/lock/lock-gc.js +8 -13
  85. package/dist/core/lock/lock.js +5 -4
  86. package/dist/core/output/output.d.ts +2 -0
  87. package/dist/core/output/output.js +46 -14
  88. package/dist/core/search/vector-stores.js +6 -11
  89. package/dist/core/shared/command-types.d.ts +2 -0
  90. package/dist/core/shared/command-types.js +2 -2
  91. package/dist/core/shared/errors.d.ts +5 -0
  92. package/dist/core/shared/errors.js +2 -2
  93. package/dist/core/store/item-metadata-cache.d.ts +1 -1
  94. package/dist/core/store/item-metadata-cache.js +16 -9
  95. package/dist/core/telemetry/runtime.d.ts +6 -0
  96. package/dist/core/telemetry/runtime.js +101 -30
  97. package/dist/sdk/agent/command-recovery.d.ts +2 -0
  98. package/dist/sdk/agent/command-recovery.js +10 -2
  99. package/dist/sdk/annotations.js +4 -4
  100. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  101. package/dist/sdk/cli-bootstrap.js +6 -2
  102. package/dist/sdk/cli-contracts/completeness.js +10 -3
  103. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  104. package/dist/sdk/cli-contracts/flag-contracts.js +9 -3
  105. package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
  106. package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
  107. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +40 -6
  108. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +27 -3
  109. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  110. package/dist/sdk/cli-contracts/tool-parameter-tables.js +55 -5
  111. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  112. package/dist/sdk/cli-contracts/tool-schema.js +22 -4
  113. package/dist/sdk/cli-program.js +3 -2
  114. package/dist/sdk/comments.js +4 -3
  115. package/dist/sdk/compile-cache.js +4 -3
  116. package/dist/sdk/completion.js +16 -7
  117. package/dist/sdk/compose.d.ts +3 -1
  118. package/dist/sdk/compose.js +16 -2
  119. package/dist/sdk/context-intent-contracts.js +45 -4
  120. package/dist/sdk/context-signal-store.js +4 -3
  121. package/dist/sdk/core.d.ts +1 -0
  122. package/dist/sdk/core.js +3 -2
  123. package/dist/sdk/extension/install-runtime.js +4 -4
  124. package/dist/sdk/extension/managed-state.js +4 -3
  125. package/dist/sdk/extension-contracts.d.ts +1 -1
  126. package/dist/sdk/flag-invocation-contracts.js +5 -6
  127. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
  128. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1597 -0
  129. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
  130. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
  131. package/dist/sdk/generated-error-code-catalog.js +6 -3140
  132. package/dist/sdk/governance/assurance-action.d.ts +27 -3
  133. package/dist/sdk/governance/assurance-action.js +117 -31
  134. package/dist/sdk/governance/assurance-mutation-error.d.ts +14 -0
  135. package/dist/sdk/governance/assurance-mutation-error.js +58 -0
  136. package/dist/sdk/governance/assurance-presets.d.ts +54 -0
  137. package/dist/sdk/governance/assurance-presets.js +136 -0
  138. package/dist/sdk/governance/assurance-runtime.d.ts +4 -0
  139. package/dist/sdk/governance/assurance-runtime.js +118 -14
  140. package/dist/sdk/governance/assurance.d.ts +51 -6
  141. package/dist/sdk/governance/assurance.js +321 -67
  142. package/dist/sdk/governance/gc.js +5 -11
  143. package/dist/sdk/governance/health.d.ts +3 -1
  144. package/dist/sdk/governance/health.js +24 -7
  145. package/dist/sdk/governance/validate-item-reader.js +3 -3
  146. package/dist/sdk/governance/validate.d.ts +2 -0
  147. package/dist/sdk/governance/validate.js +15 -5
  148. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  149. package/dist/sdk/graph/durable-cache.js +156 -29
  150. package/dist/sdk/graph/governance-contracts.d.ts +12 -0
  151. package/dist/sdk/graph/governance-contracts.js +27 -0
  152. package/dist/sdk/graph/governance.d.ts +44 -2
  153. package/dist/sdk/graph/governance.js +156 -12
  154. package/dist/sdk/guide.js +4 -4
  155. package/dist/sdk/index.d.ts +3 -2
  156. package/dist/sdk/index.js +5 -4
  157. package/dist/sdk/lifecycle/claim.js +10 -3
  158. package/dist/sdk/linked-artifacts.d.ts +2 -0
  159. package/dist/sdk/linked-artifacts.js +29 -4
  160. package/dist/sdk/merge/driver.d.ts +2 -2
  161. package/dist/sdk/merge/driver.js +3 -3
  162. package/dist/sdk/merge/install.js +5 -4
  163. package/dist/sdk/merge/receipts.d.ts +6 -4
  164. package/dist/sdk/merge/receipts.js +7 -5
  165. package/dist/sdk/merge/three-way.d.ts +2 -2
  166. package/dist/sdk/merge/three-way.js +3 -3
  167. package/dist/sdk/output-projection.d.ts +9 -1
  168. package/dist/sdk/output-projection.js +45 -9
  169. package/dist/sdk/query/activity.d.ts +49 -2
  170. package/dist/sdk/query/activity.js +185 -38
  171. package/dist/sdk/query/get.js +19 -2
  172. package/dist/sdk/read-output-contracts.d.ts +5 -1
  173. package/dist/sdk/read-output-contracts.js +17 -2
  174. package/dist/sdk/read-output-session.d.ts +2 -0
  175. package/dist/sdk/read-output-session.js +12 -5
  176. package/dist/sdk/relationship-history.js +5 -5
  177. package/dist/sdk/runtime-primitives.d.ts +3 -3
  178. package/dist/sdk/runtime-primitives.js +5 -5
  179. package/dist/sdk/runtime-stats-options.js +3 -2
  180. package/dist/sdk/runtime.js +5 -9
  181. package/dist/sdk/schema-migration.js +4 -4
  182. package/dist/sdk/stats.d.ts +36 -3
  183. package/dist/sdk/stats.js +55 -15
  184. package/dist/sdk/test/execution.d.ts +4 -0
  185. package/dist/sdk/test/execution.js +88 -23
  186. package/dist/sdk/workspace-memory.js +4 -4
  187. package/dist/sdk/workspace-snapshot.js +8 -14
  188. package/dist/sdk/workspace-transaction-gc.js +4 -9
  189. package/dist/sdk/workspace-transaction.js +4 -4
  190. package/dist/sdk/workspace.js +4 -3
  191. package/dist/types.d.ts +2 -0
  192. package/dist/types.js +2 -2
  193. package/docs/ASSURANCE.md +170 -14
  194. package/docs/COMMANDS.md +29 -8
  195. package/docs/CONFIGURATION.md +9 -0
  196. package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
  197. package/docs/EXTENSIONS.md +11 -12
  198. package/docs/MERGE_SAFETY.md +3 -1
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
  202. package/docs/RELATIONSHIP_GRAPH.md +15 -0
  203. package/docs/SDK.md +17 -3
  204. package/docs/SDK_AGENT_SESSION_CONTEXT.md +12 -1
  205. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
  206. package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
  207. package/docs/TESTING.md +24 -15
  208. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
  209. package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
  210. package/marketplace.json +2 -2
  211. package/package.json +6 -6
  212. package/packages/pm-beads/package.json +1 -1
  213. package/packages/pm-calendar/package.json +1 -1
  214. package/packages/pm-command-kit/package.json +1 -1
  215. package/packages/pm-digital-twin/package.json +1 -1
  216. package/packages/pm-governance-audit/package.json +1 -1
  217. package/packages/pm-guide-shell/package.json +1 -1
  218. package/packages/pm-kanban/package.json +1 -1
  219. package/packages/pm-lifecycle-hooks/package.json +1 -1
  220. package/packages/pm-linked-test-adapters/package.json +1 -1
  221. package/packages/pm-search-advanced/package.json +1 -1
  222. package/packages/pm-templates/package.json +1 -1
  223. package/packages/pm-todos/package.json +1 -1
  224. package/packages/pm-vcs/package.json +1 -1
  225. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  226. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  227. package/sdk/public-surface.json +384 -83
  228. package/dist/cli-bundle/chunks/chunk-2OOU2AFH.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +0 -33
  230. package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +0 -13
  231. package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +0 -194
  232. package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +0 -2
  234. package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +0 -5
  235. package/dist/cli-bundle/chunks/register-list-query-HAUXVUPY.js +0 -10
  236. package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +0 -20
  237. package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +0 -2
  240. package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +0 -16
  241. package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +0 -8
  242. package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +0 -2
  243. package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +0 -31
  244. package/dist/cli-bundle/focused-chunks/chunk-E3KCL7AY.js +0 -5
  245. package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +0 -153
  246. package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +0 -2
  247. package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +0 -18
  248. package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +0 -4
  249. package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +0 -17
@@ -4,9 +4,10 @@
4
4
  * Normalizes the assurance action vocabulary once for CLI, SDK, and MCP hosts.
5
5
  */
6
6
  import type { GlobalOptions } from "../../core/shared/command-types.js";
7
- import { type AssuranceDeclaration, type AssuranceGateVerdict, type AssuranceMutationReceipt } from "./assurance.js";
7
+ import { type AssuranceBundleMutationReceipt, type AssuranceDeclaration, type AssuranceGateVerdict, type AssuranceMutationReceipt } from "./assurance.js";
8
+ import { type AssuranceDerivedProposal, type AssurancePreset, type AssurancePresetId } from "./assurance-presets.js";
8
9
  /** Assurance registry and evaluation verbs shared by every transport. */
9
- export declare const ASSURANCE_ACTIONS: readonly ["list", "show", "put", "remove", "run", "verdicts"];
10
+ export declare const ASSURANCE_ACTIONS: readonly ["list", "show", "put", "remove", "run", "verdicts", "presets", "apply", "derive", "promote"];
10
11
  /** Assurance declaration kinds shared by every transport. */
11
12
  export declare const ASSURANCE_DECLARATION_KINDS: readonly ["measurement", "assertion", "gate"];
12
13
  /** Assurance action verb. */
@@ -39,9 +40,32 @@ export interface AssuranceActionInput {
39
40
  author?: string;
40
41
  /** Audited mutation rationale. */
41
42
  message?: string;
43
+ /** Built-in preset selected for preview or application. */
44
+ preset?: string;
45
+ /** pm item that owns preset or derived assertions. */
46
+ owner?: string;
47
+ /** Explicitly accept derived proposals. */
48
+ apply?: boolean;
49
+ /** Explicit next assertion enforcement level. */
50
+ enforcement?: string;
42
51
  }
43
52
  /** Result union returned by transport-neutral assurance execution. */
44
- export type AssuranceActionResult = AssuranceDeclaration | AssuranceMutationReceipt | AssuranceGateVerdict | {
53
+ export type AssuranceActionResult = AssuranceDeclaration | AssuranceMutationReceipt | AssuranceGateVerdict | AssuranceBundleMutationReceipt | AssurancePreset | {
54
+ items: AssuranceDerivedProposal[];
55
+ count: number;
56
+ applied?: AssuranceBundleMutationReceipt;
57
+ } | {
58
+ items: Array<{
59
+ id: AssurancePresetId;
60
+ title: string;
61
+ description: string;
62
+ }>;
63
+ count: number;
64
+ row_contract: {
65
+ row_keys: ["items"];
66
+ jq_selector: ".items[]";
67
+ };
68
+ } | {
45
69
  id: string;
46
70
  } | {
47
71
  /** Registry declarations. */
@@ -1,9 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="597e1ac0-f461-5984-95a9-cd3447b1fea7")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="36dfa230-06bd-5902-a0c9-94a7c34cda90")}catch(e){}}();
3
3
  import { EXIT_CODE } from "../../core/shared/constants.js";
4
4
  import { PmCliError } from "../../core/shared/errors.js";
5
5
  import { ASSURANCE_GATE_TRIGGERS, evaluateAssuranceGate, getAssuranceDeclaration, listAssuranceDeclarations, listAssuranceVerdicts, putAssuranceDeclaration, recordAssuranceVerdict, removeAssuranceDeclaration, } from "./assurance.js";
6
+ import { ASSURANCE_PRESET_IDS, acceptAssuranceProposals, applyAssurancePreset, createAssurancePreset, deriveAssuranceProposals, promoteAssuranceAssertion, } from "./assurance-presets.js";
6
7
  import { MAX_ASSURANCE_VERDICT_LIMIT } from "./assurance-limits.js";
8
+ import { normalizeAssuranceEvaluation, normalizeAssuranceMutation, } from "./assurance-mutation-error.js";
7
9
  import { createAssuranceWorkspaceContext } from "./assurance-runtime.js";
8
10
  import { resolvePmRoot } from "../runtime-primitives.js";
9
11
  import { parseRuntimeInteger, readRuntimeString } from "../runtime-input.js";
@@ -15,6 +17,10 @@ export const ASSURANCE_ACTIONS = [
15
17
  "remove",
16
18
  "run",
17
19
  "verdicts",
20
+ "presets",
21
+ "apply",
22
+ "derive",
23
+ "promote",
18
24
  ];
19
25
  /** Assurance declaration kinds shared by every transport. */
20
26
  export const ASSURANCE_DECLARATION_KINDS = [
@@ -35,6 +41,17 @@ function parseKind(value) {
35
41
  }
36
42
  throw new PmCliError(`Assurance declaration kind is required. Expected: ${ASSURANCE_DECLARATION_KINDS.join(", ")}`, EXIT_CODE.USAGE);
37
43
  }
44
+ function parsePreset(value) {
45
+ if (value && ASSURANCE_PRESET_IDS.includes(value)) {
46
+ return value;
47
+ }
48
+ throw new PmCliError(`Assurance preset is required. Expected: ${ASSURANCE_PRESET_IDS.join(", ")}`, EXIT_CODE.USAGE);
49
+ }
50
+ function requireOwner(input) {
51
+ if (input.owner?.trim())
52
+ return input.owner.trim();
53
+ throw new PmCliError("assurance preset and derivation actions require --owner <pm-item-id>", EXIT_CODE.USAGE);
54
+ }
38
55
  function parseDefinition(kind, value) {
39
56
  let parsed = value;
40
57
  if (typeof value === "string") {
@@ -109,38 +126,99 @@ async function runVerdictsAction(input, pmRoot) {
109
126
  row_contract: { row_keys: ["items"], jq_selector: ".items[]" },
110
127
  };
111
128
  }
129
+ async function runAdoptionAction(action, input, pmRoot) {
130
+ if (action === "presets") {
131
+ if (input.preset ?? input.id) {
132
+ return createAssurancePreset(parsePreset(input.preset ?? input.id), requireOwner(input));
133
+ }
134
+ const items = ASSURANCE_PRESET_IDS.map((id) => {
135
+ const preset = createAssurancePreset(id, "pm-owner");
136
+ return { id, title: preset.title, description: preset.description };
137
+ });
138
+ return {
139
+ items,
140
+ count: items.length,
141
+ row_contract: { row_keys: ["items"], jq_selector: ".items[]" },
142
+ };
143
+ }
144
+ if (action === "apply") {
145
+ return normalizeAssuranceMutation(() => applyAssurancePreset(pmRoot, parsePreset(input.preset ?? input.id), requireOwner(input), { author: input.author, message: input.message }));
146
+ }
147
+ if (action === "derive") {
148
+ const proposals = await deriveAssuranceProposals(await createAssuranceWorkspaceContext(pmRoot, {
149
+ resolve_tree: false,
150
+ trigger: "derive",
151
+ }), requireOwner(input));
152
+ const applied = input.apply
153
+ ? await normalizeAssuranceMutation(() => acceptAssuranceProposals(pmRoot, proposals, {
154
+ author: input.author,
155
+ message: input.message ?? "Accept observation-derived assurance proposals",
156
+ }))
157
+ : undefined;
158
+ return {
159
+ items: proposals,
160
+ count: proposals.length,
161
+ ...(applied ? { applied } : {}),
162
+ };
163
+ }
164
+ if (!input.id) {
165
+ throw new PmCliError("assurance promote requires an assertion id", EXIT_CODE.USAGE);
166
+ }
167
+ if (input.enforcement !== "warn" && input.enforcement !== "block") {
168
+ throw new PmCliError("assurance promote requires --enforcement warn|block", EXIT_CODE.USAGE);
169
+ }
170
+ const definition = (await getAssuranceDeclaration(pmRoot, "assertion", input.id));
171
+ return normalizeAssuranceMutation(() => promoteAssuranceAssertion(pmRoot, definition, input.enforcement, {
172
+ author: input.author,
173
+ message: input.message,
174
+ }));
175
+ }
176
+ async function runGateAction(input, pmRoot) {
177
+ if (!input.id) {
178
+ throw new PmCliError("assurance run requires a gate id", EXIT_CODE.USAGE);
179
+ }
180
+ const gateId = input.id;
181
+ if (!input.trigger) {
182
+ throw new PmCliError("assurance run requires a trigger", EXIT_CODE.USAGE);
183
+ }
184
+ if (!ASSURANCE_GATE_TRIGGERS.includes(input.trigger)) {
185
+ throw new PmCliError(`Unknown assurance trigger ${input.trigger}. Expected: ${ASSURANCE_GATE_TRIGGERS.join(", ")}`, EXIT_CODE.USAGE);
186
+ }
187
+ const trigger = input.trigger;
188
+ const [document, workspaceContext] = await Promise.all([
189
+ readDocument(pmRoot),
190
+ createAssuranceWorkspaceContext(pmRoot, {
191
+ tree_id: input.tree,
192
+ trigger,
193
+ }),
194
+ ]);
195
+ const verdict = await normalizeAssuranceEvaluation(() => evaluateAssuranceGate(gateId, document, workspaceContext, {
196
+ trigger,
197
+ dry_run: input.dry_run === true,
198
+ }));
199
+ if (!verdict.dry_run) {
200
+ await recordAssuranceVerdict(pmRoot, verdict, {
201
+ author: input.author,
202
+ message: input.message,
203
+ });
204
+ }
205
+ return verdict;
206
+ }
112
207
  /** Execute one assurance request through the public assurance SDK primitives. */
113
208
  export async function runAssuranceAction(input, global = {}) {
114
209
  const action = parseAction(input.action);
115
210
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
211
+ if (action === "presets" ||
212
+ action === "apply" ||
213
+ action === "derive" ||
214
+ action === "promote") {
215
+ return runAdoptionAction(action, input, pmRoot);
216
+ }
116
217
  if (action === "verdicts") {
117
218
  return runVerdictsAction(input, pmRoot);
118
219
  }
119
220
  if (action === "run") {
120
- if (!input.id) {
121
- throw new PmCliError("assurance run requires a gate id", EXIT_CODE.USAGE);
122
- }
123
- if (!input.trigger) {
124
- throw new PmCliError("assurance run requires a trigger", EXIT_CODE.USAGE);
125
- }
126
- if (!ASSURANCE_GATE_TRIGGERS.includes(input.trigger)) {
127
- throw new PmCliError(`Unknown assurance trigger ${input.trigger}. Expected: ${ASSURANCE_GATE_TRIGGERS.join(", ")}`, EXIT_CODE.USAGE);
128
- }
129
- const [document, workspaceContext] = await Promise.all([
130
- readDocument(pmRoot),
131
- createAssuranceWorkspaceContext(pmRoot, { tree_id: input.tree }),
132
- ]);
133
- const verdict = await evaluateAssuranceGate(input.id, document, workspaceContext, {
134
- trigger: input.trigger,
135
- dry_run: input.dry_run === true,
136
- });
137
- if (!verdict.dry_run) {
138
- await recordAssuranceVerdict(pmRoot, verdict, {
139
- author: input.author,
140
- message: input.message,
141
- });
142
- }
143
- return verdict;
221
+ return runGateAction(input, pmRoot);
144
222
  }
145
223
  const kind = parseKind(input.kind);
146
224
  if (action === "list")
@@ -148,16 +226,20 @@ export async function runAssuranceAction(input, global = {}) {
148
226
  if (!input.id) {
149
227
  throw new PmCliError(`assurance ${action} requires an id`, EXIT_CODE.USAGE);
150
228
  }
229
+ const id = input.id;
151
230
  if (action === "show") {
152
- return getAssuranceDeclaration(pmRoot, kind, input.id);
231
+ return getAssuranceDeclaration(pmRoot, kind, id);
153
232
  }
154
233
  if (action === "remove") {
155
- const receipt = await removeAssuranceDeclaration(pmRoot, kind, input.id, { author: input.author, message: input.message });
234
+ const receipt = await normalizeAssuranceMutation(() => removeAssuranceDeclaration(pmRoot, kind, id, {
235
+ author: input.author,
236
+ message: input.message,
237
+ }));
156
238
  return projectMutationReceipt(receipt, input.idOnly);
157
239
  }
158
240
  const definition = parseDefinition(kind, input.definition);
159
- if (definition.id !== input.id) {
160
- throw new PmCliError(`Assurance definition id ${definition.id} does not match requested id ${input.id}`, EXIT_CODE.USAGE);
241
+ if (definition.id !== id) {
242
+ throw new PmCliError(`Assurance definition id ${definition.id} does not match requested id ${id}`, EXIT_CODE.USAGE);
161
243
  }
162
244
  const mutationOptions = {
163
245
  author: input.author,
@@ -168,7 +250,7 @@ export async function runAssuranceAction(input, global = {}) {
168
250
  }
169
251
  : {}),
170
252
  };
171
- const receipt = await putAssuranceDeclaration(pmRoot, kind, definition, mutationOptions);
253
+ const receipt = await normalizeAssuranceMutation(() => putAssuranceDeclaration(pmRoot, kind, definition, mutationOptions));
172
254
  return projectMutationReceipt(receipt, input.idOnly);
173
255
  }
174
256
  /** Normalize a generic SDK or MCP argument envelope into one assurance request. */
@@ -192,7 +274,11 @@ export function runAssuranceDispatch(args, options, global) {
192
274
  idOnly: merged.idOnly === true,
193
275
  author: readRuntimeString(merged, "author"),
194
276
  message: readRuntimeString(merged, "message"),
277
+ preset: readRuntimeString(merged, "preset"),
278
+ owner: readRuntimeString(merged, "owner"),
279
+ apply: merged.apply === true,
280
+ enforcement: readRuntimeString(merged, "enforcement"),
195
281
  }, global);
196
282
  }
197
283
  //# sourceMappingURL=assurance-action.js.map
198
- //# debugId=597e1ac0-f461-5984-95a9-cd3447b1fea7
284
+ //# debugId=36dfa230-06bd-5902-a0c9-94a7c34cda90
@@ -0,0 +1,14 @@
1
+ /** Expected declaration-validation or mutation-policy refusal. */
2
+ export declare class AssuranceMutationRefusalError extends TypeError {
3
+ /** Create one typed refusal while retaining TypeError compatibility for SDK callers. */
4
+ constructor(message: string);
5
+ }
6
+ /** Expected gate-policy refusal caused by an incomplete or disallowed provider contract. */
7
+ export declare class AssuranceEvaluationRefusalError extends TypeError {
8
+ /** Create one typed refusal while retaining TypeError compatibility for SDK callers. */
9
+ constructor(message: string);
10
+ }
11
+ /** Normalize only expected assurance mutation refusals for CLI and MCP hosts. */
12
+ export declare function normalizeAssuranceMutation<T>(operation: () => Promise<T>): Promise<T>;
13
+ /** Normalize only expected assurance evaluation-policy refusals for transport hosts. */
14
+ export declare function normalizeAssuranceEvaluation<T>(operation: () => Promise<T>): Promise<T>;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @module sdk/assurance-mutation-error
3
+ *
4
+ * Distinguishes expected assurance mutation refusals from unexpected runtime
5
+ * faults before transport layers normalize them into stable usage errors.
6
+ */
7
+
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="93a32771-bf95-5df4-8019-b6be45a5051b")}catch(e){}}();
9
+ import { EXIT_CODE } from "../../core/shared/constants.js";
10
+ import { PmCliError } from "../../core/shared/errors.js";
11
+ /** Expected declaration-validation or mutation-policy refusal. */
12
+ export class AssuranceMutationRefusalError extends TypeError {
13
+ /** Create one typed refusal while retaining TypeError compatibility for SDK callers. */
14
+ constructor(message) {
15
+ super(message);
16
+ this.name = "AssuranceMutationRefusalError";
17
+ }
18
+ }
19
+ /** Expected gate-policy refusal caused by an incomplete or disallowed provider contract. */
20
+ export class AssuranceEvaluationRefusalError extends TypeError {
21
+ /** Create one typed refusal while retaining TypeError compatibility for SDK callers. */
22
+ constructor(message) {
23
+ super(message);
24
+ this.name = "AssuranceEvaluationRefusalError";
25
+ }
26
+ }
27
+ /** Normalize only expected assurance mutation refusals for CLI and MCP hosts. */
28
+ export async function normalizeAssuranceMutation(operation) {
29
+ try {
30
+ return await operation();
31
+ }
32
+ catch (error) {
33
+ if (error instanceof AssuranceMutationRefusalError) {
34
+ throw new PmCliError(error.message, EXIT_CODE.USAGE, {
35
+ code: "invalid_argument_value",
36
+ reason: "assurance_mutation_refused",
37
+ });
38
+ }
39
+ throw error;
40
+ }
41
+ }
42
+ /** Normalize only expected assurance evaluation-policy refusals for transport hosts. */
43
+ export async function normalizeAssuranceEvaluation(operation) {
44
+ try {
45
+ return await operation();
46
+ }
47
+ catch (error) {
48
+ if (error instanceof AssuranceEvaluationRefusalError) {
49
+ throw new PmCliError(error.message, EXIT_CODE.USAGE, {
50
+ code: "invalid_argument_value",
51
+ reason: "assurance_evaluation_refused",
52
+ });
53
+ }
54
+ throw error;
55
+ }
56
+ }
57
+ //# sourceMappingURL=assurance-mutation-error.js.map
58
+ //# debugId=93a32771-bf95-5df4-8019-b6be45a5051b
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @module sdk/governance/assurance-presets
3
+ *
4
+ * Supplies readable assurance starter bundles and observation-derived proposals
5
+ * without introducing privileged evaluation semantics.
6
+ */
7
+ import { putAssuranceDeclaration, type AssuranceAssertionDefinition, type AssuranceBundleMutationReceipt, type AssuranceDeclarationBundle, type AssuranceEnforcement, type AssuranceEvaluationContext, type AssuranceScope } from "./assurance.js";
8
+ /** Built-in project shapes that can acquire a quality contract in one command. */
9
+ export declare const ASSURANCE_PRESET_IDS: readonly ["software-delivery", "research", "agent-evaluation", "operations"];
10
+ /** Stable built-in assurance preset id. */
11
+ export type AssurancePresetId = (typeof ASSURANCE_PRESET_IDS)[number];
12
+ /** Readable preset bundle before or after application. */
13
+ export interface AssurancePreset {
14
+ /** Stable preset id. */
15
+ id: AssurancePresetId;
16
+ /** Human-readable project shape. */
17
+ title: string;
18
+ /** Why the initial contract is useful. */
19
+ description: string;
20
+ /** Ordinary declarations that become editable workspace data. */
21
+ declarations: AssuranceDeclarationBundle;
22
+ }
23
+ /** One observe-level candidate produced from authoritative workspace state. */
24
+ export interface AssuranceDerivedProposal {
25
+ /** Stable proposal id. */
26
+ id: string;
27
+ /** Population used to calculate the proposed threshold. */
28
+ population_size: number;
29
+ /** Scope applied while measuring. */
30
+ scope: AssuranceScope;
31
+ /** Observed value proposed as the initial ceiling. */
32
+ observed: number;
33
+ /** Ordinary declarations created only after explicit acceptance. */
34
+ declarations: AssuranceDeclarationBundle;
35
+ }
36
+ /** Materialize one built-in preset as ordinary declarations owned by a pm item. */
37
+ export declare function createAssurancePreset(id: AssurancePresetId, ownerItemId: string): AssurancePreset;
38
+ /** Apply one preset atomically; a second identical application is idempotent. */
39
+ export declare function applyAssurancePreset(pmRoot: string, id: AssurancePresetId, ownerItemId: string, options?: {
40
+ author?: string;
41
+ message?: string;
42
+ }): Promise<AssuranceBundleMutationReceipt>;
43
+ /** Propose active-scope evidence ceilings from the record without persisting them. */
44
+ export declare function deriveAssuranceProposals(context: AssuranceEvaluationContext, ownerItemId: string): Promise<AssuranceDerivedProposal[]>;
45
+ /** Accept all derived proposals in one audited registry transaction. */
46
+ export declare function acceptAssuranceProposals(pmRoot: string, proposals: readonly AssuranceDerivedProposal[], options?: {
47
+ author?: string;
48
+ message?: string;
49
+ }): Promise<AssuranceBundleMutationReceipt>;
50
+ /** Promote one assertion by exactly one enforcement level and audit the transition. */
51
+ export declare function promoteAssuranceAssertion(pmRoot: string, definition: AssuranceAssertionDefinition, enforcement: Exclude<AssuranceEnforcement, "observe">, options?: {
52
+ author?: string;
53
+ message?: string;
54
+ }): Promise<Awaited<ReturnType<typeof putAssuranceDeclaration>>>;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @module sdk/governance/assurance-presets
3
+ *
4
+ * Supplies readable assurance starter bundles and observation-derived proposals
5
+ * without introducing privileged evaluation semantics.
6
+ */
7
+
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="05c29627-6763-5aee-8579-71e563a98780")}catch(e){}}();
9
+ import { evaluateMeasurement, putAssuranceDeclaration, putAssuranceDeclarationBundle, } from "./assurance.js";
10
+ /** Built-in project shapes that can acquire a quality contract in one command. */
11
+ export const ASSURANCE_PRESET_IDS = [
12
+ "software-delivery",
13
+ "research",
14
+ "agent-evaluation",
15
+ "operations",
16
+ ];
17
+ function assertion(id, measurementId, ownerItemId, ceiling, enforcement) {
18
+ return {
19
+ id,
20
+ measurement_id: measurementId,
21
+ owner_item_id: ownerItemId,
22
+ scope: { kind: "active" },
23
+ ceiling,
24
+ lifetime: "hold",
25
+ enforcement,
26
+ negative_control: {
27
+ cases: [
28
+ { observed: ceiling, expected: "pass" },
29
+ { observed: ceiling + 1, expected: "fail" },
30
+ ],
31
+ },
32
+ };
33
+ }
34
+ function evidencePreset(id, title, description, ownerItemId, links) {
35
+ const prefix = `preset-${id}`;
36
+ const measurements = links.map((link) => ({
37
+ id: `${prefix}-missing-${link}`,
38
+ description: `Active items missing ${link} evidence.`,
39
+ source: { kind: "links", link, state: "missing" },
40
+ }));
41
+ const assertions = measurements.map((measurement) => assertion(`${measurement.id}-zero`, measurement.id, ownerItemId, 0, "warn"));
42
+ return {
43
+ id,
44
+ title,
45
+ description,
46
+ declarations: {
47
+ measurements,
48
+ assertions,
49
+ gates: [
50
+ {
51
+ id: `${prefix}-readiness`,
52
+ description,
53
+ assertion_ids: assertions.map((entry) => entry.id),
54
+ triggers: ["ci", "scheduled"],
55
+ },
56
+ ],
57
+ },
58
+ };
59
+ }
60
+ /** Materialize one built-in preset as ordinary declarations owned by a pm item. */
61
+ export function createAssurancePreset(id, ownerItemId) {
62
+ if (id === "software-delivery") {
63
+ return evidencePreset(id, "Software delivery", "Warn when active delivery work lacks executable tests or documentation.", ownerItemId, ["tests", "docs"]);
64
+ }
65
+ if (id === "research") {
66
+ return evidencePreset(id, "Research", "Warn when active research work lacks reproducibility files or documentation.", ownerItemId, ["files", "docs"]);
67
+ }
68
+ if (id === "agent-evaluation") {
69
+ return evidencePreset(id, "Agent evaluation", "Warn when active evaluation work lacks executable scenarios or recorded artifacts.", ownerItemId, ["tests", "files"]);
70
+ }
71
+ return evidencePreset(id, "Operations", "Warn when active operational work lacks runbook documentation or repair evidence.", ownerItemId, ["docs", "files"]);
72
+ }
73
+ /** Apply one preset atomically; a second identical application is idempotent. */
74
+ export function applyAssurancePreset(pmRoot, id, ownerItemId, options = {}) {
75
+ return putAssuranceDeclarationBundle(pmRoot, createAssurancePreset(id, ownerItemId).declarations, options);
76
+ }
77
+ /** Propose active-scope evidence ceilings from the record without persisting them. */
78
+ export async function deriveAssuranceProposals(context, ownerItemId) {
79
+ const terminalStatuses = new Set(context.terminal_statuses ?? ["closed", "canceled"]);
80
+ const activeContext = {
81
+ ...context,
82
+ items: context.items.filter((item) => !terminalStatuses.has(item.status)),
83
+ };
84
+ const proposals = await Promise.all(["files", "tests", "docs"].map(async (link) => {
85
+ const measurement = {
86
+ id: `derived-active-missing-${link}`,
87
+ description: `Observed active items missing ${link} evidence.`,
88
+ source: { kind: "links", link, state: "missing" },
89
+ };
90
+ const measured = await evaluateMeasurement(measurement, activeContext);
91
+ const observed = measured.value;
92
+ const derivedAssertion = assertion(`${measurement.id}-ceiling`, measurement.id, ownerItemId, observed, "observe");
93
+ const id = `active-missing-${link}`;
94
+ return {
95
+ id,
96
+ population_size: activeContext.items.length,
97
+ scope: { kind: "active" },
98
+ observed,
99
+ declarations: {
100
+ measurements: [measurement],
101
+ assertions: [derivedAssertion],
102
+ gates: [
103
+ {
104
+ id: `derived-${id}`,
105
+ description: `Observe the accepted ${link} evidence baseline.`,
106
+ assertion_ids: [derivedAssertion.id],
107
+ triggers: ["ci", "scheduled"],
108
+ },
109
+ ],
110
+ },
111
+ };
112
+ }));
113
+ return proposals;
114
+ }
115
+ /** Accept all derived proposals in one audited registry transaction. */
116
+ export function acceptAssuranceProposals(pmRoot, proposals, options = {}) {
117
+ return putAssuranceDeclarationBundle(pmRoot, {
118
+ measurements: proposals.flatMap((proposal) => proposal.declarations.measurements),
119
+ assertions: proposals.flatMap((proposal) => proposal.declarations.assertions),
120
+ gates: proposals.flatMap((proposal) => proposal.declarations.gates),
121
+ }, options);
122
+ }
123
+ /** Promote one assertion by exactly one enforcement level and audit the transition. */
124
+ export async function promoteAssuranceAssertion(pmRoot, definition, enforcement, options = {}) {
125
+ const expected = definition.enforcement === "observe" ? "warn" : "block";
126
+ if (definition.enforcement === "block" || enforcement !== expected) {
127
+ throw new TypeError(`assurance assertion ${definition.id} promotion must be ${definition.enforcement} -> ${expected}`);
128
+ }
129
+ return putAssuranceDeclaration(pmRoot, "assertion", { ...definition, enforcement }, {
130
+ ...options,
131
+ message: options.message ??
132
+ `Promote assurance assertion ${definition.id} from ${definition.enforcement} to ${enforcement}`,
133
+ });
134
+ }
135
+ //# sourceMappingURL=assurance-presets.js.map
136
+ //# debugId=05c29627-6763-5aee-8579-71e563a98780
@@ -11,6 +11,10 @@ export interface CreateAssuranceWorkspaceContextOptions {
11
11
  resolve_tree?: boolean;
12
12
  /** Provider resolvers keyed by stable provider id. */
13
13
  providers?: Readonly<Record<string, AssuranceProviderResolver>>;
14
+ /** Capabilities for host-provided resolvers that are not extension registrations. */
15
+ provider_capabilities?: AssuranceEvaluationContext["provider_capabilities"];
16
+ /** Gate trigger supplied to extension provider resolvers. */
17
+ trigger?: string;
14
18
  }
15
19
  /**
16
20
  * Build an assurance context from authoritative workspace data and public SDK