@unbrained/pm-cli 2026.8.30 → 2026.9.1

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 (176) hide show
  1. package/.agents/skills/HARNESS_COMPATIBILITY.md +1 -1
  2. package/.agents/skills/README.md +1 -1
  3. package/.agents/skills/pm-developer/SKILL.md +1 -1
  4. package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +2 -2
  5. package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +1 -1
  6. package/.agents/skills/pm-developer/references/TOKEN_BUDGETS.md +1 -1
  7. package/.agents/skills/pm-extensions/SKILL.md +2 -2
  8. package/.agents/skills/pm-extensions/references/AUTHORING.md +1 -1
  9. package/.agents/skills/pm-extensions/references/LIFECYCLE.md +1 -1
  10. package/.agents/skills/pm-sdk/SKILL.md +1 -1
  11. package/.agents/skills/pm-user/SKILL.md +2 -2
  12. package/.agents/skills/pm-user/references/WORKFLOWS.md +2 -2
  13. package/.claude-plugin/marketplace.json +2 -2
  14. package/AGENTS.md +16 -14
  15. package/CHANGELOG.md +41 -6
  16. package/README.md +3 -3
  17. package/dist/cli/commands/merge.d.ts +1 -1
  18. package/dist/cli/commands/merge.js +3 -3
  19. package/dist/cli/register-list-query.js +32 -17
  20. package/dist/cli/register-mutation.js +8 -5
  21. package/dist/cli/register-operations.d.ts +2 -0
  22. package/dist/cli/register-operations.js +20 -9
  23. package/dist/cli-bundle/bundle-manifest.json +144 -144
  24. package/dist/cli-bundle/chunks/{chunk-CMIEDWAY.js → chunk-2MC2LCXZ.js} +41 -41
  25. package/dist/cli-bundle/chunks/{chunk-WS2GJQVG.js → chunk-3WICXLVT.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-7SKMLSMX.js → chunk-6XIIGE7U.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-ALKKAUFN.js +35 -0
  28. package/dist/cli-bundle/chunks/{chunk-MTTKAUBX.js → chunk-DTGWEL23.js} +2 -2
  29. package/dist/cli-bundle/chunks/chunk-GOACULJW.js +13 -0
  30. package/dist/cli-bundle/chunks/chunk-NOPL37X4.js +205 -0
  31. package/dist/cli-bundle/chunks/{chunk-2UETTHY6.js → chunk-TAG4VC22.js} +30 -30
  32. package/dist/cli-bundle/chunks/{chunk-3TEF3HM5.js → chunk-U45JXJCC.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-TGNAA66W.js → chunk-X4RCGLTX.js} +2 -2
  34. package/dist/cli-bundle/chunks/{chunk-2MKLQL2E.js → chunk-Y7VOMSZT.js} +2 -2
  35. package/dist/cli-bundle/chunks/{register-list-query-OMKJ5ONN.js → register-list-query-XYNX4ASQ.js} +11 -11
  36. package/dist/cli-bundle/chunks/register-mutation-2MVLRS3J.js +20 -0
  37. package/dist/cli-bundle/chunks/register-operations-WCIDXBU3.js +2 -0
  38. package/dist/cli-bundle/chunks/{register-setup-GLQ5SYV3.js → register-setup-KVNC5KPL.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-HVQ22RC4.js → chunk-2FEZ5SKM.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-Y3JJXRVK.js → chunk-4O4CJAR6.js} +5 -5
  41. package/dist/cli-bundle/focused-chunks/chunk-7VATS5QY.js +16 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-LYFWQMVC.js → chunk-BEVHCEWG.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-TDK3OCX3.js → chunk-FWPLDEXF.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-JEFKLWMM.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-JZYPPMXF.js → chunk-KB5OFSFD.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-73EDXGYE.js → chunk-MKHG3T76.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-3AVAWVZA.js → chunk-PF3E6Q36.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-AD6ULRAF.js → chunk-QDFJIRKN.js} +4 -4
  49. package/dist/cli-bundle/focused-chunks/{chunk-RKOKG43G.js → chunk-RMRCQPWU.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-XXOWRJZ5.js → chunk-S4U5CN5Q.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-THEPQMLX.js → chunk-SVXJYD6G.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-T2LXXSOD.js +158 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-Y6JJIX6I.js +51 -0
  54. package/dist/cli-bundle/main.js +2 -2
  55. package/dist/cli-bundle/sdk-authoring.js +1 -1
  56. package/dist/cli-bundle/sdk-contracts.js +1 -1
  57. package/dist/cli-bundle/sdk-core.js +27 -27
  58. package/dist/cli-bundle/sdk-governance.js +1 -1
  59. package/dist/cli-bundle/sdk-graph.js +1 -1
  60. package/dist/cli-bundle/sdk-merge.js +33 -33
  61. package/dist/cli-bundle/sdk-query.js +1 -1
  62. package/dist/cli-bundle/sdk-runtime.js +1 -1
  63. package/dist/cli-bundle/sdk-testing.js +1 -1
  64. package/dist/cli-bundle/sdk.js +10 -10
  65. package/dist/core/history/drift-scan.js +6 -6
  66. package/dist/core/history/history.d.ts +6 -0
  67. package/dist/core/history/history.js +47 -5
  68. package/dist/core/history/replay.d.ts +12 -1
  69. package/dist/core/history/replay.js +60 -39
  70. package/dist/core/schema/runtime-schema.d.ts +4 -0
  71. package/dist/core/schema/runtime-schema.js +60 -48
  72. package/dist/core/schema/status-defs-file.js +5 -2
  73. package/dist/mcp/legacy-adapter.d.ts +11 -2
  74. package/dist/mcp/legacy-adapter.js +26 -12
  75. package/dist/mcp/server.d.ts +2 -2
  76. package/dist/mcp/server.js +78 -15
  77. package/dist/mcp/tool-definitions.js +56 -2
  78. package/dist/sdk/agent-capability-contracts.js +4 -2
  79. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  80. package/dist/sdk/cli-contracts/flag-contracts.js +6 -2
  81. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +1 -1
  82. package/dist/sdk/cli-contracts/grammar-contracts.js +12 -2
  83. package/dist/sdk/cli-contracts/runtime-contracts.js +3 -2
  84. package/dist/sdk/cli-contracts/tool-schema.js +11 -3
  85. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +14 -2
  86. package/dist/sdk/governance/health.js +17 -6
  87. package/dist/sdk/governance/status-role-diagnostics.d.ts +27 -0
  88. package/dist/sdk/governance/status-role-diagnostics.js +36 -0
  89. package/dist/sdk/governance/validate-normalization.d.ts +6 -0
  90. package/dist/sdk/governance/validate-normalization.js +37 -0
  91. package/dist/sdk/governance/validate.d.ts +1 -1
  92. package/dist/sdk/governance/validate.js +20 -35
  93. package/dist/sdk/governance/workspace-position.d.ts +69 -0
  94. package/dist/sdk/governance/workspace-position.js +164 -0
  95. package/dist/sdk/governance.d.ts +2 -0
  96. package/dist/sdk/governance.js +4 -2
  97. package/dist/sdk/history-read.js +14 -6
  98. package/dist/sdk/history-repair.js +17 -10
  99. package/dist/sdk/index.d.ts +2 -1
  100. package/dist/sdk/index.js +4 -3
  101. package/dist/sdk/init-agent-guidance.js +4 -4
  102. package/dist/sdk/lifecycle/update.js +23 -10
  103. package/dist/sdk/mcp/discovery.d.ts +152 -0
  104. package/dist/sdk/mcp/discovery.js +495 -0
  105. package/dist/sdk/mcp/protocol.d.ts +10 -2
  106. package/dist/sdk/mcp/protocol.js +15 -4
  107. package/dist/sdk/merge/index.d.ts +1 -1
  108. package/dist/sdk/merge/index.js +3 -3
  109. package/dist/sdk/merge/receipts.d.ts +27 -1
  110. package/dist/sdk/merge/receipts.js +27 -8
  111. package/dist/sdk/merge/three-way.d.ts +3 -1
  112. package/dist/sdk/merge/three-way.js +9 -7
  113. package/dist/sdk/query/context.js +11 -14
  114. package/dist/sdk/query/list.d.ts +2 -0
  115. package/dist/sdk/query/list.js +33 -12
  116. package/dist/sdk/runtime-extended-actions.js +10 -6
  117. package/dist/sdk/schema.js +12 -2
  118. package/dist/sdk/test/execution.d.ts +15 -0
  119. package/dist/sdk/test/execution.js +35 -27
  120. package/docs/AGENT_GUIDE.md +12 -4
  121. package/docs/AGENT_PROVENANCE_ADR.md +1 -1
  122. package/docs/AGENT_RUNTIME_PRIMITIVES.md +2 -2
  123. package/docs/ARCHITECTURE.md +5 -0
  124. package/docs/CLAUDE_CODE_PLUGIN.md +5 -5
  125. package/docs/COMMANDS.md +12 -12
  126. package/docs/CONFIGURATION.md +1 -1
  127. package/docs/CONTEXT_RECOVERY_PRIMITIVES.md +14 -5
  128. package/docs/DEFECT_RECURRENCE.md +2 -0
  129. package/docs/MCP_2026_07_28.md +33 -9
  130. package/docs/MCP_2026_07_28_CONFORMANCE.md +1 -0
  131. package/docs/MCP_CAPABILITY_SURFACES.md +7 -1
  132. package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +15 -3
  133. package/docs/MERGE_SAFETY.md +30 -2
  134. package/docs/ONBOARDING.md +1 -1
  135. package/docs/OUTPUT_TOKEN_ACCOUNTING.md +5 -3
  136. package/docs/PROGRESSIVE_TOOL_DISCOVERY.md +42 -0
  137. package/docs/README.md +3 -1
  138. package/docs/READ_OUTPUT_CONTRACTS.md +1 -1
  139. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +1 -1
  140. package/docs/SDK.md +3 -3
  141. package/docs/TESTING.md +23 -14
  142. package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +113 -0
  143. package/docs/agent-task-token-baseline.json +157 -3
  144. package/docs/agent-task-transcripts.json +143 -0
  145. package/docs/examples/policy-restricted-extension/README.md +2 -2
  146. package/docs/examples/starter-extension/README.md +1 -1
  147. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  148. package/docs/performance/cli-transport-overhead.md +8 -6
  149. package/marketplace.json +2 -2
  150. package/package.json +4 -4
  151. package/packages/pm-beads/package.json +1 -1
  152. package/packages/pm-calendar/package.json +1 -1
  153. package/packages/pm-command-kit/package.json +1 -1
  154. package/packages/pm-digital-twin/package.json +1 -1
  155. package/packages/pm-governance-audit/package.json +1 -1
  156. package/packages/pm-guide-shell/package.json +1 -1
  157. package/packages/pm-kanban/package.json +1 -1
  158. package/packages/pm-lifecycle-hooks/package.json +1 -1
  159. package/packages/pm-linked-test-adapters/package.json +1 -1
  160. package/packages/pm-search-advanced/package.json +1 -1
  161. package/packages/pm-templates/package.json +1 -1
  162. package/packages/pm-todos/package.json +1 -1
  163. package/packages/pm-vcs/package.json +1 -1
  164. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  165. package/plugins/pm-claude/README.md +4 -3
  166. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  167. package/sdk/public-surface.json +314 -10
  168. package/dist/cli-bundle/chunks/chunk-7X6OZEIV.js +0 -34
  169. package/dist/cli-bundle/chunks/chunk-GNWPTEBW.js +0 -205
  170. package/dist/cli-bundle/chunks/chunk-N6OR6FAR.js +0 -13
  171. package/dist/cli-bundle/chunks/register-mutation-QBSNCOY3.js +0 -20
  172. package/dist/cli-bundle/chunks/register-operations-UC77FQZC.js +0 -2
  173. package/dist/cli-bundle/focused-chunks/chunk-3UMBF26I.js +0 -158
  174. package/dist/cli-bundle/focused-chunks/chunk-AXZ5AJAF.js +0 -50
  175. package/dist/cli-bundle/focused-chunks/chunk-G6PATS5E.js +0 -16
  176. package/dist/cli-bundle/focused-chunks/chunk-LLNTHF5X.js +0 -2
@@ -4,7 +4,7 @@
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]="3c68e4be-fd09-560c-9654-f270e5d7ba73")}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]="76693c03-9395-5bbf-bcc8-fa15e408f30f")}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";
@@ -50,6 +50,7 @@ import { inspectMergeReceiptEvidence, partitionMergeReceipts, } from "../merge/r
50
50
  import { runHistoryRepair } from "../history-repair.js";
51
51
  import { resolveWorkspaceRelationshipKindRegistry } from "../graph/assembly.js";
52
52
  import { analyzeHierarchyIntegrity, } from "../graph/hierarchy-integrity.js";
53
+ import { buildStatusRoleWarnings, inspectStatusRoleAssignments, } from "./status-role-diagnostics.js";
53
54
  const PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
54
55
  const STALE_VECTORIZATION_SUMMARY_LIMIT = 25;
55
56
  const BRIEF_HEALTH_DETAIL_LIMIT = 8;
@@ -1834,12 +1835,17 @@ function buildDirectoriesHealthCheck(directoryState, strictDirectories) {
1834
1835
  },
1835
1836
  };
1836
1837
  }
1837
- function buildSettingsValuesHealthCheck(settingWarnings) {
1838
+ function buildSettingsValuesHealthCheck(settingWarnings, statusRoleDiagnostics) {
1838
1839
  return {
1839
1840
  name: "settings_values",
1840
1841
  status: settingWarnings.length === 0 ? "ok" : "warn",
1841
1842
  ok: settingWarnings.length === 0,
1842
- details: { warnings: settingWarnings },
1843
+ details: {
1844
+ warnings: settingWarnings,
1845
+ ...(statusRoleDiagnostics.roleless_status_count > 0
1846
+ ? { lifecycle_status_roles: statusRoleDiagnostics }
1847
+ : {}),
1848
+ },
1843
1849
  };
1844
1850
  }
1845
1851
  /** Preserve unknown-author totals for current and legacy scan payloads. */
@@ -2129,7 +2135,7 @@ export async function runHealth(global, options = {}) {
2129
2135
  const strictDirectories = options.strictDirectories === true;
2130
2136
  const refreshPolicy = resolveVectorRefreshPolicy(options);
2131
2137
  const directoryState = await scanHealthDirectories(pmRoot, typeRegistry, strictDirectories);
2132
- const settingWarnings = validateSettingsValues(settings);
2138
+ const settingsValueWarnings = validateSettingsValues(settings);
2133
2139
  const telemetryCheck = await buildTelemetryCheck(settings, {
2134
2140
  checkTelemetry: options.checkTelemetry === true,
2135
2141
  });
@@ -2144,6 +2150,11 @@ export async function runHealth(global, options = {}) {
2144
2150
  itemReadWarnings,
2145
2151
  });
2146
2152
  const itemsWithBody = items;
2153
+ const statusRoleDiagnostics = inspectStatusRoleAssignments(resolveRuntimeStatusRegistry(settings.schema), items);
2154
+ const settingWarnings = [
2155
+ ...settingsValueWarnings,
2156
+ ...buildStatusRoleWarnings(statusRoleDiagnostics),
2157
+ ];
2147
2158
  const historyPolicy = skipPolicy.skipDrift
2148
2159
  ? { warnings: [] }
2149
2160
  : await enforceHistoryStreamPolicyForItems({
@@ -2197,7 +2208,7 @@ export async function runHealth(global, options = {}) {
2197
2208
  const checks = [
2198
2209
  buildSettingsHealthCheck(settingsPath, settings, normalizedSettingsReadWarnings),
2199
2210
  buildDirectoriesHealthCheck(directoryState, strictDirectories),
2200
- buildSettingsValuesHealthCheck(settingWarnings),
2211
+ buildSettingsValuesHealthCheck(settingWarnings, statusRoleDiagnostics),
2201
2212
  telemetryCheck.check,
2202
2213
  extensionCheck.check,
2203
2214
  buildStorageHealthCheck(items, settings, historySummary, authorAttribution, staleInProgress.scan, provenanceResolverOutcomes, provenanceInvalidValues),
@@ -2298,4 +2309,4 @@ export const _testOnlyHealthCommand = {
2298
2309
  warningCode,
2299
2310
  };
2300
2311
  //# sourceMappingURL=health.js.map
2301
- //# debugId=3c68e4be-fd09-560c-9654-f270e5d7ba73
2312
+ //# debugId=76693c03-9395-5bbf-bcc8-fa15e408f30f
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @module sdk/governance/status-role-diagnostics
3
+ *
4
+ * Diagnoses lifecycle statuses that cannot participate in role-derived project
5
+ * management views because they have no registered lifecycle role.
6
+ */
7
+ import type { ItemMetadata } from "../../types/index.js";
8
+ import { type RuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
9
+ /** Bounded evidence describing roleless status definitions and affected items. */
10
+ export interface StatusRoleDiagnostics {
11
+ /** Total number of registered status ids that have no lifecycle role. */
12
+ roleless_status_count: number;
13
+ /** Registered status ids that have no lifecycle role. */
14
+ roleless_statuses: string[];
15
+ /** Whether roleless status ids were omitted from the bounded sample. */
16
+ roleless_statuses_truncated: boolean;
17
+ /** Number of items whose status resolves to a roleless definition. */
18
+ affected_item_count: number;
19
+ /** Bounded, deterministic sample of affected item ids. */
20
+ affected_item_ids: string[];
21
+ /** Whether affected item ids were omitted from the bounded sample. */
22
+ affected_item_ids_truncated: boolean;
23
+ }
24
+ /** Inspect role registration and affected items without mutating the tracker. */
25
+ export declare function inspectStatusRoleAssignments(statusRegistry: RuntimeStatusRegistry, items: readonly ItemMetadata[], itemLimit?: number): StatusRoleDiagnostics;
26
+ /** Convert role diagnostics into the stable health/validate warning token. */
27
+ export declare function buildStatusRoleWarnings(diagnostics: StatusRoleDiagnostics): string[];
@@ -0,0 +1,36 @@
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]="cd7acf28-cb93-516e-9058-54c32625ec26")}catch(e){}}();
3
+ import { normalizeStatusInputWithRegistry, } from "../../core/schema/runtime-schema.js";
4
+ /** Inspect role registration and affected items without mutating the tracker. */
5
+ export function inspectStatusRoleAssignments(statusRegistry, items, itemLimit = 25) {
6
+ const rolelessStatuses = statusRegistry.definitions
7
+ .filter((definition) => definition.roles.length === 0)
8
+ .map((definition) => definition.id)
9
+ .sort((left, right) => left.localeCompare(right));
10
+ const rolelessSet = new Set(rolelessStatuses);
11
+ const affectedItemIds = items
12
+ .filter((item) => {
13
+ const resolved = normalizeStatusInputWithRegistry(item.status, statusRegistry);
14
+ return resolved !== undefined && rolelessSet.has(resolved);
15
+ })
16
+ .map((item) => item.id)
17
+ .sort((left, right) => left.localeCompare(right));
18
+ return {
19
+ roleless_status_count: rolelessStatuses.length,
20
+ roleless_statuses: rolelessStatuses.slice(0, itemLimit),
21
+ roleless_statuses_truncated: rolelessStatuses.length > itemLimit,
22
+ affected_item_count: affectedItemIds.length,
23
+ affected_item_ids: affectedItemIds.slice(0, itemLimit),
24
+ affected_item_ids_truncated: affectedItemIds.length > itemLimit,
25
+ };
26
+ }
27
+ /** Convert role diagnostics into the stable health/validate warning token. */
28
+ export function buildStatusRoleWarnings(diagnostics) {
29
+ return diagnostics.roleless_status_count === 0
30
+ ? []
31
+ : [
32
+ `schema_status_missing_lifecycle_role:${diagnostics.roleless_status_count}`,
33
+ ];
34
+ }
35
+ //# sourceMappingURL=status-role-diagnostics.js.map
36
+ //# debugId=cd7acf28-cb93-516e-9058-54c32625ec26
@@ -0,0 +1,6 @@
1
+ /** Normalize a repository-relative path to stable forward-slash form. */
2
+ export declare function normalizeRelativePath(value: string): string;
3
+ /** Normalize a repository-relative directory without trailing separators. */
4
+ export declare function normalizeRelativeDirectoryPath(value: string): string;
5
+ /** Treat blank and legacy null-like metadata tokens as absent values. */
6
+ export declare function toMeaningfulString(value: unknown): string | undefined;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @module sdk/governance/validate-normalization
3
+ *
4
+ * Provides shared path and meaningful-value normalization for validation
5
+ * diagnostics without coupling the helpers to the command orchestration.
6
+ */
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]="de2cc648-965a-59c9-b688-0fe12edeec82")}catch(e){}}();
9
+ import { toNonEmptyStringOrUndefined } from "../../core/shared/primitives.js";
10
+ /** Normalize a repository-relative path to stable forward-slash form. */
11
+ export function normalizeRelativePath(value) {
12
+ return value
13
+ .replaceAll("\\", "/")
14
+ .replace(/^\.\/+/, "")
15
+ .replace(/^\/+/, "");
16
+ }
17
+ /** Normalize a repository-relative directory without trailing separators. */
18
+ export function normalizeRelativeDirectoryPath(value) {
19
+ return normalizeRelativePath(value).replace(/\/+$/, "");
20
+ }
21
+ /** Treat blank and legacy null-like metadata tokens as absent values. */
22
+ export function toMeaningfulString(value) {
23
+ const normalized = toNonEmptyStringOrUndefined(value);
24
+ if (!normalized) {
25
+ return undefined;
26
+ }
27
+ const lowered = normalized.toLowerCase();
28
+ if (lowered === "none" ||
29
+ lowered === "null" ||
30
+ lowered === "n/a" ||
31
+ lowered === "na") {
32
+ return undefined;
33
+ }
34
+ return normalized;
35
+ }
36
+ //# sourceMappingURL=validate-normalization.js.map
37
+ //# debugId=de2cc648-965a-59c9-b688-0fe12edeec82
@@ -8,6 +8,7 @@ import { type OutputProjectionDeclaration } from "../output-projection.js";
8
8
  import { type RelationshipKindRegistry } from "../relationships.js";
9
9
  import { type ValidateItem } from "./validate-item-reader.js";
10
10
  import { buildLifecycleParentGraph, detectLifecycleParentCycles, resolveLifecycleDependencyCycleSamplePath } from "./hierarchy-validation.js";
11
+ import { toMeaningfulString } from "./validate-normalization.js";
11
12
  type ValidateCheckName = "metadata" | "resolution" | "lifecycle" | "dependency_references" | "files" | "command_references" | "history_drift" | "format_version" | "storage_integrity";
12
13
  type ValidateStatus = "ok" | "warn" | "error";
13
14
  type ValidateDependencyCycleSeverity = "off" | "warn" | "error";
@@ -153,7 +154,6 @@ export interface ValidateCountsResult extends Omit<ValidateResult, "fixes"> {
153
154
  * totals, statuses, and truncation markers are preserved.
154
155
  */
155
156
  export declare function projectValidateCounts(result: ValidateResult): ValidateCountsResult;
156
- declare function toMeaningfulString(value: unknown): string | undefined;
157
157
  interface ValidateMetadataPolicy {
158
158
  profile: ValidateMetadataProfile;
159
159
  profile_source: "default" | "settings" | "option";
@@ -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]="e7a231e7-0546-5d5f-b0c8-59629ad4d731")}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]="cde10e58-cfeb-5718-a471-3e4acf46cfe7")}catch(e){}}();
8
8
  import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
9
  import fs from "node:fs/promises";
10
10
  import { realpathSync } from "node:fs";
@@ -46,6 +46,8 @@ import { resolveLinkedTestSourceRef, resolveLinkedTestSourceWorkspaceRoot, resol
46
46
  import { readValidateItems, } from "./validate-item-reader.js";
47
47
  import { buildValidateHistoryDriftCheck } from "./validate-history-drift.js";
48
48
  import { buildLifecycleParentGraph, detectLifecycleParentCycles, resolveLifecycleDependencyCycleSamplePath, } from "./hierarchy-validation.js";
49
+ import { buildStatusRoleWarnings, inspectStatusRoleAssignments, } from "./status-role-diagnostics.js";
50
+ import { normalizeRelativeDirectoryPath, normalizeRelativePath, toMeaningfulString, } from "./validate-normalization.js";
49
51
  const FILE_SCAN_DIRECTORIES = ["src", "tests", "docs"];
50
52
  const FILE_SCAN_ROOT_FILES = [
51
53
  "README.md",
@@ -205,30 +207,6 @@ export function projectValidateCounts(result) {
205
207
  : {}),
206
208
  };
207
209
  }
208
- function normalizeRelativePath(value) {
209
- return value
210
- .replaceAll("\\", "/")
211
- .replace(/^\.\/+/, "")
212
- .replace(/^\/+/, "");
213
- }
214
- function normalizeRelativeDirectoryPath(value) {
215
- const normalized = normalizeRelativePath(value);
216
- return normalized.replace(/\/+$/, "");
217
- }
218
- function toMeaningfulString(value) {
219
- const normalized = toNonEmptyStringOrUndefined(value);
220
- if (!normalized) {
221
- return undefined;
222
- }
223
- const lowered = normalized.toLowerCase();
224
- if (lowered === "none" ||
225
- lowered === "null" ||
226
- lowered === "n/a" ||
227
- lowered === "na") {
228
- return undefined;
229
- }
230
- return normalized;
231
- }
232
210
  /* c8 ignore start -- runtime-status alias normalization is covered by status-registry integration tests */
233
211
  function normalizeStatusForRegistry(status, statusRegistry) {
234
212
  return normalizeStatusInput(status, statusRegistry) ?? status;
@@ -1484,15 +1462,21 @@ function buildLifecycleCheck(items, includeStaleBlockers, dependencyCycleSeverit
1484
1462
  sortLifecycleScanRows(rows);
1485
1463
  const dependencyCycleDiagnostics = detectLifecycleDependencyCycles(rows.activeItems, idPrefix);
1486
1464
  const parentCycleDiagnostics = detectLifecycleParentCycles(items, statusRegistry);
1487
- const warnings = buildLifecycleWarnings(rows, includeStaleBlockers, dependencyCycleSeverity, parentCycleSeverity, {
1488
- dependencyCycles: dependencyCycleDiagnostics.cycle_count,
1489
- activeHierarchyCycles: parentCycleDiagnostics.active_cycle_count,
1490
- activeHierarchyCardinality: parentCycleDiagnostics.active_cardinality_violation_count,
1491
- activeHierarchyDivergence: parentCycleDiagnostics.active_parent_divergence_count,
1492
- legacyHierarchyCycles: parentCycleDiagnostics.legacy_cycle_count,
1493
- legacyHierarchyCardinality: parentCycleDiagnostics.legacy_cardinality_violation_count,
1494
- legacyHierarchyDivergence: parentCycleDiagnostics.legacy_parent_divergence_count,
1495
- });
1465
+ const statusRoleDiagnostics = inspectStatusRoleAssignments(statusRegistry, items, verboseDiagnostics
1466
+ ? Number.POSITIVE_INFINITY
1467
+ : DIAGNOSTIC_LIST_SUMMARY_LIMIT);
1468
+ const warnings = [
1469
+ ...buildLifecycleWarnings(rows, includeStaleBlockers, dependencyCycleSeverity, parentCycleSeverity, {
1470
+ dependencyCycles: dependencyCycleDiagnostics.cycle_count,
1471
+ activeHierarchyCycles: parentCycleDiagnostics.active_cycle_count,
1472
+ activeHierarchyCardinality: parentCycleDiagnostics.active_cardinality_violation_count,
1473
+ activeHierarchyDivergence: parentCycleDiagnostics.active_parent_divergence_count,
1474
+ legacyHierarchyCycles: parentCycleDiagnostics.legacy_cycle_count,
1475
+ legacyHierarchyCardinality: parentCycleDiagnostics.legacy_cardinality_violation_count,
1476
+ legacyHierarchyDivergence: parentCycleDiagnostics.legacy_parent_divergence_count,
1477
+ }),
1478
+ ...buildStatusRoleWarnings(statusRoleDiagnostics),
1479
+ ];
1496
1480
  const diagnosticLimit = verboseDiagnostics
1497
1481
  ? Number.POSITIVE_INFINITY
1498
1482
  : DIAGNOSTIC_LIST_SUMMARY_LIMIT;
@@ -1522,6 +1506,7 @@ function buildLifecycleCheck(items, includeStaleBlockers, dependencyCycleSeverit
1522
1506
  ok: !hasErrorSeverityCycle && warnings.length === 0,
1523
1507
  details: {
1524
1508
  checked_active_items: rows.activeItems.length,
1509
+ lifecycle_status_roles: statusRoleDiagnostics,
1525
1510
  active_closure_like_metadata_items: rows.closureLikeRows.length,
1526
1511
  active_closure_like_metadata_rows: summarizedClosureLikeRows.values,
1527
1512
  active_closure_like_metadata_rows_truncated: summarizedClosureLikeRows.truncated,
@@ -2288,4 +2273,4 @@ export async function runValidate(options, global, services = {}) {
2288
2273
  }
2289
2274
  /* c8 ignore stop */
2290
2275
  //# sourceMappingURL=validate.js.map
2291
- //# debugId=e7a231e7-0546-5d5f-b0c8-59629ad4d731
2276
+ //# debugId=cde10e58-cfeb-5718-a471-3e4acf46cfe7
@@ -0,0 +1,69 @@
1
+ import type { GlobalOptions } from "../../core/shared/command-types.js";
2
+ import { type MergeDriverConfigurationAuditResult, type MergeFenceAuditResult } from "../merge/install.js";
3
+ /** Stable readiness classifications returned by the workspace-position read. */
4
+ export type WorkspacePositionState = "ready" | "merge_evidence_invalid" | "history_evidence_invalid" | "merge_reconciliation_required" | "history_repair_required" | "merge_fence_unprepared";
5
+ /** One deterministic recovery action selected from aggregate workspace evidence. */
6
+ export interface WorkspacePositionNextAction {
7
+ /** Executable pm command, or null when the workspace is ready. */
8
+ command: string | null;
9
+ /** Stable reason code explaining why this action takes precedence. */
10
+ reason: WorkspacePositionState;
11
+ }
12
+ /** Bounded SDK result shared by CLI, MCP, and package consumers. */
13
+ export interface WorkspacePositionResult {
14
+ /** Whether all readiness evidence is clean. */
15
+ ok: boolean;
16
+ /** Highest-priority workspace readiness classification. */
17
+ state: WorkspacePositionState;
18
+ /** Committed merge-fence and clone-local driver evidence. */
19
+ merge_fence: {
20
+ committed: MergeFenceAuditResult;
21
+ clone_local_drivers: MergeDriverConfigurationAuditResult | null;
22
+ };
23
+ /** Bounded pending receipt evidence without private merge values. */
24
+ merge_receipts: {
25
+ pending_decision_count: number;
26
+ pending_item_ids: string[];
27
+ pending_item_ids_truncated: boolean;
28
+ lossless_count: number;
29
+ invalid_evidence_count: number;
30
+ };
31
+ /** Bounded append-only history drift evidence. */
32
+ history_drift: {
33
+ /** Whether the required history-drift evidence has its expected shape. */
34
+ evidence_valid: boolean;
35
+ drifted_item_count: number;
36
+ drifted_item_ids: string[];
37
+ drifted_item_ids_truncated: boolean;
38
+ counts: Record<string, unknown>;
39
+ };
40
+ /** One deterministic next action, avoiding multi-command guesswork. */
41
+ next_action: WorkspacePositionNextAction;
42
+ /** Non-fatal read warnings retained from the authoritative item scan. */
43
+ warnings: string[];
44
+ /** ISO timestamp for this aggregate read. */
45
+ generated_at: string;
46
+ }
47
+ declare function selectWorkspacePositionState(params: {
48
+ invalidEvidenceCount: number;
49
+ pendingDecisionCount: number;
50
+ losslessCount: number;
51
+ historyEvidenceValid: boolean;
52
+ driftedItemCount: number;
53
+ fence: MergeFenceAuditResult;
54
+ drivers: MergeDriverConfigurationAuditResult | null;
55
+ }): WorkspacePositionState;
56
+ declare function commandForWorkspacePositionState(state: WorkspacePositionState, pmRoot: string, platform?: NodeJS.Platform): string | null;
57
+ /** Normalize defensive history-check evidence into the bounded position shape. */
58
+ declare function normalizeWorkspaceHistoryDrift(details: Record<string, unknown>): WorkspacePositionResult["history_drift"];
59
+ /** Read aggregate workspace position without flags, session state, or mutation. */
60
+ export declare function readWorkspacePosition(global: GlobalOptions): Promise<WorkspacePositionResult>;
61
+ /** Render the bounded workspace position for human CLI output. */
62
+ export declare function formatWorkspacePositionHuman(result: WorkspacePositionResult): string;
63
+ /** Public contract for focused unit verification. */
64
+ export declare const _testOnlyWorkspacePosition: {
65
+ commandForWorkspacePositionState: typeof commandForWorkspacePositionState;
66
+ normalizeWorkspaceHistoryDrift: typeof normalizeWorkspaceHistoryDrift;
67
+ selectWorkspacePositionState: typeof selectWorkspacePositionState;
68
+ };
69
+ export {};
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @module sdk/governance/workspace-position
3
+ *
4
+ * Produces one bounded, read-only workspace readiness answer from merge-fence,
5
+ * merge-receipt, and append-only history evidence.
6
+ */
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]="e900c117-6d8d-55d3-86df-f543dc499930")}catch(e){}}();
9
+ import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
10
+ import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
11
+ import { nowIso } from "../../core/shared/time.js";
12
+ import { resolvePmRoot } from "../../core/store/paths.js";
13
+ import { readSettings } from "../../core/store/settings.js";
14
+ import { renderPmCommand } from "../command-line.js";
15
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
16
+ import { auditMergeAttributeFence, auditMergeDriverConfiguration, findGitWorkspaceRoot, resolveProjectMergeTypeFolders, } from "../merge/install.js";
17
+ import { inspectMergeReceiptEvidence, partitionMergeReceipts, } from "../merge/receipts.js";
18
+ import { buildValidateHistoryDriftCheck } from "./validate-history-drift.js";
19
+ import { readValidateItems } from "./validate-item-reader.js";
20
+ function selectWorkspacePositionState(params) {
21
+ if (params.invalidEvidenceCount > 0)
22
+ return "merge_evidence_invalid";
23
+ if (!params.historyEvidenceValid)
24
+ return "history_evidence_invalid";
25
+ if (params.pendingDecisionCount > 0 || params.losslessCount > 0) {
26
+ return "merge_reconciliation_required";
27
+ }
28
+ if (params.driftedItemCount > 0)
29
+ return "history_repair_required";
30
+ if (params.fence.status !== "ok" ||
31
+ params.drivers === null ||
32
+ params.drivers.status !== "ok") {
33
+ return "merge_fence_unprepared";
34
+ }
35
+ return "ready";
36
+ }
37
+ function commandForWorkspacePositionState(state, pmRoot, platform = process.platform) {
38
+ const commandArgs = ["--pm-path", pmRoot];
39
+ if (state === "merge_evidence_invalid")
40
+ return renderPmCommand([...commandArgs, "merge", "report"], platform);
41
+ if (state === "history_evidence_invalid") {
42
+ return renderPmCommand([...commandArgs, "validate", "--check-history-drift", "--full"], platform);
43
+ }
44
+ if (state === "merge_reconciliation_required") {
45
+ return renderPmCommand([...commandArgs, "merge", "reconcile"], platform);
46
+ }
47
+ if (state === "history_repair_required") {
48
+ return renderPmCommand([...commandArgs, "history-repair", "--all"], platform);
49
+ }
50
+ if (state === "merge_fence_unprepared") {
51
+ return renderPmCommand([...commandArgs, "merge", "install"], platform);
52
+ }
53
+ return null;
54
+ }
55
+ /** Normalize defensive history-check evidence into the bounded position shape. */
56
+ function normalizeWorkspaceHistoryDrift(details) {
57
+ const driftedItemIds = Array.isArray(details.drifted_items)
58
+ ? details.drifted_items.filter((entry) => typeof entry === "string")
59
+ : [];
60
+ const evidenceValid = Array.isArray(details.drifted_items) &&
61
+ details.drifted_items.every((entry) => typeof entry === "string") &&
62
+ typeof details.drifted_items_count === "number" &&
63
+ Number.isInteger(details.drifted_items_count) &&
64
+ details.drifted_items_count >= 0 &&
65
+ typeof details.drifted_items_truncated === "boolean" &&
66
+ typeof details.counts === "object" &&
67
+ details.counts !== null &&
68
+ !Array.isArray(details.counts);
69
+ return {
70
+ evidence_valid: evidenceValid,
71
+ drifted_item_count: typeof details.drifted_items_count === "number"
72
+ ? details.drifted_items_count
73
+ : driftedItemIds.length,
74
+ drifted_item_ids: driftedItemIds,
75
+ drifted_item_ids_truncated: details.drifted_items_truncated === true,
76
+ counts: typeof details.counts === "object" && details.counts !== null
77
+ ? details.counts
78
+ : {},
79
+ };
80
+ }
81
+ /** Read aggregate workspace position without flags, session state, or mutation. */
82
+ export async function readWorkspacePosition(global) {
83
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
84
+ await assertInitializedTracker(pmRoot);
85
+ const settings = await readSettings(pmRoot);
86
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
87
+ const itemReadWarnings = [];
88
+ const items = await readValidateItems({
89
+ includeBody: true,
90
+ pmRoot,
91
+ settings,
92
+ typeToFolder: typeRegistry.type_to_folder,
93
+ warnings: itemReadWarnings,
94
+ });
95
+ const gitWorkspaceRoot = await findGitWorkspaceRoot(pmRoot);
96
+ const [fence, drivers, receiptEvidence, drift] = await Promise.all([
97
+ auditMergeAttributeFence(pmRoot, resolveProjectMergeTypeFolders(settings)),
98
+ gitWorkspaceRoot === null
99
+ ? Promise.resolve(null)
100
+ : auditMergeDriverConfiguration(gitWorkspaceRoot),
101
+ inspectMergeReceiptEvidence(gitWorkspaceRoot ?? pmRoot, {
102
+ includeLossless: true,
103
+ pmRoot,
104
+ }),
105
+ buildValidateHistoryDriftCheck(pmRoot, items, false),
106
+ ]);
107
+ const { pendingDecisions, lossless } = partitionMergeReceipts(receiptEvidence.receipts);
108
+ const pendingItemIds = [
109
+ ...new Set(pendingDecisions.map((receipt) => receipt.item_id)),
110
+ ].sort((left, right) => left.localeCompare(right));
111
+ const driftDetails = drift.check.details;
112
+ const historyDrift = normalizeWorkspaceHistoryDrift(driftDetails);
113
+ const state = selectWorkspacePositionState({
114
+ invalidEvidenceCount: receiptEvidence.invalid_evidence_count,
115
+ pendingDecisionCount: pendingDecisions.length,
116
+ losslessCount: lossless.length,
117
+ historyEvidenceValid: historyDrift.evidence_valid,
118
+ driftedItemCount: historyDrift.drifted_item_count,
119
+ fence,
120
+ drivers,
121
+ });
122
+ return {
123
+ ok: state === "ready",
124
+ state,
125
+ merge_fence: {
126
+ committed: fence,
127
+ clone_local_drivers: drivers,
128
+ },
129
+ merge_receipts: {
130
+ pending_decision_count: pendingDecisions.length,
131
+ pending_item_ids: pendingItemIds.slice(0, 25),
132
+ pending_item_ids_truncated: pendingItemIds.length > 25,
133
+ lossless_count: lossless.length,
134
+ invalid_evidence_count: receiptEvidence.invalid_evidence_count,
135
+ },
136
+ history_drift: historyDrift,
137
+ next_action: {
138
+ command: commandForWorkspacePositionState(state, pmRoot),
139
+ reason: state,
140
+ },
141
+ warnings: [...new Set(itemReadWarnings)].sort((left, right) => left.localeCompare(right)),
142
+ generated_at: nowIso(),
143
+ };
144
+ }
145
+ /** Render the bounded workspace position for human CLI output. */
146
+ export function formatWorkspacePositionHuman(result) {
147
+ const action = result.next_action.command ?? "none";
148
+ return [
149
+ `workspace_position: ${result.state}`,
150
+ `merge_fence: ${result.merge_fence.committed.status}`,
151
+ `clone_local_drivers: ${result.merge_fence.clone_local_drivers?.status ?? "unavailable"}`,
152
+ `pending_merge_decisions: ${result.merge_receipts.pending_decision_count}`,
153
+ `history_drifted_items: ${result.history_drift.drifted_item_count}`,
154
+ `next_action: ${action}`,
155
+ ].join("\n");
156
+ }
157
+ /** Public contract for focused unit verification. */
158
+ export const _testOnlyWorkspacePosition = {
159
+ commandForWorkspacePositionState,
160
+ normalizeWorkspaceHistoryDrift,
161
+ selectWorkspacePositionState,
162
+ };
163
+ //# sourceMappingURL=workspace-position.js.map
164
+ //# debugId=e900c117-6d8d-55d3-86df-f543dc499930
@@ -16,6 +16,8 @@ export * from "./governance/defect-recurrence.js";
16
16
  export { runReindex, type ReindexOptions, type ReindexResult, } from "./governance/reindex.js";
17
17
  export * from "./governance/stale-work.js";
18
18
  export * from "./governance/storage-integrity.js";
19
+ export * from "./governance/status-role-diagnostics.js";
20
+ export * from "./governance/workspace-position.js";
19
21
  export { runUpgrade, type UpgradeCliResult, type UpgradeCommandOptions, type UpgradeCommandRunner, type UpgradeCommandRunnerResult, type UpgradePackageResult, type UpgradeResult, } from "./governance/upgrade.js";
20
22
  export * from "./governance/validate.js";
21
23
  export * from "./author-attribution.js";
@@ -4,7 +4,7 @@
4
4
  * Provides validation, health, integrity, and mutation-policy primitives.
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]="c2063b82-58b6-54c9-baff-ca252cadf463")}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]="ff251826-36f0-5b92-bee8-ca71d265986c")}catch(e){}}();
8
8
  export * from "./governance/gc.js";
9
9
  export * from "./governance/health.js";
10
10
  export * from "./governance/extension-host-version.js";
@@ -18,6 +18,8 @@ export * from "./governance/defect-recurrence.js";
18
18
  export { runReindex, } from "./governance/reindex.js";
19
19
  export * from "./governance/stale-work.js";
20
20
  export * from "./governance/storage-integrity.js";
21
+ export * from "./governance/status-role-diagnostics.js";
22
+ export * from "./governance/workspace-position.js";
21
23
  export { runUpgrade, } from "./governance/upgrade.js";
22
24
  export * from "./governance/validate.js";
23
25
  export * from "./author-attribution.js";
@@ -25,4 +27,4 @@ export * from "./mutation-guard.js";
25
27
  export * from "./governance/provenance-health.js";
26
28
  export * from "./similarity.js";
27
29
  //# sourceMappingURL=governance.js.map
28
- //# debugId=c2063b82-58b6-54c9-baff-ca252cadf463
30
+ //# debugId=ff251826-36f0-5b92-bee8-ca71d265986c
@@ -7,13 +7,13 @@
7
7
  * systems without acquiring locks or appending history.
8
8
  */
9
9
 
10
- !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]="aca866d3-32b9-5212-bb4b-f1484e41bb27")}catch(e){}}();
10
+ !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]="f1ea4209-59d4-53f0-a8ea-2e060e385d14")}catch(e){}}();
11
11
  import { assertInitializedTracker } from "./environment/tracker-preflight.js";
12
12
  import { getActiveExtensionRegistrations } from "../core/extensions/index.js";
13
13
  import { applyHistoryPatch, ensureMaterializedHistoryTarget, extractPatchFailureContext, replayHistoryToTarget, resolveHistoryTarget, } from "../core/history/projection.js";
14
14
  import { readHistoryEntries } from "../core/history/read.js";
15
- import { hashDocument, hashEmptyDocument, } from "../core/history/history.js";
16
- import { replayToCanonicalItemDocument, verifyHistoryChain, } from "../core/history/replay.js";
15
+ import { hashDocument, hashDocumentVerificationCandidates, hashEmptyDocument, } from "../core/history/history.js";
16
+ import { replayToCanonicalItemDocument, verifyHistoryChainWithVersion, } from "../core/history/replay.js";
17
17
  import { resolveItemTypeRegistry } from "../core/item/type-registry.js";
18
18
  import { EXIT_CODE } from "../core/shared/constants.js";
19
19
  import { PmCliError } from "../core/shared/errors.js";
@@ -28,11 +28,19 @@ import { resolveHistorySubject } from "./history-redact.js";
28
28
  * document to compare.
29
29
  */
30
30
  export function verifyHistoryEntries(history, currentDocument) {
31
- const verification = verifyHistoryChain(history);
31
+ const verification = verifyHistoryChainWithVersion(history);
32
32
  const latestAfterHash = history.length > 0
33
33
  ? history[history.length - 1].after_hash
34
34
  : hashEmptyDocument();
35
- const currentItemHash = currentDocument === undefined ? undefined : hashDocument(currentDocument);
35
+ const currentItemHashCandidates = currentDocument === undefined ||
36
+ verification.item_hash_version === undefined
37
+ ? undefined
38
+ : hashDocumentVerificationCandidates(currentDocument, verification.item_hash_version);
39
+ const currentItemHash = currentDocument === undefined
40
+ ? undefined
41
+ : currentItemHashCandidates === undefined
42
+ ? hashDocument(currentDocument)
43
+ : currentItemHashCandidates[Math.max(0, currentItemHashCandidates.indexOf(latestAfterHash))];
36
44
  const currentMatchesLatest = currentItemHash === undefined
37
45
  ? undefined
38
46
  : currentItemHash === latestAfterHash;
@@ -83,4 +91,4 @@ export async function getItemAt(id, target, options = {}) {
83
91
  }
84
92
  export { applyHistoryPatch, ensureMaterializedHistoryTarget, extractPatchFailureContext, readHistoryEntries, replayHistoryToTarget, resolveHistoryTarget, };
85
93
  //# sourceMappingURL=history-read.js.map
86
- //# debugId=aca866d3-32b9-5212-bb4b-f1484e41bb27
94
+ //# debugId=f1ea4209-59d4-53f0-a8ea-2e060e385d14