@unbrained/pm-cli 2026.8.21 → 2026.8.23

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 (228) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +44 -0
  3. package/dist/cli/error-guidance.d.ts +22 -4
  4. package/dist/cli/error-guidance.js +73 -16
  5. package/dist/cli/main.d.ts +3 -0
  6. package/dist/cli/main.js +51 -9
  7. package/dist/cli/register-mutation.js +6 -6
  8. package/dist/cli/register-operations.d.ts +73 -0
  9. package/dist/cli/register-operations.js +39 -14
  10. package/dist/cli/register-setup.js +3 -3
  11. package/dist/cli/schema-registration-helpers.d.ts +8 -1
  12. package/dist/cli/schema-registration-helpers.js +14 -5
  13. package/dist/cli-bundle/bundle-manifest.json +149 -149
  14. package/dist/cli-bundle/chunks/chunk-3ENVHX6C.js +36 -0
  15. package/dist/cli-bundle/chunks/{chunk-LOVTQ52Z.js → chunk-DW2CGEMU.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-EG6CLDZT.js +5 -0
  17. package/dist/cli-bundle/chunks/{chunk-LARJJ3RK.js → chunk-F3AI2JFL.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-N3DSV4CH.js → chunk-HWZ6CELB.js} +8 -8
  19. package/dist/cli-bundle/chunks/chunk-HZBMLSZI.js +201 -0
  20. package/dist/cli-bundle/chunks/chunk-JB4KZWBF.js +3 -0
  21. package/dist/cli-bundle/chunks/chunk-KPH73XXJ.js +2 -0
  22. package/dist/cli-bundle/chunks/{chunk-BKYB45NQ.js → chunk-KXPMB2YL.js} +50 -50
  23. package/dist/cli-bundle/chunks/{chunk-BUNIEJNE.js → chunk-QDVHNHAQ.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-TFI5V5N2.js +13 -0
  25. package/dist/cli-bundle/chunks/{register-list-query-F57EWDEF.js → register-list-query-UJB5FMV2.js} +2 -2
  26. package/dist/cli-bundle/chunks/register-mutation-NX5XE4VX.js +20 -0
  27. package/dist/cli-bundle/chunks/register-operations-RXIJIYXC.js +2 -0
  28. package/dist/cli-bundle/chunks/{register-setup-HXU7IZZD.js → register-setup-GFUZEKRE.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-F4YEW5I2.js → chunk-37Z4OEAP.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/chunk-3UPTYG44.js +8 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-5S7E72FY.js +16 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-4ERLO7QD.js → chunk-AUFH5H35.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-E7X25GC3.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-FQCSTBWE.js +4 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-FH6DYED3.js → chunk-FZS4H32O.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/chunk-IFLWKY2R.js +156 -0
  37. package/dist/cli-bundle/focused-chunks/{chunk-YKBKIEAJ.js → chunk-JOWDB2MH.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-LYVSW5VM.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-MRCNF3U6.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-UZE7XUZK.js → chunk-OFVUGTLJ.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-FJ22HNRP.js → chunk-OGLQBL46.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/chunk-OY7QAV4Y.js +51 -0
  43. package/dist/cli-bundle/focused-chunks/chunk-QGFNI65N.js +26 -0
  44. package/dist/cli-bundle/focused-chunks/{chunk-KDNG7TKQ.js → chunk-R27IDGHD.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/chunk-UYRFYCDQ.js +5 -0
  46. package/dist/cli-bundle/focused-chunks/{chunk-2NIY5NKG.js → chunk-ZHVA42R5.js} +9 -9
  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 +2 -2
  50. package/dist/cli-bundle/sdk-core.js +40 -40
  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 +33 -32
  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 +5 -5
  58. package/dist/core/config/nested-settings.js +8 -2
  59. package/dist/core/config/positional-value.d.ts +1 -1
  60. package/dist/core/config/positional-value.js +5 -2
  61. package/dist/core/extensions/extension-hook-runtime.js +22 -20
  62. package/dist/core/extensions/extension-types.d.ts +8 -1
  63. package/dist/core/extensions/extension-types.js +2 -2
  64. package/dist/core/extensions/loader.js +7 -3
  65. package/dist/core/extensions/service-ownership.d.ts +8 -0
  66. package/dist/core/extensions/service-ownership.js +20 -0
  67. package/dist/core/history/history.js +3 -3
  68. package/dist/core/item/id.js +20 -5
  69. package/dist/core/item/item-format.js +81 -2
  70. package/dist/core/reproducibility/context.d.ts +4 -0
  71. package/dist/core/reproducibility/context.js +14 -8
  72. package/dist/core/shared/author.d.ts +55 -1
  73. package/dist/core/shared/author.js +333 -16
  74. package/dist/core/shared/constants.js +3 -2
  75. package/dist/core/shared/errors.d.ts +4 -0
  76. package/dist/core/shared/errors.js +2 -2
  77. package/dist/core/store/settings-validator.d.ts +1 -0
  78. package/dist/core/store/settings-validator.js +6 -3
  79. package/dist/core/store/settings.js +5 -2
  80. package/dist/mcp/server.d.ts +1 -1
  81. package/dist/mcp/server.js +30 -9
  82. package/dist/sdk/agent/identity-config.d.ts +63 -0
  83. package/dist/sdk/agent/identity-config.js +107 -0
  84. package/dist/sdk/agent/refusal-corpus-contracts.d.ts +76 -0
  85. package/dist/sdk/agent/refusal-corpus-contracts.js +194 -0
  86. package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
  87. package/dist/sdk/authoring.d.ts +1 -1
  88. package/dist/sdk/authoring.js +2 -2
  89. package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +77 -0
  90. package/dist/sdk/cli-contracts/agent-output-contracts.js +326 -2
  91. package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -3
  92. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -0
  93. package/dist/sdk/cli-contracts/enum-contracts.js +9 -2
  94. package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
  95. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +4 -4
  96. package/dist/sdk/cli-contracts/registration-helpers.js +5 -2
  97. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
  98. package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
  99. package/dist/sdk/cli-contracts/tool-parameter-tables.js +22 -2
  100. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  101. package/dist/sdk/cli-contracts/tool-schema.js +14 -3
  102. package/dist/sdk/cli-contracts.d.ts +4 -4
  103. package/dist/sdk/cli-contracts.js +5 -5
  104. package/dist/sdk/config.d.ts +6 -1
  105. package/dist/sdk/config.js +119 -14
  106. package/dist/sdk/context-intent-contracts.js +4 -2
  107. package/dist/sdk/core-governance.d.ts +1 -1
  108. package/dist/sdk/core-governance.js +3 -3
  109. package/dist/sdk/extension/install-sources.d.ts +1 -1
  110. package/dist/sdk/extension/install-sources.js +6 -3
  111. package/dist/sdk/extension/output-ownership.d.ts +1 -0
  112. package/dist/sdk/extension/output-ownership.js +3 -2
  113. package/dist/sdk/extension/scaffold.js +11 -5
  114. package/dist/sdk/flag-invocation-contracts.js +4 -2
  115. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +74 -2
  116. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +87 -26
  117. package/dist/sdk/governance/assurance-action.js +30 -10
  118. package/dist/sdk/governance/health.d.ts +3 -0
  119. package/dist/sdk/governance/health.js +39 -7
  120. package/dist/sdk/governance/hierarchy-validation.d.ts +29 -0
  121. package/dist/sdk/governance/hierarchy-validation.js +109 -0
  122. package/dist/sdk/governance/validate.d.ts +3 -9
  123. package/dist/sdk/governance/validate.js +84 -111
  124. package/dist/sdk/graph/assembly.d.ts +6 -1
  125. package/dist/sdk/graph/assembly.js +16 -22
  126. package/dist/sdk/graph/governance-contracts.d.ts +1 -1
  127. package/dist/sdk/graph/governance-contracts.js +8 -2
  128. package/dist/sdk/graph/governance.js +46 -2
  129. package/dist/sdk/graph/hierarchy-integrity.d.ts +94 -0
  130. package/dist/sdk/graph/hierarchy-integrity.js +311 -0
  131. package/dist/sdk/graph/index.d.ts +2 -1
  132. package/dist/sdk/graph/index.js +3 -2
  133. package/dist/sdk/graph/remediation.js +32 -2
  134. package/dist/sdk/graph/run.d.ts +31 -2
  135. package/dist/sdk/graph/run.js +80 -31
  136. package/dist/sdk/graph/workspace-relationship-kind-registry.d.ts +8 -0
  137. package/dist/sdk/graph/workspace-relationship-kind-registry.js +28 -0
  138. package/dist/sdk/index.d.ts +8 -3
  139. package/dist/sdk/index.js +9 -4
  140. package/dist/sdk/item-children.js +21 -8
  141. package/dist/sdk/lifecycle/create.js +129 -97
  142. package/dist/sdk/lifecycle/hierarchy-mutation-lock.d.ts +15 -0
  143. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +25 -0
  144. package/dist/sdk/lifecycle/update.d.ts +2 -0
  145. package/dist/sdk/lifecycle/update.js +174 -84
  146. package/dist/sdk/merge/three-way.js +105 -26
  147. package/dist/sdk/query/complete-list.d.ts +3 -3
  148. package/dist/sdk/query/complete-list.js +46 -3
  149. package/dist/sdk/query/list.d.ts +4 -3
  150. package/dist/sdk/query/list.js +89 -49
  151. package/dist/sdk/read-output-budget.d.ts +21 -0
  152. package/dist/sdk/read-output-budget.js +39 -2
  153. package/dist/sdk/read-output-contracts.d.ts +10 -4
  154. package/dist/sdk/read-output-contracts.js +105 -32
  155. package/dist/sdk/relationship-context.js +3 -4
  156. package/dist/sdk/relationships.js +17 -10
  157. package/dist/sdk/reproducibility/process.d.ts +19 -0
  158. package/dist/sdk/reproducibility/process.js +88 -0
  159. package/dist/sdk/runtime-primitives.d.ts +1 -1
  160. package/dist/sdk/runtime-primitives.js +3 -3
  161. package/dist/sdk/runtime.d.ts +3 -2
  162. package/dist/sdk/runtime.js +7 -5
  163. package/dist/sdk/test/batch.d.ts +6 -0
  164. package/dist/sdk/test/batch.js +26 -6
  165. package/dist/sdk/test/entry.d.ts +1 -1
  166. package/dist/sdk/test/entry.js +3 -2
  167. package/dist/sdk/test/execution.d.ts +28 -3
  168. package/dist/sdk/test/execution.js +201 -34
  169. package/dist/sdk/test/parsers.d.ts +6 -0
  170. package/dist/sdk/test/parsers.js +21 -2
  171. package/dist/sdk/test/trust.d.ts +33 -0
  172. package/dist/sdk/test/trust.js +207 -0
  173. package/dist/types.d.ts +34 -0
  174. package/dist/types.js +2 -2
  175. package/docs/AGENT_PROVENANCE_ADR.md +41 -5
  176. package/docs/AGENT_UX_CONTRACTS.md +20 -4
  177. package/docs/COMMANDS.md +29 -14
  178. package/docs/CONFIGURATION.md +4 -0
  179. package/docs/DEPENDENCY_KIND_CONTRACT.md +31 -3
  180. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +115 -0
  181. package/docs/EXTENSIONS.md +2 -1
  182. package/docs/MERGE_SAFETY.md +15 -1
  183. package/docs/README.md +1 -0
  184. package/docs/READ_OUTPUT_CONTRACTS.md +19 -2
  185. package/docs/RELATIONSHIP_GRAPH.md +6 -3
  186. package/docs/REPRODUCIBLE_WORKSPACES.md +42 -8
  187. package/docs/SDK.md +9 -0
  188. package/docs/SDK_AGENT_SESSION_CONTEXT.md +6 -4
  189. package/docs/SDK_EVIDENCE_TRACEABILITY.md +1 -1
  190. package/docs/TESTING.md +83 -1
  191. package/docs/agent-task-token-baseline.json +2 -2
  192. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  193. package/marketplace.json +2 -2
  194. package/package.json +2 -2
  195. package/packages/pm-beads/package.json +1 -1
  196. package/packages/pm-calendar/package.json +1 -1
  197. package/packages/pm-command-kit/package.json +1 -1
  198. package/packages/pm-digital-twin/package.json +1 -1
  199. package/packages/pm-governance-audit/package.json +1 -1
  200. package/packages/pm-guide-shell/package.json +1 -1
  201. package/packages/pm-kanban/package.json +1 -1
  202. package/packages/pm-lifecycle-hooks/package.json +1 -1
  203. package/packages/pm-linked-test-adapters/package.json +1 -1
  204. package/packages/pm-search-advanced/package.json +1 -1
  205. package/packages/pm-templates/package.json +1 -1
  206. package/packages/pm-todos/package.json +1 -1
  207. package/packages/pm-vcs/package.json +1 -1
  208. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  209. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  210. package/sdk/public-surface.json +1021 -53
  211. package/dist/cli-bundle/chunks/chunk-2MA6ZQVZ.js +0 -197
  212. package/dist/cli-bundle/chunks/chunk-3AFAUHUE.js +0 -2
  213. package/dist/cli-bundle/chunks/chunk-7VHZS727.js +0 -5
  214. package/dist/cli-bundle/chunks/chunk-JSLOFXGA.js +0 -3
  215. package/dist/cli-bundle/chunks/chunk-OCLPLFAY.js +0 -35
  216. package/dist/cli-bundle/chunks/chunk-S4IRYKBU.js +0 -13
  217. package/dist/cli-bundle/chunks/register-mutation-7IY2D5KO.js +0 -20
  218. package/dist/cli-bundle/chunks/register-operations-FALL3YTU.js +0 -2
  219. package/dist/cli-bundle/focused-chunks/chunk-7WZRLCYF.js +0 -50
  220. package/dist/cli-bundle/focused-chunks/chunk-CKKQSJNN.js +0 -2
  221. package/dist/cli-bundle/focused-chunks/chunk-EEFKYMDR.js +0 -16
  222. package/dist/cli-bundle/focused-chunks/chunk-F2A56DHV.js +0 -8
  223. package/dist/cli-bundle/focused-chunks/chunk-FV5ACOK7.js +0 -2
  224. package/dist/cli-bundle/focused-chunks/chunk-JEAVFOWM.js +0 -2
  225. package/dist/cli-bundle/focused-chunks/chunk-NJ63LOP6.js +0 -155
  226. package/dist/cli-bundle/focused-chunks/chunk-NXRTQ7HI.js +0 -2
  227. package/dist/cli-bundle/focused-chunks/chunk-TJ7EMJ46.js +0 -4
  228. package/dist/cli-bundle/focused-chunks/chunk-ZOSEELYJ.js +0 -26
@@ -4,7 +4,7 @@
4
4
  * Classifies output overrides against manifest-declared command ownership.
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]="0dc7b063-dc72-595f-8e40-8a06f9db69e1")}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]="e5a4cea9-ac5d-5bda-9f7c-6cf8cf9e9998")}catch(e){}}();
8
8
  import { normalizeExtensionNameForMatch } from "./shared.js";
9
9
  /** Collect doctor warnings for output overrides without an explicit command or result ownership boundary. */
10
10
  export function collectGlobalOutputOverrideDoctorWarnings(activationResult, loadResult) {
@@ -13,6 +13,7 @@ export function collectGlobalOutputOverrideDoctorWarnings(activationResult, load
13
13
  : []));
14
14
  const serviceWarnings = activationResult.services.overrides
15
15
  .filter((entry) => entry.service === "output_format")
16
+ .filter((entry) => entry.passThrough !== true)
16
17
  .filter((entry) => !commandScopedOwners.has(`${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`))
17
18
  .map((entry) => `extension_output_service_override_global:${entry.service}:${entry.layer}:${entry.name}`);
18
19
  const rendererWarnings = activationResult.renderers.overrides
@@ -22,4 +23,4 @@ export function collectGlobalOutputOverrideDoctorWarnings(activationResult, load
22
23
  return [...new Set([...serviceWarnings, ...rendererWarnings])].sort((left, right) => left.localeCompare(right));
23
24
  }
24
25
  //# sourceMappingURL=output-ownership.js.map
25
- //# debugId=0dc7b063-dc72-595f-8e40-8a06f9db69e1
26
+ //# debugId=e5a4cea9-ac5d-5bda-9f7c-6cf8cf9e9998
@@ -4,7 +4,7 @@
4
4
  * Implements extension package-management support for Scaffold.
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]="30dfc6e4-27c5-56c0-981b-94e85b780f1f")}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]="5321d574-4de4-5f94-99db-0c49639673fc")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { pathExists } from "../../core/fs/fs-utils.js";
@@ -1483,6 +1483,12 @@ function buildDeclarativeCapabilityTestBlock(extensionName, commandName, capabil
1483
1483
  "",
1484
1484
  " // The starter provider reads only document title/id, so `settings` is a minimal",
1485
1485
  " // typed stub and `documents` carry just the fields it inspects.",
1486
+ " const settings = {",
1487
+ " testing: {",
1488
+ " record_results_to_items: false,",
1489
+ " allow_untrusted_linked_tests: false,",
1490
+ " },",
1491
+ " } as PmSettings;",
1486
1492
  " const query = await ext.runSearchProvider({",
1487
1493
  ` provider: ${JSON.stringify(searchProviderName)},`,
1488
1494
  ' operation: "query",',
@@ -1491,7 +1497,7 @@ function buildDeclarativeCapabilityTestBlock(extensionName, commandName, capabil
1491
1497
  ' mode: "semantic",',
1492
1498
  ' tokens: ["sync"],',
1493
1499
  " options: {},",
1494
- " settings: {} as PmSettings,",
1500
+ " settings,",
1495
1501
  " documents: [",
1496
1502
  ' { metadata: { id: "pm-1", title: "Sync external context" }, body: "" },',
1497
1503
  ' { metadata: { id: "pm-2", title: "Unrelated task" }, body: "" },',
@@ -1503,14 +1509,14 @@ function buildDeclarativeCapabilityTestBlock(extensionName, commandName, capabil
1503
1509
  " const embedding = await ext.runSearchProvider({",
1504
1510
  ` provider: ${JSON.stringify(searchProviderName)},`,
1505
1511
  ' operation: "embed",',
1506
- ' context: { input: "abc", settings: {} as PmSettings, model: "starter-model" },',
1512
+ ' context: { input: "abc", settings, model: "starter-model" },',
1507
1513
  " });",
1508
1514
  " assert.deepEqual(embedding, [3]);",
1509
1515
  "",
1510
1516
  " const vectorHits = await ext.runVectorStoreAdapter({",
1511
1517
  ` adapter: ${JSON.stringify(vectorAdapterName)},`,
1512
1518
  ' operation: "query",',
1513
- " context: { vector: [0.1, 0.2], limit: 2, settings: {} as PmSettings },",
1519
+ " context: { vector: [0.1, 0.2], limit: 2, settings },",
1514
1520
  " });",
1515
1521
  ' assert.deepEqual(vectorHits, [{ id: "starter-vector-hit", score: 2 }]);',
1516
1522
  ]),
@@ -2300,4 +2306,4 @@ export async function scaffoldExtensionProject(target, vocabulary = "extension",
2300
2306
  };
2301
2307
  }
2302
2308
  //# sourceMappingURL=scaffold.js.map
2303
- //# debugId=30dfc6e4-27c5-56c0-981b-94e85b780f1f
2309
+ //# debugId=5321d574-4de4-5f94-99db-0c49639673fc
@@ -1,5 +1,5 @@
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]="0f857893-8441-54ad-af99-abaae9af864d")}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]="32dca84c-9a21-570c-a0e0-0f0356c84c0d")}catch(e){}}();
3
3
  const FLAG_DESCRIPTIONS = Object.freeze({
4
4
  "--body": "Set the item body.",
5
5
  "--body-file": "Read the item body from a file.",
@@ -68,6 +68,7 @@ const BOOLEAN_FLAG_NAMES = new Set([
68
68
  "--all-affected-ids",
69
69
  "--all-day",
70
70
  "--all-streams",
71
+ "--acknowledge-linked-tests",
71
72
  "--append-stable",
72
73
  "--auto-fix",
73
74
  "--auto-pm-context",
@@ -133,6 +134,7 @@ const BOOLEAN_FLAG_NAMES = new Set([
133
134
  "--only-last",
134
135
  "--output-row-contract",
135
136
  "--override-linked-pm-context",
137
+ "--override-linked-workspace-context",
136
138
  "--packages-only",
137
139
  "--past",
138
140
  "--phrase-exact",
@@ -315,4 +317,4 @@ export function verifyCliFlagInvocationParity(command, declarations, observation
315
317
  };
316
318
  }
317
319
  //# sourceMappingURL=flag-invocation-contracts.js.map
318
- //# debugId=0f857893-8441-54ad-af99-abaae9af864d
320
+ //# debugId=32dca84c-9a21-570c-a0e0-0f0356c84c0d
@@ -1,6 +1,6 @@
1
1
  /** Generated partition 1 of the exhaustive error-code catalog. */
2
2
 
3
- !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]="4959a1ef-29e6-50ae-aaf8-fe078001bff6")}catch(e){}}();
3
+ !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]="30cf6de5-af9b-54a1-b376-1c9e5d543ae1")}catch(e){}}();
4
4
  export const PM_ERROR_CODE_CATALOG_PART_1 = [
5
5
  {
6
6
  code: "acceptance_criteria_mutation_conflict",
@@ -962,6 +962,42 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
962
962
  canonical_code: "github_source_entry_unbuilt",
963
963
  aliases: [],
964
964
  },
965
+ {
966
+ code: "hierarchy_cardinality_created",
967
+ meaning: "Hierarchy cardinality created condition.",
968
+ stability: "provisional",
969
+ exit_code: 4,
970
+ class: "conflict",
971
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
972
+ sources: ["sdk/graph/hierarchy-integrity.ts"],
973
+ emitting_commands: ["*"],
974
+ canonical_code: "hierarchy_cardinality_created",
975
+ aliases: [],
976
+ },
977
+ {
978
+ code: "hierarchy_cycle_created",
979
+ meaning: "Hierarchy cycle created condition.",
980
+ stability: "provisional",
981
+ exit_code: 4,
982
+ class: "conflict",
983
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
984
+ sources: ["sdk/graph/hierarchy-integrity.ts"],
985
+ emitting_commands: ["*"],
986
+ canonical_code: "hierarchy_cycle_created",
987
+ aliases: [],
988
+ },
989
+ {
990
+ code: "hierarchy_parent_divergence_created",
991
+ meaning: "Hierarchy parent divergence created condition.",
992
+ stability: "provisional",
993
+ exit_code: 4,
994
+ class: "conflict",
995
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
996
+ sources: ["sdk/graph/hierarchy-integrity.ts"],
997
+ emitting_commands: ["*"],
998
+ canonical_code: "hierarchy_parent_divergence_created",
999
+ aliases: [],
1000
+ },
965
1001
  {
966
1002
  code: "history_author_acknowledge_plan_conflict",
967
1003
  meaning: "History author acknowledge plan conflict condition.",
@@ -1620,6 +1656,18 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
1620
1656
  canonical_code: "invalid_read_output_session",
1621
1657
  aliases: [],
1622
1658
  },
1659
+ {
1660
+ code: "invalid_reproducible_process_environment",
1661
+ meaning: "Invalid reproducible process environment condition.",
1662
+ stability: "provisional",
1663
+ exit_code: 2,
1664
+ class: "usage",
1665
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
1666
+ sources: ["sdk/reproducibility/process.ts"],
1667
+ emitting_commands: ["*"],
1668
+ canonical_code: "invalid_reproducible_process_environment",
1669
+ aliases: [],
1670
+ },
1623
1671
  {
1624
1672
  code: "invalid_workspace_snapshot_target",
1625
1673
  meaning: "Invalid workspace snapshot target condition.",
@@ -1944,6 +1992,30 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
1944
1992
  canonical_code: "missing_cli_flag",
1945
1993
  aliases: [],
1946
1994
  },
1995
+ {
1996
+ code: "missing_destination",
1997
+ meaning: "Missing destination condition.",
1998
+ stability: "provisional",
1999
+ exit_code: 1,
2000
+ class: "generic_failure",
2001
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
2002
+ sources: ["sdk/cli-contracts/grammar-contracts.ts"],
2003
+ emitting_commands: ["*"],
2004
+ canonical_code: "missing_destination",
2005
+ aliases: [],
2006
+ },
2007
+ {
2008
+ code: "missing_directory",
2009
+ meaning: "Missing directory condition.",
2010
+ stability: "stable",
2011
+ exit_code: 1,
2012
+ class: "generic_failure",
2013
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
2014
+ sources: ["core/diagnostics/remediation.ts"],
2015
+ emitting_commands: ["*"],
2016
+ canonical_code: "missing_directory",
2017
+ aliases: [],
2018
+ },
1947
2019
  ];
1948
2020
  //# sourceMappingURL=generated-error-code-catalog-part-1.js.map
1949
- //# debugId=4959a1ef-29e6-50ae-aaf8-fe078001bff6
2021
+ //# debugId=30cf6de5-af9b-54a1-b376-1c9e5d543ae1
@@ -1,31 +1,7 @@
1
1
  /** Generated partition 2 of the exhaustive error-code catalog. */
2
2
 
3
- !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]="d7f4f4f0-d044-5216-b2c4-d76b4d8854a9")}catch(e){}}();
3
+ !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]="9b6149b0-ca3e-5093-aba5-43385d3368f7")}catch(e){}}();
4
4
  export const PM_ERROR_CODE_CATALOG_PART_2 = [
5
- {
6
- code: "missing_destination",
7
- meaning: "Missing destination condition.",
8
- stability: "provisional",
9
- exit_code: 1,
10
- class: "generic_failure",
11
- recovery: "Inspect the structured error guidance and retry the suggested command.",
12
- sources: ["sdk/cli-contracts/grammar-contracts.ts"],
13
- emitting_commands: ["*"],
14
- canonical_code: "missing_destination",
15
- aliases: [],
16
- },
17
- {
18
- code: "missing_directory",
19
- meaning: "Missing directory condition.",
20
- stability: "stable",
21
- exit_code: 1,
22
- class: "generic_failure",
23
- recovery: "Inspect the structured error guidance and retry the suggested command.",
24
- sources: ["core/diagnostics/remediation.ts"],
25
- emitting_commands: ["*"],
26
- canonical_code: "missing_directory",
27
- aliases: [],
28
- },
29
5
  {
30
6
  code: "missing_init_recovery",
31
7
  meaning: "Missing init recovery condition.",
@@ -110,6 +86,7 @@ export const PM_ERROR_CODE_CATALOG_PART_2 = [
110
86
  "cli/main.ts",
111
87
  "cli/register-mutation.ts",
112
88
  "core/telemetry/observability.ts",
89
+ "sdk/governance/assurance-action.ts",
113
90
  "sdk/history-redact.ts",
114
91
  "sdk/invocation-author.ts",
115
92
  ],
@@ -531,6 +508,78 @@ export const PM_ERROR_CODE_CATALOG_PART_2 = [
531
508
  canonical_code: "redundant_edge",
532
509
  aliases: [],
533
510
  },
511
+ {
512
+ code: "refusal_allowed_values_mismatch",
513
+ meaning: "Refusal allowed values mismatch condition.",
514
+ stability: "provisional",
515
+ exit_code: 1,
516
+ class: "generic_failure",
517
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
518
+ sources: ["sdk/agent/refusal-corpus-contracts.ts"],
519
+ emitting_commands: ["*"],
520
+ canonical_code: "refusal_allowed_values_mismatch",
521
+ aliases: [],
522
+ },
523
+ {
524
+ code: "refusal_error_code_mismatch",
525
+ meaning: "Refusal error code mismatch condition.",
526
+ stability: "provisional",
527
+ exit_code: 1,
528
+ class: "generic_failure",
529
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
530
+ sources: ["sdk/agent/refusal-corpus-contracts.ts"],
531
+ emitting_commands: ["*"],
532
+ canonical_code: "refusal_error_code_mismatch",
533
+ aliases: [],
534
+ },
535
+ {
536
+ code: "refusal_exit_code_mismatch",
537
+ meaning: "Refusal exit code mismatch condition.",
538
+ stability: "provisional",
539
+ exit_code: 1,
540
+ class: "generic_failure",
541
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
542
+ sources: ["sdk/agent/refusal-corpus-contracts.ts"],
543
+ emitting_commands: ["*"],
544
+ canonical_code: "refusal_exit_code_mismatch",
545
+ aliases: [],
546
+ },
547
+ {
548
+ code: "refusal_mutated_state",
549
+ meaning: "Refusal mutated state condition.",
550
+ stability: "provisional",
551
+ exit_code: 1,
552
+ class: "generic_failure",
553
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
554
+ sources: ["sdk/agent/refusal-corpus-contracts.ts"],
555
+ emitting_commands: ["*"],
556
+ canonical_code: "refusal_mutated_state",
557
+ aliases: [],
558
+ },
559
+ {
560
+ code: "refusal_probe_missing",
561
+ meaning: "Refusal probe missing condition.",
562
+ stability: "provisional",
563
+ exit_code: 1,
564
+ class: "generic_failure",
565
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
566
+ sources: ["sdk/agent/refusal-corpus-contracts.ts"],
567
+ emitting_commands: ["*"],
568
+ canonical_code: "refusal_probe_missing",
569
+ aliases: [],
570
+ },
571
+ {
572
+ code: "refusal_recovery_failed",
573
+ meaning: "Refusal recovery failed condition.",
574
+ stability: "provisional",
575
+ exit_code: 1,
576
+ class: "generic_failure",
577
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
578
+ sources: ["sdk/agent/refusal-corpus-contracts.ts"],
579
+ emitting_commands: ["*"],
580
+ canonical_code: "refusal_recovery_failed",
581
+ aliases: [],
582
+ },
534
583
  {
535
584
  code: "reindex_already_running",
536
585
  meaning: "Reindex already running condition.",
@@ -1099,6 +1148,18 @@ export const PM_ERROR_CODE_CATALOG_PART_2 = [
1099
1148
  canonical_code: "undeclared_observation",
1100
1149
  aliases: [],
1101
1150
  },
1151
+ {
1152
+ code: "unexpected_refusal_probe",
1153
+ meaning: "Unexpected refusal probe condition.",
1154
+ stability: "provisional",
1155
+ exit_code: 1,
1156
+ class: "generic_failure",
1157
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
1158
+ sources: ["sdk/agent/refusal-corpus-contracts.ts"],
1159
+ emitting_commands: ["*"],
1160
+ canonical_code: "unexpected_refusal_probe",
1161
+ aliases: [],
1162
+ },
1102
1163
  {
1103
1164
  code: "unknown_command",
1104
1165
  meaning: "Unknown command condition.",
@@ -1978,4 +2039,4 @@ export const PM_ERROR_CODE_CATALOG_PART_2 = [
1978
2039
  },
1979
2040
  ];
1980
2041
  //# sourceMappingURL=generated-error-code-catalog-part-2.js.map
1981
- //# debugId=d7f4f4f0-d044-5216-b2c4-d76b4d8854a9
2042
+ //# debugId=9b6149b0-ca3e-5093-aba5-43385d3368f7
@@ -4,7 +4,7 @@
4
4
  * Normalizes the assurance action vocabulary once for CLI, SDK, and MCP hosts.
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]="57c12241-812d-5db6-9a07-ca256152b130")}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]="f66a964d-1352-5523-ab91-5177d0d93ce8")}catch(e){}}();
8
8
  import { createHash } from "node:crypto";
9
9
  import { EXIT_CODE } from "../../core/shared/constants.js";
10
10
  import { PmCliError } from "../../core/shared/errors.js";
@@ -18,6 +18,7 @@ import { resolvePmRoot } from "../runtime-primitives.js";
18
18
  import { parseRuntimeInteger, readRuntimeString } from "../runtime-input.js";
19
19
  import { analyzeDefectChangeRisk, buildDefectRecurrenceIndex, parseDefectChangeRiskRequest, } from "./defect-recurrence.js";
20
20
  import { defectRecurrenceItemSignals } from "./defect-recurrence-signals.js";
21
+ import { createUnknownSubcommandError } from "../agent/subcommand-recovery.js";
21
22
  let riskIndexCache;
22
23
  /** Assurance registry and evaluation verbs shared by every transport. */
23
24
  export const ASSURANCE_ACTIONS = [
@@ -43,17 +44,36 @@ function parseAction(value) {
43
44
  if (ASSURANCE_ACTIONS.includes(value)) {
44
45
  return value;
45
46
  }
46
- throw new PmCliError(`Unknown assurance action ${value}. Expected: ${ASSURANCE_ACTIONS.join(", ")}`, EXIT_CODE.USAGE);
47
+ throw createUnknownSubcommandError({
48
+ command_path: "assurance",
49
+ token: value,
50
+ allowed: ASSURANCE_ACTIONS,
51
+ display_name: "assurance action",
52
+ });
53
+ }
54
+ /** Throw the shared structured usage refusal for a missing assurance operand. */
55
+ function missingAssuranceArgument(operand, detail, example) {
56
+ throw new PmCliError(detail, EXIT_CODE.USAGE, {
57
+ code: "missing_required_argument",
58
+ required: `Provide the missing assurance operand: ${operand}.`,
59
+ examples: [example],
60
+ recovery: { missing: [operand] },
61
+ });
47
62
  }
48
63
  function parseKind(value) {
49
- if (value &&
50
- ASSURANCE_DECLARATION_KINDS.includes(value)) {
64
+ if (!value) {
65
+ return missingAssuranceArgument("kind", `Assurance declaration kind is required. Expected: ${ASSURANCE_DECLARATION_KINDS.join(", ")}`, "pm assurance list measurement");
66
+ }
67
+ if (ASSURANCE_DECLARATION_KINDS.includes(value)) {
51
68
  return value;
52
69
  }
53
70
  throw new PmCliError(`Assurance declaration kind is required. Expected: ${ASSURANCE_DECLARATION_KINDS.join(", ")}`, EXIT_CODE.USAGE);
54
71
  }
55
72
  function parsePreset(value) {
56
- if (value && ASSURANCE_PRESET_IDS.includes(value)) {
73
+ if (!value) {
74
+ return missingAssuranceArgument("preset", `Assurance preset is required. Expected: ${ASSURANCE_PRESET_IDS.join(", ")}`, "pm assurance apply software-delivery --owner <pm-item-id>");
75
+ }
76
+ if (ASSURANCE_PRESET_IDS.includes(value)) {
57
77
  return value;
58
78
  }
59
79
  throw new PmCliError(`Assurance preset is required. Expected: ${ASSURANCE_PRESET_IDS.join(", ")}`, EXIT_CODE.USAGE);
@@ -61,7 +81,7 @@ function parsePreset(value) {
61
81
  function requireOwner(input) {
62
82
  if (input.owner?.trim())
63
83
  return input.owner.trim();
64
- throw new PmCliError("assurance preset and derivation actions require --owner <pm-item-id>", EXIT_CODE.USAGE);
84
+ return missingAssuranceArgument("owner", "assurance preset and derivation actions require --owner <pm-item-id>", "pm assurance apply software-delivery --owner <pm-item-id>");
65
85
  }
66
86
  function parseDefinition(kind, value) {
67
87
  let parsed = value;
@@ -173,7 +193,7 @@ async function runAdoptionAction(action, input, pmRoot) {
173
193
  };
174
194
  }
175
195
  if (!input.id) {
176
- throw new PmCliError("assurance promote requires an assertion id", EXIT_CODE.USAGE);
196
+ return missingAssuranceArgument("assertion-id", "assurance promote requires an assertion id", "pm assurance promote <assertion-id> --enforcement warn");
177
197
  }
178
198
  if (input.enforcement !== "warn" && input.enforcement !== "block") {
179
199
  throw new PmCliError("assurance promote requires --enforcement warn|block", EXIT_CODE.USAGE);
@@ -186,7 +206,7 @@ async function runAdoptionAction(action, input, pmRoot) {
186
206
  }
187
207
  async function runGateAction(input, pmRoot, runtime) {
188
208
  if (!input.id) {
189
- throw new PmCliError("assurance run requires a gate id", EXIT_CODE.USAGE);
209
+ return missingAssuranceArgument("gate-id", "assurance run requires a gate id", "pm assurance run <gate-id> --trigger ci --dry-run");
190
210
  }
191
211
  const gateId = input.id;
192
212
  if (!input.trigger) {
@@ -320,7 +340,7 @@ export async function runAssuranceAction(input, global = {}, runtime = {}) {
320
340
  if (action === "list")
321
341
  return listAssuranceDeclarations(pmRoot, kind);
322
342
  if (!input.id) {
323
- throw new PmCliError(`assurance ${action} requires an id`, EXIT_CODE.USAGE);
343
+ return missingAssuranceArgument("id", `assurance ${action} requires an id`, `pm assurance ${action} ${kind} <id>`);
324
344
  }
325
345
  const id = input.id;
326
346
  if (action === "show") {
@@ -377,4 +397,4 @@ export function runAssuranceDispatch(args, options, global) {
377
397
  }, global);
378
398
  }
379
399
  //# sourceMappingURL=assurance-action.js.map
380
- //# debugId=57c12241-812d-5db6-9a07-ca256152b130
400
+ //# debugId=f66a964d-1352-5523-ab91-5177d0d93ce8
@@ -7,6 +7,7 @@ import { type HistoryAuthorAttributionScan } from "../author-attribution.js";
7
7
  import type { PmSettings } from "../../types/index.js";
8
8
  import { buildCapabilityContractMetadata, collectUnknownCapabilityGuidance } from "../extension/doctor.js";
9
9
  import { type StaleInProgressScan } from "./stale-work.js";
10
+ import { type HierarchyIntegrityAnalysis } from "../graph/hierarchy-integrity.js";
10
11
  type HealthStatus = "ok" | "warn";
11
12
  type MigrationRuntimeStatus = "pending" | "failed" | "applied";
12
13
  /** Documents the health check payload exchanged by command, SDK, and package integrations. */
@@ -145,6 +146,7 @@ declare function normalizeExtensionNameForMatch(value: string): string;
145
146
  declare function isExpectedUnmanagedExtension(name: string, directory: string): boolean;
146
147
  declare function isDirectory(targetPath: string): Promise<boolean>;
147
148
  declare function listItemDocumentPaths(pmRoot: string, typeToFolder: Record<string, string>): Promise<string[]>;
149
+ declare function buildHierarchyIntegrityWarnings(analysis: HierarchyIntegrityAnalysis): string[];
148
150
  declare function buildExtensionHealthTriageSummary(warnings: string[], loadFailureCount: number, activationFailureCount: number, migrationStatus: MigrationStatusSummary, managedStateWarningCount: number, managedExtensionEntriesCount: number, unmanagedLoadedExtensions: string[], unmanagedExpectedExtensions: string[], unmanagedActionRequiredExtensions: string[]): ExtensionHealthTriageSummary;
149
151
  declare function summarizeRecordList(value: unknown, limit: number): {
150
152
  count: number;
@@ -218,6 +220,7 @@ declare function projectHealthResult(result: HealthResult, options: RunHealthOpt
218
220
  export declare function runHealth(global: GlobalOptions, options?: RunHealthOptions): Promise<HealthResult>;
219
221
  /** Public contract for test only health command, shared by SDK and presentation-layer consumers. */
220
222
  export declare const _testOnlyHealthCommand: {
223
+ buildHierarchyIntegrityWarnings: typeof buildHierarchyIntegrityWarnings;
221
224
  buildExtensionHealthTriageSummary: typeof buildExtensionHealthTriageSummary;
222
225
  buildHealthFindings: typeof buildHealthFindings;
223
226
  buildCapabilityContractMetadata: typeof buildCapabilityContractMetadata;
@@ -4,11 +4,13 @@
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]="a7e3a41b-7d69-526d-aa3e-bc244ef8fe0c")}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]="f7b3ff92-1fc7-55e9-aa76-af956714998f")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { assertInitializedTracker } from "../environment/tracker-preflight.js";
11
+ import { isTerminalStatus } from "../../core/item/status.js";
11
12
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
13
+ import { resolveRuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
12
14
  import { isFileMissingError, readFileIfExists, } from "../../core/fs/fs-utils.js";
13
15
  import { activateExtensions, getActiveExtensionRegistrations, loadExtensions, runActiveOnReadHooks, } from "../../core/extensions/index.js";
14
16
  import { collectRegisteredItemFieldNames } from "../../core/extensions/item-fields.js";
@@ -44,6 +46,8 @@ import { scanStaleInProgressItems, } from "./stale-work.js";
44
46
  import { scanTrackedRuntimeCache } from "./tracked-runtime-cache.js";
45
47
  import { auditMergeDriverConfiguration, findGitWorkspaceRoot, } from "../merge/install.js";
46
48
  import { listMergeReceipts, partitionMergeReceipts, } from "../merge/receipts.js";
49
+ import { resolveWorkspaceRelationshipKindRegistry } from "../graph/assembly.js";
50
+ import { analyzeHierarchyIntegrity, } from "../graph/hierarchy-integrity.js";
47
51
  const PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
48
52
  const STALE_VECTORIZATION_SUMMARY_LIMIT = 25;
49
53
  const BRIEF_HEALTH_DETAIL_LIMIT = 8;
@@ -61,6 +65,7 @@ const TELEMETRY_SERVER_MAX_SCHEMA_VERSION_HEADERS = [
61
65
  function isAdvisoryHealthWarning(warning, requireMergeDrivers = false) {
62
66
  return (warning.startsWith("telemetry_") ||
63
67
  warning.startsWith("history_stream_over_compact_threshold:") ||
68
+ warning.startsWith("integrity_legacy_hierarchy_") ||
64
69
  warning.startsWith("stale_in_progress_items:") ||
65
70
  warning.startsWith("provenance_resolver_zero_success:") ||
66
71
  warning.startsWith("provenance_value_domain_invalid:") ||
@@ -315,10 +320,25 @@ async function scanHistoryIntegrity(pmRoot) {
315
320
  }
316
321
  return { files, unreadable, conflictMarkers, invalidJson };
317
322
  }
318
- async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDrivers) {
323
+ function buildHierarchyIntegrityWarnings(analysis) {
324
+ return [
325
+ ...analysis.cycles.map((cycle) => cycle.legacy_terminal
326
+ ? `integrity_legacy_hierarchy_cycle:${cycle.item_ids.join(",")}`
327
+ : `integrity_hierarchy_cycle:${cycle.item_ids.join(",")}`),
328
+ ...analysis.cardinality_violations.map((finding) => finding.legacy_terminal
329
+ ? `integrity_legacy_hierarchy_cardinality:${finding.child_id}`
330
+ : `integrity_hierarchy_cardinality:${finding.child_id}`),
331
+ ...analysis.divergences.map((finding) => finding.legacy_terminal
332
+ ? `integrity_legacy_hierarchy_divergence:${finding.child_id}`
333
+ : `integrity_hierarchy_divergence:${finding.child_id}`),
334
+ ];
335
+ }
336
+ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDrivers, items) {
319
337
  const itemScan = await scanItemIntegrity(pmRoot, typeToFolder, schema);
320
338
  const historyScan = await scanHistoryIntegrity(pmRoot);
321
339
  const formatVersionScan = scanItemFormatVersions(itemScan.formatVersions);
340
+ const statusRegistry = resolveRuntimeStatusRegistry(schema);
341
+ const hierarchyIntegrity = analyzeHierarchyIntegrity(items, (status) => isTerminalStatus(status, statusRegistry), resolveWorkspaceRelationshipKindRegistry());
322
342
  const trackedRuntimeCache = await scanTrackedRuntimeCache(pmRoot);
323
343
  const gitWorkspaceRoot = await findGitWorkspaceRoot(pmRoot);
324
344
  const mergeDriverAudit = gitWorkspaceRoot === null
@@ -345,6 +365,7 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
345
365
  ...formatVersionScan.outdated.map((entry) => `integrity_item_outdated_format_version:${entry}`),
346
366
  /* c8 ignore stop */
347
367
  ...formatVersionScan.ahead.map((entry) => `integrity_item_ahead_format_version:${entry}`),
368
+ ...buildHierarchyIntegrityWarnings(hierarchyIntegrity),
348
369
  ...(trackedRuntimeCache.tracked_path_count > 0
349
370
  ? [
350
371
  `tracked_runtime_cache_files:${trackedRuntimeCache.tracked_path_count}`,
@@ -360,11 +381,12 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
360
381
  : []),
361
382
  ];
362
383
  const normalizedWarnings = [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
384
+ const actionableWarnings = normalizedWarnings.filter((warning) => !warning.startsWith("integrity_legacy_hierarchy_"));
363
385
  return {
364
386
  check: {
365
387
  name: "integrity",
366
- status: normalizedWarnings.length === 0 ? "ok" : "warn",
367
- ok: normalizedWarnings.length === 0,
388
+ status: actionableWarnings.length === 0 ? "ok" : "warn",
389
+ ok: actionableWarnings.length === 0,
368
390
  details: {
369
391
  checked_item_files: itemScan.paths.length,
370
392
  checked_history_streams: historyScan.files.length,
@@ -377,6 +399,9 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
377
399
  history_invalid_json: historyScan.invalidJson.length,
378
400
  item_outdated_format_version: formatVersionScan.outdated.length,
379
401
  item_ahead_format_version: formatVersionScan.ahead.length,
402
+ hierarchy_cycles: hierarchyIntegrity.cycles.length,
403
+ hierarchy_cardinality_violations: hierarchyIntegrity.cardinality_violations.length,
404
+ hierarchy_parent_divergences: hierarchyIntegrity.divergences.length,
380
405
  tracked_runtime_cache_files: trackedRuntimeCache.tracked_path_count,
381
406
  merge_driver_configuration: mergeDriverAudit === null || mergeDriverAudit.status === "ok"
382
407
  ? 0
@@ -390,6 +415,10 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
390
415
  item_parse_failures: itemScan.parseFailures,
391
416
  item_outdated_format_version: formatVersionScan.outdated,
392
417
  item_ahead_format_version: formatVersionScan.ahead,
418
+ hierarchy_integrity: {
419
+ ...hierarchyIntegrity,
420
+ relations: summarizeRecordList(hierarchyIntegrity.relations, BRIEF_HEALTH_DETAIL_LIMIT),
421
+ },
393
422
  history_unreadable: historyScan.unreadable,
394
423
  history_conflict_markers: historyScan.conflictMarkers,
395
424
  history_invalid_json: historyScan.invalidJson,
@@ -1832,7 +1861,9 @@ function extractHistoryDriftedCount(historyDriftCheck) {
1832
1861
  function buildHealthRemediationSources(params) {
1833
1862
  return {
1834
1863
  settings: params.normalizedSettingsReadWarnings,
1835
- directories: params.directoryState.missingDirs.map((dir) => `missing_directory:${dir}`).concat(params.directoryState.hookWarnings),
1864
+ directories: params.directoryState.missingDirs
1865
+ .map((dir) => `missing_directory:${dir}`)
1866
+ .concat(params.directoryState.hookWarnings),
1836
1867
  settings_values: params.settingWarnings,
1837
1868
  telemetry: params.telemetryCheck.warnings,
1838
1869
  extensions: params.extensionCheck.warnings,
@@ -2000,7 +2031,7 @@ export async function runHealth(global, options = {}) {
2000
2031
  const locksCheck = await buildLocksCheck(pmRoot);
2001
2032
  const integrityCheck = skipPolicy.skipIntegrity
2002
2033
  ? buildSkippedHealthCheck("integrity")
2003
- : await buildIntegrityCheck(pmRoot, typeRegistry.type_to_folder, settings.schema, options.requireMergeDrivers === true);
2034
+ : await buildIntegrityCheck(pmRoot, typeRegistry.type_to_folder, settings.schema, options.requireMergeDrivers === true, items);
2004
2035
  const historyDriftCheck = skipPolicy.skipDrift
2005
2036
  ? buildSkippedHealthCheck("history_drift")
2006
2037
  : await buildHistoryDriftCheck(pmRoot, itemsWithBody);
@@ -2082,6 +2113,7 @@ export async function runHealth(global, options = {}) {
2082
2113
  }
2083
2114
  /** Public contract for test only health command, shared by SDK and presentation-layer consumers. */
2084
2115
  export const _testOnlyHealthCommand = {
2116
+ buildHierarchyIntegrityWarnings,
2085
2117
  buildExtensionHealthTriageSummary,
2086
2118
  buildHealthFindings,
2087
2119
  buildCapabilityContractMetadata,
@@ -2110,4 +2142,4 @@ export const _testOnlyHealthCommand = {
2110
2142
  warningCode,
2111
2143
  };
2112
2144
  //# sourceMappingURL=health.js.map
2113
- //# debugId=a7e3a41b-7d69-526d-aa3e-bc244ef8fe0c
2145
+ //# debugId=f7b3ff92-1fc7-55e9-aa76-af956714998f
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @module sdk/governance/hierarchy-validation
3
+ *
4
+ * Adapts the shared hierarchy analyzer to validation-specific diagnostics and
5
+ * deterministic cycle paths without coupling the analyzer to CLI policy.
6
+ */
7
+ import { type RuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
8
+ import type { RelationshipKindRegistry } from "../relationships.js";
9
+ import type { ValidateItem } from "./validate-item-reader.js";
10
+ /** Resolve one deterministic closed walk through a known cycle component. */
11
+ export declare function resolveLifecycleDependencyCycleSamplePath(component: string[], graph: Map<string, string[]>): string[];
12
+ /** Build canonical child-to-parent adjacency across every hierarchy spelling. */
13
+ export declare function buildLifecycleParentGraph(items: ValidateItem[], relationshipRegistry?: RelationshipKindRegistry): Map<string, string[]>;
14
+ /** Project shared hierarchy analysis into the validation result contract. */
15
+ export declare function detectLifecycleParentCycles(items: ValidateItem[], statusRegistry?: RuntimeStatusRegistry, relationshipRegistry?: RelationshipKindRegistry): {
16
+ cycle_count: number;
17
+ active_cycle_count: number;
18
+ legacy_cycle_count: number;
19
+ cycle_item_ids: string[];
20
+ cycle_sample_paths: string[];
21
+ cardinality_violation_count: number;
22
+ active_cardinality_violation_count: number;
23
+ legacy_cardinality_violation_count: number;
24
+ cardinality_violation_rows: string[];
25
+ parent_divergence_count: number;
26
+ active_parent_divergence_count: number;
27
+ legacy_parent_divergence_count: number;
28
+ parent_divergence_rows: string[];
29
+ };