@unbrained/pm-cli 2026.8.10 → 2026.8.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +153 -100
  3. package/dist/cli/commander-usage.js +113 -15
  4. package/dist/cli/error-guidance.d.ts +12 -0
  5. package/dist/cli/error-guidance.js +147 -29
  6. package/dist/cli/main.js +38 -19
  7. package/dist/cli/register-annotations.js +56 -3
  8. package/dist/cli/register-assurance.d.ts +8 -0
  9. package/dist/cli/register-assurance.js +52 -0
  10. package/dist/cli/register-files-lookup.js +14 -3
  11. package/dist/cli/register-list-query.js +10 -7
  12. package/dist/cli/register-mutation.js +30 -9
  13. package/dist/cli/register-operations.js +30 -15
  14. package/dist/cli-bundle/bundle-manifest.json +155 -155
  15. package/dist/cli-bundle/chunks/{chunk-TRWXF476.js → chunk-3PS7X6GS.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-7KL6KMWF.js +13 -0
  17. package/dist/cli-bundle/chunks/{chunk-EBO7OUUE.js → chunk-BM5YJ2UW.js} +69 -55
  18. package/dist/cli-bundle/chunks/chunk-D55A5AEN.js +33 -0
  19. package/dist/cli-bundle/chunks/chunk-KIKDWECH.js +196 -0
  20. package/dist/cli-bundle/chunks/{chunk-ETML5C6H.js → chunk-KOQMGCTA.js} +47 -47
  21. package/dist/cli-bundle/chunks/chunk-R76342NV.js +2 -0
  22. package/dist/cli-bundle/chunks/chunk-RBTK5EZV.js +5 -0
  23. package/dist/cli-bundle/chunks/chunk-VLUQOIDT.js +2 -0
  24. package/dist/cli-bundle/chunks/chunk-WLAHPSOX.js +3 -0
  25. package/dist/cli-bundle/chunks/register-list-query-XPCJRUUD.js +10 -0
  26. package/dist/cli-bundle/chunks/register-mutation-4RJCBKRS.js +20 -0
  27. package/dist/cli-bundle/chunks/register-operations-2OGISOVR.js +2 -0
  28. package/dist/cli-bundle/chunks/{register-setup-S3KT2LTH.js → register-setup-LLHAKP2V.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-2DALMVF7.js +5 -0
  30. package/dist/cli-bundle/focused-chunks/chunk-5OQIMELN.js +155 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-5TAGTDRE.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-ECADZMVC.js +18 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-EJGXRA6B.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-FFGSZCPK.js +16 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-IW43E4XL.js → chunk-GQW4BPUT.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/chunk-ISKOBJCM.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/{chunk-75774JWP.js → chunk-JAFRIWVF.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-2COZ67XT.js → chunk-KHM2CS2C.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-M6RPIXKC.js → chunk-KPSXVBDV.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-34SX654S.js → chunk-KTLOKKCQ.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-LGYK3NUF.js +8 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-2EXI2DKR.js → chunk-NBLUKITQ.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-NYLOUPOB.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-Q4T463SD.js +31 -0
  45. package/dist/cli-bundle/focused-chunks/chunk-QVZVY53N.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/{chunk-DZGAHZZV.js → chunk-RWPAWUOT.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/chunk-UTEWXDEQ.js +17 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-7UN6BHHO.js → chunk-YIAXMC3T.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-ZMGWAYH7.js +2 -0
  50. package/dist/cli-bundle/main.js +13 -13
  51. package/dist/cli-bundle/sdk-authoring.js +1 -1
  52. package/dist/cli-bundle/sdk-contracts.js +1 -1
  53. package/dist/cli-bundle/sdk-core.js +41 -39
  54. package/dist/cli-bundle/sdk-governance.js +1 -1
  55. package/dist/cli-bundle/sdk-graph.js +1 -1
  56. package/dist/cli-bundle/sdk-merge.js +1 -1
  57. package/dist/cli-bundle/sdk-query.js +1 -1
  58. package/dist/cli-bundle/sdk-runtime.js +1 -1
  59. package/dist/cli-bundle/sdk-testing.js +1 -1
  60. package/dist/cli-bundle/sdk.js +2 -2
  61. package/dist/core/extensions/reserved-host-flags.js +3 -2
  62. package/dist/core/history/drift-scan.js +13 -8
  63. package/dist/core/history/history.d.ts +8 -0
  64. package/dist/core/history/history.js +57 -7
  65. package/dist/core/history/replay.d.ts +9 -1
  66. package/dist/core/history/replay.js +48 -13
  67. package/dist/core/output/output.d.ts +2 -0
  68. package/dist/core/output/output.js +46 -14
  69. package/dist/core/session/session-state.d.ts +47 -0
  70. package/dist/core/session/session-state.js +207 -6
  71. package/dist/core/shared/author.d.ts +7 -1
  72. package/dist/core/shared/author.js +66 -46
  73. package/dist/core/shared/command-types.d.ts +2 -0
  74. package/dist/core/shared/command-types.js +2 -2
  75. package/dist/core/shared/errors.d.ts +13 -0
  76. package/dist/core/shared/errors.js +2 -2
  77. package/dist/core/store/item-metadata-cache.d.ts +1 -1
  78. package/dist/core/store/item-metadata-cache.js +14 -7
  79. package/dist/sdk/agent/refusal-reachability.d.ts +40 -0
  80. package/dist/sdk/agent/refusal-reachability.js +72 -0
  81. package/dist/sdk/agent/subcommand-recovery.d.ts +40 -0
  82. package/dist/sdk/agent/subcommand-recovery.js +84 -0
  83. package/dist/sdk/cli-bootstrap.d.ts +10 -0
  84. package/dist/sdk/cli-bootstrap.js +11 -7
  85. package/dist/sdk/cli-contracts/completeness.js +14 -3
  86. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  87. package/dist/sdk/cli-contracts/enum-contracts.js +3 -2
  88. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  89. package/dist/sdk/cli-contracts/flag-contracts.js +20 -2
  90. package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
  91. package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
  92. package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
  93. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +515 -0
  94. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +252 -0
  95. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  96. package/dist/sdk/cli-contracts/tool-parameter-tables.js +99 -2
  97. package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -3
  98. package/dist/sdk/cli-contracts/tool-schema.js +38 -5
  99. package/dist/sdk/cli-contracts.d.ts +1 -1
  100. package/dist/sdk/cli-contracts.js +3 -3
  101. package/dist/sdk/cli-program.js +3 -2
  102. package/dist/sdk/completion.js +23 -8
  103. package/dist/sdk/config.js +9 -3
  104. package/dist/sdk/context/semantic-session-attribution.d.ts +32 -0
  105. package/dist/sdk/context/semantic-session-attribution.js +83 -0
  106. package/dist/sdk/context-intent-contracts.js +45 -4
  107. package/dist/sdk/core-governance.d.ts +3 -1
  108. package/dist/sdk/core-governance.js +5 -3
  109. package/dist/sdk/core.d.ts +2 -1
  110. package/dist/sdk/core.js +3 -2
  111. package/dist/sdk/error-code-catalog.d.ts +13 -0
  112. package/dist/sdk/error-code-catalog.js +35 -2
  113. package/dist/sdk/extension.js +18 -17
  114. package/dist/sdk/files.d.ts +11 -0
  115. package/dist/sdk/files.js +82 -24
  116. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
  117. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1585 -0
  118. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
  119. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
  120. package/dist/sdk/generated-error-code-catalog.js +6 -3121
  121. package/dist/sdk/governance/assurance-action-contracts.d.ts +7 -0
  122. package/dist/sdk/governance/assurance-action-contracts.js +5 -0
  123. package/dist/sdk/governance/assurance-action.d.ts +70 -0
  124. package/dist/sdk/governance/assurance-action.js +200 -0
  125. package/dist/sdk/governance/assurance-limits.d.ts +7 -0
  126. package/dist/sdk/governance/assurance-limits.js +11 -0
  127. package/dist/sdk/governance/assurance-mutation-error.d.ts +7 -0
  128. package/dist/sdk/governance/assurance-mutation-error.js +35 -0
  129. package/dist/sdk/governance/assurance-runtime.d.ts +20 -0
  130. package/dist/sdk/governance/assurance-runtime.js +134 -0
  131. package/dist/sdk/governance/assurance.d.ts +438 -0
  132. package/dist/sdk/governance/assurance.js +804 -0
  133. package/dist/sdk/governance/health.d.ts +3 -1
  134. package/dist/sdk/governance/health.js +21 -4
  135. package/dist/sdk/governance/validate-item-reader.js +3 -3
  136. package/dist/sdk/governance/validate.d.ts +2 -0
  137. package/dist/sdk/governance/validate.js +13 -3
  138. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  139. package/dist/sdk/graph/durable-cache.js +98 -29
  140. package/dist/sdk/graph/governance.d.ts +14 -0
  141. package/dist/sdk/graph/governance.js +34 -9
  142. package/dist/sdk/graph/run.js +8 -3
  143. package/dist/sdk/index.d.ts +7 -2
  144. package/dist/sdk/index.js +9 -4
  145. package/dist/sdk/lifecycle/claim.js +26 -4
  146. package/dist/sdk/lifecycle/focus.js +13 -3
  147. package/dist/sdk/lifecycle/plan.js +8 -3
  148. package/dist/sdk/merge/driver.d.ts +2 -2
  149. package/dist/sdk/merge/driver.js +3 -3
  150. package/dist/sdk/merge/receipts.d.ts +6 -4
  151. package/dist/sdk/merge/receipts.js +7 -5
  152. package/dist/sdk/merge/three-way.d.ts +2 -2
  153. package/dist/sdk/merge/three-way.js +3 -3
  154. package/dist/sdk/output-projection.d.ts +9 -1
  155. package/dist/sdk/output-projection.js +45 -9
  156. package/dist/sdk/provenance.d.ts +38 -0
  157. package/dist/sdk/provenance.js +64 -2
  158. package/dist/sdk/query/activity.d.ts +49 -2
  159. package/dist/sdk/query/activity.js +183 -37
  160. package/dist/sdk/query/context.js +19 -8
  161. package/dist/sdk/query/get.js +19 -2
  162. package/dist/sdk/read-output-contracts.d.ts +5 -1
  163. package/dist/sdk/read-output-contracts.js +17 -2
  164. package/dist/sdk/read-output-session.d.ts +2 -0
  165. package/dist/sdk/read-output-session.js +12 -5
  166. package/dist/sdk/runtime-extended-actions.js +22 -5
  167. package/dist/sdk/runtime-primitives.d.ts +5 -3
  168. package/dist/sdk/runtime-primitives.js +7 -5
  169. package/dist/sdk/runtime-stats-options.js +3 -2
  170. package/dist/sdk/runtime.d.ts +4 -0
  171. package/dist/sdk/runtime.js +34 -34
  172. package/dist/sdk/stats.d.ts +36 -3
  173. package/dist/sdk/stats.js +55 -15
  174. package/dist/sdk/telemetry.js +7 -4
  175. package/dist/sdk/test/execution.d.ts +4 -0
  176. package/dist/sdk/test/execution.js +86 -21
  177. package/dist/sdk/traceability/runtime-files-lookup.d.ts +8 -0
  178. package/dist/sdk/traceability/runtime-files-lookup.js +33 -0
  179. package/dist/sdk/traceability/source-traceability.d.ts +102 -0
  180. package/dist/sdk/traceability/source-traceability.js +293 -0
  181. package/dist/types.d.ts +10 -2
  182. package/dist/types.js +2 -2
  183. package/docs/ASSURANCE.md +137 -0
  184. package/docs/COMMANDS.md +29 -8
  185. package/docs/CONFIGURATION.md +7 -0
  186. package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
  187. package/docs/MERGE_SAFETY.md +3 -1
  188. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
  189. package/docs/README.md +3 -0
  190. package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
  191. package/docs/RELEASING.md +9 -5
  192. package/docs/SDK.md +12 -1
  193. package/docs/SDK_AGENT_SESSION_CONTEXT.md +52 -5
  194. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
  195. package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
  196. package/docs/SDK_EVIDENCE_TRACEABILITY.md +39 -1
  197. package/docs/SDK_RUNTIME_BOUNDARIES.md +36 -1
  198. package/docs/TESTING.md +12 -9
  199. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
  200. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
  201. package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
  202. package/marketplace.json +2 -2
  203. package/package.json +7 -7
  204. package/packages/pm-beads/package.json +1 -1
  205. package/packages/pm-calendar/package.json +1 -1
  206. package/packages/pm-command-kit/package.json +1 -1
  207. package/packages/pm-digital-twin/package.json +1 -1
  208. package/packages/pm-governance-audit/package.json +1 -1
  209. package/packages/pm-guide-shell/package.json +1 -1
  210. package/packages/pm-kanban/package.json +1 -1
  211. package/packages/pm-lifecycle-hooks/package.json +1 -1
  212. package/packages/pm-linked-test-adapters/package.json +1 -1
  213. package/packages/pm-search-advanced/package.json +1 -1
  214. package/packages/pm-templates/extensions/templates/index.ts +9 -3
  215. package/packages/pm-templates/package.json +1 -1
  216. package/packages/pm-todos/package.json +1 -1
  217. package/packages/pm-vcs/package.json +1 -1
  218. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  219. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  220. package/sdk/public-surface.json +1030 -67
  221. package/dist/cli-bundle/chunks/chunk-2QYH4QMI.js +0 -30
  222. package/dist/cli-bundle/chunks/chunk-JUDU4RO4.js +0 -194
  223. package/dist/cli-bundle/chunks/chunk-JZSNADRR.js +0 -5
  224. package/dist/cli-bundle/chunks/chunk-MENWVGJW.js +0 -2
  225. package/dist/cli-bundle/chunks/chunk-S4EITGLA.js +0 -3
  226. package/dist/cli-bundle/chunks/chunk-TIGKWVLA.js +0 -13
  227. package/dist/cli-bundle/chunks/chunk-TSLDTJLQ.js +0 -2
  228. package/dist/cli-bundle/chunks/register-list-query-OJ6ZXKV4.js +0 -10
  229. package/dist/cli-bundle/chunks/register-mutation-DKI7QC7O.js +0 -20
  230. package/dist/cli-bundle/chunks/register-operations-P5OGMT6I.js +0 -2
  231. package/dist/cli-bundle/focused-chunks/chunk-36FTZ2NT.js +0 -2
  232. package/dist/cli-bundle/focused-chunks/chunk-3CQECMKR.js +0 -16
  233. package/dist/cli-bundle/focused-chunks/chunk-CHIBMEZR.js +0 -8
  234. package/dist/cli-bundle/focused-chunks/chunk-FF4MNAYB.js +0 -153
  235. package/dist/cli-bundle/focused-chunks/chunk-GHTN2ILR.js +0 -2
  236. package/dist/cli-bundle/focused-chunks/chunk-I4YM2I7S.js +0 -2
  237. package/dist/cli-bundle/focused-chunks/chunk-IMDTEN7K.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-JMVA4HKR.js +0 -5
  239. package/dist/cli-bundle/focused-chunks/chunk-KR5RVXLQ.js +0 -31
  240. package/dist/cli-bundle/focused-chunks/chunk-KSNJG4KI.js +0 -16
  241. package/dist/cli-bundle/focused-chunks/chunk-MXYSIQ56.js +0 -18
  242. package/dist/cli-bundle/focused-chunks/chunk-RIIN5V4N.js +0 -2
  243. package/dist/cli-bundle/focused-chunks/chunk-RKWSCYYN.js +0 -2
@@ -12,7 +12,10 @@ cursor-chain amortization are tracked by
12
12
  [pm-yekkvt](../.agents/pm/issues/pm-yekkvt.toon), and
13
13
  [pm-sf31yl](../.agents/pm/issues/pm-sf31yl.toon). Trustworthy collection
14
14
  selectors are tracked by
15
- [pm-x710qm](../.agents/pm/issues/pm-x710qm.toon).
15
+ [pm-x710qm](../.agents/pm/issues/pm-x710qm.toon). Default contract suppression
16
+ and canonical TOON tables are tracked by
17
+ [pm-gjjurs](../.agents/pm/issues/pm-gjjurs.toon) and
18
+ [pm-5y05kq](../.agents/pm/issues/pm-5y05kq.toon).
16
19
 
17
20
  ## Agent Quick Context
18
21
 
@@ -38,12 +41,13 @@ explicit receipt with `has_omissions: false`,
38
41
 
39
42
  Mutually exclusive output modes emit only their active row collection:
40
43
 
41
- | Command mode | Active row key | Withheld group | Restore |
42
- | --------------------------- | ------------------ | -------------- | ---------------- |
43
- | `activity --compact` | `compact_activity` | `provenance` | `--full` |
44
- | `activity --full` | `activity` | none | already complete |
45
- | `history` (compact default) | `compact_history` | `raw_history` | `--full` |
46
- | `history --full` | `history` | none | already complete |
44
+ | Command mode | Active row key | Withheld group | Restore |
45
+ | --------------------------- | --------------------- | -------------- | ---------------- |
46
+ | `activity` (digest default) | `activity_digest` | `event_rows` | `--raw` |
47
+ | `activity --raw/--compact` | `compact_activity` | `provenance` | `--full` |
48
+ | `activity --full` | `activity` | none | already complete |
49
+ | `history` (compact default) | `compact_history` | `raw_history` | `--full` |
50
+ | `history --full` | `history` | none | already complete |
47
51
 
48
52
  Inactive row keys are omitted, not zero-filled. This makes a wrong parser loud:
49
53
  reading `.activity` from compact activity now yields a missing key instead of a
@@ -57,8 +61,11 @@ integrations and built-in output cannot drift independently.
57
61
 
58
62
  ## Universal Read Rows
59
63
 
60
- Core read results expose a `row_contract` whether or not the current page has
61
- rows:
64
+ Core read results expose `row_contract` only when callers request
65
+ `--output-row-contract` / `outputRowContract: true`. Keeping discovery metadata
66
+ off by default makes ordinary reads pay for project data rather than repeating
67
+ the same selector declaration. The explicit contract remains available whether
68
+ or not the current page has rows:
62
69
 
63
70
  ```json
64
71
  {
@@ -67,7 +74,8 @@ rows:
67
74
  "row_kind": "collection",
68
75
  "row_keys": ["items"],
69
76
  "fields": "supported",
70
- "jq_selector": ".row_contract.row_keys[] as $key | getpath($key | split(\".\")) | if type == \"array\" then .[] else if type == \"object\" then to_entries[] else empty end end"
77
+ "jq_selector": ".row_contract.row_keys[] as $key | getpath($key | split(\".\")) | if type == \"array\" then .[] else if type == \"object\" then to_entries[] else empty end end",
78
+ "toon_encoding": "tabular_when_uniform"
71
79
  }
72
80
  }
73
81
  ```
@@ -80,7 +88,12 @@ collections declare every active dot-delimited path. This keeps
80
88
  nested dependency graph and relationship-context rows addressable as
81
89
  `graph.nodes`, `graph.edges`, `context.nodes`, and `context.edges` without
82
90
  duplicating them at the envelope root. Array collections produce their
83
- elements; object maps such as stats counts produce jq `to_entries` rows.
91
+ elements; object maps produce jq `to_entries` rows.
92
+ `toon_encoding: "tabular_when_uniform"` declares that an array of flat objects
93
+ with one shared key set renders as a length-marked TOON table; mixed, nested,
94
+ or heterogeneous arrays retain the expanded representation. Quoted,
95
+ separator-bearing, and multiline values use the canonical TOON encoder and
96
+ round-trip through the strict decoder.
84
97
  Commands without a row collection, including a dependency tree or leaf `get`,
85
98
  declare `row_kind: "none"`, an empty `row_keys` array, and omit `jq_selector`.
86
99
  The absence is therefore distinguishable from a legitimate empty collection.
@@ -94,8 +107,8 @@ publish a row contract.
94
107
  SDK and package authors can import `PM_READ_ROW_CONTRACTS`,
95
108
  `PM_READ_ROW_JQ_SELECTOR`, and `resolveReadRowContract` from
96
109
  `@unbrained/pm-cli/sdk`. Existing package declarations are preserved only
97
- when `command`, `row_kind`, `row_keys`, `fields`, and the conditional
98
- `jq_selector` form a structurally valid row contract; malformed declarations
110
+ when `command`, `row_kind`, `row_keys`, `fields`, the conditional
111
+ `jq_selector`, and any supplied `toon_encoding` form a structurally valid row contract; malformed declarations
99
112
  are replaced by the canonical built-in contract when one applies.
100
113
 
101
114
  ## Self-Describing SDK Projections
package/docs/README.md CHANGED
@@ -53,7 +53,10 @@ pm guide release --json
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
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
+ - [Trustworthy Context and Evidence Contracts](TRUSTWORTHY_CONTEXT_EVIDENCE.md) - full-record assurance, graph composition, boolean health rows, lossless linked-test removal, and role-labelled recovery.
56
58
  - [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.
59
+ - [SDK Context and Evidence Contracts](SDK_CONTEXT_EVIDENCE_CONTRACTS.md) - material omission receipts, scoped preflight activation, truthful merge preference, claim-race classification, and versioned history hashes.
57
60
  - [Reproducible Workspaces and Snapshots](REPRODUCIBLE_WORKSPACES.md) - deterministic SDK recipes and content-addressed authoritative tracker restore points.
58
61
  - [Portable Corpus Shapes](CORPUS_SHAPES.md) - versioned SDK populations for realistic benchmarks, evaluations, and package tests.
59
62
  - [Agent UX Contracts](AGENT_UX_CONTRACTS.md) - ordering-cycle advisories, graph count units, collision safety, compact context, ownership wording, and recovery behavior.
@@ -1,6 +1,6 @@
1
1
  # Universal Read Output Contracts
2
2
 
3
- Tracker references: [pm-hb7ug8](../.agents/pm/features/pm-hb7ug8.toon), [pm-cxr0jb](../.agents/pm/features/pm-cxr0jb.toon), [pm-hid9g1](../.agents/pm/features/pm-hid9g1.toon), and [pm-sb0tns](../.agents/pm/issues/pm-sb0tns.toon).
3
+ Tracker references: [pm-hb7ug8](../.agents/pm/features/pm-hb7ug8.toon), [pm-cxr0jb](../.agents/pm/features/pm-cxr0jb.toon), [pm-hid9g1](../.agents/pm/features/pm-hid9g1.toon), [pm-sb0tns](../.agents/pm/issues/pm-sb0tns.toon), and [pm-gjjurs](../.agents/pm/issues/pm-gjjurs.toon).
4
4
 
5
5
  ## Agent Quick Context
6
6
 
@@ -19,6 +19,10 @@ Row shaping follows each envelope's `row_contract.row_keys`, including
19
19
  dot-delimited nested arrays and object maps such as `graph.nodes`. Include,
20
20
  amount, repeat suppression, and cost compaction therefore operate on the same
21
21
  machine-declared rows; they do not rely on command-specific top-level keys.
22
+ The runtime uses that declaration internally on every read but omits the
23
+ repeated metadata from results by default. Request
24
+ `--output-row-contract` / `outputRowContract: true` when a consumer needs the
25
+ row paths, jq selector, and active TOON encoding contract.
22
26
 
23
27
  ## Cross-Call Context Sessions
24
28
 
@@ -46,6 +50,15 @@ tokens separately when the remaining group allowance is smaller than the
46
50
  minimum control envelope, plus the accumulated spend, remaining capacity,
47
51
  newly served items, and suppressed repeats.
48
52
 
53
+ The carried served-item set accepts at most 10,000 identities. A receipt always
54
+ preserves identities already present in the supplied state and retains newly
55
+ served identities in deterministic order until that capacity is full. When a
56
+ single read crosses the boundary, `seen_item_overflow_count` reports how many
57
+ new identities were not carried forward; those facts remain in the current
58
+ envelope and may be served in full again on a later read. The emitted
59
+ `next_state` therefore always remains valid input to the next call without
60
+ silently widening the safety bound.
61
+
49
62
  Session state is deliberately caller-carried: CLI processes, SDK clients, MCP
50
63
  hosts, and packages share the same deterministic primitive without a hidden
51
64
  daemon or mutable cache. Validation rejects unknown fields, invalid identifiers,
@@ -69,12 +82,13 @@ tracker content.
69
82
 
70
83
  ## Precedence and Compatibility
71
84
 
72
- Resolution is deterministic: canonical controls win over command-local compatibility options, which win over intent defaults, which win over command defaults. Existing options such as `--fields`, `--limit`, `--token-budget`, `--format`, `--brief`, and `--full` remain accepted. Contract output marks them as hidden compatibility aliases and supplies a migration hint; traversal, cursor, side-effect, and streaming controls instead receive an explicit behavior-preservation hint because a static output control cannot replace their semantics. Callers that omit the canonical controls receive the byte-identical established result.
85
+ Resolution is deterministic: canonical controls win over command-local compatibility options, which win over intent defaults, which win over command defaults. Existing options such as `--fields`, `--limit`, `--token-budget`, `--format`, `--brief`, and `--full` remain accepted. Contract output marks them as hidden compatibility aliases and supplies a migration hint; traversal, cursor, side-effect, and streaming controls instead receive an explicit behavior-preservation hint because a static output control cannot replace their semantics. Callers that omit the four shaping dimensions retain the established data projection; the one intentional envelope correction is that repeated `row_contract` metadata is now opt-in.
73
86
 
74
87
  ```bash
75
88
  pm list-open --output-include id,title,status --output-limit 10
76
89
  pm context --for orient --output-budget 900 --output-format toon
77
90
  pm search "runtime contracts" --output-limit 5 --output-format json
91
+ pm stats --output-row-contract
78
92
  pm contracts --full --json
79
93
  ```
80
94
 
@@ -93,6 +107,7 @@ const result = await pm.list({
93
107
  outputInclude: "id,title,status",
94
108
  outputLimit: 10,
95
109
  outputBudget: 800,
110
+ outputRowContract: true,
96
111
  outputSession: {
97
112
  version: 1,
98
113
  id: "orientation",
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
@@ -317,7 +317,8 @@ Command/action contract exports:
317
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.
318
318
  - Execution and diagnostics contracts: `TestCommandOptions` / `TestResult` / `TestRunResult`, `TestAllCommandOptions` / `TestAllResult`, `StartBackgroundRunCommandOptions` / `StartBackgroundRunResult`, `TestRuns*CommandOptions`, `EvalOptions` / `EvalResult`, `TelemetryCommandOptions` / `TelemetrySubcommand`, and `StatsCommandOptions` / `StatsResult`.
319
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; `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.
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.
321
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`
322
323
  - Plan contracts: `PlanSubcommand`, `PlanCommandOptions`, `PlanCommandResult`, `PlanResultPlan`, `PlanStepSummary`, `PlanShowDepth`, and `PlanTemplateName`
323
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.
@@ -3274,6 +3275,10 @@ For SDK and automation consumers, the key runtime change is the optional `recove
3274
3275
  - `normalized_args`
3275
3276
  - `provided_fields`
3276
3277
  - `missing`
3278
+ - `allowed_values`
3279
+ - `candidate_commands`
3280
+ - `candidate_commands_total`
3281
+ - `candidate_commands_truncated`
3277
3282
  - `suggested_retry`
3278
3283
 
3279
3284
  Treat `recovery.suggested_retry` as the first-choice deterministic replay
@@ -3287,6 +3292,12 @@ interpreted as a missing input. Strict close validation reports missing
3287
3292
  resolution fields first and suggests a targeted `pm update` before retrying the
3288
3293
  original close invocation.
3289
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.
3300
+
3290
3301
  ## Authoring Pattern
3291
3302
 
3292
3303
  - Keep handlers deterministic and JSON-like.
@@ -5,7 +5,8 @@ Tracker references: [pm-9wbiye](../.agents/pm/issues/pm-9wbiye.toon),
5
5
  [pm-oqo9l2](../.agents/pm/features/pm-oqo9l2.toon),
6
6
  [pm-3zgh2c](../.agents/pm/features/pm-3zgh2c.toon),
7
7
  [pm-eq9dlw](../.agents/pm/issues/pm-eq9dlw.toon), and
8
- [pm-lu6sca](../.agents/pm/features/pm-lu6sca.toon).
8
+ [pm-lu6sca](../.agents/pm/features/pm-lu6sca.toon), plus
9
+ [pm-5q8wa0](../.agents/pm/issues/pm-5q8wa0.toon).
9
10
 
10
11
  Project management is context management. The public SDK therefore carries a
11
12
  session's purpose and episode boundary through the same immutable history that
@@ -85,10 +86,38 @@ values are ignored instead of polluting analytics. Presence-only harness flags,
85
86
  including `CLAUDE_CODE_CHILD_SESSION=1`, are detection evidence and are never
86
87
  persisted as semantic roles.
87
88
 
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.
89
+ ## Infer semantic context from lifecycle state
90
+
91
+ Successful `claim`, `release`, and `focus` operations maintain a bounded,
92
+ checkout-local semantic workset. Later CLI and SDK mutations can therefore
93
+ record useful role and topic provenance without repeating identity flags or
94
+ retaining prompt text:
95
+
96
+ - a claim records the item and at most 16 canonical parent ancestors, infers
97
+ `role=implementer`, and uses the item or stable multi-item workset as topic;
98
+ - an explicit focus becomes the high-confidence topic and infers
99
+ `role=planner`;
100
+ - a release removes only that claim and records `role=release-operator` while
101
+ other active claims remain; and
102
+ - clearing the final claim and focus removes the inferred session record.
103
+
104
+ At most 64 active item ids and 32 evidence rows are retained. Multi-item topics
105
+ are deterministically bounded and hashed when their full identity would exceed
106
+ the provenance limit. The state is partitioned by the privacy-safe agent
107
+ instance when available, otherwise by a truncated hash of the resolved author.
108
+ It lives in the gitignored runtime session file and malformed records fail open.
109
+
110
+ The same workset feeds `pm context` as `claim_focus` relevance: claimed and
111
+ focused items receive affinity `1`, while bounded canonical ancestors receive
112
+ `0.75`. Active work is preserved by the context packer under its existing token
113
+ ceiling; the inference never raises the requested budget.
114
+
115
+ Explicit overrides, declared session context, command flags, environment,
116
+ MCP-client declarations, host declarations, and configured probes all retain
117
+ precedence. Automatic observations use `source=inferred`, `rule_version=v2`,
118
+ and carry the bounded claim/focus/lineage evidence that supports them. The pure
119
+ `semanticAttributionAffinity()` helper and lifecycle recording primitives are
120
+ public SDK exports for custom hosts.
92
121
 
93
122
  ## Diagnose missing provenance
94
123
 
@@ -109,6 +138,16 @@ without confusing an unavailable harness signal with a failed resolver. The
109
138
  warning is advisory and the storage check includes the bounded attempt and
110
139
  success counters for diagnosis.
111
140
 
141
+ Older immutable history can also contain roles outside the controlled domain,
142
+ including values recorded from presence-only harness flags before semantic role
143
+ validation existed. `pm health` retains the privacy-safe
144
+ `provenance_value_domain_invalid:<harness>:<dimension>:<value-shape>:<count>`
145
+ warning and its bounded storage aggregate, but treats the finding as advisory:
146
+ truthful append-only history is not rewritten merely to make health green. New
147
+ session, environment, MCP, and inferred provenance still pass through the
148
+ controlled write-time validator, so this disposition does not permit new
149
+ invalid values.
150
+
112
151
  ## Cross an MCP boundary
113
152
 
114
153
  An embedding MCP client can add bounded `provenance` and `episode` fields to
@@ -145,6 +184,11 @@ declared a dimension but supplied no value. The compatibility helper
145
184
  `summarizeAgentModelProvenance(entries)` remains available for model-only
146
185
  consumers.
147
186
 
187
+ `evaluateSemanticAttributionCoverage(entries, options)` groups role/topic
188
+ availability by harness and precedence source. Its explicit minimum-entry and
189
+ minimum-coverage ratchet fails empty corpora, making a negative control part of
190
+ the contract instead of allowing an unobserved harness to pass vacuously.
191
+
148
192
  `groupHistoryByEpisode(entries)` returns deterministic nested groups:
149
193
 
150
194
  - recorded episode keys produce `source: "declared"`;
@@ -166,3 +210,6 @@ channel. Do not put tokens, private hostnames, signed URLs, or raw external
166
210
  payloads in ids, labels, roles, or topics. Session ids used to derive
167
211
  `agent_instance` remain transient and are not persisted. Every new history
168
212
  field is optional, so existing streams and packages remain readable.
213
+ Automatic semantic attribution is likewise restricted to item ids, controlled
214
+ roles, rule metadata, and canonical lineage ids. It never persists argv,
215
+ environment values, prompts, filesystem contents, or raw harness session ids.
@@ -0,0 +1,53 @@
1
+ # SDK Context and Evidence Contracts
2
+
3
+ Tracked by [pm-gok2km](../.agents/pm/issues/pm-gok2km.toon), [pm-zryb9d](../.agents/pm/issues/pm-zryb9d.toon), [pm-qckpnq](../.agents/pm/issues/pm-qckpnq.toon), [pm-hfqju5](../.agents/pm/issues/pm-hfqju5.toon), [pm-2htk4p](../.agents/pm/issues/pm-2htk4p.toon), and [pm-v0a0un](../.agents/pm/issues/pm-v0a0un.toon).
4
+
5
+ These contracts keep SDK context truthful, bounded, and reusable across the CLI, MCP, packages, and automation. They are designed around the project principle that project management is context management: a compact response must reveal material omissions, merge evidence must describe what actually survived, and compatibility failures must not masquerade as corruption.
6
+
7
+ ## Material omission receipts
8
+
9
+ `pm get` derives omission receipts from non-serialized materiality evidence. Empty bodies and zero-cardinality collections do not consume receipt tokens merely because a richer projection could render them. Material body, linked-artifact, collection, schedule, child, and claim-state groups retain exact `--fields` restoration guidance.
10
+
11
+ Package authors can use `registerOutputMaterialFieldGroups(result, groups)` before the shared output boundary attaches a receipt. The registration is held in process memory through a `WeakMap`; it never appears in JSON, TOON, item storage, history, or package output.
12
+
13
+ ## Scoped preflight ownership
14
+
15
+ An extension contribution inventory can declare `preflight_ownership` command sets. Static activation uses those same sets as runtime dispatch:
16
+
17
+ - a scoped preflight activates only for an owned command;
18
+ - disjoint scoped preflights do not collide or activate for `pm health` merely because both advertise the `preflight` capability;
19
+ - `preflight_overrides` entries without corresponding ownership remain global.
20
+
21
+ This keeps health diagnostics and lazy runtime behavior on one ownership contract.
22
+
23
+ ## Merge provenance
24
+
25
+ Stable-value item merges distinguish a caller request from the outcome. Low-level item results, driver results, clone-local receipts, and privacy-safe summaries expose `requested_preference`. The actual outcome remains in each decision's `retained` and `discarded` values or hashes. New receipts do not emit the ambiguous `preferred` key; readers still ingest legacy schema-v1 receipts and normalize that key to `requested_preference`.
26
+
27
+ ## Claim race classification
28
+
29
+ Extensions can import `isAlreadyClaimedError` from either supported lifecycle entrypoint:
30
+
31
+ ```ts
32
+ import { isAlreadyClaimedError } from "@unbrained/pm-cli/sdk";
33
+ // or the compact lifecycle surface
34
+ import { isAlreadyClaimedError as isCoreAlreadyClaimedError } from "@unbrained/pm-cli/sdk/core";
35
+ ```
36
+
37
+ The predicate recognizes only the canonical `PmCliError` code `already_claimed_by`; consumers do not need to duplicate an internal string check.
38
+
39
+ ## Versioned history item hashes
40
+
41
+ New history events carry `item_hash_version: 2`, whose canonicalization preserves linked-test insertion order. The verifier auto-detects unversioned legacy streams against both the legacy sorted-test epoch and the order-preserving epoch. `hashDocumentForVersion` and `verifyHistoryChainWithVersion` expose the same compatibility logic to SDK consumers.
42
+
43
+ Unknown explicit epochs return `verify_failed:unsupported_item_hash_version:<version>:entry_<n>`. Repair refuses those streams instead of rewriting evidence with a guessed algorithm. Re-anchored supported streams are normalized to the current epoch, and the drift cache records the detected epoch so item-versus-history comparison uses the same canonicalization.
44
+
45
+ ## Assurance mutation refusals
46
+
47
+ Assurance `put` and `remove` operations validate untrusted declaration shapes at the shared action boundary used by the CLI, SDK, and MCP. Malformed definitions, referenced-declaration removals, and unauthorized assertion weakening return `PmCliError` with the canonical `invalid_argument_value` code and usage exit semantics. Evaluation and storage failures that are not input `TypeError`s remain unexpected and fail closed.
48
+
49
+ This boundary keeps deterministic operator refusals out of unexpected-error reporting while preserving Sentry and release-gate signal for genuine runtime faults.
50
+
51
+ ## Verification expectations
52
+
53
+ Changes to these contracts require focused unit coverage, exact repository coverage, packed ESM and TypeScript consumption, and temporary-workspace CLI acceptance. Merge changes additionally require the temporary-Git workflow in [Multi-Branch Merge Safety](MERGE_SAFETY.md).
@@ -1,6 +1,6 @@
1
1
  # SDK Context Integrity
2
2
 
3
- Tracker: [pm-0k19l7](../.agents/pm/issues/pm-0k19l7.toon), [pm-9stazf](../.agents/pm/issues/pm-9stazf.toon), [pm-tu71](../.agents/pm/issues/pm-tu71.toon), [pm-0xmajx](../.agents/pm/issues/pm-0xmajx.toon), [pm-7rrqsk](../.agents/pm/issues/pm-7rrqsk.toon), [pm-ety1qc](../.agents/pm/issues/pm-ety1qc.toon), and [pm-lu6sca](../.agents/pm/features/pm-lu6sca.toon).
3
+ Tracker: [pm-0k19l7](../.agents/pm/issues/pm-0k19l7.toon), [pm-9stazf](../.agents/pm/issues/pm-9stazf.toon), [pm-tu71](../.agents/pm/issues/pm-tu71.toon), [pm-0xmajx](../.agents/pm/issues/pm-0xmajx.toon), [pm-7rrqsk](../.agents/pm/issues/pm-7rrqsk.toon), [pm-ety1qc](../.agents/pm/issues/pm-ety1qc.toon), [pm-lu6sca](../.agents/pm/features/pm-lu6sca.toon), [pm-5y05kq](../.agents/pm/issues/pm-5y05kq.toon), [pm-gjjurs](../.agents/pm/issues/pm-gjjurs.toon), and [pm-h97qxd](../.agents/pm/issues/pm-h97qxd.toon).
4
4
 
5
5
  ## Agent Quick Context
6
6
 
@@ -31,6 +31,28 @@ selector grammar and omission receipts as any other SDK-owned item field.
31
31
 
32
32
  The same SDK-owned read-output registry now declares `package manage` as a first-class read surface. Package authors can resolve either `package manage` or `package-manage` to its canonical contract and discover the universal include, amount, cost, and encoding dimensions without copying CLI knowledge.
33
33
 
34
+ ## Row discovery and exact output receipts
35
+
36
+ Row locations and encoding capabilities remain part of the SDK-owned read
37
+ contract, but the `row_contract` discovery block is opt-in on rendered command
38
+ results. Use `--output-row-contract` in the CLI or `outputRowContract: true` in
39
+ SDK and MCP options when a generic consumer must discover row selectors. Normal
40
+ agent reads omit the repeated metadata and retain the same internal projections.
41
+
42
+ Uniform flat object arrays use canonical tabular TOON when TOON output is
43
+ selected. Mixed, nested, or scalar collections retain the general recursive
44
+ encoding, so package authors can add richer shapes without pretending they are
45
+ tabular. The optional row contract declares
46
+ `toon_encoding: tabular_when_uniform` for consumers that negotiate this
47
+ optimization.
48
+
49
+ When discovery metadata is omitted, every `context_intent`, `read_output`, and
50
+ `read_session` estimate is stabilized against the final serialized envelope.
51
+ Consequently `estimated_tokens` and `spent_this_call_tokens` never charge an
52
+ agent for hidden row metadata, and a caller-carried output session remains an
53
+ exact cross-command budget rather than an approximation of an intermediate
54
+ shape.
55
+
34
56
  ## Bounded annotation mutations
35
57
 
36
58
  Adding, editing, or deleting a comment, note, or learning returns the changed entry plus mutation and omission receipts. The reply size therefore stays independent of the item’s existing annotation history. Pass `--full-history` when a human or integration genuinely needs the complete post-mutation collection:
@@ -68,6 +90,11 @@ reader. Validation uses collection-bearing metadata for evidence and
68
90
  relationship checks and materializes bodies only when strict history-drift
69
91
  verification is requested.
70
92
 
93
+ Every health check row exposes both its tri-state `status` and a required
94
+ boolean `ok`. The boolean is exactly `status === "ok"` in full, brief, and
95
+ summary projections, so generic SDK and package consumers can use a stable
96
+ success predicate without discarding warning-versus-error detail.
97
+
71
98
  The storage check also reads at most 10,000 local immutable events for bounded
72
99
  agent-provenance resolver outcomes. This scan performs no network or provider
73
100
  I/O, tolerates malformed streams already owned by integrity diagnostics, and
@@ -12,6 +12,8 @@ Use `pm files lookup` with one or more project-relative or absolute paths:
12
12
  pm files lookup src/sdk/files.ts
13
13
  pm files lookup src/sdk/files.ts docs/SDK_EVIDENCE_TRACEABILITY.md --limit 20
14
14
  pm files lookup /absolute/project/src/sdk/files.ts --scope project --strict-read --json
15
+ pm files lookup src/sdk/files.ts --explain
16
+ pm files lookup src/sdk/files.ts --lines 650:720 --decision-depth 12 --json
15
17
  ```
16
18
 
17
19
  The command normalizes in-project absolute paths to project-relative paths, deduplicates targets, and returns referencing items in deterministic priority, update-time, and ID order. The default result limit is 50. Use `--offset` for bounded pagination or `--no-truncate` for an authoritative unbounded source scan.
@@ -26,6 +28,34 @@ Every response includes:
26
28
 
27
29
  `--strict-read` fails instead of returning partial source-scan results. Indexed reads are intentionally reported as `unchecked`: they are cursor-bound projections optimized for bounded context retrieval, while strict reads force authoritative item loading.
28
30
 
31
+ ## Explain why source exists
32
+
33
+ `--explain` upgrades reverse lookup from an ownership list to a bounded context
34
+ projection. Every match adds:
35
+
36
+ - its linked-file evidence and compact `value`, `why_now`, `outcome`, and
37
+ `objective` rationale;
38
+ - the shortest typed relationship path to a governing Decision, including
39
+ inverse edge names when traversal crosses an edge backwards;
40
+ - a deterministic relevance score used before normal priority, update-time,
41
+ and id tie-breakers; and
42
+ - explicit ambiguity codes when Git attribution is unavailable, selected lines
43
+ have no mapped commit, no governing Decision is reachable, or several
44
+ equally short Decisions exist.
45
+
46
+ `--lines start:end` is an inclusive, one-based selector that implies
47
+ `--explain` and accepts exactly one path. It runs bounded `git blame` and a
48
+ 256-commit path log. A blamed commit contributes only when its commit message
49
+ contains the exact pm item id, so Git history supplements linked tracker
50
+ evidence without inventing lineage. Git failures are non-fatal and appear as
51
+ ambiguity rather than silently claiming attribution. `--decision-depth` is
52
+ bounded from 1 through 32 and defaults to 8.
53
+
54
+ The top-level `traceability_receipt` reports the requested range, blamed,
55
+ mapped, and unmapped commit counts, and effective decision depth. Explained
56
+ lookups use an authoritative source scan because a compact metadata index does
57
+ not contain the rationale and graph fields required to support the answer.
58
+
29
59
  ## SDK and MCP
30
60
 
31
61
  The public SDK exposes both reusable-client and one-shot forms:
@@ -37,6 +67,9 @@ const client = new PmClient({ cwd: process.cwd() });
37
67
  const fromClient = await client.filesLookup({
38
68
  paths: ["src/sdk/files.ts"],
39
69
  limit: 20,
70
+ explain: true,
71
+ lineRange: { start: 650, end: 720 },
72
+ decisionDepth: 12,
40
73
  });
41
74
 
42
75
  const oneShot = await filesLookup(
@@ -45,7 +78,12 @@ const oneShot = await filesLookup(
45
78
  );
46
79
  ```
47
80
 
48
- The MCP `files` action uses the same primitive when `lookupPath` is present. `id` remains required for item-local add, remove, discover, and list operations; reverse lookup instead requires one or more `lookupPath` values. Use `pm contracts --command files --flags-only --json` for the active machine contract.
81
+ The MCP `files` action uses the same primitive when `lookupPath` is present and
82
+ accepts `explain`, `lines`, and `decisionDepth`. The dedicated `files_lookup`
83
+ tool exposes the same fields. `id` remains required for item-local add, remove,
84
+ discover, and list operations; reverse lookup instead requires one or more
85
+ `lookupPath` values. Use `pm contracts --command files --flags-only --json` for
86
+ the active machine contract.
49
87
 
50
88
  SDK hosts that manage authoritative item writes directly can use `queryLinkedFileMetadataIndex` from the public item-metadata-index surface. The reverse projection is rebuilt from linked-file collections and updated in the same derived-index writer section as normal metadata deltas. A missing, stale, corrupt, or extension-incompatible index must fall back to authoritative reads.
51
89
 
@@ -2,7 +2,11 @@
2
2
 
3
3
  Tracker: [pm-1eted6](../.agents/pm/issues/pm-1eted6.toon),
4
4
  [pm-3lhth4](../.agents/pm/issues/pm-3lhth4.toon), and
5
- [pm-0xmajx](../.agents/pm/issues/pm-0xmajx.toon).
5
+ [pm-0xmajx](../.agents/pm/issues/pm-0xmajx.toon). Refusal reachability and
6
+ recovery completeness are tracked by
7
+ [pm-elmpav](../.agents/pm/features/pm-elmpav.toon),
8
+ [pm-185870](../.agents/pm/issues/pm-185870.toon), and
9
+ [pm-yqe0mo](../.agents/pm/issues/pm-yqe0mo.toon).
6
10
 
7
11
  These SDK primitives keep host and project-runtime policy consistent across the
8
12
  bundled CLI, packages, and automation without requiring consumers to reproduce
@@ -56,3 +60,34 @@ guidance when presenting refusals as human-readable or structured output.
56
60
  Host-only validation remains at the transport boundary, while rules shared by
57
61
  packages and commands live in public SDK primitives so callers receive the
58
62
  same refusal contract regardless of entrypoint.
63
+
64
+ `createUnknownSubcommandError` is the shared constructor for positional command
65
+ families. It emits `unknown_subcommand` with the stable
66
+ `unknown_positional_token` reason, a complete sorted `allowed_values` set, the
67
+ attempted command, and a nearest copy-pasteable retry when edit distance gives
68
+ an unambiguous candidate. CLI, direct SDK dispatch, MCP, and package hosts use
69
+ the same primitive. The CLI also recognizes split schema actions such as
70
+ `schema add type Name` and recommends the declared `schema add-type Name`
71
+ form instead of collapsing the failure into a generic arity error.
72
+ Core graph, config, plan, schema, profile, merge, telemetry, workspace, and
73
+ package/extension lifecycle dispatchers use this contract. The bundled
74
+ templates package demonstrates the same primitive for package-registered
75
+ families; custom packages can import it from the public SDK instead of
76
+ inventing a private refusal envelope. The former `unknown_lifecycle_action`
77
+ catalog name remains a compatibility alias of `unknown_subcommand`.
78
+
79
+ `PmErrorCodeContract.owned_states` declares concrete refusal states, their
80
+ probe ids, reachable entrypoints, and expected exit classes. The generated
81
+ catalog joins those declarations to the discovered error-code inventory.
82
+ Package and test harnesses can pass real-entrypoint observations to
83
+ `verifyPmRefusalReachability`; missing probes, wrong codes, wrong exit classes,
84
+ and undeclared observations fail closed. This makes an error code's existence
85
+ and its runtime reachability independently testable.
86
+
87
+ Unknown-option recovery separates human and machine budgets. Human guidance
88
+ shows the first three ranked command paths plus an explicit remainder count.
89
+ The structured envelope returns up to twelve ranked paths alongside
90
+ `candidate_commands_total` and `candidate_commands_truncated`, ordered by
91
+ shared option vocabulary and then command path. Consumers must inspect another
92
+ command contract before changing operations; candidate discovery is not an
93
+ instruction to run a different command.
package/docs/TESTING.md CHANGED
@@ -242,12 +242,12 @@ baseline, scorer tests, and SDK documentation together.
242
242
  Tracked by [pm-k6t4yb](../.agents/pm/tasks/pm-k6t4yb.toon) and
243
243
  [pm-b2hc4x](../.agents/pm/tasks/pm-b2hc4x.toon).
244
244
 
245
- Every named workflow step that makes a build, test, quality, security, package,
246
- or release claim is discovered and matched exactly against
247
- `scripts/release/gate-registry.json`. Each registry entry declares:
245
+ Every workflow job is discovered by its stable `workflow-file#job-id` identity
246
+ and matched exactly against `scripts/release/gate-registry.json`; human-facing
247
+ step names never define the inventory. Each registry entry declares:
248
248
 
249
249
  - a canonical pm owner;
250
- - the enforced workflow steps it owns;
250
+ - the enforced workflow jobs it participates in;
251
251
  - actionable failure taxonomy;
252
252
  - explicit bypass policy and audit rationale;
253
253
  - an executable negative-control test and assertion.
@@ -259,11 +259,14 @@ pnpm quality:gate-registry
259
259
  node scripts/release/gate-registry.mjs --inventory
260
260
  ```
261
261
 
262
- `pnpm quality:static` includes the registry. A newly named workflow gate fails
263
- until it has an owner and negative-control proof; a removed or renamed workflow
264
- step also fails until stale policy is reconciled. Public source claims are
265
- mapped to exact evidence strings and an enforced registry entry so
266
- documentation cannot silently advertise advisory behavior.
262
+ `pnpm quality:static` includes the registry. A new workflow job fails until it
263
+ is declared under at least one canonical gate, and a removed or renamed job id
264
+ fails until stale policy is reconciled. Display-name edits do not mutate gate
265
+ identity. Public source claims are mapped to exact evidence strings and an
266
+ enforced registry entry so documentation cannot silently advertise advisory
267
+ behavior.
268
+ The inventory output lists registry-derived `registered` job IDs beside the
269
+ parsed `workflow_jobs`; validation requires the two sets to match exactly.
267
270
 
268
271
  ## Tracker Context-Quality Ratchets
269
272