@unbrained/pm-cli 2026.11.20 → 2026.11.22

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 (265) hide show
  1. package/.agents/skills/pm-developer/SKILL.md +1 -1
  2. package/.agents/skills/pm-sdk/SKILL.md +1 -1
  3. package/.agents/skills/pm-test-audit/SKILL.md +1 -1
  4. package/.claude-plugin/marketplace.json +1 -1
  5. package/CONTRIBUTING.md +2 -1
  6. package/dist/cli/error-guidance.js +2 -2
  7. package/dist/cli/register-history-maintenance.js +2 -2
  8. package/dist/cli/register-list-query.js +2 -2
  9. package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
  10. package/dist/cli-bundle/bundle-manifest.json +1 -1
  11. package/dist/cli-bundle/chunks/chunk-3W47ZZ5T.js +9 -0
  12. package/dist/cli-bundle/chunks/chunk-4TB5D6HL.js +125 -0
  13. package/dist/cli-bundle/chunks/{chunk-4TZW4NLM.js → chunk-5ZMVLWE3.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-6BBDEIKC.js +33 -0
  15. package/dist/cli-bundle/chunks/{chunk-GXGW6KHB.js → chunk-AR4NP5HI.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-6X2AGUOT.js → chunk-B4PPFOPY.js} +3 -3
  17. package/dist/cli-bundle/chunks/{chunk-XK25TAJZ.js → chunk-B76TFRO2.js} +47 -45
  18. package/dist/cli-bundle/chunks/chunk-CAR2L5NW.js +8 -0
  19. package/dist/cli-bundle/chunks/{chunk-KDDIHGAO.js → chunk-EIGUKEV6.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-ZAO7VGX3.js → chunk-GTPCAJMZ.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-GYP24M7W.js +2 -0
  22. package/dist/cli-bundle/chunks/{chunk-KQSPKWFH.js → chunk-HC2OPETM.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-5LF5QZT3.js → chunk-HKUV74K3.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-HXHYDO2R.js +115 -0
  25. package/dist/cli-bundle/chunks/{chunk-FF4TXJDH.js → chunk-J2LABXBL.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-3BOR22MC.js → chunk-J52BEBSS.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +3 -0
  28. package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +3 -0
  29. package/dist/cli-bundle/chunks/chunk-OJTMGDON.js +31 -0
  30. package/dist/cli-bundle/chunks/{chunk-DG2EOOFX.js → chunk-TC6XLIYO.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-MGYAJONE.js → chunk-U7EL3AYA.js} +2 -2
  32. package/dist/cli-bundle/chunks/chunk-VQFWW4EF.js +6 -0
  33. package/dist/cli-bundle/chunks/{chunk-ZVEHACE6.js → chunk-X6MIWTTT.js} +2 -2
  34. package/dist/cli-bundle/chunks/chunk-XC5Q2ZV7.js +2 -0
  35. package/dist/cli-bundle/chunks/{chunk-KEBLUTC3.js → chunk-XFHPKXAE.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-OXG5XPC7.js → chunk-YHVLVSEZ.js} +2 -2
  37. package/dist/cli-bundle/chunks/{chunk-Y4LXVPA5.js → chunk-YMUSRWV4.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-HQYIKAC6.js → chunk-YR2KEBHP.js} +2 -2
  39. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-ELEMA7IW.js → indexed-receipt-blobs-ITTXIN4K.js} +2 -2
  40. package/dist/cli-bundle/chunks/{item-revision-GE2CQECR.js → item-revision-4QBMZXKX.js} +2 -2
  41. package/dist/cli-bundle/chunks/item-transaction-QY3PUHEI.js +2 -0
  42. package/dist/cli-bundle/chunks/{mutation-actor-5GYX7LP3.js → mutation-actor-FWLYWJ37.js} +2 -2
  43. package/dist/cli-bundle/chunks/{mutation-admission-72TYKPGU.js → mutation-admission-7ZDCK3G2.js} +2 -2
  44. package/dist/cli-bundle/chunks/{register-list-query-OQZZEWEB.js → register-list-query-RR5KACJ3.js} +10 -10
  45. package/dist/cli-bundle/chunks/{register-mutation-YZEUZ6XT.js → register-mutation-57AJQWFV.js} +2 -2
  46. package/dist/cli-bundle/chunks/{register-operations-JNVCF7EW.js → register-operations-RKWST7CU.js} +2 -2
  47. package/dist/cli-bundle/chunks/{register-setup-LDKULZSD.js → register-setup-CMI23PC5.js} +2 -2
  48. package/dist/cli-bundle/chunks/{settlement-hook-E5LHZ4RD.js → settlement-hook-BXN5LEQD.js} +2 -2
  49. package/dist/cli-bundle/chunks/{stage-Q2QZ2IBG.js → stage-4KDVXC5Z.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-JUYJ7NXL.js → chunk-2ZD7275J.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-7SB6VKEI.js → chunk-324AHXJO.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-IXYBN6D2.js → chunk-3IRCYJI5.js} +3 -3
  53. package/dist/cli-bundle/focused-chunks/{chunk-DH4DHL6V.js → chunk-3V53UBHN.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/chunk-3XSWH6QC.js +91 -0
  55. package/dist/cli-bundle/focused-chunks/{chunk-V55XZFOP.js → chunk-4JZITIJB.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/chunk-4KTFKSS3.js +2 -0
  57. package/dist/cli-bundle/focused-chunks/chunk-5C5TK3ET.js +78 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-AKJYOZZP.js +2 -0
  59. package/dist/cli-bundle/focused-chunks/{chunk-BZCLW5V7.js → chunk-BRZV7BFV.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +3 -0
  61. package/dist/cli-bundle/focused-chunks/{chunk-PKMDWIP3.js → chunk-HDEKFSOK.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-O25KFLLA.js → chunk-IWOXAUDU.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-UATP3RK3.js → chunk-ML3JHCC6.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-ZKGGGU2K.js → chunk-OPGOOP25.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-PRFEOCNZ.js → chunk-RE7ZWT7D.js} +3 -3
  66. package/dist/cli-bundle/focused-chunks/chunk-RKQNVYGF.js +3 -0
  67. package/dist/cli-bundle/focused-chunks/chunk-RQ252B6V.js +8 -0
  68. package/dist/cli-bundle/focused-chunks/{chunk-KQJNJZKP.js → chunk-URGHTTT3.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/chunk-USPYKWQG.js +13 -0
  70. package/dist/cli-bundle/focused-chunks/chunk-UWS3FC4D.js +102 -0
  71. package/dist/cli-bundle/focused-chunks/chunk-UXQGFGAT.js +44 -0
  72. package/dist/cli-bundle/focused-chunks/{chunk-PQXTZLK3.js → chunk-WZWXGDYY.js} +2 -2
  73. package/dist/cli-bundle/focused-chunks/{chunk-5VSXKA35.js → chunk-YKSLZPLT.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/chunk-ZWJTY4ID.js +2 -0
  75. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-ZTRFCPH7.js → indexed-receipt-blobs-AF4U3F3D.js} +2 -2
  76. package/dist/cli-bundle/focused-chunks/{item-revision-OXDZHMJ7.js → item-revision-2O6MLPEX.js} +2 -2
  77. package/dist/cli-bundle/focused-chunks/item-transaction-GLACUTPL.js +2 -0
  78. package/dist/cli-bundle/focused-chunks/{mutation-actor-6DYIF6NH.js → mutation-actor-TCYDPUGG.js} +2 -2
  79. package/dist/cli-bundle/focused-chunks/{mutation-admission-2BYXANVJ.js → mutation-admission-LY73EJWM.js} +2 -2
  80. package/dist/cli-bundle/focused-chunks/{settlement-hook-OUBUN45C.js → settlement-hook-ARYCZQY4.js} +2 -2
  81. package/dist/cli-bundle/focused-chunks/{stage-FGHSB3QX.js → stage-DQ7RQQ52.js} +2 -2
  82. package/dist/cli-bundle/main.js +25 -25
  83. package/dist/cli-bundle/sdk-authoring.js +1 -1
  84. package/dist/cli-bundle/sdk-contracts.js +2 -2
  85. package/dist/cli-bundle/sdk-core.js +1 -1
  86. package/dist/cli-bundle/sdk-governance.js +1 -1
  87. package/dist/cli-bundle/sdk-graph.js +1 -1
  88. package/dist/cli-bundle/sdk-merge.js +70 -57
  89. package/dist/cli-bundle/sdk-query.js +1 -1
  90. package/dist/cli-bundle/sdk-runtime.js +1 -1
  91. package/dist/cli-bundle/sdk-testing.js +1 -1
  92. package/dist/cli-bundle/sdk.js +11 -11
  93. package/dist/core/diagnostics/remediation.js +1 -1
  94. package/dist/core/extensions/index.d.ts +2 -0
  95. package/dist/core/extensions/index.js +1 -1
  96. package/dist/core/fs/atomic-create.js +1 -1
  97. package/dist/core/fs/file-glob.js +1 -1
  98. package/dist/core/fs/fs-utils.d.ts +3 -1
  99. package/dist/core/fs/fs-utils.js +1 -1
  100. package/dist/core/history/bridge.js +2 -0
  101. package/dist/core/history/drift-scan.js +1 -1
  102. package/dist/core/history/history-rewrite.js +1 -1
  103. package/dist/core/history/history-stream-policy.js +1 -1
  104. package/dist/core/history/history.d.ts +12 -0
  105. package/dist/core/history/history.js +2 -2
  106. package/dist/core/history/projection.js +1 -1
  107. package/dist/core/history/read.d.ts +20 -1
  108. package/dist/core/history/read.js +1 -1
  109. package/dist/core/history/replay.d.ts +46 -5
  110. package/dist/core/history/replay.js +2 -2
  111. package/dist/core/history/stream-summary.d.ts +129 -0
  112. package/dist/core/history/stream-summary.js +3 -0
  113. package/dist/core/shared/errors.d.ts +8 -0
  114. package/dist/core/shared/errors.js +1 -1
  115. package/dist/core/shared/url-credentials.js +1 -1
  116. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  117. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  118. package/dist/sdk/cli-contracts/registration-helpers.js +2 -2
  119. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  120. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  121. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
  122. package/dist/sdk/completion/fish.js +3 -2
  123. package/dist/sdk/completion/zsh.js +3 -2
  124. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  125. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  126. package/dist/sdk/governance/gc.js +1 -1
  127. package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
  128. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  129. package/dist/sdk/governance/health.js +2 -2
  130. package/dist/sdk/governance/validate.js +1 -1
  131. package/dist/sdk/governance/workspace-position.js +1 -1
  132. package/dist/sdk/history/append-only-repair.d.ts +30 -0
  133. package/dist/sdk/history/append-only-repair.js +6 -0
  134. package/dist/sdk/history/maintenance.d.ts +8 -2
  135. package/dist/sdk/history/maintenance.js +1 -1
  136. package/dist/sdk/history/reanchor-refusal.js +2 -0
  137. package/dist/sdk/history/reseed.d.ts +15 -0
  138. package/dist/sdk/history/reseed.js +2 -0
  139. package/dist/sdk/history/salvage.d.ts +19 -8
  140. package/dist/sdk/history/salvage.js +5 -3
  141. package/dist/sdk/history-compact.js +1 -1
  142. package/dist/sdk/history-provenance.js +1 -1
  143. package/dist/sdk/history-redact.js +1 -1
  144. package/dist/sdk/history-repair.d.ts +8 -2
  145. package/dist/sdk/history-repair.js +1 -1
  146. package/dist/sdk/index.d.ts +1 -1
  147. package/dist/sdk/item-transaction.d.ts +33 -1
  148. package/dist/sdk/item-transaction.js +1 -1
  149. package/dist/sdk/lifecycle/restore.js +1 -1
  150. package/dist/sdk/merge/index.d.ts +1 -1
  151. package/dist/sdk/merge/index.js +1 -1
  152. package/dist/sdk/merge/install.d.ts +20 -6
  153. package/dist/sdk/merge/install.js +3 -3
  154. package/dist/sdk/merge/three-way.d.ts +22 -3
  155. package/dist/sdk/merge/three-way.js +8 -2
  156. package/dist/sdk/merge/worktree-config.js +2 -1
  157. package/dist/sdk/public-surface.json +1 -1
  158. package/dist/sdk/query/activity.d.ts +67 -5
  159. package/dist/sdk/query/activity.js +1 -1
  160. package/dist/sdk/query/context.d.ts +13 -3
  161. package/dist/sdk/query/context.js +2 -2
  162. package/dist/sdk/query.d.ts +1 -1
  163. package/dist/sdk/runtime/actions.js +1 -1
  164. package/dist/sdk/runtime-input.d.ts +6 -2
  165. package/dist/sdk/runtime-input.js +1 -1
  166. package/dist/sdk/runtime-primitives.d.ts +1 -1
  167. package/dist/sdk/runtime-primitives.js +1 -1
  168. package/dist/sdk/runtime.d.ts +7 -0
  169. package/dist/sdk/runtime.js +1 -1
  170. package/dist/sdk/structured-mutations.d.ts +5 -5
  171. package/dist/sdk/structured-mutations.js +1 -1
  172. package/dist/sdk/transactions/item-finalization.js +2 -0
  173. package/dist/types.d.ts +20 -0
  174. package/dist/types.js +1 -1
  175. package/docs/AGENT_GUIDE.md +1 -1
  176. package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
  177. package/docs/COMMANDS.md +62 -4
  178. package/docs/HISTORY_RECOVERY.md +229 -5
  179. package/docs/MERGE_SAFETY.md +8 -0
  180. package/docs/MUTATION_INTEGRITY.md +3 -1
  181. package/docs/README.md +8 -6
  182. package/docs/SDK.md +128 -5
  183. package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
  184. package/docs/TESTING.md +8 -697
  185. package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +1 -1
  186. package/marketplace.json +1 -1
  187. package/node_modules/tar/package.json +2 -3
  188. package/package.json +35 -3
  189. package/packages/pm-beads/package.json +1 -1
  190. package/packages/pm-calendar/package.json +1 -1
  191. package/packages/pm-command-kit/package.json +1 -1
  192. package/packages/pm-digital-twin/package.json +1 -1
  193. package/packages/pm-governance-audit/package.json +1 -1
  194. package/packages/pm-guide-shell/package.json +1 -1
  195. package/packages/pm-kanban/package.json +1 -1
  196. package/packages/pm-lifecycle-hooks/package.json +1 -1
  197. package/packages/pm-linked-test-adapters/package.json +1 -1
  198. package/packages/pm-search-advanced/package.json +1 -1
  199. package/packages/pm-templates/package.json +1 -1
  200. package/packages/pm-todos/package.json +1 -1
  201. package/packages/pm-vcs/package.json +1 -1
  202. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  203. package/plugins/pm-claude/package.json +1 -1
  204. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  205. package/plugins/pm-codex/package.json +1 -1
  206. package/plugins/pm-codex/plugin.json +1 -1
  207. package/runtime-dependencies.json +1 -1
  208. package/dist/cli-bundle/chunks/chunk-2IZGNOGT.js +0 -6
  209. package/dist/cli-bundle/chunks/chunk-4QQPM3IY.js +0 -2
  210. package/dist/cli-bundle/chunks/chunk-5OFMWP3Q.js +0 -3
  211. package/dist/cli-bundle/chunks/chunk-6HRPGEBF.js +0 -2
  212. package/dist/cli-bundle/chunks/chunk-7ESF676D.js +0 -125
  213. package/dist/cli-bundle/chunks/chunk-7EZZ4W7O.js +0 -20
  214. package/dist/cli-bundle/chunks/chunk-FOYRE23V.js +0 -115
  215. package/dist/cli-bundle/chunks/chunk-HJQ3XPS3.js +0 -31
  216. package/dist/cli-bundle/chunks/chunk-M5D3CEMY.js +0 -9
  217. package/dist/cli-bundle/chunks/chunk-VS565KBX.js +0 -2
  218. package/dist/cli-bundle/chunks/chunk-W4TLA5H3.js +0 -8
  219. package/dist/cli-bundle/chunks/item-transaction-YSAWJRA2.js +0 -2
  220. package/dist/cli-bundle/focused-chunks/chunk-3LRSQXCN.js +0 -2
  221. package/dist/cli-bundle/focused-chunks/chunk-FOA7XKWP.js +0 -2
  222. package/dist/cli-bundle/focused-chunks/chunk-FPKVHC3Q.js +0 -2
  223. package/dist/cli-bundle/focused-chunks/chunk-I7XBR2RM.js +0 -91
  224. package/dist/cli-bundle/focused-chunks/chunk-MJP3TFVW.js +0 -2
  225. package/dist/cli-bundle/focused-chunks/chunk-PZSTRYTA.js +0 -102
  226. package/dist/cli-bundle/focused-chunks/chunk-QNJQPJWO.js +0 -44
  227. package/dist/cli-bundle/focused-chunks/chunk-SIPDQBJI.js +0 -8
  228. package/dist/cli-bundle/focused-chunks/chunk-SJE3PYPI.js +0 -3
  229. package/dist/cli-bundle/focused-chunks/chunk-TNKI6WKG.js +0 -66
  230. package/dist/cli-bundle/focused-chunks/chunk-TRCXANRR.js +0 -12
  231. package/dist/cli-bundle/focused-chunks/item-transaction-54VSTT6L.js +0 -2
  232. package/dist/sdk/agent/refusal-closure.js +0 -2
  233. package/dist/sdk/agent/refusal-reachability.js +0 -4
  234. package/dist/sdk/agent/task-transcript-contracts.js +0 -2
  235. package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
  236. package/dist/sdk/authoring.js +0 -2
  237. package/dist/sdk/compose.js +0 -2
  238. package/dist/sdk/contracts.js +0 -2
  239. package/dist/sdk/core-governance.js +0 -2
  240. package/dist/sdk/core.js +0 -2
  241. package/dist/sdk/corpus-shape.js +0 -2
  242. package/dist/sdk/define.js +0 -2
  243. package/dist/sdk/environment/agent-environment.js +0 -2
  244. package/dist/sdk/governance/artifact-ledgers.js +0 -2
  245. package/dist/sdk/governance/coverage-assurance.js +0 -2
  246. package/dist/sdk/governance/reliability.js +0 -2
  247. package/dist/sdk/governance.js +0 -2
  248. package/dist/sdk/graph/adapter.js +0 -2
  249. package/dist/sdk/graph/conformance.js +0 -2
  250. package/dist/sdk/graph/index.js +0 -2
  251. package/dist/sdk/graph.js +0 -2
  252. package/dist/sdk/index.js +0 -2
  253. package/dist/sdk/query.js +0 -2
  254. package/dist/sdk/relationship-migration.js +0 -2
  255. package/dist/sdk/testing.js +0 -8
  256. package/dist/sdk/workspace-recipe.js +0 -2
  257. package/docs/AGENT_PROVENANCE_ADR.md +0 -206
  258. package/docs/DEFECT_RECURRENCE.md +0 -257
  259. package/docs/MCP_2026_07_28_CONFORMANCE.md +0 -41
  260. package/docs/PERFORMANCE.md +0 -189
  261. package/docs/QUALITY_EVIDENCE.md +0 -130
  262. package/docs/generated/FLAG_LEXICON_BUDGETS.md +0 -117
  263. package/docs/performance/cli-transport-overhead.md +0 -51
  264. package/docs/performance/runner-qualification.md +0 -36
  265. package/docs/performance/sdk-entrypoint-import-costs.md +0 -32
package/docs/SDK.md CHANGED
@@ -129,7 +129,7 @@ surface change. The bare
129
129
  `@unbrained/pm-cli` root export is recorded as an `aggregate_alias` of
130
130
  `@unbrained/pm-cli/sdk`: its symbols are not duplicated, but a retarget of its
131
131
  declaration path is a snapshot change. The committed
132
- [entrypoint import-cost table](performance/sdk-entrypoint-import-costs.md)
132
+ [entrypoint import-cost table](https://github.com/unbraind/pm-cli/blob/main/docs/performance/sdk-entrypoint-import-costs.md) (repository-only, excluded from npm)
133
133
  records fresh-process latency, RSS, and reduction versus the aggregate barrel.
134
134
  Every narrow entrypoint is bundled and type-tested independently.
135
135
 
@@ -830,6 +830,30 @@ Content fingerprints hash canonical rows incrementally, bounding additional
830
830
  serialization storage to the largest row. Digest activity also hashes its full
831
831
  source events incrementally so hidden patch changes still invalidate a cursor.
832
832
 
833
+ On a tracker with 500 or more history streams, `runActivity` parses only the
834
+ streams its window can reach, using derived per-stream bounds that are trusted
835
+ only while each stream's stat signature is unchanged; rows, totals, cursors and
836
+ errors are those of a complete read. A stream the window reaches is parsed in
837
+ full, so the cost follows the streams with entries in the window, not the
838
+ archive. A read that could not be bounded carries
839
+ `history_read: { reason, streams_read, streams_total }`, where `reason` is
840
+ `summary_missing`, `summary_invalid`, `summary_stale` or
841
+ `irregular_timestamps` (named by the larger cause, when more than half of all
842
+ streams lack usable regular bounds as the read opens, or when the read parsed
843
+ most streams and more than half of those it parsed were stale or irregular),
844
+ `read_hooks_active` (read hooks were active when the read opened, or became
845
+ active while it ran, which ends pruning), `unwindowed_query`
846
+ (no `from` bound and most streams parsed; pass one to bound the read), or
847
+ `window_reaches_most_streams` (current bounds, but the window still reached
848
+ most streams).
849
+ `readRecentActivity({ limit }, global)` returns the newest compact rows (the
850
+ first page of `raw: true`) without totals or a cursor. `limit` caps the rows
851
+ returned, not the streams parsed: with usable stream bounds and no active read
852
+ hooks it prunes streams that cannot reach those rows, while under 500 streams
853
+ or with read hooks it parses every stream. `pm context` builds its activity
854
+ section with it and reports a fallback as `activity_history_read`. Repository tracking:
855
+ [pm-gh1664](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-gh1664.toon).
856
+
833
857
  `runCalendar` uses the same `after` contract and frozen clock. `total_count`
834
858
  counts matching expanded rows within the selected window and recurrence caps;
835
859
  `count`, `page_start`, `omitted_count`, `has_more`, and `next_cursor` describe
@@ -1338,10 +1362,21 @@ the placeholder "none". Pass unset: ["parent"] to clear it, or omit parent.`;
1338
1362
  CLI refusals keep their flag wording. `PmCreateActionOptions`,
1339
1363
  `PmUpdateActionOptions`, `CreateOperationOptions` and `UpdateOperationOptions`
1340
1364
  type the clearable fields as nullable, so `runCreate`/`runUpdate` accept the
1341
- same input as `PmClient.create`/`update`. A direct SDK `runUpdateMany` folds a
1342
- null in its update record like `runUpdate`, but `runAction("update-many")` drops
1343
- it (pm-w7clh6), so `PmUpdateManyActionOptions` stays non-nullable: use `unset`
1344
- there and in MCP tools.
1365
+ same input as `PmClient.create`/`update`. `update-many` follows the same rule
1366
+ in every typed spelling (pm-w7clh6): a direct SDK `runUpdateMany`, and
1367
+ `runAction("update-many")` with flat fields or a nested `update` record, clear a
1368
+ clearable built-in field given `null` on every matched row and refuse a `null`
1369
+ on any other built-in update option by name before a row changes, so
1370
+ `PmUpdateManyActionOptions` types the clearable fields as nullable.
1371
+ `runAction("update-many")` also refuses, by name, a `null` that would otherwise
1372
+ be read as absent or stored as text: on a selection or control key (`ids`,
1373
+ `list`, `update`, `limit`, `offset`, `dryRun`, `rollback`, the checkpoint keys,
1374
+ any `filter*` key, any key of a nested `list` record), on an outer key beside a
1375
+ nested `update` record, and on a key that is no declared update option, such as
1376
+ a schema or extension field (clear those with `unset`). Those refusals belong
1377
+ to action dispatch; a direct `runUpdateMany` does not add them.
1378
+ MCP tools are unchanged: they never clear a field from a `null`, so use `unset`
1379
+ there.
1345
1380
  CLI adapters retain `--description -`, append stdin, file flags, and legacy
1346
1381
  clear-token compatibility. Values inside CLI `--stdin-json` documents are
1347
1382
  literal data, including `"none"` and `"null"`. Explicit CLI flags override
@@ -1737,6 +1772,12 @@ registries across concurrent requests, and is reentrant: SDK primitives called
1737
1772
  inside the callback reuse the active scope instead of attempting a nested
1738
1773
  activation cycle.
1739
1774
 
1775
+ `runInActiveExtensionScope(pmRoot, run)` is the reentrant form for code that
1776
+ writes through the item store without dispatching an action: it reuses the
1777
+ caller's open scope, and otherwise activates the workspace's extensions for
1778
+ that one call. The SDK's own `finalize` step uses it, so guards and extension
1779
+ fields judge the write the same way whether or not the caller opened a scope.
1780
+
1740
1781
  ```ts
1741
1782
  import {
1742
1783
  commitItemMutations,
@@ -1771,6 +1812,88 @@ const result = await commitItemMutations({
1771
1812
  `commitWorkspaceTransaction` remains the escape hatch for arbitrary domains
1772
1813
  (relationship events, foreign stores, mixed-step plans); `commitItemMutations`
1773
1814
  covers the item-mutation 90% case with correct-by-construction wiring.
1815
+
1816
+ ##### Finalization steps
1817
+
1818
+ An importer often has to write fields that `update` reserves for the lifecycle
1819
+ commands: exact source clocks (`created_at`, `closed_at`, `completed_at`), a
1820
+ terminal `status` with its `close_reason`, or extension fields. Writing them
1821
+ beside the transaction (for example from an `onTransition` observer) leaves an
1822
+ event the transaction does not own, so a later failure refuses compensation
1823
+ with `transaction_partial_mutation` and the tracker stays half-imported. A
1824
+ `finalize` row makes that write a journaled step (GH-1656):
1825
+
1826
+ ```ts
1827
+ await commitItemMutations({
1828
+ pmRoot,
1829
+ transactionId: "github-import-1042",
1830
+ author: "pm-github",
1831
+ mutations: [
1832
+ { op: "update", id: itemId, options: { title: "Fix login flow" } },
1833
+ {
1834
+ op: "finalize",
1835
+ id: itemId,
1836
+ set: {
1837
+ status: "closed",
1838
+ close_reason: "Closed on GitHub as completed",
1839
+ created_at: "2025-03-01T09:00:00.000Z",
1840
+ closed_at: "2025-03-04T16:20:00.000Z",
1841
+ github_number: 1042,
1842
+ },
1843
+ unset: ["assignee"],
1844
+ match: { key: "github_url", value: issueUrl },
1845
+ },
1846
+ ],
1847
+ });
1848
+ ```
1849
+
1850
+ - `set` writes each front-matter field as given and `unset` removes fields
1851
+ (a field the item format always stores, such as `tags`, is left empty). A
1852
+ row needs at least one of them. Values are retained in the journal, so they
1853
+ must be plain JSON data (no class instances, sparse arrays, or `__proto__`,
1854
+ `constructor` and `prototype` keys) and must not be secrets.
1855
+ - Field names are letters, digits and underscores, so an extension field keeps
1856
+ its registered spelling (`legacyId`). `id`, `updated_at`, `pm_format_version`
1857
+ and `type` are refused: the writer
1858
+ derives the first three, and `type` selects the storage location, so it
1859
+ changes through an `update` row. `null` is refused; remove a field with
1860
+ `unset`.
1861
+ - The patched document is read back through the item reader under the
1862
+ workspace schema before it is stored, and every `set` value must be stored
1863
+ in its own JSON shape, an array with every entry. A value the reader
1864
+ refuses, or one that normalization would drop, shorten or replace
1865
+ (`tags: "a"`, `tags: [1]`, duplicate tags, a blank `assignee`), or a set
1866
+ field named like a part of the item format (`front_matter`), refuses the
1867
+ step with `finalization_invalid_document` and writes nothing. `unset`
1868
+ refuses `body` and `front_matter` at admission. Other
1869
+ canonicalization (tag order, status aliases, trimmed strings) applies as it
1870
+ does for every write.
1871
+ - A finalization is a raw front-matter write. Workflow policies and
1872
+ `beforeMutation` guards judge it, with the workspace's extensions active on
1873
+ every call path, but the checks the lifecycle commands add (dependency target
1874
+ resolution, close validation, deferral rules) do not run. Use `update`,
1875
+ `close` and `release` rows for everything those commands can express.
1876
+ - A deferral that the same write resolves (`assignee` set beside a
1877
+ `deferred_fields` entry for `assignee`) is pruned by the store, so the row is
1878
+ refused as not stored as declared.
1879
+ - `match` is re-checked under the item lock and refuses with
1880
+ `upsert_match_changed` when the item no longer carries that field value.
1881
+ `force: true` overrides the assignee-ownership check, as it does for an
1882
+ update.
1883
+ - The step is compensated like an update: the journal captures the version
1884
+ before the write and a failure restores it. The ownership guard is unchanged,
1885
+ so a write by anyone else between the finalization and its compensation
1886
+ still refuses with `transaction_partial_mutation`.
1887
+ - The event is recorded under the native `import` history operation, with the
1888
+ step marker as its message and in `context.item_transaction_step`. Mutation
1889
+ guards and workflow policies judge it as an `import` operation.
1890
+ - Every finalization appends its event, even when no field changes. The event
1891
+ is what recovery reads, so a completed row is adopted and never re-evaluated
1892
+ against state a later row produced. Leave a row out of the batch when the
1893
+ plan already knows it changes nothing.
1894
+
1895
+ `finalize` is an SDK row. Structured mutation documents (`pm item mutate`, MCP
1896
+ `pm_mutate`) accept `create`, `update`, `close` and `release` only.
1774
1897
  Update mutation options use the same lossless acceptance-criteria contract as
1775
1898
  the CLI: criteria are stored in one string with semicolons as boundaries, so
1776
1899
  each `addAc`/`removeAc` entry must be semicolon-free. Every removal must match or
@@ -55,7 +55,8 @@ Use `listMutationEvents({ item: "pm-abcd", verify: true })` or
55
55
  The SDK reads authoritative bytes and verifies each complete selected stream
56
56
  before applying operation, author, timestamp, cursor, or row-limit filters.
57
57
  Selected-record failures are detected even outside the returned page. JSON
58
- parsing failures from `readHistorySnapshot` report `history_json_invalid`;
58
+ parsing failures from `readHistorySnapshot` report `history_json_invalid`, and a
59
+ line that is valid JSON but not an object reports `history_record_invalid`;
59
60
  chain-verification failures report `event_history_integrity_failed` with
60
61
  history-inspection recovery. Follow the returned typed recovery guidance. Select
61
62
  `item` to bound verification cost and exclude unrelated streams. With no item
@@ -257,7 +258,7 @@ and identifier-minified, and command-family registration loads only the create
257
258
  surface for a cold `pm create`.
258
259
 
259
260
  The fixed 10,000-item latency, RSS, correctness, and token budgets remain
260
- unchanged. See [Performance and scale](PERFORMANCE.md) for the reproducible
261
+ unchanged. See [Performance and scale](https://github.com/unbraind/pm-cli/blob/main/docs/PERFORMANCE.md) (repository-only, excluded from npm) for the reproducible
261
262
  gate; never relax a budget to accommodate a new context primitive.
262
263
 
263
264
  ## Contract discovery