@unbrained/pm-cli 2026.8.9 → 2026.8.11

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 (249) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +142 -80
  3. package/dist/cli/commander-usage.js +94 -17
  4. package/dist/cli/error-guidance.d.ts +10 -0
  5. package/dist/cli/error-guidance.js +76 -25
  6. package/dist/cli/help-json-payload.js +51 -16
  7. package/dist/cli/main.js +11 -6
  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-mutation.js +30 -9
  12. package/dist/cli/register-operations.js +16 -11
  13. package/dist/cli-bundle/bundle-manifest.json +163 -163
  14. package/dist/cli-bundle/chunks/{chunk-RJC7TPF4.js → chunk-2OOU2AFH.js} +2 -2
  15. package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +33 -0
  16. package/dist/cli-bundle/chunks/chunk-A2SJGHSI.js +3 -0
  17. package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +13 -0
  18. package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +194 -0
  19. package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +2 -0
  21. package/dist/cli-bundle/chunks/{chunk-YC3UF2IO.js → chunk-WMEZHCFI.js} +66 -60
  22. package/dist/cli-bundle/chunks/{chunk-GMX5YOI3.js → chunk-ZU34C3LH.js} +48 -48
  23. package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +5 -0
  24. package/dist/cli-bundle/chunks/{register-list-query-BUE7PTCU.js → register-list-query-HAUXVUPY.js} +8 -8
  25. package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +20 -0
  26. package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +2 -0
  27. package/dist/cli-bundle/chunks/{register-setup-UQDTNTLJ.js → register-setup-NOCOOWQY.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-KNEHLPBF.js → chunk-23FTGO3W.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-6DO4YQWZ.js → chunk-2DL3MRTD.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +2 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-MRWVJ3ZG.js → chunk-4H5IA6AV.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +16 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-55BIB6DV.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +8 -0
  36. package/dist/cli-bundle/focused-chunks/chunk-BKPIY34S.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +31 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-3WVHTUAW.js → chunk-E3KCL7AY.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +153 -0
  41. package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +18 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-73FIJONU.js → chunk-J5EKAIVD.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +4 -0
  45. package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/chunk-TL5M2PAY.js +3 -0
  47. package/dist/cli-bundle/focused-chunks/chunk-UDAZWT25.js +6 -0
  48. package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +17 -0
  49. package/dist/cli-bundle/main.js +13 -13
  50. package/dist/cli-bundle/sdk-authoring.js +1 -1
  51. package/dist/cli-bundle/sdk-contracts.js +1 -1
  52. package/dist/cli-bundle/sdk-core.js +41 -39
  53. package/dist/cli-bundle/sdk-governance.js +1 -1
  54. package/dist/cli-bundle/sdk-graph.js +1 -1
  55. package/dist/cli-bundle/sdk-merge.js +1 -1
  56. package/dist/cli-bundle/sdk-query.js +1 -1
  57. package/dist/cli-bundle/sdk-runtime.js +1 -1
  58. package/dist/cli-bundle/sdk-testing.js +1 -1
  59. package/dist/cli-bundle/sdk.js +2 -2
  60. package/dist/core/diagnostics/remediation.js +9 -9
  61. package/dist/core/fs/fs-utils.d.ts +10 -0
  62. package/dist/core/fs/fs-utils.js +16 -4
  63. package/dist/core/item/item-format.js +3 -32
  64. package/dist/core/schema/fields-file.d.ts +1 -2
  65. package/dist/core/schema/fields-file.js +4 -11
  66. package/dist/core/schema/runtime-schema.js +3 -10
  67. package/dist/core/schema/status-defs-file.d.ts +1 -2
  68. package/dist/core/schema/status-defs-file.js +4 -32
  69. package/dist/core/schema/status-token.d.ts +2 -0
  70. package/dist/core/schema/status-token.js +32 -0
  71. package/dist/core/schema/type-workflows.d.ts +1 -2
  72. package/dist/core/schema/type-workflows.js +4 -11
  73. package/dist/core/session/session-state.d.ts +47 -0
  74. package/dist/core/session/session-state.js +207 -6
  75. package/dist/core/shared/author.d.ts +8 -2
  76. package/dist/core/shared/author.js +85 -52
  77. package/dist/core/shared/errors.d.ts +12 -0
  78. package/dist/core/shared/errors.js +2 -2
  79. package/dist/core/shared/text-normalization.d.ts +1 -1
  80. package/dist/core/shared/text-normalization.js +2 -2
  81. package/dist/sdk/agent/command-recovery.d.ts +4 -0
  82. package/dist/sdk/agent/command-recovery.js +52 -0
  83. package/dist/sdk/agent/command-suggestions.d.ts +4 -0
  84. package/dist/sdk/agent/command-suggestions.js +67 -0
  85. package/dist/sdk/agent/create-option-policy.d.ts +12 -0
  86. package/dist/sdk/agent/create-option-policy.js +32 -0
  87. package/dist/sdk/agent/item-addressing.d.ts +19 -0
  88. package/dist/sdk/agent/item-addressing.js +208 -0
  89. package/dist/sdk/agent/refusal-reachability.d.ts +40 -0
  90. package/dist/sdk/agent/refusal-reachability.js +72 -0
  91. package/dist/sdk/agent/subcommand-recovery.d.ts +40 -0
  92. package/dist/sdk/agent/subcommand-recovery.js +84 -0
  93. package/dist/sdk/cli-bootstrap.d.ts +9 -1
  94. package/dist/sdk/cli-bootstrap.js +25 -10
  95. package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -4
  96. package/dist/sdk/cli-contracts/completeness.js +13 -3
  97. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  98. package/dist/sdk/cli-contracts/enum-contracts.js +3 -2
  99. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  100. package/dist/sdk/cli-contracts/flag-contracts.js +77 -21
  101. package/dist/sdk/cli-contracts/registration-helpers.js +10 -2
  102. package/dist/sdk/cli-contracts/runtime-contracts.js +6 -3
  103. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +513 -0
  104. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +251 -0
  105. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +6 -0
  106. package/dist/sdk/cli-contracts/tool-option-contracts.js +4 -2
  107. package/dist/sdk/cli-contracts/tool-parameter-tables.js +96 -4
  108. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  109. package/dist/sdk/cli-contracts/tool-schema.js +49 -6
  110. package/dist/sdk/cli-contracts.d.ts +1 -1
  111. package/dist/sdk/cli-contracts.js +3 -3
  112. package/dist/sdk/completion.js +9 -3
  113. package/dist/sdk/config.js +9 -3
  114. package/dist/sdk/context/semantic-session-attribution.d.ts +32 -0
  115. package/dist/sdk/context/semantic-session-attribution.js +83 -0
  116. package/dist/sdk/context-intent-runtime.js +8 -5
  117. package/dist/sdk/context-signal-store.d.ts +34 -0
  118. package/dist/sdk/context-signal-store.js +24 -2
  119. package/dist/sdk/core-governance.d.ts +3 -1
  120. package/dist/sdk/core-governance.js +5 -3
  121. package/dist/sdk/core.d.ts +1 -1
  122. package/dist/sdk/core.js +2 -2
  123. package/dist/sdk/dependency-flag-validation.d.ts +15 -1
  124. package/dist/sdk/dependency-flag-validation.js +54 -2
  125. package/dist/sdk/error-code-catalog.d.ts +13 -0
  126. package/dist/sdk/error-code-catalog.js +35 -2
  127. package/dist/sdk/extension.js +18 -17
  128. package/dist/sdk/files.d.ts +11 -0
  129. package/dist/sdk/files.js +82 -24
  130. package/dist/sdk/generated-error-code-catalog.js +104 -13
  131. package/dist/sdk/governance/assurance-action-contracts.d.ts +7 -0
  132. package/dist/sdk/governance/assurance-action-contracts.js +5 -0
  133. package/dist/sdk/governance/assurance-action.d.ts +70 -0
  134. package/dist/sdk/governance/assurance-action.js +198 -0
  135. package/dist/sdk/governance/assurance-limits.d.ts +7 -0
  136. package/dist/sdk/governance/assurance-limits.js +11 -0
  137. package/dist/sdk/governance/assurance-runtime.d.ts +20 -0
  138. package/dist/sdk/governance/assurance-runtime.js +131 -0
  139. package/dist/sdk/governance/assurance.d.ts +432 -0
  140. package/dist/sdk/governance/assurance.js +689 -0
  141. package/dist/sdk/governance/health.js +14 -7
  142. package/dist/sdk/governance/provenance-health.d.ts +13 -0
  143. package/dist/sdk/governance/provenance-health.js +63 -17
  144. package/dist/sdk/governance/validate-item-reader.d.ts +13 -0
  145. package/dist/sdk/governance/validate-item-reader.js +18 -0
  146. package/dist/sdk/governance/validate.d.ts +2 -2
  147. package/dist/sdk/governance/validate.js +15 -6
  148. package/dist/sdk/graph/run.js +8 -3
  149. package/dist/sdk/index.d.ts +10 -1
  150. package/dist/sdk/index.js +12 -3
  151. package/dist/sdk/lifecycle/claim.js +18 -3
  152. package/dist/sdk/lifecycle/close.js +17 -14
  153. package/dist/sdk/lifecycle/create.d.ts +2 -0
  154. package/dist/sdk/lifecycle/create.js +62 -9
  155. package/dist/sdk/lifecycle/focus.js +13 -3
  156. package/dist/sdk/lifecycle/plan.js +8 -3
  157. package/dist/sdk/lifecycle/update-many.js +39 -27
  158. package/dist/sdk/lifecycle/update.d.ts +6 -1
  159. package/dist/sdk/lifecycle/update.js +47 -10
  160. package/dist/sdk/merge/index.d.ts +1 -1
  161. package/dist/sdk/merge/index.js +3 -3
  162. package/dist/sdk/merge/install.d.ts +4 -0
  163. package/dist/sdk/merge/install.js +28 -16
  164. package/dist/sdk/merge/receipts.d.ts +3 -0
  165. package/dist/sdk/merge/receipts.js +81 -17
  166. package/dist/sdk/output-projection.js +24 -4
  167. package/dist/sdk/provenance.d.ts +38 -0
  168. package/dist/sdk/provenance.js +64 -2
  169. package/dist/sdk/query/context.d.ts +2 -0
  170. package/dist/sdk/query/context.js +24 -10
  171. package/dist/sdk/query/light-metadata.d.ts +3 -0
  172. package/dist/sdk/query/light-metadata.js +19 -0
  173. package/dist/sdk/runtime-extended-actions.js +22 -5
  174. package/dist/sdk/runtime-primitives.d.ts +2 -0
  175. package/dist/sdk/runtime-primitives.js +4 -2
  176. package/dist/sdk/runtime.d.ts +8 -1
  177. package/dist/sdk/runtime.js +37 -28
  178. package/dist/sdk/schema-migration.js +7 -9
  179. package/dist/sdk/similarity-scoring.d.ts +1 -2
  180. package/dist/sdk/similarity-scoring.js +4 -16
  181. package/dist/sdk/telemetry.js +7 -4
  182. package/dist/sdk/traceability/runtime-files-lookup.d.ts +8 -0
  183. package/dist/sdk/traceability/runtime-files-lookup.js +33 -0
  184. package/dist/sdk/traceability/source-traceability.d.ts +102 -0
  185. package/dist/sdk/traceability/source-traceability.js +293 -0
  186. package/dist/sdk/workspace-snapshot.d.ts +4 -0
  187. package/dist/sdk/workspace-snapshot.js +24 -11
  188. package/dist/types.d.ts +8 -2
  189. package/dist/types.js +2 -2
  190. package/docs/AGENT_GUIDE.md +3 -1
  191. package/docs/ASSURANCE.md +132 -0
  192. package/docs/COMMANDS.md +8 -5
  193. package/docs/MERGE_SAFETY.md +7 -5
  194. package/docs/README.md +3 -5
  195. package/docs/READ_OUTPUT_CONTRACTS.md +2 -2
  196. package/docs/RELEASING.md +9 -5
  197. package/docs/SDK.md +44 -8
  198. package/docs/SDK_AGENT_SESSION_CONTEXT.md +43 -6
  199. package/docs/SDK_CONTEXT.md +97 -0
  200. package/docs/SDK_CONTEXT_INTEGRITY.md +18 -3
  201. package/docs/SDK_EVIDENCE_TRACEABILITY.md +39 -1
  202. package/docs/SDK_RUNTIME_BOUNDARIES.md +36 -1
  203. package/docs/TESTING.md +12 -9
  204. package/docs/agent-task-token-baseline.json +2 -2
  205. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
  206. package/marketplace.json +2 -2
  207. package/package.json +7 -6
  208. package/packages/pm-beads/package.json +1 -1
  209. package/packages/pm-calendar/package.json +1 -1
  210. package/packages/pm-command-kit/package.json +1 -1
  211. package/packages/pm-digital-twin/package.json +1 -1
  212. package/packages/pm-governance-audit/package.json +1 -1
  213. package/packages/pm-guide-shell/package.json +1 -1
  214. package/packages/pm-kanban/package.json +1 -1
  215. package/packages/pm-lifecycle-hooks/package.json +1 -1
  216. package/packages/pm-linked-test-adapters/package.json +1 -1
  217. package/packages/pm-search-advanced/package.json +1 -1
  218. package/packages/pm-templates/extensions/templates/index.ts +9 -3
  219. package/packages/pm-templates/package.json +1 -1
  220. package/packages/pm-todos/package.json +1 -1
  221. package/packages/pm-vcs/package.json +1 -1
  222. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  223. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  224. package/sdk/public-surface.json +1028 -48
  225. package/dist/cli-bundle/chunks/chunk-2DTCZXSD.js +0 -13
  226. package/dist/cli-bundle/chunks/chunk-5JO6R4BS.js +0 -3
  227. package/dist/cli-bundle/chunks/chunk-5KN4DZYV.js +0 -194
  228. package/dist/cli-bundle/chunks/chunk-EF43KODO.js +0 -2
  229. package/dist/cli-bundle/chunks/chunk-HUV2Z7IS.js +0 -28
  230. package/dist/cli-bundle/chunks/chunk-MHBVCUF2.js +0 -2
  231. package/dist/cli-bundle/chunks/chunk-PYO5GZU6.js +0 -5
  232. package/dist/cli-bundle/chunks/register-mutation-FC3XLVIK.js +0 -20
  233. package/dist/cli-bundle/chunks/register-operations-YH2WAOXU.js +0 -2
  234. package/dist/cli-bundle/focused-chunks/chunk-2VVP5RAA.js +0 -153
  235. package/dist/cli-bundle/focused-chunks/chunk-3GSFUDAI.js +0 -2
  236. package/dist/cli-bundle/focused-chunks/chunk-4H6MVCK3.js +0 -16
  237. package/dist/cli-bundle/focused-chunks/chunk-54TZJ4BM.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-5NK5TJ5D.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/chunk-C3GCHDSQ.js +0 -31
  240. package/dist/cli-bundle/focused-chunks/chunk-JGRSQZJT.js +0 -18
  241. package/dist/cli-bundle/focused-chunks/chunk-NL57J7BZ.js +0 -4
  242. package/dist/cli-bundle/focused-chunks/chunk-P6BBIQRG.js +0 -6
  243. package/dist/cli-bundle/focused-chunks/chunk-PZAGVQNN.js +0 -3
  244. package/dist/cli-bundle/focused-chunks/chunk-QDAO3XEK.js +0 -14
  245. package/dist/cli-bundle/focused-chunks/chunk-T4IGQCSY.js +0 -2
  246. package/dist/cli-bundle/focused-chunks/chunk-U46GQJNY.js +0 -2
  247. package/dist/cli-bundle/focused-chunks/chunk-VRXJSGIT.js +0 -8
  248. package/dist/cli-bundle/focused-chunks/chunk-XC2ZW3CJ.js +0 -2
  249. package/dist/cli-bundle/focused-chunks/chunk-ZG54B4XG.js +0 -2
@@ -0,0 +1,132 @@
1
+ # Project Assurance Primitives
2
+
3
+ Tracker: [pm-2lex4r](../.agents/pm/features/pm-2lex4r.toon), [pm-lyfu7b](../.agents/pm/features/pm-lyfu7b.toon), [pm-wn6wot](../.agents/pm/features/pm-wn6wot.toon), [pm-91xeam](../.agents/pm/features/pm-91xeam.toon)
4
+
5
+ ## Agent Quick Context
6
+
7
+ Assurance turns project policy into three reusable SDK-owned declarations:
8
+
9
+ 1. A **measurement** selects authoritative project data and produces a number or labelled set plus population, contributor, and compute-cost receipts.
10
+ 2. An **assertion** applies exactly one explicit bound, scope, lifetime, and enforcement level to a measurement. Required negative controls prove that the bound can both pass and fail.
11
+ 3. A **gate** evaluates named assertions at declared lifecycle triggers and returns one structured verdict shared by CLI, SDK, MCP, and CI callers.
12
+
13
+ Declarations live in `.agents/pm/assurance.json`. Every registry mutation and non-dry gate verdict is appended through the verified workspace history stream; never edit either file directly.
14
+
15
+ ## Why Assurance Exists
16
+
17
+ Project management is context management. A useful quality gate therefore needs more than a shell exit code: it must preserve what was measured, which population was judged, why a bound exists, who owns it, what changed the result, how expensive the evaluation was, and which immutable tree received the verdict.
18
+
19
+ The assurance SDK keeps those semantics independent from presentation. Commander and MCP only normalize inputs. Package authors and CI hosts can use the same public functions without reconstructing policy in scripts.
20
+
21
+ ## Declaration Vocabulary
22
+
23
+ Measurements support these built-in sources:
24
+
25
+ | Source | Purpose |
26
+ | --- | --- |
27
+ | `items` | Count items matching status, type, tags, or an exact metadata field. |
28
+ | `dependency_kind` | Count typed relationship edges such as `blocked_by` or `verifies`. |
29
+ | `graph` | Select a numeric or labelled-set field from a public graph SDK result. |
30
+ | `validate` | Select a validator check status or numeric detail. |
31
+ | `health` | Select a health check status, numeric detail, or labelled set. |
32
+ | `history` | Count immutable events by operation, author, harness, or model. |
33
+ | `links` | Count items with present or missing file, test, or documentation evidence. |
34
+ | `derived` | Combine numeric measurements with deterministic arithmetic and cycle detection. |
35
+ | `provider` | Delegate a measurement to an explicitly supplied host/package resolver. |
36
+
37
+ Each measurement may declare `max_cost`. Evaluation fails closed when the total abstract compute units exceed that ceiling. Every result reports units, scanned items, scanned history rows, provider calls, duration, population size, and contributors.
38
+
39
+ Assertions require exactly one polarity:
40
+
41
+ - `ceiling`, `floor`, `equals`, or `zero`
42
+ - `monotone_nondecreasing` or `monotone_nonincreasing`
43
+ - `subset_of` for labelled sets
44
+
45
+ Scopes are `all`, `active`, or `filter`. A filter names another measurement whose contributors define the item population. `lifetime: hold` keeps the guarantee after its owner item becomes terminal. `lifetime: retire` retires it only after owner termination and requires `retire_reason`.
46
+
47
+ Enforcement is `block`, `warn`, or `observe`. Weakening a bound, scope, lifetime, owner, source measurement, or enforcement requires `authorization_decision` naming a terminal Decision item verified by the host. The transport verifies only that explicitly named item; it never treats unrelated workspace Decisions as authorization. Tightening does not require authorization.
48
+
49
+ ## CLI Workflow
50
+
51
+ Create a measurement:
52
+
53
+ ```bash
54
+ pm assurance put measurement active-issues \
55
+ --definition '{"id":"active-issues","source":{"kind":"items","statuses":["open","in_progress"],"types":["Issue"]},"max_cost":5000}' \
56
+ --message "Track the active issue population"
57
+ ```
58
+
59
+ Create an assertion with executable negative controls:
60
+
61
+ ```bash
62
+ pm assurance put assertion active-issues-ceiling \
63
+ --definition '{"id":"active-issues-ceiling","measurement_id":"active-issues","owner_item_id":"pm-example","scope":{"kind":"active"},"ceiling":25,"lifetime":"hold","enforcement":"block","negative_control":{"cases":[{"observed":25,"expected":"pass"},{"observed":26,"expected":"fail"}]}}'
64
+ ```
65
+
66
+ Create and evaluate a gate:
67
+
68
+ ```bash
69
+ pm assurance put gate release-readiness \
70
+ --definition '{"id":"release-readiness","assertion_ids":["active-issues-ceiling"],"triggers":["ci","pre-release"]}'
71
+
72
+ pm assurance run release-readiness --trigger ci --dry-run --json
73
+ pm assurance run release-readiness --trigger pre-release --tree "$(git rev-parse HEAD)" --json
74
+ pm assurance verdicts release-readiness --limit 20 --json
75
+ ```
76
+
77
+ Registry reads and removals use the same nouns:
78
+
79
+ ```bash
80
+ pm assurance list measurement --json
81
+ pm assurance show assertion active-issues-ceiling --json
82
+ pm assurance remove gate release-readiness
83
+ ```
84
+
85
+ Referenced measurements and assertions cannot be removed. Remove the consuming gate or assertion first.
86
+
87
+ ## SDK and MCP
88
+
89
+ The reusable client exposes the same action grammar:
90
+
91
+ ```ts
92
+ import { PmClient } from "@unbrained/pm-cli/sdk";
93
+
94
+ const pm = new PmClient({ pmRoot: ".agents/pm" });
95
+
96
+ await pm.assurance({
97
+ action: "run",
98
+ id: "release-readiness",
99
+ trigger: "ci",
100
+ dry_run: true,
101
+ });
102
+ ```
103
+
104
+ For direct host composition, use `evaluateMeasurement`, `evaluateAssuranceGate`, `createAssuranceWorkspaceContext`, and the audited declaration/verdict helpers exported from `@unbrained/pm-cli/sdk`. A host contributes provider measurements by passing stable resolver ids to `createAssuranceWorkspaceContext`; an absent resolver fails loudly. External adapters must enforce an appropriate timeout. The core evaluator bounds concurrent assertions and expression operands, and workspace history loading uses bounded concurrency; item-only callers can explicitly skip history and Git identity resolution.
105
+
106
+ Generic SDK and MCP dispatch use `action: "assurance"` with `subcommand` set to `list`, `show`, `put`, `remove`, `run`, or `verdicts`. Discover the current machine contract instead of copying parameter lists:
107
+
108
+ ```bash
109
+ pm contracts --action assurance --schema-only --json
110
+ pm contracts --command assurance --flags-only --json
111
+ ```
112
+
113
+ ## Verdict Contract
114
+
115
+ A gate emits one object containing:
116
+
117
+ - gate id, evaluated tree, trigger, timestamp, and dry-run status;
118
+ - overall `pass`, `warn`, or `block` plus stable exit code;
119
+ - every assertion's measurement, scope, population, observed value, structured bound, signed distance, enforcement, negative-control proof, cost, and contributors;
120
+ - an aggregate compute receipt.
121
+
122
+ Dry runs never write history. Non-dry verdicts are immutable workspace audit events and remain queryable after ordinary registry changes. Verdict reads return newest entries first and default to a bounded result; use `--limit` to select up to 1,000 matching records. A blocking verdict exits non-zero; warnings and observations remain successful while preserving their failed assertion rows.
123
+
124
+ ## Safety and Evolution
125
+
126
+ - Use stable lowercase ids; prose belongs in descriptions and mutation messages.
127
+ - Prefer saved measurements and derived arithmetic over duplicating queries in scripts.
128
+ - Give expensive graph, health, validate, or provider measurements explicit cost ceilings.
129
+ - Keep owner items and authorization Decisions linked into the project graph.
130
+ - Treat negative controls as part of the policy, not test decoration.
131
+ - Use `hold` unless a time-bounded guarantee has an explicit retirement rationale.
132
+ - Use `--dry-run` while authoring or tightening a gate, then persist a verdict against an immutable tree.
package/docs/COMMANDS.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This is a task-oriented command guide. For exact flags, use runtime help because extensions and settings can change the active surface:
4
4
 
5
- Tracked implementation updates: [pm-52eh](../.agents/pm/features/pm-52eh.toon), [pm-mcxr](../.agents/pm/issues/pm-mcxr.toon), [pm-qd3woa](../.agents/pm/issues/pm-qd3woa.toon), [pm-ypuc39](../.agents/pm/issues/pm-ypuc39.toon), [pm-tz2ikr](../.agents/pm/issues/pm-tz2ikr.toon), and the schema-migration recovery contract [pm-s79kel](../.agents/pm/issues/pm-s79kel.toon).
5
+ Tracked implementation updates: [pm-52eh](../.agents/pm/features/pm-52eh.toon), [pm-mcxr](../.agents/pm/issues/pm-mcxr.toon), [pm-qd3woa](../.agents/pm/issues/pm-qd3woa.toon), [pm-ypuc39](../.agents/pm/issues/pm-ypuc39.toon), [pm-tz2ikr](../.agents/pm/issues/pm-tz2ikr.toon), the schema-migration recovery contract [pm-s79kel](../.agents/pm/issues/pm-s79kel.toon), the lossless mutation contracts [pm-x3dq0l](../.agents/pm/issues/pm-x3dq0l.toon), [pm-lppm6y](../.agents/pm/issues/pm-lppm6y.toon), and [pm-embm6t](../.agents/pm/issues/pm-embm6t.toon), and the SDK-first agent grammar tranche [pm-p316vn](../.agents/pm/issues/pm-p316vn.toon), [pm-st7wgu](../.agents/pm/issues/pm-st7wgu.toon), [pm-mkinft](../.agents/pm/issues/pm-mkinft.toon), [pm-ulqu](../.agents/pm/issues/pm-ulqu.toon), [pm-qmjx](../.agents/pm/issues/pm-qmjx.toon), [pm-4bzq](../.agents/pm/features/pm-4bzq.toon), [pm-x2vx](../.agents/pm/issues/pm-x2vx.toon), and [pm-g543](../.agents/pm/issues/pm-g543.toon).
6
6
 
7
7
  ```bash
8
8
  pm <command> --help
@@ -358,7 +358,9 @@ pm close-many --rollback close-many-20260604-abc123 # restore the batch
358
358
 
359
359
  `close-many` skips already-terminal matches by default (pass `--force` to re-close), accepts `--completed-at <timestamp>` to preserve one shared actual-completion time across the batch, reports a per-item plan (`close`/`skip`, plus `active_child_ids` for parents that would be orphaned) under `--dry-run`, and writes a checkpoint by default (`--no-checkpoint` to disable). Checkpoints for both commands live under `.agents/pm/checkpoints/<command>/` and are restored with `--rollback <checkpoint-id>`.
360
360
 
361
- When a flag is rejected with `Unknown option`, the error guidance now suggests the nearest supported flag (including abbreviations like `--desc` → `--description`) and notes when the flag is valid on a different command (for example `--type` on `test-all` points to `create`/`list`).
361
+ When a flag is rejected with `Unknown option`, the error guidance now suggests the nearest supported flag (including abbreviations like `--desc` → `--description`) and notes when the flag is valid on a different command (for example `--type` on `test-all` points to `create`/`list`). Unknown-command guidance ranks agent verb synonyms first, bounded edit distance second, and substring matches last; `pm log` therefore points to `history`, `comments`, and `notes`, never a `catalog` command.
362
+
363
+ Commands addressed to one item retain their canonical positional form and also accept `--id <item-id>` consistently. For example, `pm get --id pm-a1`, `pm comments --id pm-a1 --add "..."`, and `pm test --id pm-a1 --run` are equivalent to their positional forms. Supplying both forms is a usage error. Command-scoped `pm contracts --flags-only`, completion, and help expose the same alias.
362
364
 
363
365
  ## Create and Update
364
366
 
@@ -379,6 +381,7 @@ pm create "Fix login bug" --type Issue --priority high
379
381
  `pm create` defaults `--type` to `settings.governance.create_default_type` (falling back to `Task`).
380
382
  Set it with `pm config project set governance-create-default-type <Type>` (must resolve to a known item type).
381
383
  Pass `--create-mode strict` to require an explicit `--type` flag for governance-controlled flows.
384
+ Type-aware help reports requirements for the selected mode and lists stricter requirements separately. A strict required repeatable collection can be deliberately empty: for example, `--clear-deps` satisfies a required dependency consideration while writing no relationship edge and recording `explicit_unset=dependencies` in history. Required runtime-schema fields are named with their metadata key and expected input format in structured recovery.
382
385
  `pm update --status` can be constrained per item type via `schema.type_workflows` plus
383
386
  `pm config project set governance-workflow-enforcement <off|warn|strict>` (see CONFIGURATION.md → Per-Type Workflows).
384
387
  Priority accepts either `0..4` or the equivalent names `critical`, `high`, `medium`, `low`, and `minimal`.
@@ -450,7 +453,7 @@ pm update pm-abc1 --remove-tags stale # drops "stale", keeps the rest
450
453
  pm create "New backend task" --add-tags backend,p1
451
454
  ```
452
455
 
453
- Acceptance criteria get the same additive treatment on `update`/`update-many`: `--acceptance-criteria`/`--ac` REPLACES the whole value, while `--add-ac <text>` appends one criterion (repeatable; deduped on exact text) and `--remove-ac <text>` removes one criterion by exact text match (repeatable; a non-matching selector adds a `remove_ac_unmatched:<text>` warning instead of silently no-oping). Criteria are stored with semicolon-space separators, so one criterion cannot contain a semicolon. Disjoint `--add-ac` edits from concurrent agents/branches merge cleanly instead of clobbering each other.
456
+ Acceptance criteria get the same additive treatment on `update`/`update-many`: `--acceptance-criteria`/`--ac` explicitly REPLACES the whole value and returns an `acceptance_criteria_replaced:<before-count>:<after-count>` warning when it changes existing criteria. `--add-ac <text>` appends one criterion (repeatable; deduped on exact text), while `--remove-ac <text>` removes one criterion by exact text match. Every requested removal must match: otherwise the mutation fails atomically with `acceptance_criteria_remove_unmatched` and reports the unmatched selectors, without applying valid removals or additions. Whole-value replacement cannot be combined with additive flags in one mutation. Criteria are stored with semicolon-space separators, so one criterion cannot contain a semicolon. Disjoint `--add-ac` edits from concurrent agents/branches merge cleanly instead of clobbering each other.
454
457
 
455
458
  ```bash
456
459
  pm update pm-abc1 --add-ac "error path covered by a regression test"
@@ -489,7 +492,7 @@ pm update <id> \
489
492
  pm update <id> --expected "Retry succeeds after backoff" --actual "Retry threw on first attempt"
490
493
  ```
491
494
 
492
- Repeat `--ac`/`--acceptance-criteria` to build multi-part criteria; values are stored in order joined by `; `. Dependency inputs accept either a bare existing item id or the explicit `id=<id>,kind=<kind>` form, and malformed shorthand such as `related:pm-abcd` fails before it can create a dangling graph edge.
495
+ Repeat `--ac`/`--acceptance-criteria` to build multi-part criteria; values are stored in order joined by `; `. Dependency inputs accept either a bare existing item id or the explicit `id=<id>,kind=<kind>` form, and malformed shorthand such as `related:pm-abcd` fails before it can create a dangling graph edge. New local dependency targets must already exist. Cross-workspace targets must declare `source_kind=external` (canonicalized to `global`); deliberately staged local edges require `--allow-unresolved-deps` and return one structured `dependency_target_unresolved:<id>` warning per missing target. The same validation runs during `update-many --dry-run`, so preview and apply cannot disagree.
493
496
 
494
497
  Mutation commands (`create`/`update`/`close`/`append`/...) default to an
495
498
  agent-efficient `id`/`status`/`changed_field_count` envelope. Use
@@ -747,7 +750,7 @@ pm test <id> --run --only-last
747
750
  pm test-all --status in_progress --progress
748
751
  ```
749
752
 
750
- Linked test commands should be sandbox-safe. Prefer `node scripts/run-tests.mjs ...` for repo-local test suites; normal package-manager scripts such as `pnpm test` and `npm run test` are accepted because linked-test execution injects temporary `PM_PATH` and `PM_GLOBAL_PATH`. Direct runner binaries such as `vitest` or `node --test` still need the wrapper or explicit inline sandbox env. The two-token form `--add command "npm test -- parser"` (and `--add path "..."` / `--remove command "..."`) is accepted when the value is quoted into a single shell argument; it is normalized to `--add command=...` before parsing. Use `--add-json` when command strings contain commas, nested quotes, shell variables, or `--` separators that are awkward to preserve through CSV-style `--add` parsing. `--match`, `--only-index`, and `--only-last` select which linked tests execute without mutating the stored linked-test list.
753
+ Linked test commands should be sandbox-safe. Prefer `node scripts/run-tests.mjs ...` for repo-local test suites; normal package-manager scripts such as `pnpm test` and `npm run test` are accepted because linked-test execution injects temporary `PM_PATH` and `PM_GLOBAL_PATH`. Direct runner binaries such as `vitest` or `node --test` still need the wrapper or explicit inline sandbox env. The two-token form `--add command "npm test -- parser"` (and `--add path "..."` / `--remove command "..."`) is accepted when the value is quoted into a single shell argument; it is normalized to `--add command=...` before parsing. Use `--add-json` when command strings contain commas, nested quotes, shell variables, or `--` separators that are awkward to preserve through CSV-style `--add` parsing. Linked tests retain append order; consequently `--only-last` always selects the most recently added stored test. `--match`, `--only-index`, and `--only-last` select which linked tests execute without mutating the stored linked-test list.
751
754
 
752
755
  Strict linked-test guards:
753
756
 
@@ -65,11 +65,13 @@ When both sides change the same item scalar differently, the driver writes the s
65
65
 
66
66
  The driver result's `guidance` always points unresolved conflicts to `pm merge report`. When a clone-local receipt exists, guidance includes its privacy-safe receipt and item ids for exact correlation; discarded values remain confined to the local receipt and never appear in generic logs or tracker history. Tracked by [pm-fbrz7p](../.agents/pm/issues/pm-fbrz7p.toon).
67
67
 
68
- For item conflicts, the driver also writes a clone-local receipt below the Git
69
- directory. It contains retained and discarded values so recovery does not
70
- depend on a reflog. Raw values never enter public tracker history:
71
- reconciliation records field names and value hashes, while the explicit local
72
- report is the only command that shows recoverable values:
68
+ For item conflicts, the driver writes a clone-local receipt below the Git
69
+ directory and a durable privacy-safe sidecar below `merge-receipts/` in the
70
+ tracker. The local receipt contains retained and discarded values so recovery
71
+ does not depend on a reflog. The tracked sidecar contains only field names and
72
+ value hashes, so fresh clones and CI can still fail closed on an unreviewed
73
+ decision without publishing either value. When both copies exist the SDK
74
+ deduplicates them and prefers the locally recoverable copy:
73
75
 
74
76
  ```bash
75
77
  pm merge report
package/docs/README.md CHANGED
@@ -46,17 +46,15 @@ pm guide release --json
46
46
  - [Context Relevance and Packing](CONTEXT_RELEVANCE.md) - shared CLI/SDK signals, derived-store provenance, ranking explanations, and token budgets.
47
47
  - [Output Projection and Omission Contracts](OUTPUT_PROJECTION_CONTRACTS.md) - explicit withheld-field receipts, mode-paired row keys, and completion resolver outcomes.
48
48
  - [Output Token Accounting](OUTPUT_TOKEN_ACCOUNTING.md) - opt-in CLI/MCP byte attribution, bounded receipt overhead, and release-level tokens-per-task baselines.
49
- - [SDK Context Truth Contracts](SDK_CONTEXT_TRUTH_CONTRACTS.md) - typed tracker-root diagnostics and explicit merge-driver enforcement policy.
49
+ - [SDK Context Platform](SDK_CONTEXT.md) - task-oriented entry point for authoritative reads, ranking, package workflows, diagnostics, recovery, and verification.
50
50
  - [Self-Describing Context Contracts](SELF_DESCRIBING_CONTEXT_CONTRACTS.md) - intent-scoped reads, semantic flag invocation metadata, visibility parity, and generated error vocabulary.
51
51
  - [Universal Read Output Contracts](READ_OUTPUT_CONTRACTS.md) - cross-command include, amount, cost, and encoding controls for CLI, SDK, MCP, and packages.
52
52
  - [Mutation Integrity](MUTATION_INTEGRITY.md) - shared CLI/SDK/MCP author, secret, append-only disposition, and stale-work guardrails.
53
53
  - [Agent Provenance ADR Amendment](AGENT_PROVENANCE_ADR.md) - extensible model, effort, role, and host provenance with privacy and compatibility boundaries.
54
54
  - [SDK Agent Session and Episode Context](SDK_AGENT_SESSION_CONTEXT.md) - inherited role/topic context, cross-process episode identity, and deterministic history grouping.
55
- - [SDK Context Coordination](SDK_CONTEXT_COORDINATION.md) - durable mutation events, bounded duplicate governance, and scale-safe package primitives.
56
55
  - [Improvement Ledger and History Analytics](IMPROVEMENT_ANALYTICS.md) - audited quantitative observations, live provenance coverage, and bounded observational fleet outcomes.
56
+ - [Project Assurance Primitives](ASSURANCE.md) - SDK-owned measurements, assertions, lifecycle gates, cost receipts, and durable verdict history shared by CLI and MCP.
57
57
  - [SDK Evidence Traceability and Integrity](SDK_EVIDENCE_TRACEABILITY.md) - reverse source-to-item lookup, atomic evidence replacement, no-op history, linked-test collision classification, and telemetry drain receipts.
58
- - [SDK Context Integrity Primitives](SDK_CONTEXT_INTEGRITY_PRIMITIVES.md) - batch duplicate discovery, structured errors, Plan evidence/lifecycle, sparse settings, tombstones, linked-test output, relocation diagnostics, and scoped output services.
59
- - [SDK Context Integrity](SDK_CONTEXT_INTEGRITY.md) - truthful `get` projections, bounded annotation mutations, shared author coordinates, health provider boundaries, and changeset-aware replication gates.
60
58
  - [Reproducible Workspaces and Snapshots](REPRODUCIBLE_WORKSPACES.md) - deterministic SDK recipes and content-addressed authoritative tracker restore points.
61
59
  - [Portable Corpus Shapes](CORPUS_SHAPES.md) - versioned SDK populations for realistic benchmarks, evaluations, and package tests.
62
60
  - [Agent UX Contracts](AGENT_UX_CONTRACTS.md) - ordering-cycle advisories, graph count units, collision safety, compact context, ownership wording, and recovery behavior.
@@ -80,7 +78,7 @@ pm guide release --json
80
78
  | `quickstart` | [Quickstart](QUICKSTART.md), [Command Reference](COMMANDS.md) |
81
79
  | `commands` | [Command Reference](COMMANDS.md), [Configuration](CONFIGURATION.md) |
82
80
  | `workflows` | [Agent Guide](AGENT_GUIDE.md), [Testing](TESTING.md) |
83
- | `sdk` | [SDK](SDK.md), [Architecture](ARCHITECTURE.md) |
81
+ | `sdk` | [SDK](SDK.md), [SDK context contracts](SDK_CONTEXT.md), [Architecture](ARCHITECTURE.md) |
84
82
  | `extensions`, `packages` | [Packages and Extensions](EXTENSIONS.md), [starter extension](examples/starter-extension/README.md) |
85
83
  | `skills` | [Agent Guide](AGENT_GUIDE.md) plus `.agents/skills/*` |
86
84
  | `harnesses` | [Agent Guide](AGENT_GUIDE.md) plus `.agents/skills/HARNESS_COMPATIBILITY.md` |
@@ -60,8 +60,8 @@ also fixes the expected unique-fact shape:
60
60
 
61
61
  | Tracker tier | Group spend / budget | Seen items | Suppressed repeats | Delivered bytes |
62
62
  | ------------ | -------------------- | ---------- | ------------------ | --------------- |
63
- | 2 items | 3,663 / 20,000 | 2 | 3 | 14,646 |
64
- | 2,243 items | 9,999 / 20,000 | 106 | 7 | 39,985 |
63
+ | 2 items | 3,820 / 20,000 | 2 | 3 | 15,274 |
64
+ | 2,243 items | 10,156 / 20,000 | 106 | 7 | 40,614 |
65
65
 
66
66
  These are deterministic synthetic-corpus measurements from
67
67
  `scripts/release/context-intent-calibration.json`; they contain no hosted
package/docs/RELEASING.md CHANGED
@@ -106,7 +106,7 @@ The pipeline performs:
106
106
  1. change detection + one-release-per-day guard
107
107
  2. a single `YYYY.M.D` version bump; ordinal targets and the removed
108
108
  `--allow-same-day-release` override fail closed
109
- 3. latest `pm-changelog` install and main changelog refresh through package-owned full-history generation; the release pipeline passes `--release-version` with `--all-release-tags` so the pending release section matches post-tag CI checks
109
+ 3. latest `pm-changelog` install and main changelog refresh through package-owned full-history generation; the release pipeline passes `--release-version`, `--all-release-tags`, and the canonical `--exclude-tag changelog-exclude` policy so the pending release section matches post-tag CI checks
110
110
  4. build, clone-local merge-driver installation, then the remaining strict gates (typecheck, docs/skills freshness, coverage, static quality, compatibility, security, smoke checks, reliability gate); this ordering makes the checkout-owned CLI available before bootstrap, matches CI, and prevents fresh-clone tracker measurements from observing undeclared merge-driver repairs
111
111
  5. release note generation from changelog + pm evidence
112
112
  6. commit and tag creation (plus optional push)
@@ -265,7 +265,10 @@ git push origin v<version>
265
265
  - build, clone-local merge-driver installation, typecheck, test, and coverage
266
266
  - generated changelog verification and `pm-changelog` installation before the
267
267
  tracker-bearing static gate, so a clean checkout does not misclassify the
268
- managed extension's linked files as missing
268
+ managed extension's linked files as missing. Recovery of an unpublished
269
+ immutable tag regenerates only `CHANGELOG.md` with the tagged checkout's
270
+ canonical package script and fails if that operation changes any other
271
+ tracked source path (apart from managed-extension install metadata).
269
272
  - static quality gate (shared complexity, duplication, dead/orphan module, file/folder hygiene, source/exported docstring coverage profile)
270
273
  - temporary-project compatibility gate against latest published tracker data
271
274
  - reliability threshold gate (Sentry severity threshold, bounded to a recent-activity window via `--sentry-window-days` (default `14`, `0` = unbounded) so a stale benign unresolved issue cannot block every scheduled release; `--telemetry-mode` gate policy: `off` | `best-effort` | `required`). Scheduled `auto-release.yml` failures open/update an `Auto Release blocked` GitHub issue so blocked daily releases are never silently skipped.
@@ -350,9 +353,10 @@ Use the npm registry package for maintainer global updates. Do not use `npm inst
350
353
  existing version keeps the reviewed dispatch-time `main` source and cannot
351
354
  be republished. A definitive missing-version response pins the checkout to
352
355
  the existing immutable tag, reapplies the version guard, installs the managed
353
- changelog extension before tracker measurement, and permits first publication
354
- only from that exact tagged source. Other registry failures stop before
355
- source selection or publication.
356
+ changelog extension, regenerates the package changelog with the tagged
357
+ checkout's canonical policy under a tracked-path mutation guard, and permits
358
+ first publication only from that tagged source. Other registry failures stop
359
+ before source selection or publication.
356
360
  - If an immutable published package contains a defect that cannot be repaired
357
361
  by rerunning the same tag workflow, document the incident and ship the code
358
362
  fix in the next UTC day's release.
package/docs/SDK.md CHANGED
@@ -35,6 +35,14 @@ ownership are tracked by [pm-ig5cfe](../.agents/pm/issues/pm-ig5cfe.toon),
35
35
  [pm-495lkc](../.agents/pm/issues/pm-495lkc.toon), and
36
36
  [pm-miy5k6](../.agents/pm/issues/pm-miy5k6.toon).
37
37
 
38
+ Shared item addressing, lossless recovery, explicit-empty create policy,
39
+ semantic command discovery, and append-stable linked tests are tracked by
40
+ [pm-mkinft](../.agents/pm/issues/pm-mkinft.toon),
41
+ [pm-p316vn](../.agents/pm/issues/pm-p316vn.toon),
42
+ [pm-st7wgu](../.agents/pm/issues/pm-st7wgu.toon),
43
+ [pm-g543](../.agents/pm/issues/pm-g543.toon), and
44
+ [pm-x2vx](../.agents/pm/issues/pm-x2vx.toon).
45
+
38
46
  Use it for extension authoring, package authoring, command/action contract discovery, and deterministic app or CI automation. Do not import private `src/core/...` modules from external integrations or packages.
39
47
 
40
48
  ## Install
@@ -309,6 +317,8 @@ Command/action contract exports:
309
317
  - Execution and diagnostics engines: `runTest`, `runLinkedTests`, `runTestAll`, `runStartBackgroundRun`, `runTestRunsList`, `runTestRunsStatus`, `runTestRunsLogs`, `runTestRunsStop`, `runTestRunsResume`, `runTestRunsWorker`, `runEval`, `runTelemetry`, and `runStats`. Their CLI modules are compatibility re-exports of SDK-owned implementations.
310
318
  - Execution and diagnostics contracts: `TestCommandOptions` / `TestResult` / `TestRunResult`, `TestAllCommandOptions` / `TestAllResult`, `StartBackgroundRunCommandOptions` / `StartBackgroundRunResult`, `TestRuns*CommandOptions`, `EvalOptions` / `EvalResult`, `TelemetryCommandOptions` / `TelemetrySubcommand`, and `StatsCommandOptions` / `StatsResult`.
311
319
  - Linked-test authoring primitives: `parseLinkedTestJsonEntries`, the `parseLinkedTest*` field parsers, `LINKED_TEST_PM_CONTEXT_MODE_VALUES`, `LINKED_TEST_PROTECTED_ENV_KEYS`, `classifyLinkedTestFailure`, `countFailureCategories`, and `summarizeContextPreflight` let custom hosts validate, execute, classify, and report linked tests without duplicating CLI policy.
320
+ - Agent command primitives: `normalizeItemAddressInvocation` and `supportsItemIdAlias` project one item-id grammar across CLI adapters; `renderMissingOptionRetry` and `resolveMissingOptionPlaceholder` preserve attempted argv while deriving enum, boolean, and scalar recovery arity from flag contracts; `createUnknownSubcommandError` provides one typed positional refusal with complete allowed values and deterministic nearest retry; `rankCommandPaths` and `scoreCommandPathMatch` provide deterministic synonym/edit-distance/substring ranking; `resolveCreateExplicitEmptyFlag` and `supportsCreateExplicitEmpty` model a considered-but-empty strict repeatable input without inventing metadata or graph edges.
321
+ - Refusal reachability primitives: generated `PmErrorCodeContract.owned_states` declarations bind stable codes to concrete states, probe ids, entrypoints, and exit classes; `verifyPmRefusalReachability` compares those declarations with real CLI, SDK, MCP, or package observations and fails closed for missing, duplicate, wrong-entrypoint, mismatched, or undeclared probes.
312
322
  - Typed plan workflow primitives on `PmClient`: `plan`, `planCreate`, `planShow`, `planAddStep`, `planUpdateStep`, `planCompleteStep`, `planBlockStep`, `planReorderStep`, `planRemoveStep`, `planLink`, `planUnlink`, `planDecision`, `planDiscovery`, `planValidation`, `planResume`, `planApprove`, and `planMaterialize`
313
323
  - Plan contracts: `PlanSubcommand`, `PlanCommandOptions`, `PlanCommandResult`, `PlanResultPlan`, `PlanStepSummary`, `PlanShowDepth`, and `PlanTemplateName`
314
324
  - Typed package and extension lifecycle primitives on `PmClient`: `extension`, `extensionList`, `extensionActivate`, `extensionDeactivate`, `package`, `packageList`, `packageInstall`, `packageUninstall`, `packageDoctor`, `packageManage`, `packageDescribe`, `packageReload`, `packageCatalog`, `packageActivate`, `packageDeactivate`, `packageMigrate`, and `upgrade`; one-shot `extensionMigrate` and `packageMigrate` helpers mirror those lifecycle actions.
@@ -1272,11 +1282,21 @@ const result = await commitItemMutations({
1272
1282
  `commitWorkspaceTransaction` remains the escape hatch for arbitrary domains
1273
1283
  (relationship events, foreign stores, mixed-step plans); `commitItemMutations`
1274
1284
  covers the item-mutation 90% case with correct-by-construction wiring.
1275
- Update mutation options use the same acceptance-criteria representation as the
1276
- CLI: criteria are stored in one string with semicolons as boundaries. Therefore
1277
- each `addAc`/`removeAc` entry must be semicolon-free; unmatched removals are
1278
- reported as `remove_ac_unmatched:<text>` warnings rather than disappearing as
1279
- silent no-ops.
1285
+ Update mutation options use the same lossless acceptance-criteria contract as
1286
+ the CLI: criteria are stored in one string with semicolons as boundaries, so
1287
+ each `addAc`/`removeAc` entry must be semicolon-free. Every removal must match or
1288
+ the complete mutation rejects with `acceptance_criteria_remove_unmatched` and
1289
+ structured `unmatched` recovery data. Whole-value `acceptanceCriteria`
1290
+ replacement is mutually exclusive with additive edits and returns an
1291
+ `acceptance_criteria_replaced:<before-count>:<after-count>` warning when it
1292
+ changes existing criteria.
1293
+
1294
+ Create and update mutation options also resolve every newly supplied local
1295
+ dependency target before persistence. Use `source_kind: "external"` for a
1296
+ cross-workspace endpoint. A staged local import must opt in with
1297
+ `allowUnresolvedDeps: true`; successful results then retain one
1298
+ `dependency_target_unresolved:<id>` warning per missing target. Bulk dry-runs
1299
+ perform the identical validation before producing a plan.
1280
1300
 
1281
1301
  `parseItemMutationBatch` is the strict legacy JSON boundary for that primitive. It
1282
1302
  accepts either a non-empty mutation array or `{ "mutations": [...] }`, derives
@@ -3255,12 +3275,28 @@ For SDK and automation consumers, the key runtime change is the optional `recove
3255
3275
  - `normalized_args`
3256
3276
  - `provided_fields`
3257
3277
  - `missing`
3278
+ - `allowed_values`
3279
+ - `candidate_commands`
3280
+ - `candidate_commands_total`
3281
+ - `candidate_commands_truncated`
3258
3282
  - `suggested_retry`
3259
3283
 
3260
3284
  Treat `recovery.suggested_retry` as the first-choice deterministic replay
3261
- command when present. It is emitted only from structured recovery metadata or
3262
- flags declared on the invoked command; prose that merely mentions another flag
3263
- is not interpreted as a missing input.
3285
+ command when present. Generic missing-option retries preserve every original
3286
+ argv token, insert only absent real flags before the first `--` argument
3287
+ terminator while leaving that terminator in place, and derive placeholders from
3288
+ the declared flag domain (`<off|warn|strict>` for enum values and no placeholder
3289
+ for booleans). It is emitted only from structured recovery metadata or flags
3290
+ declared on the invoked command; prose that merely mentions another flag is not
3291
+ interpreted as a missing input. Strict close validation reports missing
3292
+ resolution fields first and suggests a targeted `pm update` before retrying the
3293
+ original close invocation.
3294
+
3295
+ Unknown-option envelopes rank command paths that accept the rejected flag by
3296
+ shared vocabulary and include explicit total/truncation metadata. They are
3297
+ contract-discovery hints, not permission to change the requested operation.
3298
+ Unknown positional subcommands expose the complete `allowed_values` vocabulary
3299
+ and use `suggested_retry` only when a deterministic nearby value exists.
3264
3300
 
3265
3301
  ## Authoring Pattern
3266
3302
 
@@ -85,24 +85,53 @@ values are ignored instead of polluting analytics. Presence-only harness flags,
85
85
  including `CLAUDE_CODE_CHILD_SESSION=1`, are detection evidence and are never
86
86
  persisted as semantic roles.
87
87
 
88
- For ordinary CLI mutations, the detector can infer an `implementer` or
89
- `reviewer` role from the bounded command verb and a topic from an explicit
90
- `pm-...` item argument. Explicit overrides, session declarations, and trusted
91
- host declarations retain precedence over this inference.
88
+ ## Infer semantic context from lifecycle state
89
+
90
+ Successful `claim`, `release`, and `focus` operations maintain a bounded,
91
+ checkout-local semantic workset. Later CLI and SDK mutations can therefore
92
+ record useful role and topic provenance without repeating identity flags or
93
+ retaining prompt text:
94
+
95
+ - a claim records the item and at most 16 canonical parent ancestors, infers
96
+ `role=implementer`, and uses the item or stable multi-item workset as topic;
97
+ - an explicit focus becomes the high-confidence topic and infers
98
+ `role=planner`;
99
+ - a release removes only that claim and records `role=release-operator` while
100
+ other active claims remain; and
101
+ - clearing the final claim and focus removes the inferred session record.
102
+
103
+ At most 64 active item ids and 32 evidence rows are retained. Multi-item topics
104
+ are deterministically bounded and hashed when their full identity would exceed
105
+ the provenance limit. The state is partitioned by the privacy-safe agent
106
+ instance when available, otherwise by a truncated hash of the resolved author.
107
+ It lives in the gitignored runtime session file and malformed records fail open.
108
+
109
+ The same workset feeds `pm context` as `claim_focus` relevance: claimed and
110
+ focused items receive affinity `1`, while bounded canonical ancestors receive
111
+ `0.75`. Active work is preserved by the context packer under its existing token
112
+ ceiling; the inference never raises the requested budget.
113
+
114
+ Explicit overrides, declared session context, command flags, environment,
115
+ MCP-client declarations, host declarations, and configured probes all retain
116
+ precedence. Automatic observations use `source=inferred`, `rule_version=v2`,
117
+ and carry the bounded claim/focus/lineage evidence that supports them. The pure
118
+ `semanticAttributionAffinity()` helper and lifecycle recording primitives are
119
+ public SDK exports for custom hosts.
92
120
 
93
121
  ## Diagnose missing provenance
94
122
 
95
123
  `diagnoseAgentIdentity()` is the additive diagnostic companion to
96
124
  `detectAgentIdentity()`. It returns the same privacy-safe identity plus a
97
125
  `provenance_outcomes` row for every built-in dimension. Each row is
98
- `resolved`, `unavailable`, or `failed`, carries rule version `v1`, and may name
126
+ `resolved`, `unavailable`, `not_configured`, or `failed`, carries rule version `v1`, and may name
99
127
  the bounded built-in resolver. It never contains environment values, session
100
128
  paths, prompts, or file contents.
101
129
 
102
130
  New mutation history records failed resolver outcomes under
103
131
  `context.agent_provenance_outcomes`; ordinary unavailable dimensions retain
104
132
  the compact legacy-compatible null projection. A resolver is only counted as
105
- attempted when its required input exists. Consequently `pm health` can report
133
+ attempted when its required input belongs to the detected harness; a foreign
134
+ host's shared `AI_AGENT` value is not Codex input. Consequently `pm health` can report
106
135
  `provenance_resolver_zero_success:<harness>:<dimension>:<resolver>:<attempts>`
107
136
  without confusing an unavailable harness signal with a failed resolver. The
108
137
  warning is advisory and the storage check includes the bounded attempt and
@@ -144,6 +173,11 @@ declared a dimension but supplied no value. The compatibility helper
144
173
  `summarizeAgentModelProvenance(entries)` remains available for model-only
145
174
  consumers.
146
175
 
176
+ `evaluateSemanticAttributionCoverage(entries, options)` groups role/topic
177
+ availability by harness and precedence source. Its explicit minimum-entry and
178
+ minimum-coverage ratchet fails empty corpora, making a negative control part of
179
+ the contract instead of allowing an unobserved harness to pass vacuously.
180
+
147
181
  `groupHistoryByEpisode(entries)` returns deterministic nested groups:
148
182
 
149
183
  - recorded episode keys produce `source: "declared"`;
@@ -165,3 +199,6 @@ channel. Do not put tokens, private hostnames, signed URLs, or raw external
165
199
  payloads in ids, labels, roles, or topics. Session ids used to derive
166
200
  `agent_instance` remain transient and are not persisted. Every new history
167
201
  field is optional, so existing streams and packages remain readable.
202
+ Automatic semantic attribution is likewise restricted to item ids, controlled
203
+ roles, rule metadata, and canonical lineage ids. It never persists argv,
204
+ environment values, prompts, filesystem contents, or raw harness session ids.
@@ -0,0 +1,97 @@
1
+ # SDK context platform
2
+
3
+ Tracker: [pm-9hv1o7](../.agents/pm/issues/pm-9hv1o7.toon).
4
+
5
+ `pm` treats project management as context management. This task-oriented entry
6
+ point routes SDK hosts, package authors, CLI integrators, and agents to the
7
+ smallest authoritative context primitive.
8
+
9
+ ## Choose the smallest authoritative read
10
+
11
+ - Use `PmClient.context()` for ranked working context and bounded workspace memory.
12
+ - Use `PmClient.listAllItemMetadataLight()` or
13
+ `listAllItemMetadataLight(pmRoot)` for whole-project scalar metadata without
14
+ bodies or heavy annotation/evidence collections.
15
+ - Use `PmClient.get(id, { depth: "deep" })` when one item needs its complete
16
+ collections. Shallower reads carry an omission receipt naming every withheld
17
+ group and the exact `--fields` restoration.
18
+ - Use mutation events for changes since a cursor instead of repeatedly loading
19
+ a full workspace.
20
+
21
+ The root package, `sdk/runtime`, and `PmClient` expose the lightweight reader.
22
+ It distinguishes an empty tracker from a missing or invalid root and preserves
23
+ custom item-type folders from workspace settings.
24
+
25
+ ## Rank and pack context
26
+
27
+ Context ranking combines recency, activity, graph proximity, priority, risk,
28
+ knowledge density, structural fit, and caller affinity. Derived signal snapshots
29
+ are rebuildable; item documents and history remain authoritative. Invalid,
30
+ stale, or unwritable snapshots return a stable warning, its meaning, an
31
+ executable recovery command, and the expected effect. Re-running `pm context`
32
+ confirms a successful rebuild as fresh.
33
+
34
+ See [Context relevance and packing](CONTEXT_RELEVANCE.md) for signal and token
35
+ budgets, and [context coordination](SDK_CONTEXT_COORDINATION.md) for cursored
36
+ events and duplicate governance.
37
+
38
+ ## Preserve truth at boundaries
39
+
40
+ Bounded reads disclose omissions. Bounded annotation mutations return the
41
+ changed entry instead of replaying complete history. Unknown-author findings
42
+ route directly to append-only attribution. Diagnostics remain read-only unless
43
+ a mutation is explicitly selected.
44
+
45
+ See [context integrity](SDK_CONTEXT_INTEGRITY.md) for output selectors,
46
+ annotation receipts, attribution coordinates, provider boundaries, and
47
+ replication enforcement; see [truth contracts](SDK_CONTEXT_TRUTH_CONTRACTS.md)
48
+ for tracker-root and merge-driver distinctions.
49
+
50
+ ## Build package workflows
51
+
52
+ Use the root SDK for application workflows and `sdk/runtime` for dependency-light
53
+ host primitives. Runtime contracts are authoritative for active flags and
54
+ package-contributed commands:
55
+
56
+ ```bash
57
+ pm <command> --help --json
58
+ pm contracts --command <command> --flags-only --json
59
+ pm contracts --runtime-only --json
60
+ ```
61
+
62
+ Use `findSimilarItems` for one proposal, `findDuplicateClusters` for a bounded
63
+ whole-tracker sweep, and `prepareSimilarityText` with
64
+ `scorePreparedItemSimilarity` for custom pipelines. All paths share one
65
+ canonical Jaccard implementation and one canonical status-token normalizer.
66
+
67
+ See [context integrity primitives](SDK_CONTEXT_INTEGRITY_PRIMITIVES.md) for
68
+ duplicate batches, structured errors, Plan evidence, tombstones, linked-test
69
+ output, and extension output ownership.
70
+
71
+ ## Validate and recover
72
+
73
+ Fast health projections use light metadata. Validation materializes collections
74
+ needed by evidence and relationship checks, but loads bodies only for strict
75
+ history-drift verification. Unknown-author remediation is shared:
76
+
77
+ ```bash
78
+ pm health --verbose-author-events --json
79
+ pm history-author-acknowledge --all-actionable \
80
+ --attributed-author "<principal>" \
81
+ --reviewer "<reviewer>" \
82
+ --reason "<evidence>"
83
+ ```
84
+
85
+ Run repository gates after public SDK changes:
86
+
87
+ ```bash
88
+ pnpm build
89
+ pnpm typecheck
90
+ pnpm quality:surface-replication
91
+ pnpm sdk:surface:check
92
+ node scripts/run-tests.mjs coverage
93
+ ```
94
+
95
+ The replication gate reports an AST-derived denominator of repeated named rule
96
+ bodies and enforces a non-decreasing detector floor, so deleting declarations
97
+ cannot make recurring implementation rules disappear from governance reports.
@@ -18,6 +18,12 @@ pm get pm-a1b2 --output-include item,claim_state
18
18
 
19
19
  An unknown selector is a usage refusal that lists the valid vocabulary. Selecting the complete `item` object together with an item field is also refused because the two selectors express conflicting projection depths. Every successful projection carries an `omission_receipt` with the exact selectors needed to restore withheld item fields or sections.
20
20
 
21
+ Automatic receipts cover every heavy item collection (`comments`, `notes`,
22
+ `learnings`, `files`, `tests`, `docs`, `reminders`, and `events`) plus `body`,
23
+ `children`, `claim_state`, `linked`, and `schedule`. Empty included collections
24
+ are distinguishable from omitted collections because inclusion is derived from
25
+ property presence, not collection length.
26
+
21
27
  Standard and brief item reads expose the stable `collection_counts` selector;
22
28
  full reads retain those counts and normalize every supported collection key to
23
29
  an array. `--output-include item.collection_counts` therefore uses the same
@@ -49,7 +55,7 @@ pm history-author-acknowledge \
49
55
  --reason "Verified workspace provenance"
50
56
  ```
51
57
 
52
- The SDK exposes `resolveUnknownAuthorAcknowledgmentSelector` and `parseUnknownAuthorHistoryEventCoordinates` so packages never need a private copy of this grammar.
58
+ The SDK exposes `resolveUnknownAuthorAcknowledgmentSelector` and `parseUnknownAuthorHistoryEventCoordinates` so packages never need a private copy of this grammar. Health and validate map actionable unknown-author warnings directly to this append-only acknowledgment command instead of sending callers through another diagnostic loop.
53
59
 
54
60
  ## Health provider boundary
55
61
 
@@ -57,11 +63,18 @@ The SDK exposes `resolveUnknownAuthorAcknowledgmentSelector` and `parseUnknownAu
57
63
 
58
64
  Storage integrity is evaluated independently of that provider boundary. Lossless merge receipts remain visible as provenance, while only receipts containing discarded scalar values produce `merge_decisions_unreviewed` guidance; neither classification enables vector refresh or remote provider I/O.
59
65
 
66
+ Brief and summary check-only health projections use the scalar-only metadata
67
+ reader. Validation uses collection-bearing metadata for evidence and
68
+ relationship checks and materializes bodies only when strict history-drift
69
+ verification is requested.
70
+
60
71
  The storage check also reads at most 10,000 local immutable events for bounded
61
72
  agent-provenance resolver outcomes. This scan performs no network or provider
62
73
  I/O, tolerates malformed streams already owned by integrity diagnostics, and
63
74
  reports an advisory warning only when a resolver was actually attempted but
64
- never succeeded.
75
+ never succeeded. The same bounded pass classifies bare boolean and single-digit
76
+ values across every recorded provenance dimension, publishes only aggregate
77
+ harness/dimension/kind counts, and never echoes the historical value.
65
78
 
66
79
  ## Replication and refusal gate
67
80
 
@@ -70,7 +83,9 @@ never succeeded.
70
83
  - active set recurrence density;
71
84
  - the largest source member’s utilization of the mandatory file-size cap;
72
85
  - every remaining CLI-owned `PmCliError`, grouped by an explicit adapter-level disposition;
73
- - applied waivers, including their PM owner and expiry.
86
+ - applied waivers, including their PM owner and expiry;
87
+ - an AST-derived denominator of identical named rule bodies, declared coverage,
88
+ and a non-decreasing detected-cluster floor.
74
89
 
75
90
  Query waivers directly with:
76
91