@unbrained/pm-cli 2026.8.11 → 2026.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +74 -21
  3. package/dist/cli/commander-usage.js +37 -11
  4. package/dist/cli/error-guidance.d.ts +2 -0
  5. package/dist/cli/error-guidance.js +82 -19
  6. package/dist/cli/main.js +35 -19
  7. package/dist/cli/register-annotations.js +56 -3
  8. package/dist/cli/register-assurance.js +28 -17
  9. package/dist/cli/register-list-query.js +10 -7
  10. package/dist/cli/register-operations.js +16 -6
  11. package/dist/cli-bundle/bundle-manifest.json +163 -163
  12. package/dist/cli-bundle/chunks/chunk-3ZMOWAFM.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-DEDU3DG7.js +196 -0
  14. package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +13 -0
  15. package/dist/cli-bundle/chunks/chunk-F7FJYGK3.js +8 -0
  16. package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +5 -0
  17. package/dist/cli-bundle/chunks/chunk-IMGIN7R6.js +2 -0
  18. package/dist/cli-bundle/chunks/{chunk-A2SJGHSI.js → chunk-Q47C67TQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-WMEZHCFI.js → chunk-QGTUPEU5.js} +62 -54
  20. package/dist/cli-bundle/chunks/chunk-TF3TPKPR.js +34 -0
  21. package/dist/cli-bundle/chunks/{chunk-ZU34C3LH.js → chunk-YLBAPY22.js} +50 -50
  22. package/dist/cli-bundle/chunks/register-list-query-4HIZ7EA3.js +10 -0
  23. package/dist/cli-bundle/chunks/register-mutation-W64FZ5HN.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-C44ET7R5.js +2 -0
  25. package/dist/cli-bundle/chunks/{register-setup-NOCOOWQY.js → register-setup-634MFRXU.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +31 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-4H5IA6AV.js → chunk-2JP7W7GO.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-2RI2FESN.js +4 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +8 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-2DL3MRTD.js → chunk-3DJSGWVB.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +5 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +155 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-TL5M2PAY.js → chunk-E3AVJ655.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-J5EKAIVD.js → chunk-HC2OL2H2.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-BKPIY34S.js → chunk-I75MANL7.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-IIS2FRKL.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-NFHFZH2Z.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +17 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-UDAZWT25.js → chunk-OOYYKQWX.js} +4 -4
  42. package/dist/cli-bundle/focused-chunks/{chunk-23FTGO3W.js → chunk-PKPOZXLL.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-QDZUABWL.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +16 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-55BIB6DV.js → chunk-TEZIXMTH.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +18 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +42 -41
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +1 -1
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +2 -2
  58. package/dist/core/checkpoint/checkpoint-gc.js +7 -12
  59. package/dist/core/extensions/activation-summary-markdown.js +5 -4
  60. package/dist/core/extensions/activation-summary.d.ts +2 -0
  61. package/dist/core/extensions/activation-summary.js +6 -2
  62. package/dist/core/extensions/capability-usage.d.ts +1 -1
  63. package/dist/core/extensions/capability-usage.js +4 -3
  64. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  65. package/dist/core/extensions/contribution-inventory.js +6 -2
  66. package/dist/core/extensions/extension-registries.js +3 -2
  67. package/dist/core/extensions/extension-types.d.ts +83 -1
  68. package/dist/core/extensions/extension-types.js +3 -2
  69. package/dist/core/extensions/loader.d.ts +2 -8
  70. package/dist/core/extensions/loader.js +53 -144
  71. package/dist/core/extensions/registration-values.d.ts +43 -0
  72. package/dist/core/extensions/registration-values.js +210 -0
  73. package/dist/core/extensions/reserved-host-flags.js +3 -2
  74. package/dist/core/extensions/runtime-registrations.d.ts +3 -1
  75. package/dist/core/extensions/runtime-registrations.js +12 -2
  76. package/dist/core/fs/fs-utils.d.ts +2 -0
  77. package/dist/core/fs/fs-utils.js +7 -3
  78. package/dist/core/history/drift-cache.js +4 -3
  79. package/dist/core/history/drift-scan.js +16 -17
  80. package/dist/core/history/history.d.ts +8 -0
  81. package/dist/core/history/history.js +57 -7
  82. package/dist/core/history/replay.d.ts +9 -1
  83. package/dist/core/history/replay.js +48 -13
  84. package/dist/core/lock/lock-gc.js +8 -13
  85. package/dist/core/lock/lock.js +5 -4
  86. package/dist/core/output/output.d.ts +2 -0
  87. package/dist/core/output/output.js +46 -14
  88. package/dist/core/search/vector-stores.js +6 -11
  89. package/dist/core/shared/command-types.d.ts +2 -0
  90. package/dist/core/shared/command-types.js +2 -2
  91. package/dist/core/shared/errors.d.ts +5 -0
  92. package/dist/core/shared/errors.js +2 -2
  93. package/dist/core/store/item-metadata-cache.d.ts +1 -1
  94. package/dist/core/store/item-metadata-cache.js +16 -9
  95. package/dist/core/telemetry/runtime.d.ts +6 -0
  96. package/dist/core/telemetry/runtime.js +101 -30
  97. package/dist/sdk/agent/command-recovery.d.ts +2 -0
  98. package/dist/sdk/agent/command-recovery.js +10 -2
  99. package/dist/sdk/annotations.js +4 -4
  100. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  101. package/dist/sdk/cli-bootstrap.js +6 -2
  102. package/dist/sdk/cli-contracts/completeness.js +10 -3
  103. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  104. package/dist/sdk/cli-contracts/flag-contracts.js +9 -3
  105. package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
  106. package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
  107. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +40 -6
  108. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +27 -3
  109. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  110. package/dist/sdk/cli-contracts/tool-parameter-tables.js +55 -5
  111. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  112. package/dist/sdk/cli-contracts/tool-schema.js +22 -4
  113. package/dist/sdk/cli-program.js +3 -2
  114. package/dist/sdk/comments.js +4 -3
  115. package/dist/sdk/compile-cache.js +4 -3
  116. package/dist/sdk/completion.js +16 -7
  117. package/dist/sdk/compose.d.ts +3 -1
  118. package/dist/sdk/compose.js +16 -2
  119. package/dist/sdk/context-intent-contracts.js +45 -4
  120. package/dist/sdk/context-signal-store.js +4 -3
  121. package/dist/sdk/core.d.ts +1 -0
  122. package/dist/sdk/core.js +3 -2
  123. package/dist/sdk/extension/install-runtime.js +4 -4
  124. package/dist/sdk/extension/managed-state.js +4 -3
  125. package/dist/sdk/extension-contracts.d.ts +1 -1
  126. package/dist/sdk/flag-invocation-contracts.js +5 -6
  127. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
  128. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1597 -0
  129. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
  130. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
  131. package/dist/sdk/generated-error-code-catalog.js +6 -3140
  132. package/dist/sdk/governance/assurance-action.d.ts +27 -3
  133. package/dist/sdk/governance/assurance-action.js +117 -31
  134. package/dist/sdk/governance/assurance-mutation-error.d.ts +14 -0
  135. package/dist/sdk/governance/assurance-mutation-error.js +58 -0
  136. package/dist/sdk/governance/assurance-presets.d.ts +54 -0
  137. package/dist/sdk/governance/assurance-presets.js +136 -0
  138. package/dist/sdk/governance/assurance-runtime.d.ts +4 -0
  139. package/dist/sdk/governance/assurance-runtime.js +118 -14
  140. package/dist/sdk/governance/assurance.d.ts +51 -6
  141. package/dist/sdk/governance/assurance.js +321 -67
  142. package/dist/sdk/governance/gc.js +5 -11
  143. package/dist/sdk/governance/health.d.ts +3 -1
  144. package/dist/sdk/governance/health.js +24 -7
  145. package/dist/sdk/governance/validate-item-reader.js +3 -3
  146. package/dist/sdk/governance/validate.d.ts +2 -0
  147. package/dist/sdk/governance/validate.js +15 -5
  148. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  149. package/dist/sdk/graph/durable-cache.js +156 -29
  150. package/dist/sdk/graph/governance-contracts.d.ts +12 -0
  151. package/dist/sdk/graph/governance-contracts.js +27 -0
  152. package/dist/sdk/graph/governance.d.ts +44 -2
  153. package/dist/sdk/graph/governance.js +156 -12
  154. package/dist/sdk/guide.js +4 -4
  155. package/dist/sdk/index.d.ts +3 -2
  156. package/dist/sdk/index.js +5 -4
  157. package/dist/sdk/lifecycle/claim.js +10 -3
  158. package/dist/sdk/linked-artifacts.d.ts +2 -0
  159. package/dist/sdk/linked-artifacts.js +29 -4
  160. package/dist/sdk/merge/driver.d.ts +2 -2
  161. package/dist/sdk/merge/driver.js +3 -3
  162. package/dist/sdk/merge/install.js +5 -4
  163. package/dist/sdk/merge/receipts.d.ts +6 -4
  164. package/dist/sdk/merge/receipts.js +7 -5
  165. package/dist/sdk/merge/three-way.d.ts +2 -2
  166. package/dist/sdk/merge/three-way.js +3 -3
  167. package/dist/sdk/output-projection.d.ts +9 -1
  168. package/dist/sdk/output-projection.js +45 -9
  169. package/dist/sdk/query/activity.d.ts +49 -2
  170. package/dist/sdk/query/activity.js +185 -38
  171. package/dist/sdk/query/get.js +19 -2
  172. package/dist/sdk/read-output-contracts.d.ts +5 -1
  173. package/dist/sdk/read-output-contracts.js +17 -2
  174. package/dist/sdk/read-output-session.d.ts +2 -0
  175. package/dist/sdk/read-output-session.js +12 -5
  176. package/dist/sdk/relationship-history.js +5 -5
  177. package/dist/sdk/runtime-primitives.d.ts +3 -3
  178. package/dist/sdk/runtime-primitives.js +5 -5
  179. package/dist/sdk/runtime-stats-options.js +3 -2
  180. package/dist/sdk/runtime.js +5 -9
  181. package/dist/sdk/schema-migration.js +4 -4
  182. package/dist/sdk/stats.d.ts +36 -3
  183. package/dist/sdk/stats.js +55 -15
  184. package/dist/sdk/test/execution.d.ts +4 -0
  185. package/dist/sdk/test/execution.js +88 -23
  186. package/dist/sdk/workspace-memory.js +4 -4
  187. package/dist/sdk/workspace-snapshot.js +8 -14
  188. package/dist/sdk/workspace-transaction-gc.js +4 -9
  189. package/dist/sdk/workspace-transaction.js +4 -4
  190. package/dist/sdk/workspace.js +4 -3
  191. package/dist/types.d.ts +2 -0
  192. package/dist/types.js +2 -2
  193. package/docs/ASSURANCE.md +170 -14
  194. package/docs/COMMANDS.md +29 -8
  195. package/docs/CONFIGURATION.md +9 -0
  196. package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
  197. package/docs/EXTENSIONS.md +11 -12
  198. package/docs/MERGE_SAFETY.md +3 -1
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
  202. package/docs/RELATIONSHIP_GRAPH.md +15 -0
  203. package/docs/SDK.md +17 -3
  204. package/docs/SDK_AGENT_SESSION_CONTEXT.md +12 -1
  205. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
  206. package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
  207. package/docs/TESTING.md +24 -15
  208. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
  209. package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
  210. package/marketplace.json +2 -2
  211. package/package.json +6 -6
  212. package/packages/pm-beads/package.json +1 -1
  213. package/packages/pm-calendar/package.json +1 -1
  214. package/packages/pm-command-kit/package.json +1 -1
  215. package/packages/pm-digital-twin/package.json +1 -1
  216. package/packages/pm-governance-audit/package.json +1 -1
  217. package/packages/pm-guide-shell/package.json +1 -1
  218. package/packages/pm-kanban/package.json +1 -1
  219. package/packages/pm-lifecycle-hooks/package.json +1 -1
  220. package/packages/pm-linked-test-adapters/package.json +1 -1
  221. package/packages/pm-search-advanced/package.json +1 -1
  222. package/packages/pm-templates/package.json +1 -1
  223. package/packages/pm-todos/package.json +1 -1
  224. package/packages/pm-vcs/package.json +1 -1
  225. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  226. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  227. package/sdk/public-surface.json +384 -83
  228. package/dist/cli-bundle/chunks/chunk-2OOU2AFH.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +0 -33
  230. package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +0 -13
  231. package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +0 -194
  232. package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +0 -2
  234. package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +0 -5
  235. package/dist/cli-bundle/chunks/register-list-query-HAUXVUPY.js +0 -10
  236. package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +0 -20
  237. package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +0 -2
  240. package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +0 -16
  241. package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +0 -8
  242. package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +0 -2
  243. package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +0 -31
  244. package/dist/cli-bundle/focused-chunks/chunk-E3KCL7AY.js +0 -5
  245. package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +0 -153
  246. package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +0 -2
  247. package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +0 -18
  248. package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +0 -4
  249. package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +0 -17
@@ -14,10 +14,10 @@
14
14
  */
15
15
  import type { RelationshipEdge } from "../relationships.js";
16
16
  import type { WorkspaceRelationshipAssembly } from "./assembly.js";
17
+ import { type RelationshipAuditFindingCode } from "./governance-contracts.js";
18
+ export type { RelationshipAuditFindingCode } from "./governance-contracts.js";
17
19
  /** Severity ladder shared by every relationship audit finding. */
18
20
  export type RelationshipAuditSeverity = "error" | "warning" | "info";
19
- /** Machine-readable identifier for one relationship audit finding family. */
20
- export type RelationshipAuditFindingCode = "missing_reference_active" | "missing_reference_terminal" | "legacy_no_blocker_sentinel" | "ordering_cycle" | "legacy_ordering_cycle" | "duplicate_edge" | "legacy_duplicate_edge" | "duplicate_dependency_row" | "legacy_duplicate_dependency_row" | "stale_lifecycle_block" | "isolated_active_node" | "sparse_active_node";
21
21
  /** One policy-aware relationship audit finding with bounded evidence. */
22
22
  export interface RelationshipAuditFinding {
23
23
  /** Machine-readable finding family identifier. */
@@ -56,6 +56,12 @@ export interface RelationshipCoverageProfile {
56
56
  edge_basis: "deduplicated_directed";
57
57
  /** Deterministic per-kind edge counts. */
58
58
  edges_by_kind: Record<string, number>;
59
+ /** Per-kind share of all deduplicated directed edges. */
60
+ edge_share_by_kind: Record<string, number>;
61
+ /** Edges carrying discovery, provenance, incident, or verification semantics. */
62
+ semantic_edges: number;
63
+ /** Share of all edges carrying discovery, provenance, incident, or verification semantics. */
64
+ semantic_edge_share: number;
59
65
  /** Nodes whose lifecycle status is active (non-terminal, non-missing). */
60
66
  active_nodes: number;
61
67
  /** Materialized placeholder nodes for referenced-but-absent items. */
@@ -66,6 +72,34 @@ export interface RelationshipCoverageProfile {
66
72
  degree_leq_one_active_nodes: number;
67
73
  /** Deterministic per-type connectivity coverage; untyped nodes bucket under `(untyped)`. */
68
74
  coverage_by_type: Record<string, RelationshipCoverageTypeProfile>;
75
+ /** Undirected cut vertices whose removal increases the component count. */
76
+ articulation_points: number;
77
+ /** Undirected cut edges whose removal disconnects their endpoints. */
78
+ bridge_edges: number;
79
+ /** Milestone nodes whose title explicitly declares an outcome. */
80
+ outcome_nodes: number;
81
+ /** Active non-outcome nodes with a typed hierarchy or implements path to an outcome. */
82
+ active_outcome_reachable_nodes: number;
83
+ /** Active non-outcome nodes without a typed hierarchy or implements path to an outcome. */
84
+ active_outcome_unreachable_nodes: number;
85
+ /** Active typed-outcome reachability expressed as integer basis points. */
86
+ active_outcome_reachability_basis_points: number;
87
+ /** Terminal non-placeholder, non-outcome nodes included in the all-status census. */
88
+ terminal_nodes: number;
89
+ /** Terminal non-outcome nodes with a typed hierarchy or implements path to an outcome. */
90
+ terminal_outcome_reachable_nodes: number;
91
+ /** Terminal non-outcome nodes without a typed hierarchy or implements path to an outcome. */
92
+ terminal_outcome_unreachable_nodes: number;
93
+ /** Terminal typed-outcome reachability expressed as integer basis points. */
94
+ terminal_outcome_reachability_basis_points: number;
95
+ /** All active and terminal non-outcome nodes with a typed path to an outcome. */
96
+ outcome_reachable_nodes: number;
97
+ /** All active and terminal non-outcome nodes without a typed path to an outcome. */
98
+ outcome_unreachable_nodes: number;
99
+ /** All-status typed-outcome reachability expressed as integer basis points. */
100
+ outcome_reachability_basis_points: number;
101
+ /** Affected-subject census containing every known finding code, including zero populations. */
102
+ finding_subjects_by_code: Record<RelationshipAuditFindingCode, number>;
69
103
  }
70
104
  /** Tuning and policy inputs accepted by the relationship audit. */
71
105
  export interface RelationshipAuditOptions {
@@ -89,6 +123,8 @@ export interface RelationshipAuditReport {
89
123
  /** Structural coverage metrics computed during the audit. */
90
124
  profile: RelationshipCoverageProfile;
91
125
  }
126
+ /** Return whether a relationship kind carries provenance or verification context. */
127
+ export declare function isSemanticContextKind(kind: string): boolean;
92
128
  /**
93
129
  * Enumerate strongly connected components with more than one member (or a
94
130
  * self-loop) over an ordering-only successor digraph using an iterative Tarjan
@@ -165,6 +201,12 @@ export interface RelationshipAuditDelta {
165
201
  degree_leq_one_active_nodes: number;
166
202
  /** Signed per-kind edge-count deltas; unchanged kinds are dropped. */
167
203
  edges_by_kind: Record<string, number>;
204
+ /** Signed per-kind edge-share deltas; unchanged kinds are dropped. */
205
+ edge_share_by_kind: Record<string, number>;
206
+ /** Change in semantic-context edge count. */
207
+ semantic_edges: number;
208
+ /** Change in semantic-context edge share. */
209
+ semantic_edge_share: number;
168
210
  /** Signed per-type coverage deltas; unchanged types are dropped. */
169
211
  coverage_by_type: Record<string, RelationshipCoverageTypeProfile>;
170
212
  };
@@ -1,8 +1,24 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="76fa19c7-a421-5026-8de8-450285987c4e")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ab8a4904-0302-5e36-9963-750b3ba79876")}catch(e){}}();
3
3
  import { isTransitiveKind, orientTransitiveEdge, transitiveFamilyKey, } from "./analytics.js";
4
+ import { findRelationshipCutStructure } from "./centrality.js";
5
+ import { RELATIONSHIP_AUDIT_FINDING_CODES, } from "./governance-contracts.js";
4
6
  /** Default bounded sample size applied to every finding family. */
5
7
  const DEFAULT_MAX_SAMPLE_SIZE = 25;
8
+ /** Canonical item type and title marker that identify explicit outcomes. */
9
+ const OUTCOME_MILESTONE_TYPE = "milestone";
10
+ const OUTCOME_MILESTONE_TITLE_PREFIX = "outcome milestone:";
11
+ /** Relationship kinds that preserve why work exists or how evidence supports it. */
12
+ const SEMANTIC_CONTEXT_KINDS = new Set([
13
+ "discovered_from",
14
+ "incident_from",
15
+ "supersedes",
16
+ "verifies",
17
+ ]);
18
+ /** Return whether a relationship kind carries provenance or verification context. */
19
+ export function isSemanticContextKind(kind) {
20
+ return SEMANTIC_CONTEXT_KINDS.has(kind);
21
+ }
6
22
  /** Rank used to order findings by decreasing severity. */
7
23
  const SEVERITY_RANK = {
8
24
  error: 0,
@@ -279,6 +295,104 @@ function collectDuplicateRowFindings(assembly, maxSampleSize) {
279
295
  appendFinding(findings, legacy, maxSampleSize, "legacy_duplicate_dependency_row", "info", "Identical repeated dependency rows on terminal holders are historical storage noise with no scheduling effect.", (count) => `${count} exactly duplicated stored dependency row(s) on terminal holder(s)`, "Leave as history debt or clean up in a dedicated changelog-safe closed-item batch.");
280
296
  return findings;
281
297
  }
298
+ /** Build the reverse typed paths that can carry context toward an outcome. */
299
+ function buildOutcomeReverseIndex(assembly, signal) {
300
+ const reverse = new Map();
301
+ for (const edge of assembly.graph.edges()) {
302
+ signal?.throwIfAborted();
303
+ const definition = assembly.graph.registry().require(edge.kind);
304
+ let oriented;
305
+ if (definition.hierarchy) {
306
+ oriented = orientTransitiveEdge(edge, definition);
307
+ }
308
+ else if (definition.kind === "implements") {
309
+ oriented = { from: edge.source, to: edge.target };
310
+ }
311
+ if (oriented === undefined)
312
+ continue;
313
+ const sources = reverse.get(oriented.to) ?? new Set();
314
+ sources.add(oriented.from);
315
+ reverse.set(oriented.to, sources);
316
+ }
317
+ return reverse;
318
+ }
319
+ /** Expand outcome nodes through every deterministic reverse typed path. */
320
+ function expandOutcomeReachability(outcomes, reverse, signal) {
321
+ const reachable = new Set(outcomes);
322
+ const queue = [...outcomes].sort();
323
+ for (let index = 0; index < queue.length; index += 1) {
324
+ signal?.throwIfAborted();
325
+ for (const source of [...(reverse.get(queue[index]) ?? [])].sort()) {
326
+ if (reachable.has(source))
327
+ continue;
328
+ reachable.add(source);
329
+ queue.push(source);
330
+ }
331
+ }
332
+ return reachable;
333
+ }
334
+ /** Count active and terminal nodes against the resolved outcome-reachable set. */
335
+ function tallyOutcomeReachability(nodeStates, outcomes, reachable, signal) {
336
+ let activeReachable = 0;
337
+ let activeUnreachable = 0;
338
+ let terminal = 0;
339
+ let terminalReachable = 0;
340
+ for (const state of nodeStates.values()) {
341
+ signal?.throwIfAborted();
342
+ if (outcomes.has(state.id))
343
+ continue;
344
+ if (state.missing || state.status === "external")
345
+ continue;
346
+ if (state.terminal) {
347
+ terminal += 1;
348
+ if (reachable.has(state.id))
349
+ terminalReachable += 1;
350
+ continue;
351
+ }
352
+ if (reachable.has(state.id))
353
+ activeReachable += 1;
354
+ else
355
+ activeUnreachable += 1;
356
+ }
357
+ const active = activeReachable + activeUnreachable;
358
+ const terminalUnreachable = terminal - terminalReachable;
359
+ const outcomeReachable = activeReachable + terminalReachable;
360
+ const outcomeUnreachable = activeUnreachable + terminalUnreachable;
361
+ const outcomePopulation = outcomeReachable + outcomeUnreachable;
362
+ return {
363
+ active_outcome_reachable_nodes: activeReachable,
364
+ active_outcome_unreachable_nodes: activeUnreachable,
365
+ active_outcome_reachability_basis_points: active === 0 ? 0 : Math.floor((activeReachable * 10_000) / active),
366
+ terminal_nodes: terminal,
367
+ terminal_outcome_reachable_nodes: terminalReachable,
368
+ terminal_outcome_unreachable_nodes: terminalUnreachable,
369
+ terminal_outcome_reachability_basis_points: terminal === 0 ? 0 : Math.floor((terminalReachable * 10_000) / terminal),
370
+ outcome_reachable_nodes: outcomeReachable,
371
+ outcome_unreachable_nodes: outcomeUnreachable,
372
+ outcome_reachability_basis_points: outcomePopulation === 0
373
+ ? 0
374
+ : Math.floor((outcomeReachable * 10_000) / outcomePopulation),
375
+ };
376
+ }
377
+ /**
378
+ * Count nodes with an explicit typed path to an outcome milestone. Hierarchy
379
+ * edges flow child to parent and `implements` flows implementation to outcome;
380
+ * unrelated association edges deliberately contribute no reachability.
381
+ */
382
+ function profileOutcomeReachability(assembly, nodeStates, signal) {
383
+ const outcomes = new Set(assembly.details
384
+ .filter((detail) => detail.type?.toLowerCase() === OUTCOME_MILESTONE_TYPE &&
385
+ detail.title
386
+ .trim()
387
+ .toLowerCase()
388
+ .startsWith(OUTCOME_MILESTONE_TITLE_PREFIX))
389
+ .map((detail) => detail.id));
390
+ const reachable = expandOutcomeReachability(outcomes, buildOutcomeReverseIndex(assembly, signal), signal);
391
+ return {
392
+ outcome_nodes: outcomes.size,
393
+ ...tallyOutcomeReachability(nodeStates, outcomes, reachable, signal),
394
+ };
395
+ }
282
396
  /** Fold one active node's degree into the aggregate and per-type coverage tallies. */
283
397
  function tallyActiveCoverageNode(tallies, state, degree, exemptIsolates, isolateExemptTypes) {
284
398
  tallies.active += 1;
@@ -305,7 +419,7 @@ function tallyActiveCoverageNode(tallies, state, degree, exemptIsolates, isolate
305
419
  else
306
420
  tallies.sparse.push(state.id);
307
421
  }
308
- function collectCoverageReport(assembly, nodeStates, exemptIsolates, isolateExemptTypes, maxSampleSize, edgesByKind) {
422
+ function collectCoverageReport(assembly, nodeStates, exemptIsolates, isolateExemptTypes, maxSampleSize, edgesByKind, signal) {
309
423
  const tallies = {
310
424
  active: 0,
311
425
  missing: 0,
@@ -316,6 +430,7 @@ function collectCoverageReport(assembly, nodeStates, exemptIsolates, isolateExem
316
430
  byType: new Map(),
317
431
  };
318
432
  for (const id of assembly.graph.nodes()) {
433
+ signal?.throwIfAborted();
319
434
  const state = nodeStates.get(id);
320
435
  /* c8 ignore next -- every graph node originates from assembly details by construction */
321
436
  if (!state)
@@ -332,18 +447,35 @@ function collectCoverageReport(assembly, nodeStates, exemptIsolates, isolateExem
332
447
  const findings = [];
333
448
  appendFinding(findings, isolates, maxSampleSize, "isolated_active_node", "warning", "Active work should be reachable from the graph unless explicitly declared a valid isolate.", (count) => `${count} active item(s) with no relationships`, "Link the item to its parent, prerequisite, or origin — or register it as an exempt isolate.");
334
449
  appendFinding(findings, sparse, maxSampleSize, "sparse_active_node", "info", "Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.", (count) => `${count} active item(s) with exactly one relationship`, "Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");
450
+ const edgeCount = assembly.graph.edges().length;
451
+ const sortedEdgesByKind = Object.fromEntries(Object.entries(edgesByKind).sort(([left], [right]) => left.localeCompare(right)));
452
+ const semanticEdges = Object.entries(sortedEdgesByKind).reduce((count, [kind, value]) => count + (isSemanticContextKind(kind) ? value : 0), 0);
453
+ const cutStructure = findRelationshipCutStructure(assembly.graph, {
454
+ signal,
455
+ }).value;
456
+ const outcomeReachability = profileOutcomeReachability(assembly, nodeStates, signal);
335
457
  return {
336
458
  findings,
337
459
  profile: {
338
460
  nodes: assembly.graph.nodes().length,
339
- edges: assembly.graph.edges().length,
461
+ edges: edgeCount,
340
462
  edge_basis: "deduplicated_directed",
341
- edges_by_kind: Object.fromEntries(Object.entries(edgesByKind).sort(([left], [right]) => left.localeCompare(right))),
463
+ edges_by_kind: sortedEdgesByKind,
464
+ edge_share_by_kind: Object.fromEntries(Object.entries(sortedEdgesByKind).map(([kind, count]) => [
465
+ kind,
466
+ count / edgeCount,
467
+ ])),
468
+ semantic_edges: semanticEdges,
469
+ semantic_edge_share: edgeCount === 0 ? 0 : semanticEdges / edgeCount,
342
470
  active_nodes: tallies.active,
343
471
  missing_nodes: tallies.missing,
344
472
  isolated_active_nodes: tallies.isolated,
345
473
  degree_leq_one_active_nodes: tallies.degreeLeqOne,
346
474
  coverage_by_type: Object.fromEntries([...tallies.byType.entries()].sort(([left], [right]) => left < right ? -1 : 1)),
475
+ articulation_points: cutStructure.articulationPoints.length,
476
+ bridge_edges: cutStructure.bridges.length,
477
+ ...outcomeReachability,
478
+ finding_subjects_by_code: Object.fromEntries(RELATIONSHIP_AUDIT_FINDING_CODES.map((code) => [code, 0])),
347
479
  },
348
480
  };
349
481
  }
@@ -390,14 +522,21 @@ export function auditWorkspaceRelationshipGraph(assembly, options = {}) {
390
522
  options.signal?.throwIfAborted();
391
523
  findings.push(...collectDuplicateEdgeFindings(assembly, nodeStates, maxSampleSize), ...collectDuplicateRowFindings(assembly, maxSampleSize));
392
524
  options.signal?.throwIfAborted();
393
- const coverage = collectCoverageReport(assembly, nodeStates, exemptIsolates, isolateExemptTypes, maxSampleSize, edgesByKind);
525
+ const coverage = collectCoverageReport(assembly, nodeStates, exemptIsolates, isolateExemptTypes, maxSampleSize, edgesByKind, options.signal);
394
526
  findings.push(...coverage.findings);
395
527
  findings.sort((left, right) => SEVERITY_RANK[left.severity] - SEVERITY_RANK[right.severity] ||
396
528
  left.code.localeCompare(right.code) ||
397
529
  left.sample[0].localeCompare(right.sample[0]));
530
+ const findingSubjectsByCode = coverage.profile.finding_subjects_by_code;
531
+ for (const finding of findings) {
532
+ findingSubjectsByCode[finding.code] += finding.count;
533
+ }
398
534
  return {
399
535
  findings,
400
- profile: coverage.profile,
536
+ profile: {
537
+ ...coverage.profile,
538
+ finding_subjects_by_code: findingSubjectsByCode,
539
+ },
401
540
  };
402
541
  }
403
542
  /** Subtract two count records, keeping only non-zero signed deltas in sorted key order. */
@@ -437,16 +576,18 @@ export function diffRelationshipAuditSnapshots(baseline, current) {
437
576
  ]),
438
577
  ].sort();
439
578
  for (const type of typeKeys) {
440
- const before = baselineCoverageByType[type];
441
- const after = currentCoverageByType[type];
579
+ const before = Object.assign({ active: 0, isolated: 0, degree_leq_one: 0 }, baselineCoverageByType[type]);
580
+ const after = Object.assign({ active: 0, isolated: 0, degree_leq_one: 0 }, currentCoverageByType[type]);
442
581
  const delta = {
443
- active: (after?.active ?? 0) - (before?.active ?? 0),
444
- isolated: (after?.isolated ?? 0) - (before?.isolated ?? 0),
445
- degree_leq_one: (after?.degree_leq_one ?? 0) - (before?.degree_leq_one ?? 0),
582
+ active: after.active - before.active,
583
+ isolated: after.isolated - before.isolated,
584
+ degree_leq_one: after.degree_leq_one - before.degree_leq_one,
446
585
  };
447
586
  if (Object.values(delta).some((value) => value !== 0))
448
587
  coverageByType[type] = delta;
449
588
  }
589
+ const { edge_share_by_kind: baselineEdgeShareByKind = {}, semantic_edges: baselineSemanticEdges = 0, semantic_edge_share: baselineSemanticEdgeShare = 0, } = baseline.profile;
590
+ const { edge_share_by_kind: currentEdgeShareByKind = {}, semantic_edges: currentSemanticEdges = 0, semantic_edge_share: currentSemanticEdgeShare = 0, } = current.profile;
450
591
  return {
451
592
  baseline_saved_at: baseline.saved_at,
452
593
  same_snapshot: baseline.fingerprint === current.fingerprint,
@@ -461,9 +602,12 @@ export function diffRelationshipAuditSnapshots(baseline, current) {
461
602
  degree_leq_one_active_nodes: current.profile.degree_leq_one_active_nodes -
462
603
  baseline.profile.degree_leq_one_active_nodes,
463
604
  edges_by_kind: diffCountRecords(baseline.profile.edges_by_kind, current.profile.edges_by_kind),
605
+ edge_share_by_kind: diffCountRecords(baselineEdgeShareByKind, currentEdgeShareByKind),
606
+ semantic_edges: currentSemanticEdges - baselineSemanticEdges,
607
+ semantic_edge_share: currentSemanticEdgeShare - baselineSemanticEdgeShare,
464
608
  coverage_by_type: coverageByType,
465
609
  },
466
610
  };
467
611
  }
468
612
  //# sourceMappingURL=governance.js.map
469
- //# debugId=76fa19c7-a421-5026-8de8-450285987c4e
613
+ //# debugId=ab8a4904-0302-5e36-9963-750b3ba79876
package/dist/sdk/guide.js CHANGED
@@ -4,7 +4,8 @@
4
4
  * Implements the pm guide command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9376fbdf-c942-5fa6-9252-92125ae44e73")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="27be0fa5-1c6a-53de-a0e8-179aab7c795a")}catch(e){}}();
8
+ import { isFileAbsentError } from "../core/fs/fs-utils.js";
8
9
  import { readFile } from "node:fs/promises";
9
10
  import path from "node:path";
10
11
  import { resolveConfiguredPmPackageRoot, EXIT_CODE, PmCliError, } from "./runtime-primitives.js";
@@ -119,8 +120,7 @@ async function renderGuideDocs(topic, depth, packageRoot) {
119
120
  }
120
121
  }
121
122
  catch (error) {
122
- const code = error?.code;
123
- const missing = code === "ENOENT";
123
+ const missing = isFileAbsentError(error);
124
124
  docs.push({
125
125
  path: doc.path,
126
126
  purpose: doc.purpose,
@@ -277,4 +277,4 @@ export function renderGuideMarkdown(result) {
277
277
  return lines.join("\n");
278
278
  }
279
279
  //# sourceMappingURL=guide.js.map
280
- //# debugId=9376fbdf-c942-5fa6-9252-92125ae44e73
280
+ //# debugId=27be0fa5-1c6a-53de-a0e8-179aab7c795a
@@ -58,6 +58,7 @@ export * from "./compose.js";
58
58
  export * from "./governance/assurance.js";
59
59
  export * from "./governance/assurance-action.js";
60
60
  export * from "./governance/assurance-runtime.js";
61
+ export * from "./governance/assurance-presets.js";
61
62
  export * from "./compile-cache.js";
62
63
  export * from "./environment/project-runtime-compatibility.js";
63
64
  export * from "./environment/source-context.js";
@@ -94,7 +95,7 @@ export { runDeps, type DepsCollapseMode, type DepsFormat, type DepsGraphEdge, ty
94
95
  export * from "./graph/index.js";
95
96
  export { runDocs } from "./docs.js";
96
97
  export { runFiles, runFilesDiscover, runFilesLookup, type FilesDiscoveryCandidate, type FilesLookupItem, type FilesLookupMatch, } from "./files.js";
97
- export { applyPathMigrations, applyStandaloneNote, artifactKey, dedupeLinkedArtifacts, ensureScope, expandAddGlobEntries, normalizeLinkedPath, parseAddEntries, parseAddGlobEntries, parseMigrateEntries, parseRemoveEntries, renameArtifactsResultKey, runLinkedArtifacts, sortLinkedArtifacts, validateLinkedPaths, type AddGlobEntry, type LinkedArtifact, type LinkedArtifactCommandOptions, type LinkedArtifactKindConfig, type LinkedArtifactResult, type LinkedPathValidation, type PathMigration, } from "./linked-artifacts.js";
98
+ export { applyPathMigrations, applyStandaloneNote, artifactKey, assertLinkedArtifactMutationIsUnambiguous, dedupeLinkedArtifacts, ensureScope, expandAddGlobEntries, normalizeLinkedPath, parseAddEntries, parseAddGlobEntries, parseMigrateEntries, parseRemoveEntries, renameArtifactsResultKey, runLinkedArtifacts, sortLinkedArtifacts, validateLinkedPaths, type AddGlobEntry, type LinkedArtifact, type LinkedArtifactCommandOptions, type LinkedArtifactKindConfig, type LinkedArtifactResult, type LinkedPathValidation, type PathMigration, } from "./linked-artifacts.js";
98
99
  export * from "./pagination.js";
99
100
  export * from "./query/item-filter-options.js";
100
101
  export * from "./query/parsers.js";
@@ -127,7 +128,7 @@ export type { UpdateManyOperationOptions } from "./lifecycle/update-many.js";
127
128
  export { runCreate } from "./lifecycle/create.js";
128
129
  export { runPlan } from "./lifecycle/plan.js";
129
130
  export { runAppend } from "./lifecycle/append.js";
130
- export { runClaim, runClaimNext, runRelease } from "./lifecycle/claim.js";
131
+ export { isAlreadyClaimedError, runClaim, runClaimNext, runRelease, } from "./lifecycle/claim.js";
131
132
  export { runCloseMany } from "./lifecycle/close-many.js";
132
133
  export { runUpdateMany } from "./lifecycle/update-many.js";
133
134
  export { runComments } from "./comments.js";
package/dist/sdk/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Defines public SDK APIs and package-author helpers for Index.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8c96c6f6-f711-559a-bb35-9eeaedc720aa")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8664ab01-dc47-5344-b2d7-9ac315e8a74b")}catch(e){}}();
8
8
  export { PM_COMMAND_VISIBILITY_CONTRACTS, PM_MCP_PROMPT_CONTRACTS, PM_MCP_RESOURCE_CONTRACTS, PM_MCP_TOOL_COMMAND_CONTRACTS, listPmCommandsForTier, listPmMcpToolsForProfile, renderPmCommandVisibilityMarkdown, resolvePmCommandVisibilityTier, } from "./agent-capability-contracts.js";
9
9
  export * from "./agent-session-context.js";
10
10
  export { isErrnoError, limitAnnotationEntries, parseAnnotationTextInput, readAnnotationEntries, normalizeAnnotationTransportOptions, resolveAnnotationInput, resolveAnnotationIndex, runAnnotationCommand, wrapOwnershipConflict, } from "./annotations.js";
@@ -56,6 +56,7 @@ export * from "./compose.js";
56
56
  export * from "./governance/assurance.js";
57
57
  export * from "./governance/assurance-action.js";
58
58
  export * from "./governance/assurance-runtime.js";
59
+ export * from "./governance/assurance-presets.js";
59
60
  export * from "./compile-cache.js";
60
61
  export * from "./environment/project-runtime-compatibility.js";
61
62
  export * from "./environment/source-context.js";
@@ -92,7 +93,7 @@ export { runDeps, } from "./dependencies.js";
92
93
  export * from "./graph/index.js";
93
94
  export { runDocs } from "./docs.js";
94
95
  export { runFiles, runFilesDiscover, runFilesLookup, } from "./files.js";
95
- export { applyPathMigrations, applyStandaloneNote, artifactKey, dedupeLinkedArtifacts, ensureScope, expandAddGlobEntries, normalizeLinkedPath, parseAddEntries, parseAddGlobEntries, parseMigrateEntries, parseRemoveEntries, renameArtifactsResultKey, runLinkedArtifacts, sortLinkedArtifacts, validateLinkedPaths, } from "./linked-artifacts.js";
96
+ export { applyPathMigrations, applyStandaloneNote, artifactKey, assertLinkedArtifactMutationIsUnambiguous, dedupeLinkedArtifacts, ensureScope, expandAddGlobEntries, normalizeLinkedPath, parseAddEntries, parseAddGlobEntries, parseMigrateEntries, parseRemoveEntries, renameArtifactsResultKey, runLinkedArtifacts, sortLinkedArtifacts, validateLinkedPaths, } from "./linked-artifacts.js";
96
97
  export * from "./pagination.js";
97
98
  export * from "./query/item-filter-options.js";
98
99
  export * from "./query/parsers.js";
@@ -119,7 +120,7 @@ export * from "./actionability.js";
119
120
  export { runCreate } from "./lifecycle/create.js";
120
121
  export { runPlan } from "./lifecycle/plan.js";
121
122
  export { runAppend } from "./lifecycle/append.js";
122
- export { runClaim, runClaimNext, runRelease } from "./lifecycle/claim.js";
123
+ export { isAlreadyClaimedError, runClaim, runClaimNext, runRelease, } from "./lifecycle/claim.js";
123
124
  export { runCloseMany } from "./lifecycle/close-many.js";
124
125
  export { runUpdateMany } from "./lifecycle/update-many.js";
125
126
  export { runComments } from "./comments.js";
@@ -150,4 +151,4 @@ export * from "./governance.js";
150
151
  export * from "./query.js";
151
152
  export * from "./testing.js";
152
153
  //# sourceMappingURL=index.js.map
153
- //# debugId=8c96c6f6-f711-559a-bb35-9eeaedc720aa
154
+ //# debugId=8664ab01-dc47-5344-b2d7-9ac315e8a74b
@@ -4,7 +4,7 @@
4
4
  * Implements the pm claim command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2e9b9321-a892-5bab-b6f8-4717fb5962df")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f70f1329-4dfb-5625-ae0a-66c858d88f7b")}catch(e){}}();
8
8
  import { pathExists, resolveRuntimeStatusRegistry, statusIsTerminal, EXIT_CODE, PmCliError, toItemRecord, mutateItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.js";
9
9
  import { wrapOwnershipConflict } from "../annotations.js";
10
10
  import { describeItemOwnershipConflict } from "../ownership-source.js";
@@ -14,7 +14,14 @@ import { recordClaimSemanticAttribution, recordReleaseSemanticAttribution, } fro
14
14
  export const NO_AVAILABLE_NEXT_ITEM_CODE = "no_available_next_item";
15
15
  /** Returns whether a failed claim lost the atomic test-and-set race. */
16
16
  export function isAlreadyClaimedError(error) {
17
- return (error instanceof PmCliError && error.context?.code === "already_claimed_by");
17
+ if (!(error instanceof Error) || error.name !== "PmCliError") {
18
+ return false;
19
+ }
20
+ const context = error.context;
21
+ return (typeof context === "object" &&
22
+ context !== null &&
23
+ "code" in context &&
24
+ context.code === "already_claimed_by");
18
25
  }
19
26
  /** Implements run claim for the public runtime surface of this module. */
20
27
  export async function runClaim(id, force, global, options = {}) {
@@ -230,4 +237,4 @@ export async function runRelease(id, force, global, options = {}) {
230
237
  };
231
238
  }
232
239
  //# sourceMappingURL=claim.js.map
233
- //# debugId=2e9b9321-a892-5bab-b6f8-4717fb5962df
240
+ //# debugId=f70f1329-4dfb-5625-ae0a-66c858d88f7b
@@ -115,6 +115,8 @@ export declare function parseRemoveEntries(raw: string[] | undefined): string[];
115
115
  export declare function parseMigrateEntries(raw: string[] | undefined): PathMigration[];
116
116
  /** Implements apply path migrations for the public runtime surface of this module. */
117
117
  export declare function applyPathMigrations(artifactPath: string, migrations: PathMigration[]): string;
118
+ /** Reject a transaction that resolves the same linked path into both add and remove sets. */
119
+ export declare function assertLinkedArtifactMutationIsUnambiguous(adds: LinkedArtifact[], removes: string[], migrations?: PathMigration[]): void;
118
120
  /** Implements normalize linked path for the public runtime surface of this module. */
119
121
  export declare function normalizeLinkedPath(value: string): string;
120
122
  /** Anchor a local linked path to the project workspace while preserving remote references and absolute paths. */
@@ -4,11 +4,11 @@
4
4
  * Implements the pm linked artifacts command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3fe80124-596b-591c-9f0d-fbbc129c6bb4")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="585364aa-e5ff-56b6-8276-8f741fbd6be4")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import fg from "fast-glob";
11
- import { pathExists } from "../core/fs/fs-utils.js";
11
+ import { isFileAbsentError, pathExists } from "../core/fs/fs-utils.js";
12
12
  import { getActiveExtensionRegistrations } from "../core/extensions/index.js";
13
13
  import { assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, parseCsvKv, } from "../core/item/parse.js";
14
14
  import { resolveItemTypeRegistry } from "../core/item/type-registry.js";
@@ -179,6 +179,30 @@ export function applyPathMigrations(artifactPath, migrations) {
179
179
  }
180
180
  return next;
181
181
  }
182
+ /** Reject a transaction that resolves the same linked path into both add and remove sets. */
183
+ export function assertLinkedArtifactMutationIsUnambiguous(adds, removes, migrations = []) {
184
+ if (adds.length === 0 || removes.length === 0) {
185
+ return;
186
+ }
187
+ const addedPaths = new Set(adds.map((entry) => applyPathMigrations(entry.path, migrations)));
188
+ const conflicts = [
189
+ ...new Set(removes
190
+ .map((entry) => applyPathMigrations(entry, migrations))
191
+ .filter((entry) => addedPaths.has(entry))),
192
+ ].sort((left, right) => left.localeCompare(right));
193
+ if (conflicts.length === 0) {
194
+ return;
195
+ }
196
+ throw new PmCliError(`Linked artifact mutation cannot add and remove the same normalized path in one transaction: ${conflicts.join(", ")}. Split the replacement into separate commands so each history event has one unambiguous intent.`, EXIT_CODE.USAGE, {
197
+ code: "linked_artifact_mutation_conflict",
198
+ reason: "same_path_added_and_removed",
199
+ required: "Use distinct normalized paths for --add and --remove in one invocation.",
200
+ why: "Conflicting batch intent cannot be applied deterministically without silently discarding metadata or a removal.",
201
+ nextSteps: [
202
+ "Run the removal and addition as separate commands with a --message describing each intent.",
203
+ ],
204
+ });
205
+ }
182
206
  /** Implements normalize linked path for the public runtime surface of this module. */
183
207
  export function normalizeLinkedPath(value) {
184
208
  return value.split(path.sep).join("/");
@@ -293,7 +317,7 @@ export async function validateLinkedPaths(paths, workspaceRoot = process.cwd())
293
317
  if (typeof error === "object" &&
294
318
  error !== null &&
295
319
  "code" in error &&
296
- error.code === "ENOENT") {
320
+ isFileAbsentError(error)) {
297
321
  missingPaths.push(relativePath);
298
322
  continue;
299
323
  }
@@ -384,6 +408,7 @@ export async function runLinkedArtifacts(id, options, global, config) {
384
408
  const adds = applyStandaloneNote([...parsedAdds, ...expandedGlobAdds], options.note, parsedAdds.length > 0 || addGlobs.length > 0);
385
409
  const removes = parseRemoveEntries(resolvedRemoves).map((entry) => anchorLinkedPath(entry, workspaceRoot, invocationRoot));
386
410
  const migrations = parseMigrateEntries(resolvedMigrations);
411
+ assertLinkedArtifactMutationIsUnambiguous(adds, removes, migrations);
387
412
  const shouldMutate = adds.length > 0 || removes.length > 0 || migrations.length > 0;
388
413
  if (!shouldMutate) {
389
414
  const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
@@ -454,4 +479,4 @@ export function renameArtifactsResultKey(result, key) {
454
479
  return out;
455
480
  }
456
481
  //# sourceMappingURL=linked-artifacts.js.map
457
- //# debugId=3fe80124-596b-591c-9f0d-fbbc129c6bb4
482
+ //# debugId=585364aa-e5ff-56b6-8276-8f741fbd6be4
@@ -30,8 +30,8 @@ export interface MergeDriverResult {
30
30
  artifact: MergeDriverArtifact;
31
31
  /** Path the merged content was written to. */
32
32
  output_path: string;
33
- /** Invocation-side preference retained for non-item artifact compatibility. */
34
- preferred: MergePreferredSide;
33
+ /** Invocation-side preference; per-decision retained values remain authoritative. */
34
+ requested_preference: MergePreferredSide;
35
35
  /** Unresolvable conflict labels: metadata field names (item), dotted key paths (json). Empty for history merges. */
36
36
  conflicts: string[];
37
37
  /** History-merge strategy and entry accounting; present only for the history artifact. */
@@ -9,7 +9,7 @@
9
9
  * merge never corrupts tracker storage the way raw conflict markers do.
10
10
  */
11
11
 
12
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e739a603-35c5-5df9-8d4b-3bbc0fe3e4fd")}catch(e){}}();
12
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8d79e3a4-6104-5855-837f-69a041b87b27")}catch(e){}}();
13
13
  import { readFile, writeFile } from "node:fs/promises";
14
14
  import path from "node:path";
15
15
  import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
@@ -179,7 +179,7 @@ export async function runMergeDriver(options, global) {
179
179
  ok: conflicts.length === 0,
180
180
  artifact,
181
181
  output_path: outputPath,
182
- preferred,
182
+ requested_preference: preferred,
183
183
  conflicts,
184
184
  ...result,
185
185
  guidance,
@@ -187,4 +187,4 @@ export async function runMergeDriver(options, global) {
187
187
  };
188
188
  }
189
189
  //# sourceMappingURL=driver.js.map
190
- //# debugId=e739a603-35c5-5df9-8d4b-3bbc0fe3e4fd
190
+ //# debugId=8d79e3a4-6104-5855-837f-69a041b87b27
@@ -8,7 +8,8 @@
8
8
  * mutations refresh the fenced block automatically once it is installed.
9
9
  */
10
10
 
11
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="94d2a7a8-ce00-5689-b2f6-3d4813234b55")}catch(e){}}();
11
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5e1810a5-04b8-5929-8eee-7a63f1684860")}catch(e){}}();
12
+ import { isFileMissingError } from "../../core/fs/fs-utils.js";
12
13
  import { readFile, realpath, writeFile } from "node:fs/promises";
13
14
  import { execFile } from "node:child_process";
14
15
  import path from "node:path";
@@ -253,7 +254,7 @@ async function reconcileGitattributesBlock(workspaceRoot, patterns, dryRun) {
253
254
  current = await readFile(gitattributesPath, "utf8");
254
255
  }
255
256
  catch (error) {
256
- if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
257
+ if (!(error instanceof Error && "code" in error && isFileMissingError(error))) {
257
258
  throw error;
258
259
  }
259
260
  }
@@ -414,7 +415,7 @@ export async function refreshMergeAttributeFenceIfInstalled(pmRoot) {
414
415
  catch (error) {
415
416
  if (error instanceof Error &&
416
417
  "code" in error &&
417
- error.code === "ENOENT") {
418
+ isFileMissingError(error)) {
418
419
  return { status: "not_installed", path: gitattributesPath };
419
420
  }
420
421
  throw error;
@@ -560,4 +561,4 @@ export async function installMergeFence(options) {
560
561
  };
561
562
  }
562
563
  //# sourceMappingURL=install.js.map
563
- //# debugId=94d2a7a8-ce00-5689-b2f6-3d4813234b55
564
+ //# debugId=5e1810a5-04b8-5929-8eee-7a63f1684860
@@ -9,8 +9,10 @@ export interface MergeDecisionReceipt {
9
9
  item_path: string;
10
10
  /** Item id derived from the merged document path. */
11
11
  item_id: string;
12
- /** Preferred side used for scalar conflicts. */
13
- preferred: MergePreferredSide;
12
+ /** Side requested by the caller; stable-value decisions can retain either side. */
13
+ requested_preference?: MergePreferredSide;
14
+ /** Legacy schema-v1 key accepted while reading older clone-local receipts. */
15
+ preferred?: MergePreferredSide;
14
16
  /** Scalar-conflict selection contract used by the item driver. */
15
17
  conflict_resolution: "preferred_side" | "stable_value_order";
16
18
  /** Fields selected cleanly from the other branch. */
@@ -42,8 +44,8 @@ export interface MergeDecisionReceiptSummary {
42
44
  fields_from_theirs: string[];
43
45
  /** Collections combined from both branches. */
44
46
  union_fields: string[];
45
- /** Preferred side used for scalar conflicts. */
46
- preferred: MergePreferredSide;
47
+ /** Side requested by the caller; decision hashes prove the actual retained values. */
48
+ requested_preference: MergePreferredSide;
47
49
  /** Scalar-conflict selection contract used by the item driver. */
48
50
  conflict_resolution: "preferred_side" | "stable_value_order";
49
51
  /** Hashes proving the retained and discarded values without publishing them. */