@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
@@ -4,13 +4,13 @@
4
4
  * Implements the pm gc 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]="0973a87f-2b63-5fa1-9624-82897d181f71")}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]="e982158e-4a8d-57a9-bd0b-24bd73aef342")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { runCheckpointGc } from "../../core/checkpoint/checkpoint-gc.js";
11
11
  import { runWorkspaceTransactionGc } from "../workspace-transaction-gc.js";
12
12
  import { runActiveOnIndexHooks, runActiveOnReadHooks, runActiveOnWriteHooks, } from "../../core/extensions/index.js";
13
- import { pathExists } from "../../core/fs/fs-utils.js";
13
+ import { isFileMissingError, pathExists } from "../../core/fs/fs-utils.js";
14
14
  import { runLockGc } from "../../core/lock/lock-gc.js";
15
15
  import { EXIT_CODE } from "../../core/shared/constants.js";
16
16
  import { PmCliError } from "../../core/shared/errors.js";
@@ -73,12 +73,6 @@ const GC_TARGETS = [
73
73
  kind: "file",
74
74
  },
75
75
  ];
76
- function isErrno(error, code) {
77
- return (typeof error === "object" &&
78
- error !== null &&
79
- "code" in error &&
80
- error.code === code);
81
- }
82
76
  async function removeCacheFile(pmRoot, target, dryRun) {
83
77
  const relativePath = target.relativePath;
84
78
  const absolutePath = path.join(pmRoot, relativePath);
@@ -123,7 +117,7 @@ async function removeCacheFile(pmRoot, target, dryRun) {
123
117
  };
124
118
  }
125
119
  catch (error) {
126
- if (isErrno(error, "ENOENT")) {
120
+ if (isFileMissingError(error)) {
127
121
  return {
128
122
  removed: false,
129
123
  warnings,
@@ -163,7 +157,7 @@ async function sweepWorkspaceSnapshotTemps(pmRoot, dryRun) {
163
157
  scope: "project",
164
158
  })));
165
159
  const stats = await fs.stat(absolutePath).catch((error) => {
166
- if (isErrno(error, "ENOENT")) {
160
+ if (isFileMissingError(error)) {
167
161
  return undefined;
168
162
  }
169
163
  throw error;
@@ -373,4 +367,4 @@ export async function runGc(global, options = {}) {
373
367
  };
374
368
  }
375
369
  //# sourceMappingURL=gc.js.map
376
- //# debugId=0973a87f-2b63-5fa1-9624-82897d181f71
370
+ //# debugId=e982158e-4a8d-57a9-bd0b-24bd73aef342
@@ -15,6 +15,8 @@ export interface HealthCheck {
15
15
  name: "settings" | "directories" | "settings_values" | "telemetry" | "extensions" | "storage" | "locks" | "integrity" | "history_drift" | "vectorization";
16
16
  /** Lifecycle state reported for status. */
17
17
  status: HealthStatus;
18
+ /** Boolean companion to status for direct agent and assurance predicates. */
19
+ ok: boolean;
18
20
  /** Value that configures or reports details for this contract. */
19
21
  details: Record<string, unknown>;
20
22
  }
@@ -113,7 +115,7 @@ interface ExtensionHealthTriageSummary {
113
115
  top_warnings: string[];
114
116
  remediation: string[];
115
117
  }
116
- /** Advisory warnings are surfaced for visibility but never flip overall health to not-ok. Telemetry is opt-out, non-critical observability: a queued/unreachable telemetry endpoint or corrupt local telemetry state is not a project-health failure and must not block agents that gate on `pm health` `ok`. History over-compaction-threshold warnings are likewise advisory maintenance hints — a deep stream is healthy, just a candidate for `pm history-compact`. */
118
+ /** Advisory warnings are surfaced for visibility but never flip overall health to not-ok. Telemetry is opt-out, non-critical observability: a queued/unreachable telemetry endpoint or corrupt local telemetry state is not a project-health failure and must not block agents that gate on `pm health` `ok`. History over-compaction-threshold warnings are likewise advisory maintenance hints — a deep stream is healthy, just a candidate for `pm history-compact`. Invalid legacy provenance values remain immutable diagnostic evidence: write-time resolvers reject new invalid values, while health reports the bounded aggregate without requiring truthful history to be rewritten. */
117
119
  declare function isAdvisoryHealthWarning(warning: string, requireMergeDrivers?: boolean): boolean;
118
120
  declare function warningCode(value: string): string;
119
121
  declare function normalizeExtensionNameForMatch(value: string): string;
@@ -4,11 +4,11 @@
4
4
  * Implements the pm health 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]="539b0cb4-5e20-51e2-a33e-1a43ca961f05")}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]="5cee1eaa-73f3-5709-867f-a8d73081da8b")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
11
- import { pathExists, readFileIfExists } from "../../core/fs/fs-utils.js";
11
+ import { isFileMissingError, pathExists, readFileIfExists } from "../../core/fs/fs-utils.js";
12
12
  import { activateExtensions, getActiveExtensionRegistrations, loadExtensions, runActiveOnReadHooks, } from "../../core/extensions/index.js";
13
13
  import { collectRegisteredItemFieldNames } from "../../core/extensions/item-fields.js";
14
14
  import { KNOWN_EXTENSION_CAPABILITIES, } from "../../core/extensions/loader.js";
@@ -54,12 +54,13 @@ const TELEMETRY_SERVER_MAX_SCHEMA_VERSION_HEADERS = [
54
54
  "x-pm-telemetry-max-schema-version",
55
55
  "x-pm-telemetry-max-version",
56
56
  ];
57
- /** Advisory warnings are surfaced for visibility but never flip overall health to not-ok. Telemetry is opt-out, non-critical observability: a queued/unreachable telemetry endpoint or corrupt local telemetry state is not a project-health failure and must not block agents that gate on `pm health` `ok`. History over-compaction-threshold warnings are likewise advisory maintenance hints — a deep stream is healthy, just a candidate for `pm history-compact`. */
57
+ /** Advisory warnings are surfaced for visibility but never flip overall health to not-ok. Telemetry is opt-out, non-critical observability: a queued/unreachable telemetry endpoint or corrupt local telemetry state is not a project-health failure and must not block agents that gate on `pm health` `ok`. History over-compaction-threshold warnings are likewise advisory maintenance hints — a deep stream is healthy, just a candidate for `pm history-compact`. Invalid legacy provenance values remain immutable diagnostic evidence: write-time resolvers reject new invalid values, while health reports the bounded aggregate without requiring truthful history to be rewritten. */
58
58
  function isAdvisoryHealthWarning(warning, requireMergeDrivers = false) {
59
59
  return (warning.startsWith("telemetry_") ||
60
60
  warning.startsWith("history_stream_over_compact_threshold:") ||
61
61
  warning.startsWith("stale_in_progress_items:") ||
62
62
  warning.startsWith("provenance_resolver_zero_success:") ||
63
+ warning.startsWith("provenance_value_domain_invalid:") ||
63
64
  (!requireMergeDrivers &&
64
65
  warning.startsWith("merge_driver_configuration_missing:")));
65
66
  }
@@ -206,7 +207,7 @@ async function listItemDocumentPaths(pmRoot, typeToFolder) {
206
207
  if (typeof error === "object" &&
207
208
  error !== null &&
208
209
  "code" in error &&
209
- error.code === "ENOENT") {
210
+ isFileMissingError(error)) {
210
211
  continue;
211
212
  }
212
213
  continue;
@@ -225,7 +226,7 @@ function shouldReportHistoryDirectoryUnreadable(error) {
225
226
  return !(typeof error === "object" &&
226
227
  error !== null &&
227
228
  "code" in error &&
228
- error.code === "ENOENT");
229
+ isFileMissingError(error));
229
230
  }
230
231
  async function scanItemIntegrity(pmRoot, typeToFolder, schema) {
231
232
  const paths = await listItemDocumentPaths(pmRoot, typeToFolder);
@@ -360,6 +361,7 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
360
361
  check: {
361
362
  name: "integrity",
362
363
  status: normalizedWarnings.length === 0 ? "ok" : "warn",
364
+ ok: normalizedWarnings.length === 0,
363
365
  details: {
364
366
  checked_item_files: itemScan.paths.length,
365
367
  checked_history_streams: historyScan.files.length,
@@ -703,6 +705,7 @@ async function buildExtensionCheck(pmRoot, settings, noExtensionsFlag) {
703
705
  check: {
704
706
  name: "extensions",
705
707
  status: extensionWarnings.length === 0 ? "ok" : "warn",
708
+ ok: extensionWarnings.length === 0,
706
709
  details: {
707
710
  ...loadResult,
708
711
  loaded: loadedSummaries,
@@ -951,6 +954,7 @@ function applyBriefHealthProjection(result) {
951
954
  checks: result.checks.map((check) => ({
952
955
  name: check.name,
953
956
  status: check.status,
957
+ ok: check.ok,
954
958
  details: summarizeHealthCheckDetails(check, BRIEF_HEALTH_DETAIL_LIMIT),
955
959
  })),
956
960
  warnings: warningsSummary.sample,
@@ -978,6 +982,7 @@ function applySummaryHealthProjection(result) {
978
982
  .map((check) => ({
979
983
  name: check.name,
980
984
  status: check.status,
985
+ ok: check.ok,
981
986
  details: {},
982
987
  })),
983
988
  warning_count: warningsSummary.count,
@@ -1261,6 +1266,7 @@ async function buildTelemetryCheck(settings, options) {
1261
1266
  check: {
1262
1267
  name: "telemetry",
1263
1268
  status: warnings.length === 0 ? "ok" : "warn",
1269
+ ok: warnings.length === 0,
1264
1270
  details: {
1265
1271
  enabled: settings.telemetry.enabled,
1266
1272
  capture_level: settings.telemetry.capture_level,
@@ -1306,6 +1312,7 @@ async function buildLocksCheck(pmRoot) {
1306
1312
  check: {
1307
1313
  name: "locks",
1308
1314
  status: "warn",
1315
+ ok: false,
1309
1316
  details: {
1310
1317
  active_lock_count: 0,
1311
1318
  stale_lock_count: 0,
@@ -1331,6 +1338,7 @@ async function buildLocksCheck(pmRoot) {
1331
1338
  check: {
1332
1339
  name: "locks",
1333
1340
  status: warnings.length === 0 ? "ok" : "warn",
1341
+ ok: warnings.length === 0,
1334
1342
  details: {
1335
1343
  active_lock_count: scan.active_lock_count,
1336
1344
  stale_lock_count: scan.stale_lock_count,
@@ -1354,6 +1362,7 @@ async function buildHistoryDriftCheck(pmRoot, items) {
1354
1362
  check: {
1355
1363
  name: "history_drift",
1356
1364
  status: warnings.length === 0 ? "ok" : "warn",
1365
+ ok: warnings.length === 0,
1357
1366
  details: {
1358
1367
  checked_items: items.length,
1359
1368
  cache_hit_verification: cacheHitVerification,
@@ -1519,6 +1528,7 @@ async function buildVectorizationCheck(pmRoot, settings, items, refreshPolicy, v
1519
1528
  check: {
1520
1529
  name: "vectorization",
1521
1530
  status: warnings.length === 0 ? "ok" : "warn",
1531
+ ok: warnings.length === 0,
1522
1532
  details: {
1523
1533
  semantic_runtime_available: snapshot.semanticRuntimeAvailable,
1524
1534
  compatibility_mode_auto_defaults: snapshot.runtimeDefaults.auto_ollama_defaults_applied,
@@ -1661,7 +1671,7 @@ async function readHealthItems(params) {
1661
1671
  }
1662
1672
  function buildSkippedHealthCheck(name) {
1663
1673
  return {
1664
- check: { name, status: "ok", details: { skipped: true } },
1674
+ check: { name, status: "ok", ok: true, details: { skipped: true } },
1665
1675
  warnings: [],
1666
1676
  };
1667
1677
  }
@@ -1670,6 +1680,7 @@ function buildSettingsHealthCheck(settingsPath, settings, normalizedSettingsRead
1670
1680
  name: "settings",
1671
1681
  /* c8 ignore next -- settings read-warning status split is covered in broader read-settings integration tests */
1672
1682
  status: normalizedSettingsReadWarnings.length === 0 ? "ok" : "warn",
1683
+ ok: normalizedSettingsReadWarnings.length === 0,
1673
1684
  details: {
1674
1685
  path: settingsPath,
1675
1686
  version: settings.version,
@@ -1683,6 +1694,7 @@ function buildDirectoriesHealthCheck(directoryState, strictDirectories) {
1683
1694
  return {
1684
1695
  name: "directories",
1685
1696
  status: directoryState.missingDirs.length === 0 ? "ok" : "warn",
1697
+ ok: directoryState.missingDirs.length === 0,
1686
1698
  details: {
1687
1699
  required: directoryState.requiredDirs,
1688
1700
  optional: directoryState.optionalDirs,
@@ -1697,6 +1709,7 @@ function buildSettingsValuesHealthCheck(settingWarnings) {
1697
1709
  return {
1698
1710
  name: "settings_values",
1699
1711
  status: settingWarnings.length === 0 ? "ok" : "warn",
1712
+ ok: settingWarnings.length === 0,
1700
1713
  details: { warnings: settingWarnings },
1701
1714
  };
1702
1715
  }
@@ -1719,6 +1732,10 @@ function buildStorageHealthCheck(items, settings, historySummary, authorAttribut
1719
1732
  !hasStaleInProgressItems
1720
1733
  ? "ok"
1721
1734
  : "warn",
1735
+ ok: historySummary.over_threshold.length === 0 &&
1736
+ historySummary.orphaned.length === 0 &&
1737
+ !hasActionableAuthorWarnings &&
1738
+ !hasStaleInProgressItems,
1722
1739
  details: {
1723
1740
  items: items.length,
1724
1741
  history_streams: historySummary.count,
@@ -1990,4 +2007,4 @@ export const _testOnlyHealthCommand = {
1990
2007
  warningCode,
1991
2008
  };
1992
2009
  //# sourceMappingURL=health.js.map
1993
- //# debugId=539b0cb4-5e20-51e2-a33e-1a43ca961f05
2010
+ //# debugId=5cee1eaa-73f3-5709-867f-a8d73081da8b
@@ -5,14 +5,14 @@
5
5
  * validation run.
6
6
  */
7
7
 
8
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="896ffe11-2cf1-5de0-8d07-5585d4f30c94")}catch(e){}}();
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="01f042d0-7f02-59f5-8894-cf48eb936d99")}catch(e){}}();
9
9
  import { listAllItemMetadata, listAllItemMetadataWithBody, } from "../../core/store/item-store.js";
10
10
  /** Load collections for normal checks and add bodies only when history hashes must be verified. */
11
11
  export async function readValidateItems(params) {
12
12
  if (params.includeBody) {
13
- return listAllItemMetadataWithBody(params.pmRoot, params.settings.item_format, params.typeToFolder, params.warnings, params.settings.schema);
13
+ return listAllItemMetadataWithBody(params.pmRoot, params.settings.item_format, params.typeToFolder, params.warnings, params.settings.schema, { forceSourceScan: true });
14
14
  }
15
15
  return listAllItemMetadata(params.pmRoot, params.settings.item_format, params.typeToFolder, params.warnings, params.settings.schema);
16
16
  }
17
17
  //# sourceMappingURL=validate-item-reader.js.map
18
- //# debugId=896ffe11-2cf1-5de0-8d07-5585d4f30c94
18
+ //# debugId=01f042d0-7f02-59f5-8894-cf48eb936d99
@@ -75,6 +75,8 @@ export interface ValidateCheck {
75
75
  name: ValidateCheckName;
76
76
  /** Lifecycle state reported for status. */
77
77
  status: ValidateStatus;
78
+ /** Direct machine predicate derived from whether status is ok. */
79
+ ok: boolean;
78
80
  /** Value that configures or reports details for this contract. */
79
81
  details: Record<string, unknown>;
80
82
  }
@@ -4,7 +4,7 @@
4
4
  * Implements the pm validate 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]="b5b7e497-f067-5504-9ffa-fd177997c518")}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]="7dd04a2f-1798-5c16-8740-5b7094f81cc0")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import { realpathSync } from "node:fs";
10
10
  import { execFile } from "node:child_process";
@@ -13,7 +13,7 @@ import { promisify } from "node:util";
13
13
  import { buildRemediationCommands } from "../../core/diagnostics/remediation.js";
14
14
  import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
15
15
  import { collectRegisteredItemFieldNames } from "../../core/extensions/item-fields.js";
16
- import { pathExists } from "../../core/fs/fs-utils.js";
16
+ import { isFileMissingError, pathExists } from "../../core/fs/fs-utils.js";
17
17
  import { scanHistoryDrift } from "../../core/history/drift-scan.js";
18
18
  import { normalizeStatusInput } from "../../core/item/status.js";
19
19
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
@@ -475,7 +475,7 @@ async function listFilesRecursive(basePath, relativePath, output) {
475
475
  entries = await fs.readdir(targetDirectory, { withFileTypes: true });
476
476
  }
477
477
  catch (error) {
478
- if (hasFilesystemErrorCode(error, ["ENOENT"])) {
478
+ if (isFileMissingError(error)) {
479
479
  return;
480
480
  }
481
481
  throw error;
@@ -913,6 +913,7 @@ function buildMetadataCheck(items, metadataPolicy, statusRegistry, verboseDiagno
913
913
  check: {
914
914
  name: "metadata",
915
915
  status: warningTokens.length === 0 ? "ok" : "warn",
916
+ ok: warningTokens.length === 0,
916
917
  details,
917
918
  },
918
919
  warnings: warningTokens,
@@ -957,6 +958,7 @@ function buildResolutionCheck(items, statusRegistry, verboseDiagnostics) {
957
958
  check: {
958
959
  name: "resolution",
959
960
  status: warnings.length === 0 ? "ok" : "warn",
961
+ ok: warnings.length === 0,
960
962
  details: {
961
963
  checked_closed_items: closedItems.length,
962
964
  missing_resolution_items: missingResolutionRows.length,
@@ -1026,6 +1028,7 @@ function buildDependencyReferencesCheck(items, verboseDiagnostics, statusRegistr
1026
1028
  check: {
1027
1029
  name: "dependency_references",
1028
1030
  status: activeRows.length === 0 ? "ok" : "warn",
1031
+ ok: activeRows.length === 0,
1029
1032
  details: {
1030
1033
  checked_items: items.length,
1031
1034
  dangling_reference_count: activeRows.length + legacyRows.length,
@@ -1582,6 +1585,7 @@ function buildLifecycleCheck(items, includeStaleBlockers, dependencyCycleSeverit
1582
1585
  : warnings.length === 0
1583
1586
  ? "ok"
1584
1587
  : "warn",
1588
+ ok: !hasErrorSeverityCycle && warnings.length === 0,
1585
1589
  details: {
1586
1590
  checked_active_items: rows.activeItems.length,
1587
1591
  active_closure_like_metadata_items: rows.closureLikeRows.length,
@@ -1709,6 +1713,7 @@ async function buildFilesCheck(items, workspaceRoot, pmRoot, fileScanMode, inclu
1709
1713
  check: {
1710
1714
  name: "files",
1711
1715
  status: warnings.length === 0 ? "ok" : "warn",
1716
+ ok: warnings.length === 0,
1712
1717
  details: {
1713
1718
  workspace_root: workspaceRoot,
1714
1719
  scan_mode_requested: fileCandidates.requestedMode,
@@ -1786,6 +1791,7 @@ async function buildHistoryDriftCheck(pmRoot, items, verboseDiagnostics) {
1786
1791
  check: {
1787
1792
  name: "history_drift",
1788
1793
  status: warnings.length === 0 ? "ok" : "warn",
1794
+ ok: warnings.length === 0,
1789
1795
  details: {
1790
1796
  checked_items: items.length,
1791
1797
  drifted_items_count: driftedItems.length,
@@ -1859,6 +1865,7 @@ function buildCommandReferencesCheck(items, idPrefix, verboseDiagnostics) {
1859
1865
  check: {
1860
1866
  name: "command_references",
1861
1867
  status: warnings.length === 0 ? "ok" : "warn",
1868
+ ok: warnings.length === 0,
1862
1869
  details: {
1863
1870
  checked_items: items.length,
1864
1871
  linked_commands_scanned: linkedCommandsScanned,
@@ -1905,6 +1912,7 @@ function buildFormatVersionCheck(items, verboseDiagnostics) {
1905
1912
  check: {
1906
1913
  name: "format_version",
1907
1914
  status,
1915
+ ok: status === "ok",
1908
1916
  details: {
1909
1917
  checked_items: items.length,
1910
1918
  current_format_version: CURRENT_ITEM_FORMAT_VERSION,
@@ -2108,13 +2116,15 @@ async function buildStorageIntegrityCheck(pmRoot, items, typeToFolder, settings)
2108
2116
  if (pendingMergeDecisions.length > 0) {
2109
2117
  warnings.push(`validate_merge_decisions_unreviewed:${pendingMergeDecisions.length}`);
2110
2118
  }
2119
+ const status = errorCount > 0 ? "error" : warnings.length > 0 ? "warn" : "ok";
2111
2120
  return {
2112
2121
  check: {
2113
2122
  name: "storage_integrity",
2114
2123
  // Corruption findings fail the check; fence drift alone is a warning —
2115
2124
  // the workspace data is intact, but future merges of uncovered paths
2116
2125
  // would fall back to git's default text driver.
2117
- status: errorCount > 0 ? "error" : warnings.length > 0 ? "warn" : "ok",
2126
+ status,
2127
+ ok: status === "ok",
2118
2128
  details: {
2119
2129
  ...scan,
2120
2130
  merge_fence: fenceAudit,
@@ -2346,4 +2356,4 @@ export async function runValidate(options, global, services = {}) {
2346
2356
  }
2347
2357
  /* c8 ignore stop */
2348
2358
  //# sourceMappingURL=validate.js.map
2349
- //# debugId=b5b7e497-f067-5504-9ffa-fd177997c518
2359
+ //# debugId=7dd04a2f-1798-5c16-8740-5b7094f81cc0
@@ -1,4 +1,4 @@
1
- import type { RelationshipAuditSnapshot } from "./governance.js";
1
+ import { type RelationshipAuditSnapshot } from "./governance.js";
2
2
  /** Envelope format version; any change invalidates persisted entries. */
3
3
  export declare const GRAPH_DURABLE_CACHE_VERSION = 1;
4
4
  /** Workspaces below this item count skip implicit persistence. */
@@ -15,10 +15,12 @@
15
15
  * threshold or after an explicit `pm graph index --rebuild` opt-in.
16
16
  */
17
17
 
18
- !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]="ee260dcf-f4df-5997-a8d7-691c19c66a41")}catch(e){}}();
18
+ !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]="2f7f14e3-6d41-5f45-a560-ebfbb8aa5828")}catch(e){}}();
19
19
  import path from "node:path";
20
20
  import { readFileIfExists, removeFileIfExists, writeFileAtomic, } from "../../core/fs/fs-utils.js";
21
21
  import { acquireLock } from "../../core/lock/lock.js";
22
+ import { isSemanticContextKind, } from "./governance.js";
23
+ import { RELATIONSHIP_AUDIT_FINDING_CODES } from "./governance-contracts.js";
22
24
  /** Envelope format version; any change invalidates persisted entries. */
23
25
  export const GRAPH_DURABLE_CACHE_VERSION = 1;
24
26
  /** Workspaces below this item count skip implicit persistence. */
@@ -140,19 +142,127 @@ export function shouldPersistDurableGraphCache(itemCount, envelopeExists) {
140
142
  }
141
143
  /** Return whether a decoded value is a string-keyed non-negative integer count map. */
142
144
  function isNonnegativeCountRecord(value) {
143
- return (typeof value === "object" &&
144
- value !== null &&
145
- !Array.isArray(value) &&
146
- Object.values(value).every((count) => Number.isInteger(count) && count >= 0));
145
+ return isRecord(value) && Object.values(value).every(isNonnegativeInteger);
146
+ }
147
+ /** Return whether a decoded value is a non-array record. */
148
+ function isRecord(value) {
149
+ return typeof value === "object" && value !== null && !Array.isArray(value);
150
+ }
151
+ /** Return whether a decoded value is a non-negative integer. */
152
+ function isNonnegativeInteger(value) {
153
+ return Number.isInteger(value) && Number(value) >= 0;
154
+ }
155
+ /** Return whether a decoded value is a finite share in the inclusive unit interval. */
156
+ function isUnitShare(value) {
157
+ return (typeof value === "number" &&
158
+ Number.isFinite(value) &&
159
+ value >= 0 &&
160
+ value <= 1);
161
+ }
162
+ /** Apply a validator only when an optional decoded value is present. */
163
+ function isOptionalValid(value, validate) {
164
+ return value === undefined || validate(value);
165
+ }
166
+ /** Return whether a decoded record contains finite shares in the inclusive unit interval. */
167
+ function isUnitShareRecord(value) {
168
+ return isRecord(value) && Object.values(value).every(isUnitShare);
147
169
  }
148
170
  /** Return whether every decoded item-type coverage entry contains valid counts. */
149
171
  function isNonnegativeCoverageByTypeRecord(value) {
150
- if (typeof value !== "object" || value === null || Array.isArray(value))
172
+ if (!isRecord(value))
151
173
  return false;
152
- return Object.values(value).every((entry) => typeof entry === "object" &&
153
- entry !== null &&
154
- !Array.isArray(entry) &&
155
- [entry.active, entry.isolated, entry.degree_leq_one].every((count) => Number.isInteger(count) && count >= 0));
174
+ return Object.values(value).every((entry) => isRecord(entry) &&
175
+ [entry.active, entry.isolated, entry.degree_leq_one].every(isNonnegativeInteger));
176
+ }
177
+ /** Decode optional structural fields while normalizing pre-structure baselines. */
178
+ function decodeStructuralProfile(profile, affectedSubjectsByCode) {
179
+ const countFields = [
180
+ "articulation_points",
181
+ "bridge_edges",
182
+ "outcome_nodes",
183
+ "active_outcome_reachable_nodes",
184
+ "active_outcome_unreachable_nodes",
185
+ "terminal_nodes",
186
+ "terminal_outcome_reachable_nodes",
187
+ "terminal_outcome_unreachable_nodes",
188
+ "outcome_reachable_nodes",
189
+ "outcome_unreachable_nodes",
190
+ ];
191
+ const rateFields = [
192
+ "active_outcome_reachability_basis_points",
193
+ "terminal_outcome_reachability_basis_points",
194
+ "outcome_reachability_basis_points",
195
+ ];
196
+ const introducedStructuralFields = [
197
+ ...countFields,
198
+ ...rateFields,
199
+ "finding_subjects_by_code",
200
+ ];
201
+ const introducedStructuralFieldCount = introducedStructuralFields.filter((field) => profile[field] !== undefined).length;
202
+ if (introducedStructuralFieldCount !== 0 &&
203
+ introducedStructuralFieldCount !== introducedStructuralFields.length) {
204
+ return undefined;
205
+ }
206
+ const validCounts = countFields.every((field) => profile[field] === undefined || isNonnegativeInteger(profile[field]));
207
+ const validRates = rateFields.every((field) => profile[field] === undefined ||
208
+ (isNonnegativeInteger(profile[field]) && Number(profile[field]) <= 10_000));
209
+ if (!validCounts || !validRates)
210
+ return undefined;
211
+ if (profile.edge_basis !== undefined &&
212
+ profile.edge_basis !== "deduplicated_directed")
213
+ return undefined;
214
+ if (!isOptionalValid(profile.finding_subjects_by_code, isNonnegativeCountRecord))
215
+ return undefined;
216
+ const findingSubjects = isNonnegativeCountRecord(profile.finding_subjects_by_code)
217
+ ? profile.finding_subjects_by_code
218
+ : {};
219
+ return {
220
+ edge_basis: "deduplicated_directed",
221
+ ...Object.fromEntries(countFields.map((field) => [field, profile[field] ?? 0])),
222
+ ...Object.fromEntries(rateFields.map((field) => [field, profile[field] ?? 0])),
223
+ finding_subjects_by_code: Object.fromEntries(RELATIONSHIP_AUDIT_FINDING_CODES.map((code) => [
224
+ code,
225
+ findingSubjects[code] ?? affectedSubjectsByCode[code] ?? 0,
226
+ ])),
227
+ };
228
+ }
229
+ /** Decode and cross-check optional graph-composition fields as one coherent unit. */
230
+ function decodeGraphComposition(edges, edgesByKind, edgeShareByKind, semanticEdgesValue, semanticEdgeShareValue) {
231
+ const values = [
232
+ edgeShareByKind,
233
+ semanticEdgesValue,
234
+ semanticEdgeShareValue,
235
+ ];
236
+ const presentCount = values.filter((value) => value !== undefined).length;
237
+ if (presentCount === 0) {
238
+ return {
239
+ edge_share_by_kind: {},
240
+ semantic_edges: 0,
241
+ semantic_edge_share: 0,
242
+ };
243
+ }
244
+ if (presentCount !== values.length ||
245
+ !isUnitShareRecord(edgeShareByKind) ||
246
+ !isNonnegativeInteger(semanticEdgesValue) ||
247
+ !isUnitShare(semanticEdgeShareValue)) {
248
+ return undefined;
249
+ }
250
+ const edgeEntries = Object.entries(edgesByKind);
251
+ if (edgeEntries.reduce((sum, [, count]) => sum + count, 0) !== edges ||
252
+ Object.keys(edgeShareByKind).length !== edgeEntries.length ||
253
+ edgeEntries.some(([kind, count]) => edgeShareByKind[kind] !== (edges === 0 ? 0 : count / edges))) {
254
+ return undefined;
255
+ }
256
+ const semanticEdges = edgeEntries.reduce((sum, [kind, count]) => sum + (isSemanticContextKind(kind) ? count : 0), 0);
257
+ if (semanticEdgesValue !== semanticEdges ||
258
+ semanticEdgeShareValue !== (edges === 0 ? 0 : semanticEdges / edges)) {
259
+ return undefined;
260
+ }
261
+ return {
262
+ edge_share_by_kind: edgeShareByKind,
263
+ semantic_edges: semanticEdgesValue,
264
+ semantic_edge_share: semanticEdgeShareValue,
265
+ };
156
266
  }
157
267
  /** Decode one persisted audit census baseline, undefined on any defect. */
158
268
  function decodeBaseline(raw) {
@@ -160,32 +270,49 @@ function decodeBaseline(raw) {
160
270
  return undefined;
161
271
  try {
162
272
  const parsed = JSON.parse(raw);
163
- if (typeof parsed !== "object" || parsed === null)
273
+ if (!isRecord(parsed))
164
274
  return undefined;
165
275
  const snapshot = parsed;
166
276
  const profile = snapshot.profile;
167
- if (typeof snapshot.saved_at !== "string" ||
168
- typeof snapshot.fingerprint !== "string" ||
169
- !isNonnegativeCountRecord(snapshot.affected_subjects_by_code) ||
170
- typeof profile !== "object" ||
171
- profile === null ||
172
- ![
173
- profile.nodes,
174
- profile.edges,
175
- profile.active_nodes,
176
- profile.missing_nodes,
177
- profile.isolated_active_nodes,
178
- profile.degree_leq_one_active_nodes,
179
- ].every((value) => Number.isInteger(value) && value >= 0) ||
180
- !isNonnegativeCountRecord(profile.edges_by_kind) ||
181
- (profile.coverage_by_type !== undefined &&
182
- !isNonnegativeCoverageByTypeRecord(profile.coverage_by_type)))
277
+ if (typeof snapshot.saved_at !== "string")
278
+ return undefined;
279
+ if (typeof snapshot.fingerprint !== "string")
280
+ return undefined;
281
+ const affectedSubjectsByCode = snapshot.affected_subjects_by_code;
282
+ if (!isNonnegativeCountRecord(affectedSubjectsByCode)) {
283
+ return undefined;
284
+ }
285
+ if (!isRecord(profile))
286
+ return undefined;
287
+ if (![
288
+ profile.nodes,
289
+ profile.edges,
290
+ profile.active_nodes,
291
+ profile.missing_nodes,
292
+ profile.isolated_active_nodes,
293
+ profile.degree_leq_one_active_nodes,
294
+ ].every(isNonnegativeInteger)) {
295
+ return undefined;
296
+ }
297
+ if (!isNonnegativeCountRecord(profile.edges_by_kind))
298
+ return undefined;
299
+ if (!isOptionalValid(profile.coverage_by_type, isNonnegativeCoverageByTypeRecord)) {
300
+ return undefined;
301
+ }
302
+ const composition = decodeGraphComposition(profile.edges, profile.edges_by_kind, profile.edge_share_by_kind, profile.semantic_edges, profile.semantic_edge_share);
303
+ if (composition === undefined)
304
+ return undefined;
305
+ const structural = decodeStructuralProfile(profile, affectedSubjectsByCode);
306
+ if (structural === undefined)
183
307
  return undefined;
308
+ const { coverage_by_type = {} } = profile;
184
309
  return {
185
310
  ...snapshot,
186
311
  profile: {
187
312
  ...profile,
188
- coverage_by_type: profile.coverage_by_type ?? {},
313
+ ...composition,
314
+ ...structural,
315
+ coverage_by_type,
189
316
  },
190
317
  };
191
318
  }
@@ -202,4 +329,4 @@ export async function saveGraphAuditBaseline(pmRoot, snapshot) {
202
329
  await writeFileAtomic(graphAuditBaselinePath(pmRoot), JSON.stringify(snapshot));
203
330
  }
204
331
  //# sourceMappingURL=durable-cache.js.map
205
- //# debugId=ee260dcf-f4df-5997-a8d7-691c19c66a41
332
+ //# debugId=2f7f14e3-6d41-5f45-a560-ebfbb8aa5828
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module sdk/graph/governance-contracts
3
+ *
4
+ * Shared, runtime-visible relationship-audit finding identifiers used by the
5
+ * live audit and backward-compatible durable baseline decoder. Keeping the
6
+ * tuple authoritative prevents the public type and persisted zero census from
7
+ * drifting when a finding family is added.
8
+ */
9
+ /** Stable machine-readable relationship audit finding families. */
10
+ export declare const RELATIONSHIP_AUDIT_FINDING_CODES: readonly ["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"];
11
+ /** Machine-readable identifier for one relationship audit finding family. */
12
+ export type RelationshipAuditFindingCode = (typeof RELATIONSHIP_AUDIT_FINDING_CODES)[number];
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @module sdk/graph/governance-contracts
3
+ *
4
+ * Shared, runtime-visible relationship-audit finding identifiers used by the
5
+ * live audit and backward-compatible durable baseline decoder. Keeping the
6
+ * tuple authoritative prevents the public type and persisted zero census from
7
+ * drifting when a finding family is added.
8
+ */
9
+ /** Stable machine-readable relationship audit finding families. */
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]="a2043b27-3dfe-5da8-a10f-d92ff33f3c28")}catch(e){}}();
12
+ export const RELATIONSHIP_AUDIT_FINDING_CODES = [
13
+ "missing_reference_active",
14
+ "missing_reference_terminal",
15
+ "legacy_no_blocker_sentinel",
16
+ "ordering_cycle",
17
+ "legacy_ordering_cycle",
18
+ "duplicate_edge",
19
+ "legacy_duplicate_edge",
20
+ "duplicate_dependency_row",
21
+ "legacy_duplicate_dependency_row",
22
+ "stale_lifecycle_block",
23
+ "isolated_active_node",
24
+ "sparse_active_node",
25
+ ];
26
+ //# sourceMappingURL=governance-contracts.js.map
27
+ //# debugId=a2043b27-3dfe-5da8-a10f-d92ff33f3c28