@unbrained/pm-cli 2026.8.10 → 2026.8.12

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 (243) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +153 -100
  3. package/dist/cli/commander-usage.js +113 -15
  4. package/dist/cli/error-guidance.d.ts +12 -0
  5. package/dist/cli/error-guidance.js +147 -29
  6. package/dist/cli/main.js +38 -19
  7. package/dist/cli/register-annotations.js +56 -3
  8. package/dist/cli/register-assurance.d.ts +8 -0
  9. package/dist/cli/register-assurance.js +52 -0
  10. package/dist/cli/register-files-lookup.js +14 -3
  11. package/dist/cli/register-list-query.js +10 -7
  12. package/dist/cli/register-mutation.js +30 -9
  13. package/dist/cli/register-operations.js +30 -15
  14. package/dist/cli-bundle/bundle-manifest.json +155 -155
  15. package/dist/cli-bundle/chunks/{chunk-TRWXF476.js → chunk-3PS7X6GS.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-7KL6KMWF.js +13 -0
  17. package/dist/cli-bundle/chunks/{chunk-EBO7OUUE.js → chunk-BM5YJ2UW.js} +69 -55
  18. package/dist/cli-bundle/chunks/chunk-D55A5AEN.js +33 -0
  19. package/dist/cli-bundle/chunks/chunk-KIKDWECH.js +196 -0
  20. package/dist/cli-bundle/chunks/{chunk-ETML5C6H.js → chunk-KOQMGCTA.js} +47 -47
  21. package/dist/cli-bundle/chunks/chunk-R76342NV.js +2 -0
  22. package/dist/cli-bundle/chunks/chunk-RBTK5EZV.js +5 -0
  23. package/dist/cli-bundle/chunks/chunk-VLUQOIDT.js +2 -0
  24. package/dist/cli-bundle/chunks/chunk-WLAHPSOX.js +3 -0
  25. package/dist/cli-bundle/chunks/register-list-query-XPCJRUUD.js +10 -0
  26. package/dist/cli-bundle/chunks/register-mutation-4RJCBKRS.js +20 -0
  27. package/dist/cli-bundle/chunks/register-operations-2OGISOVR.js +2 -0
  28. package/dist/cli-bundle/chunks/{register-setup-S3KT2LTH.js → register-setup-LLHAKP2V.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-2DALMVF7.js +5 -0
  30. package/dist/cli-bundle/focused-chunks/chunk-5OQIMELN.js +155 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-5TAGTDRE.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-ECADZMVC.js +18 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-EJGXRA6B.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-FFGSZCPK.js +16 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-IW43E4XL.js → chunk-GQW4BPUT.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/chunk-ISKOBJCM.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/{chunk-75774JWP.js → chunk-JAFRIWVF.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-2COZ67XT.js → chunk-KHM2CS2C.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-M6RPIXKC.js → chunk-KPSXVBDV.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-34SX654S.js → chunk-KTLOKKCQ.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-LGYK3NUF.js +8 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-2EXI2DKR.js → chunk-NBLUKITQ.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-NYLOUPOB.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-Q4T463SD.js +31 -0
  45. package/dist/cli-bundle/focused-chunks/chunk-QVZVY53N.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/{chunk-DZGAHZZV.js → chunk-RWPAWUOT.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/chunk-UTEWXDEQ.js +17 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-7UN6BHHO.js → chunk-YIAXMC3T.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-ZMGWAYH7.js +2 -0
  50. package/dist/cli-bundle/main.js +13 -13
  51. package/dist/cli-bundle/sdk-authoring.js +1 -1
  52. package/dist/cli-bundle/sdk-contracts.js +1 -1
  53. package/dist/cli-bundle/sdk-core.js +41 -39
  54. package/dist/cli-bundle/sdk-governance.js +1 -1
  55. package/dist/cli-bundle/sdk-graph.js +1 -1
  56. package/dist/cli-bundle/sdk-merge.js +1 -1
  57. package/dist/cli-bundle/sdk-query.js +1 -1
  58. package/dist/cli-bundle/sdk-runtime.js +1 -1
  59. package/dist/cli-bundle/sdk-testing.js +1 -1
  60. package/dist/cli-bundle/sdk.js +2 -2
  61. package/dist/core/extensions/reserved-host-flags.js +3 -2
  62. package/dist/core/history/drift-scan.js +13 -8
  63. package/dist/core/history/history.d.ts +8 -0
  64. package/dist/core/history/history.js +57 -7
  65. package/dist/core/history/replay.d.ts +9 -1
  66. package/dist/core/history/replay.js +48 -13
  67. package/dist/core/output/output.d.ts +2 -0
  68. package/dist/core/output/output.js +46 -14
  69. package/dist/core/session/session-state.d.ts +47 -0
  70. package/dist/core/session/session-state.js +207 -6
  71. package/dist/core/shared/author.d.ts +7 -1
  72. package/dist/core/shared/author.js +66 -46
  73. package/dist/core/shared/command-types.d.ts +2 -0
  74. package/dist/core/shared/command-types.js +2 -2
  75. package/dist/core/shared/errors.d.ts +13 -0
  76. package/dist/core/shared/errors.js +2 -2
  77. package/dist/core/store/item-metadata-cache.d.ts +1 -1
  78. package/dist/core/store/item-metadata-cache.js +14 -7
  79. package/dist/sdk/agent/refusal-reachability.d.ts +40 -0
  80. package/dist/sdk/agent/refusal-reachability.js +72 -0
  81. package/dist/sdk/agent/subcommand-recovery.d.ts +40 -0
  82. package/dist/sdk/agent/subcommand-recovery.js +84 -0
  83. package/dist/sdk/cli-bootstrap.d.ts +10 -0
  84. package/dist/sdk/cli-bootstrap.js +11 -7
  85. package/dist/sdk/cli-contracts/completeness.js +14 -3
  86. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  87. package/dist/sdk/cli-contracts/enum-contracts.js +3 -2
  88. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  89. package/dist/sdk/cli-contracts/flag-contracts.js +20 -2
  90. package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
  91. package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
  92. package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
  93. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +515 -0
  94. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +252 -0
  95. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  96. package/dist/sdk/cli-contracts/tool-parameter-tables.js +99 -2
  97. package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -3
  98. package/dist/sdk/cli-contracts/tool-schema.js +38 -5
  99. package/dist/sdk/cli-contracts.d.ts +1 -1
  100. package/dist/sdk/cli-contracts.js +3 -3
  101. package/dist/sdk/cli-program.js +3 -2
  102. package/dist/sdk/completion.js +23 -8
  103. package/dist/sdk/config.js +9 -3
  104. package/dist/sdk/context/semantic-session-attribution.d.ts +32 -0
  105. package/dist/sdk/context/semantic-session-attribution.js +83 -0
  106. package/dist/sdk/context-intent-contracts.js +45 -4
  107. package/dist/sdk/core-governance.d.ts +3 -1
  108. package/dist/sdk/core-governance.js +5 -3
  109. package/dist/sdk/core.d.ts +2 -1
  110. package/dist/sdk/core.js +3 -2
  111. package/dist/sdk/error-code-catalog.d.ts +13 -0
  112. package/dist/sdk/error-code-catalog.js +35 -2
  113. package/dist/sdk/extension.js +18 -17
  114. package/dist/sdk/files.d.ts +11 -0
  115. package/dist/sdk/files.js +82 -24
  116. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
  117. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1585 -0
  118. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
  119. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
  120. package/dist/sdk/generated-error-code-catalog.js +6 -3121
  121. package/dist/sdk/governance/assurance-action-contracts.d.ts +7 -0
  122. package/dist/sdk/governance/assurance-action-contracts.js +5 -0
  123. package/dist/sdk/governance/assurance-action.d.ts +70 -0
  124. package/dist/sdk/governance/assurance-action.js +200 -0
  125. package/dist/sdk/governance/assurance-limits.d.ts +7 -0
  126. package/dist/sdk/governance/assurance-limits.js +11 -0
  127. package/dist/sdk/governance/assurance-mutation-error.d.ts +7 -0
  128. package/dist/sdk/governance/assurance-mutation-error.js +35 -0
  129. package/dist/sdk/governance/assurance-runtime.d.ts +20 -0
  130. package/dist/sdk/governance/assurance-runtime.js +134 -0
  131. package/dist/sdk/governance/assurance.d.ts +438 -0
  132. package/dist/sdk/governance/assurance.js +804 -0
  133. package/dist/sdk/governance/health.d.ts +3 -1
  134. package/dist/sdk/governance/health.js +21 -4
  135. package/dist/sdk/governance/validate-item-reader.js +3 -3
  136. package/dist/sdk/governance/validate.d.ts +2 -0
  137. package/dist/sdk/governance/validate.js +13 -3
  138. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  139. package/dist/sdk/graph/durable-cache.js +98 -29
  140. package/dist/sdk/graph/governance.d.ts +14 -0
  141. package/dist/sdk/graph/governance.js +34 -9
  142. package/dist/sdk/graph/run.js +8 -3
  143. package/dist/sdk/index.d.ts +7 -2
  144. package/dist/sdk/index.js +9 -4
  145. package/dist/sdk/lifecycle/claim.js +26 -4
  146. package/dist/sdk/lifecycle/focus.js +13 -3
  147. package/dist/sdk/lifecycle/plan.js +8 -3
  148. package/dist/sdk/merge/driver.d.ts +2 -2
  149. package/dist/sdk/merge/driver.js +3 -3
  150. package/dist/sdk/merge/receipts.d.ts +6 -4
  151. package/dist/sdk/merge/receipts.js +7 -5
  152. package/dist/sdk/merge/three-way.d.ts +2 -2
  153. package/dist/sdk/merge/three-way.js +3 -3
  154. package/dist/sdk/output-projection.d.ts +9 -1
  155. package/dist/sdk/output-projection.js +45 -9
  156. package/dist/sdk/provenance.d.ts +38 -0
  157. package/dist/sdk/provenance.js +64 -2
  158. package/dist/sdk/query/activity.d.ts +49 -2
  159. package/dist/sdk/query/activity.js +183 -37
  160. package/dist/sdk/query/context.js +19 -8
  161. package/dist/sdk/query/get.js +19 -2
  162. package/dist/sdk/read-output-contracts.d.ts +5 -1
  163. package/dist/sdk/read-output-contracts.js +17 -2
  164. package/dist/sdk/read-output-session.d.ts +2 -0
  165. package/dist/sdk/read-output-session.js +12 -5
  166. package/dist/sdk/runtime-extended-actions.js +22 -5
  167. package/dist/sdk/runtime-primitives.d.ts +5 -3
  168. package/dist/sdk/runtime-primitives.js +7 -5
  169. package/dist/sdk/runtime-stats-options.js +3 -2
  170. package/dist/sdk/runtime.d.ts +4 -0
  171. package/dist/sdk/runtime.js +34 -34
  172. package/dist/sdk/stats.d.ts +36 -3
  173. package/dist/sdk/stats.js +55 -15
  174. package/dist/sdk/telemetry.js +7 -4
  175. package/dist/sdk/test/execution.d.ts +4 -0
  176. package/dist/sdk/test/execution.js +86 -21
  177. package/dist/sdk/traceability/runtime-files-lookup.d.ts +8 -0
  178. package/dist/sdk/traceability/runtime-files-lookup.js +33 -0
  179. package/dist/sdk/traceability/source-traceability.d.ts +102 -0
  180. package/dist/sdk/traceability/source-traceability.js +293 -0
  181. package/dist/types.d.ts +10 -2
  182. package/dist/types.js +2 -2
  183. package/docs/ASSURANCE.md +137 -0
  184. package/docs/COMMANDS.md +29 -8
  185. package/docs/CONFIGURATION.md +7 -0
  186. package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
  187. package/docs/MERGE_SAFETY.md +3 -1
  188. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
  189. package/docs/README.md +3 -0
  190. package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
  191. package/docs/RELEASING.md +9 -5
  192. package/docs/SDK.md +12 -1
  193. package/docs/SDK_AGENT_SESSION_CONTEXT.md +52 -5
  194. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
  195. package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
  196. package/docs/SDK_EVIDENCE_TRACEABILITY.md +39 -1
  197. package/docs/SDK_RUNTIME_BOUNDARIES.md +36 -1
  198. package/docs/TESTING.md +12 -9
  199. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
  200. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
  201. package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
  202. package/marketplace.json +2 -2
  203. package/package.json +7 -7
  204. package/packages/pm-beads/package.json +1 -1
  205. package/packages/pm-calendar/package.json +1 -1
  206. package/packages/pm-command-kit/package.json +1 -1
  207. package/packages/pm-digital-twin/package.json +1 -1
  208. package/packages/pm-governance-audit/package.json +1 -1
  209. package/packages/pm-guide-shell/package.json +1 -1
  210. package/packages/pm-kanban/package.json +1 -1
  211. package/packages/pm-lifecycle-hooks/package.json +1 -1
  212. package/packages/pm-linked-test-adapters/package.json +1 -1
  213. package/packages/pm-search-advanced/package.json +1 -1
  214. package/packages/pm-templates/extensions/templates/index.ts +9 -3
  215. package/packages/pm-templates/package.json +1 -1
  216. package/packages/pm-todos/package.json +1 -1
  217. package/packages/pm-vcs/package.json +1 -1
  218. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  219. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  220. package/sdk/public-surface.json +1030 -67
  221. package/dist/cli-bundle/chunks/chunk-2QYH4QMI.js +0 -30
  222. package/dist/cli-bundle/chunks/chunk-JUDU4RO4.js +0 -194
  223. package/dist/cli-bundle/chunks/chunk-JZSNADRR.js +0 -5
  224. package/dist/cli-bundle/chunks/chunk-MENWVGJW.js +0 -2
  225. package/dist/cli-bundle/chunks/chunk-S4EITGLA.js +0 -3
  226. package/dist/cli-bundle/chunks/chunk-TIGKWVLA.js +0 -13
  227. package/dist/cli-bundle/chunks/chunk-TSLDTJLQ.js +0 -2
  228. package/dist/cli-bundle/chunks/register-list-query-OJ6ZXKV4.js +0 -10
  229. package/dist/cli-bundle/chunks/register-mutation-DKI7QC7O.js +0 -20
  230. package/dist/cli-bundle/chunks/register-operations-P5OGMT6I.js +0 -2
  231. package/dist/cli-bundle/focused-chunks/chunk-36FTZ2NT.js +0 -2
  232. package/dist/cli-bundle/focused-chunks/chunk-3CQECMKR.js +0 -16
  233. package/dist/cli-bundle/focused-chunks/chunk-CHIBMEZR.js +0 -8
  234. package/dist/cli-bundle/focused-chunks/chunk-FF4MNAYB.js +0 -153
  235. package/dist/cli-bundle/focused-chunks/chunk-GHTN2ILR.js +0 -2
  236. package/dist/cli-bundle/focused-chunks/chunk-I4YM2I7S.js +0 -2
  237. package/dist/cli-bundle/focused-chunks/chunk-IMDTEN7K.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-JMVA4HKR.js +0 -5
  239. package/dist/cli-bundle/focused-chunks/chunk-KR5RVXLQ.js +0 -31
  240. package/dist/cli-bundle/focused-chunks/chunk-KSNJG4KI.js +0 -16
  241. package/dist/cli-bundle/focused-chunks/chunk-MXYSIQ56.js +0 -18
  242. package/dist/cli-bundle/focused-chunks/chunk-RIIN5V4N.js +0 -2
  243. package/dist/cli-bundle/focused-chunks/chunk-RKWSCYYN.js +0 -2
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @module sdk/governance/assurance-action-contracts
3
+ *
4
+ * Exposes assurance action transport types without coupling callers to the
5
+ * governance implementation module.
6
+ */
7
+ export type { AssuranceActionInput, AssuranceActionResult, } from "./assurance-action.js";
@@ -0,0 +1,5 @@
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]="443beddb-37c9-5244-a157-e07624e4a6d2")}catch(e){}}();
3
+ export {};
4
+ //# sourceMappingURL=assurance-action-contracts.js.map
5
+ //# debugId=443beddb-37c9-5244-a157-e07624e4a6d2
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @module sdk/assurance-action
3
+ *
4
+ * Normalizes the assurance action vocabulary once for CLI, SDK, and MCP hosts.
5
+ */
6
+ import type { GlobalOptions } from "../../core/shared/command-types.js";
7
+ import { type AssuranceDeclaration, type AssuranceGateVerdict, type AssuranceMutationReceipt } from "./assurance.js";
8
+ /** Assurance registry and evaluation verbs shared by every transport. */
9
+ export declare const ASSURANCE_ACTIONS: readonly ["list", "show", "put", "remove", "run", "verdicts"];
10
+ /** Assurance declaration kinds shared by every transport. */
11
+ export declare const ASSURANCE_DECLARATION_KINDS: readonly ["measurement", "assertion", "gate"];
12
+ /** Assurance action verb. */
13
+ export type AssuranceAction = (typeof ASSURANCE_ACTIONS)[number];
14
+ /** Transport-neutral assurance action request. */
15
+ export interface AssuranceActionInput {
16
+ /** CRUD, evaluation, or verdict-history action. */
17
+ action: string;
18
+ /** Declaration kind for registry actions. */
19
+ kind?: string;
20
+ /** Declaration id, gate id, or verdict gate filter. */
21
+ id?: string;
22
+ /** JSON object or serialized JSON declaration for put. */
23
+ definition?: unknown;
24
+ /** Lifecycle trigger for gate evaluation. */
25
+ trigger?: string;
26
+ /** Explicit commit, tree, or snapshot identity. */
27
+ tree?: string;
28
+ /** Verdict-history gate filter when id is used by another host field. */
29
+ gate?: string;
30
+ /** Maximum newest durable verdicts returned. */
31
+ limit?: number | string;
32
+ /** Evaluate without appending an immutable verdict. */
33
+ dry_run?: boolean;
34
+ /** Retain the complete mutation receipt; assurance receipts are complete by default. */
35
+ fullChangedFields?: boolean;
36
+ /** Project declaration mutations to their stable id. */
37
+ idOnly?: boolean;
38
+ /** Explicit author override. */
39
+ author?: string;
40
+ /** Audited mutation rationale. */
41
+ message?: string;
42
+ }
43
+ /** Result union returned by transport-neutral assurance execution. */
44
+ export type AssuranceActionResult = AssuranceDeclaration | AssuranceMutationReceipt | AssuranceGateVerdict | {
45
+ id: string;
46
+ } | {
47
+ /** Registry declarations. */
48
+ items: AssuranceDeclaration[];
49
+ /** Number of declarations. */
50
+ count: number;
51
+ /** Stable row-selection contract. */
52
+ row_contract: {
53
+ row_keys: ["items"];
54
+ jq_selector: ".items[]";
55
+ };
56
+ } | {
57
+ /** Durable gate verdicts. */
58
+ items: AssuranceGateVerdict[];
59
+ /** Number of verdicts. */
60
+ count: number;
61
+ /** Stable row-selection contract. */
62
+ row_contract: {
63
+ row_keys: ["items"];
64
+ jq_selector: ".items[]";
65
+ };
66
+ };
67
+ /** Execute one assurance request through the public assurance SDK primitives. */
68
+ export declare function runAssuranceAction(input: AssuranceActionInput, global?: Pick<GlobalOptions, "path">): Promise<AssuranceActionResult>;
69
+ /** Normalize a generic SDK or MCP argument envelope into one assurance request. */
70
+ export declare function runAssuranceDispatch(args: Record<string, unknown>, options: Record<string, unknown>, global: GlobalOptions): Promise<AssuranceActionResult>;
@@ -0,0 +1,200 @@
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]="d7b8bd03-cd67-5f3f-9ac9-74808a03c2c7")}catch(e){}}();
3
+ import { EXIT_CODE } from "../../core/shared/constants.js";
4
+ import { PmCliError } from "../../core/shared/errors.js";
5
+ import { ASSURANCE_GATE_TRIGGERS, evaluateAssuranceGate, getAssuranceDeclaration, listAssuranceDeclarations, listAssuranceVerdicts, putAssuranceDeclaration, recordAssuranceVerdict, removeAssuranceDeclaration, } from "./assurance.js";
6
+ import { MAX_ASSURANCE_VERDICT_LIMIT } from "./assurance-limits.js";
7
+ import { normalizeAssuranceMutation } from "./assurance-mutation-error.js";
8
+ import { createAssuranceWorkspaceContext } from "./assurance-runtime.js";
9
+ import { resolvePmRoot } from "../runtime-primitives.js";
10
+ import { parseRuntimeInteger, readRuntimeString } from "../runtime-input.js";
11
+ /** Assurance registry and evaluation verbs shared by every transport. */
12
+ export const ASSURANCE_ACTIONS = [
13
+ "list",
14
+ "show",
15
+ "put",
16
+ "remove",
17
+ "run",
18
+ "verdicts",
19
+ ];
20
+ /** Assurance declaration kinds shared by every transport. */
21
+ export const ASSURANCE_DECLARATION_KINDS = [
22
+ "measurement",
23
+ "assertion",
24
+ "gate",
25
+ ];
26
+ function parseAction(value) {
27
+ if (ASSURANCE_ACTIONS.includes(value)) {
28
+ return value;
29
+ }
30
+ throw new PmCliError(`Unknown assurance action ${value}. Expected: ${ASSURANCE_ACTIONS.join(", ")}`, EXIT_CODE.USAGE);
31
+ }
32
+ function parseKind(value) {
33
+ if (value &&
34
+ ASSURANCE_DECLARATION_KINDS.includes(value)) {
35
+ return value;
36
+ }
37
+ throw new PmCliError(`Assurance declaration kind is required. Expected: ${ASSURANCE_DECLARATION_KINDS.join(", ")}`, EXIT_CODE.USAGE);
38
+ }
39
+ function parseDefinition(kind, value) {
40
+ let parsed = value;
41
+ if (typeof value === "string") {
42
+ if (!value.trim())
43
+ parsed = undefined;
44
+ else {
45
+ try {
46
+ parsed = JSON.parse(value);
47
+ }
48
+ catch (error) {
49
+ throw new PmCliError("assurance definition must be valid JSON", EXIT_CODE.USAGE, { reason: error instanceof Error ? error.message : "invalid_json" });
50
+ }
51
+ }
52
+ }
53
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
54
+ throw new PmCliError("assurance put requires a JSON object definition", EXIT_CODE.USAGE);
55
+ }
56
+ if (kind === "measurement")
57
+ return parsed;
58
+ if (kind === "assertion")
59
+ return parsed;
60
+ return parsed;
61
+ }
62
+ async function readDocument(pmRoot) {
63
+ const [measurements, assertions, gates] = await Promise.all([
64
+ listAssuranceDeclarations(pmRoot, "measurement"),
65
+ listAssuranceDeclarations(pmRoot, "assertion"),
66
+ listAssuranceDeclarations(pmRoot, "gate"),
67
+ ]);
68
+ return {
69
+ version: 1,
70
+ measurements: measurements.items,
71
+ assertions: assertions.items,
72
+ gates: gates.items,
73
+ };
74
+ }
75
+ /** Apply the common id-only projection without weakening the full audit receipt. */
76
+ function projectMutationReceipt(receipt, idOnly) {
77
+ return idOnly === true ? { id: receipt.id } : receipt;
78
+ }
79
+ async function authorizedDecisionIds(pmRoot, definition) {
80
+ const decisionId = definition.authorization_decision;
81
+ if (!decisionId)
82
+ return [];
83
+ const context = await createAssuranceWorkspaceContext(pmRoot, {
84
+ include_history: false,
85
+ resolve_tree: false,
86
+ });
87
+ const decision = context.items.find((item) => item.id === decisionId);
88
+ const terminalStatuses = new Set(context.terminal_statuses);
89
+ if (!decision ||
90
+ decision.type.toLowerCase() !== "decision" ||
91
+ !terminalStatuses.has(decision.status)) {
92
+ throw new PmCliError(`Assurance authorization ${decisionId} must name a terminal Decision item`, EXIT_CODE.USAGE);
93
+ }
94
+ return [decision.id];
95
+ }
96
+ /** Validate and execute the bounded durable-verdict listing transport. */
97
+ async function runVerdictsAction(input, pmRoot) {
98
+ const limit = parseRuntimeInteger(input.limit, "assurance verdict limit");
99
+ if (limit !== undefined &&
100
+ (limit < 1 || limit > MAX_ASSURANCE_VERDICT_LIMIT)) {
101
+ throw new PmCliError(`assurance verdict limit must be an integer from 1 through ${MAX_ASSURANCE_VERDICT_LIMIT}`, EXIT_CODE.USAGE);
102
+ }
103
+ const items = await listAssuranceVerdicts(pmRoot, {
104
+ gate_id: input.id ?? input.gate,
105
+ limit,
106
+ });
107
+ return {
108
+ items,
109
+ count: items.length,
110
+ row_contract: { row_keys: ["items"], jq_selector: ".items[]" },
111
+ };
112
+ }
113
+ /** Execute one assurance request through the public assurance SDK primitives. */
114
+ export async function runAssuranceAction(input, global = {}) {
115
+ const action = parseAction(input.action);
116
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
117
+ if (action === "verdicts") {
118
+ return runVerdictsAction(input, pmRoot);
119
+ }
120
+ if (action === "run") {
121
+ if (!input.id) {
122
+ throw new PmCliError("assurance run requires a gate id", EXIT_CODE.USAGE);
123
+ }
124
+ if (!input.trigger) {
125
+ throw new PmCliError("assurance run requires a trigger", EXIT_CODE.USAGE);
126
+ }
127
+ if (!ASSURANCE_GATE_TRIGGERS.includes(input.trigger)) {
128
+ throw new PmCliError(`Unknown assurance trigger ${input.trigger}. Expected: ${ASSURANCE_GATE_TRIGGERS.join(", ")}`, EXIT_CODE.USAGE);
129
+ }
130
+ const [document, workspaceContext] = await Promise.all([
131
+ readDocument(pmRoot),
132
+ createAssuranceWorkspaceContext(pmRoot, { tree_id: input.tree }),
133
+ ]);
134
+ const verdict = await evaluateAssuranceGate(input.id, document, workspaceContext, {
135
+ trigger: input.trigger,
136
+ dry_run: input.dry_run === true,
137
+ });
138
+ if (!verdict.dry_run) {
139
+ await recordAssuranceVerdict(pmRoot, verdict, {
140
+ author: input.author,
141
+ message: input.message,
142
+ });
143
+ }
144
+ return verdict;
145
+ }
146
+ const kind = parseKind(input.kind);
147
+ if (action === "list")
148
+ return listAssuranceDeclarations(pmRoot, kind);
149
+ if (!input.id) {
150
+ throw new PmCliError(`assurance ${action} requires an id`, EXIT_CODE.USAGE);
151
+ }
152
+ const id = input.id;
153
+ if (action === "show") {
154
+ return getAssuranceDeclaration(pmRoot, kind, id);
155
+ }
156
+ if (action === "remove") {
157
+ const receipt = await normalizeAssuranceMutation(() => removeAssuranceDeclaration(pmRoot, kind, id, { author: input.author, message: input.message }));
158
+ return projectMutationReceipt(receipt, input.idOnly);
159
+ }
160
+ const definition = parseDefinition(kind, input.definition);
161
+ if (definition.id !== id) {
162
+ throw new PmCliError(`Assurance definition id ${definition.id} does not match requested id ${id}`, EXIT_CODE.USAGE);
163
+ }
164
+ const mutationOptions = {
165
+ author: input.author,
166
+ message: input.message,
167
+ ...(kind === "assertion"
168
+ ? {
169
+ authorized_decision_ids: await authorizedDecisionIds(pmRoot, definition),
170
+ }
171
+ : {}),
172
+ };
173
+ const receipt = await normalizeAssuranceMutation(() => putAssuranceDeclaration(pmRoot, kind, definition, mutationOptions));
174
+ return projectMutationReceipt(receipt, input.idOnly);
175
+ }
176
+ /** Normalize a generic SDK or MCP argument envelope into one assurance request. */
177
+ export function runAssuranceDispatch(args, options, global) {
178
+ const merged = { ...args, ...options };
179
+ return runAssuranceAction({
180
+ action: readRuntimeString(merged, "subcommand") ??
181
+ readRuntimeString(merged, "assuranceAction") ??
182
+ readRuntimeString(merged, "operation") ??
183
+ "",
184
+ kind: readRuntimeString(merged, "kind"),
185
+ id: readRuntimeString(merged, "id"),
186
+ definition: merged.definition,
187
+ trigger: readRuntimeString(merged, "trigger"),
188
+ tree: readRuntimeString(merged, "treeId") ??
189
+ readRuntimeString(merged, "tree"),
190
+ gate: readRuntimeString(merged, "gate"),
191
+ limit: parseRuntimeInteger(merged.limit, "assurance verdict limit"),
192
+ dry_run: merged.dryRun === true || merged.dry_run === true,
193
+ fullChangedFields: merged.fullChangedFields === true,
194
+ idOnly: merged.idOnly === true,
195
+ author: readRuntimeString(merged, "author"),
196
+ message: readRuntimeString(merged, "message"),
197
+ }, global);
198
+ }
199
+ //# sourceMappingURL=assurance-action.js.map
200
+ //# debugId=d7b8bd03-cd67-5f3f-9ac9-74808a03c2c7
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @module sdk/governance/assurance-limits
3
+ *
4
+ * Shares bounded assurance transport limits without expanding the public SDK.
5
+ */
6
+ /** Largest verdict-history page accepted by SDK and transport boundaries. */
7
+ export declare const MAX_ASSURANCE_VERDICT_LIMIT = 1000;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module sdk/governance/assurance-limits
3
+ *
4
+ * Shares bounded assurance transport limits without expanding the public SDK.
5
+ */
6
+ /** Largest verdict-history page accepted by SDK and transport boundaries. */
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]="b911b43d-d14d-5e4f-a35e-5020b1a84542")}catch(e){}}();
9
+ export const MAX_ASSURANCE_VERDICT_LIMIT = 1_000;
10
+ //# sourceMappingURL=assurance-limits.js.map
11
+ //# debugId=b911b43d-d14d-5e4f-a35e-5020b1a84542
@@ -0,0 +1,7 @@
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
+ /** Normalize only expected assurance mutation refusals for CLI and MCP hosts. */
7
+ export declare function normalizeAssuranceMutation<T>(operation: () => Promise<T>): Promise<T>;
@@ -0,0 +1,35 @@
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]="255eee6e-f6bb-5fd2-8a73-545e672d205d")}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
+ /** Normalize only expected assurance mutation refusals for CLI and MCP hosts. */
20
+ export async function normalizeAssuranceMutation(operation) {
21
+ try {
22
+ return await operation();
23
+ }
24
+ catch (error) {
25
+ if (error instanceof AssuranceMutationRefusalError) {
26
+ throw new PmCliError(error.message, EXIT_CODE.USAGE, {
27
+ code: "invalid_argument_value",
28
+ reason: "assurance_mutation_refused",
29
+ });
30
+ }
31
+ throw error;
32
+ }
33
+ }
34
+ //# sourceMappingURL=assurance-mutation-error.js.map
35
+ //# debugId=255eee6e-f6bb-5fd2-8a73-545e672d205d
@@ -0,0 +1,20 @@
1
+ import type { AssuranceEvaluationContext, AssuranceExternalMeasurementResult, AssuranceProviderSource } from "./assurance.js";
2
+ /** Resolver contributed by an embedding host or extension package. */
3
+ export type AssuranceProviderResolver = (source: AssuranceProviderSource) => Promise<AssuranceExternalMeasurementResult>;
4
+ /** Workspace binding options. */
5
+ export interface CreateAssuranceWorkspaceContextOptions {
6
+ /** Explicit tree identity; otherwise the current Git commit is used. */
7
+ tree_id?: string;
8
+ /** Load immutable item history for history-backed measurements. */
9
+ include_history?: boolean;
10
+ /** Resolve a Git identity; item-only callers can skip this subprocess. */
11
+ resolve_tree?: boolean;
12
+ /** Provider resolvers keyed by stable provider id. */
13
+ providers?: Readonly<Record<string, AssuranceProviderResolver>>;
14
+ }
15
+ /**
16
+ * Build an assurance context from authoritative workspace data and public SDK
17
+ * operations. Graph, validate, and health selectors run through their existing
18
+ * SDK implementations, so presentation surfaces cannot acquire divergent rules.
19
+ */
20
+ export declare function createAssuranceWorkspaceContext(pmRoot: string, options?: CreateAssuranceWorkspaceContextOptions): Promise<AssuranceEvaluationContext>;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * @module sdk/assurance-runtime
3
+ *
4
+ * Binds assurance evaluation to a real pm workspace while leaving declaration
5
+ * and verdict semantics in the host-neutral assurance module.
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]="abb3946c-ec68-52af-8521-ae0389f31f54")}catch(e){}}();
9
+ import { execFile } from "node:child_process";
10
+ import { promisify } from "node:util";
11
+ import { runGraph } from "../graph/run.js";
12
+ import { runHealth } from "./health.js";
13
+ import { runValidate } from "./validate.js";
14
+ import { getHistoryPath, listAllItemMetadata, readHistoryEntries, readSettings, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, } from "../runtime-primitives.js";
15
+ const execFileAsync = promisify(execFile);
16
+ const HISTORY_READ_CONCURRENCY = 16;
17
+ function valueAtPath(input, field) {
18
+ let current = input;
19
+ for (const segment of field.split(".")) {
20
+ if (typeof current !== "object" ||
21
+ current === null ||
22
+ Array.isArray(current)) {
23
+ throw new TypeError(`assurance field ${field} is not present`);
24
+ }
25
+ current = current[segment];
26
+ }
27
+ if (typeof current === "number" && Number.isFinite(current))
28
+ return current;
29
+ if (Array.isArray(current) &&
30
+ current.every((entry) => typeof entry === "string")) {
31
+ return current;
32
+ }
33
+ throw new TypeError(`assurance field ${field} must resolve to a finite number or string array`);
34
+ }
35
+ function checkValue(result, checkName, field) {
36
+ const check = result.checks.find((entry) => entry.name === checkName);
37
+ if (!check)
38
+ throw new TypeError(`assurance check ${checkName} is not present`);
39
+ const value = field === "status" || field === "ok"
40
+ ? check.ok
41
+ ? 0
42
+ : 1
43
+ : valueAtPath(check.details, field);
44
+ return { value, population_size: 1, cost: result.checks.length };
45
+ }
46
+ async function resolveTreeId(pmRoot, explicit) {
47
+ if (explicit?.trim())
48
+ return explicit.trim();
49
+ try {
50
+ const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD^{commit}"], {
51
+ cwd: pmRoot,
52
+ encoding: "utf8",
53
+ timeout: 5_000,
54
+ windowsHide: true,
55
+ });
56
+ return stdout.trim();
57
+ }
58
+ catch {
59
+ return "working-copy";
60
+ }
61
+ }
62
+ async function readWorkspaceHistory(pmRoot, items) {
63
+ const streams = new Array(items.length);
64
+ let nextIndex = 0;
65
+ const workers = Array.from({ length: Math.min(HISTORY_READ_CONCURRENCY, items.length) }, async () => {
66
+ while (nextIndex < items.length) {
67
+ const index = nextIndex;
68
+ nextIndex += 1;
69
+ const item = items[index];
70
+ const entries = await readHistoryEntries(getHistoryPath(pmRoot, item.id), item.id);
71
+ streams[index] = entries.map((entry) => ({
72
+ op: entry.op,
73
+ author: entry.author,
74
+ agent_harness: entry.agent_harness,
75
+ agent_model: entry.agent_model,
76
+ }));
77
+ }
78
+ });
79
+ await Promise.all(workers);
80
+ return streams.flat();
81
+ }
82
+ /**
83
+ * Build an assurance context from authoritative workspace data and public SDK
84
+ * operations. Graph, validate, and health selectors run through their existing
85
+ * SDK implementations, so presentation surfaces cannot acquire divergent rules.
86
+ */
87
+ export async function createAssuranceWorkspaceContext(pmRoot, options = {}) {
88
+ const settings = await readSettings(pmRoot);
89
+ const typeRegistry = resolveItemTypeRegistry(settings);
90
+ const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
91
+ const metadata = await listAllItemMetadata(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);
92
+ const items = metadata.map((item) => ({
93
+ ...item,
94
+ id: item.id,
95
+ status: item.status,
96
+ type: item.type,
97
+ }));
98
+ const global = { path: pmRoot };
99
+ return {
100
+ tree_id: options.resolve_tree === false
101
+ ? (options.tree_id ?? "working-copy")
102
+ : await resolveTreeId(pmRoot, options.tree_id),
103
+ items,
104
+ history: options.include_history === false
105
+ ? []
106
+ : await readWorkspaceHistory(pmRoot, items),
107
+ terminal_statuses: [...statusRegistry.terminal_statuses],
108
+ external: async (source) => {
109
+ if (source.kind === "graph") {
110
+ const result = await runGraph(source.operation, undefined, undefined, { ...source.parameters, full: true }, global);
111
+ return {
112
+ value: valueAtPath(result, source.field),
113
+ population_size: items.length,
114
+ cost: items.length,
115
+ };
116
+ }
117
+ if (source.kind === "validate") {
118
+ const result = await runValidate({ counts: true }, global);
119
+ return checkValue(result, source.check, source.field);
120
+ }
121
+ if (source.kind === "health") {
122
+ const result = await runHealth(global, { checkOnly: true, full: true });
123
+ return checkValue(result, source.check, source.field);
124
+ }
125
+ const provider = options.providers?.[source.provider];
126
+ if (!provider) {
127
+ throw new TypeError(`assurance provider ${source.provider} is not registered`);
128
+ }
129
+ return provider(source);
130
+ },
131
+ };
132
+ }
133
+ //# sourceMappingURL=assurance-runtime.js.map
134
+ //# debugId=abb3946c-ec68-52af-8521-ae0389f31f54