@unbrained/pm-cli 2026.8.24 → 2026.8.25

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 (95) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +13 -0
  3. package/dist/cli-bundle/bundle-manifest.json +152 -152
  4. package/dist/cli-bundle/chunks/{chunk-ZAVCS2GH.js → chunk-244MI4GS.js} +3 -3
  5. package/dist/cli-bundle/chunks/{chunk-NXBFO63A.js → chunk-2F3LUFMW.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-DJNJBWAQ.js → chunk-5I5RWIJC.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-X7WWQDYQ.js → chunk-65MHLHAA.js} +2 -2
  8. package/dist/cli-bundle/chunks/chunk-6C7GIMIL.js +13 -0
  9. package/dist/cli-bundle/chunks/{chunk-IW72J5FW.js → chunk-OWHNAR2B.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-TEQDR5KI.js → chunk-QKGMHGEI.js} +62 -62
  11. package/dist/cli-bundle/chunks/{chunk-L22NP5MA.js → chunk-QLUORNIB.js} +86 -86
  12. package/dist/cli-bundle/chunks/{chunk-AGUL3HUT.js → chunk-T2ENPRXF.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-I5Q7QSZX.js → chunk-TPQIBSL2.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-YQMYF3YD.js +35 -0
  15. package/dist/cli-bundle/chunks/{register-list-query-37A4P6O4.js → register-list-query-XVN2ZLI7.js} +2 -2
  16. package/dist/cli-bundle/chunks/{register-mutation-TBJDHYIT.js → register-mutation-QCKAEGIJ.js} +3 -3
  17. package/dist/cli-bundle/chunks/{register-operations-WRZNEBUM.js → register-operations-SDEAXE7E.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-setup-H4PDLACD.js → register-setup-LXVBRCJ3.js} +2 -2
  19. package/dist/cli-bundle/focused-chunks/{chunk-CWCN5RLO.js → chunk-2UIWOP3O.js} +2 -2
  20. package/dist/cli-bundle/focused-chunks/chunk-42S3GGZ7.js +50 -0
  21. package/dist/cli-bundle/focused-chunks/{chunk-BFA6KKCI.js → chunk-7I23XGWO.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/{chunk-6Z24ZMU3.js → chunk-7YCDTCBC.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/{chunk-O4ZXNJMT.js → chunk-A644DUFQ.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/{chunk-4WP7LNE3.js → chunk-GQR3WH3F.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-RASVBJX5.js → chunk-H5JZEIQV.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-IBZZZGK3.js +2 -0
  27. package/dist/cli-bundle/focused-chunks/chunk-LMKG3DFE.js +5 -0
  28. package/dist/cli-bundle/focused-chunks/{chunk-6MUTDXMP.js → chunk-N7W67YIG.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-IMWTYKII.js → chunk-NOOZGIXP.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-WZLSSGEU.js → chunk-OHIHZ7HS.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-ONYQCALA.js +19 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-QBP5FSBX.js → chunk-OVJL6NZE.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-RAFKLNZX.js +16 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-GJR6YEMR.js → chunk-VXWATRFL.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-IZNRRCU3.js → chunk-XUQPEKRN.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-MNPECIRL.js → chunk-YO3ZF3FI.js} +2 -2
  37. package/dist/cli-bundle/main.js +2 -2
  38. package/dist/cli-bundle/sdk-authoring.js +1 -1
  39. package/dist/cli-bundle/sdk-contracts.js +2 -2
  40. package/dist/cli-bundle/sdk-core.js +41 -41
  41. package/dist/cli-bundle/sdk-governance.js +1 -1
  42. package/dist/cli-bundle/sdk-graph.js +1 -1
  43. package/dist/cli-bundle/sdk-merge.js +32 -33
  44. package/dist/cli-bundle/sdk-query.js +1 -1
  45. package/dist/cli-bundle/sdk-runtime.js +1 -1
  46. package/dist/cli-bundle/sdk-testing.js +1 -1
  47. package/dist/cli-bundle/sdk.js +5 -5
  48. package/dist/core/diagnostics/remediation.js +17 -2
  49. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +10 -0
  50. package/dist/sdk/cli-contracts/runtime-contracts.js +20 -3
  51. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +49 -25
  52. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +26 -2
  53. package/dist/sdk/governance/health.js +98 -11
  54. package/dist/sdk/governance/validate.js +15 -9
  55. package/dist/sdk/history-repair.d.ts +24 -0
  56. package/dist/sdk/history-repair.js +145 -4
  57. package/dist/sdk/merge/driver.js +25 -4
  58. package/dist/sdk/merge/receipt-file-boundary.d.ts +21 -0
  59. package/dist/sdk/merge/receipt-file-boundary.js +47 -0
  60. package/dist/sdk/merge/receipts.d.ts +24 -1
  61. package/dist/sdk/merge/receipts.js +342 -36
  62. package/dist/sdk/merge/reconcile.js +117 -47
  63. package/dist/sdk/read-output/continuation.d.ts +15 -2
  64. package/dist/sdk/read-output/continuation.js +86 -6
  65. package/dist/sdk/read-output-contracts.d.ts +4 -1
  66. package/dist/sdk/read-output-contracts.js +9 -6
  67. package/docs/MERGE_SAFETY.md +34 -5
  68. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +13 -1
  69. package/docs/READ_OUTPUT_CONTRACTS.md +25 -2
  70. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +7 -3
  71. package/marketplace.json +2 -2
  72. package/package.json +1 -1
  73. package/packages/pm-beads/package.json +1 -1
  74. package/packages/pm-calendar/package.json +1 -1
  75. package/packages/pm-command-kit/package.json +1 -1
  76. package/packages/pm-digital-twin/package.json +1 -1
  77. package/packages/pm-governance-audit/package.json +1 -1
  78. package/packages/pm-guide-shell/package.json +1 -1
  79. package/packages/pm-kanban/package.json +1 -1
  80. package/packages/pm-lifecycle-hooks/package.json +1 -1
  81. package/packages/pm-linked-test-adapters/package.json +1 -1
  82. package/packages/pm-search-advanced/package.json +1 -1
  83. package/packages/pm-templates/package.json +1 -1
  84. package/packages/pm-todos/package.json +1 -1
  85. package/packages/pm-vcs/package.json +1 -1
  86. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  87. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  88. package/sdk/public-surface.json +136 -15
  89. package/dist/cli-bundle/chunks/chunk-MKE6MD2K.js +0 -36
  90. package/dist/cli-bundle/chunks/chunk-YOLLRCLY.js +0 -13
  91. package/dist/cli-bundle/focused-chunks/chunk-FCTT4CZU.js +0 -5
  92. package/dist/cli-bundle/focused-chunks/chunk-Q63PSLO4.js +0 -2
  93. package/dist/cli-bundle/focused-chunks/chunk-QV5UP27O.js +0 -51
  94. package/dist/cli-bundle/focused-chunks/chunk-RPRLENVA.js +0 -16
  95. package/dist/cli-bundle/focused-chunks/chunk-TOFVXBWA.js +0 -19
@@ -19,7 +19,7 @@
19
19
  */
20
20
  /** Registry of every non-extension `pm health` / `pm validate` warning code and its remediation. Extension findings keep their richer, contextual `details.triage.remediation` produced by the extension health triage and are intentionally excluded here (see pm-0hnu: "all non-extension checks"). */
21
21
 
22
- !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]="bc9e5edf-c275-5172-8900-fafee9b4a2db")}catch(e){}}();
22
+ !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]="c088607b-1be3-54c8-a38b-79c188924102")}catch(e){}}();
23
23
  export const REMEDIATION_REGISTRY = Object.freeze([
24
24
  // --- pm health: directories ---
25
25
  {
@@ -193,6 +193,16 @@ export const REMEDIATION_REGISTRY = Object.freeze([
193
193
  command: "pm merge reconcile --dry-run",
194
194
  summary: "Review the pending merge receipts, re-apply any intended discarded values, then run pm merge reconcile; lossy receipts require explicit --force acceptance.",
195
195
  },
196
+ {
197
+ code: "merge_receipts_pending",
198
+ command: "pm merge reconcile --dry-run",
199
+ summary: "A lossless merge receipt is still pending; preview and run pm merge reconcile so a green health gate certifies receipt settlement, not only intact data.",
200
+ },
201
+ {
202
+ code: "merge_receipt_evidence_invalid",
203
+ command: "pm health --check-only --full",
204
+ summary: "One or more receipt files failed bounded-file, schema, or identity validation; use the full health count to inspect the clone-local and durable receipt directories, then repair or remove only confirmed invalid evidence.",
205
+ },
196
206
  {
197
207
  code: "validate_merge_decisions_unreviewed",
198
208
  command: "pm merge reconcile --dry-run",
@@ -221,6 +231,11 @@ export const REMEDIATION_REGISTRY = Object.freeze([
221
231
  command: "pm history-repair <id>",
222
232
  summary: "The item's history chain is broken; re-anchor the chain (pm history-repair --all repairs every drifted stream in one pass).",
223
233
  },
234
+ {
235
+ code: "history_drift_merge_receipt",
236
+ command: "pm merge reconcile --dry-run",
237
+ summary: "Canonical path, changed-field, and merged-value hash evidence attributes this drift to a pending receipt; preview reconciliation instead of repairing history directly.",
238
+ },
224
239
  // --- pm health: storage (history compaction policy) ---
225
240
  {
226
241
  code: "history_stream_over_compact_threshold",
@@ -474,4 +489,4 @@ export function buildRemediationCommands(warnings) {
474
489
  return Object.values(buildRemediationMap(warnings));
475
490
  }
476
491
  //# sourceMappingURL=remediation.js.map
477
- //# debugId=bc9e5edf-c275-5172-8900-fafee9b4a2db
492
+ //# debugId=c088607b-1be3-54c8-a38b-79c188924102
@@ -126,6 +126,16 @@ export interface ContractsResult {
126
126
  degradation_ladder: string[];
127
127
  allows_unbounded_opt_out: boolean;
128
128
  };
129
+ /** Exact per-command projection vocabularies and the scope of the compatibility union. */
130
+ output_projection_contracts?: {
131
+ global_ladder_field: "output_policy.degradation_ladder";
132
+ global_ladder_scope: "union_not_per_command";
133
+ discovery: "pm contracts --command <command> --summary";
134
+ commands?: Array<{
135
+ command: string;
136
+ modes: string[];
137
+ }>;
138
+ };
129
139
  /** Value that configures or reports runtime schema for this contract. */
130
140
  runtime_schema?: {
131
141
  statuses: string[];
@@ -4,7 +4,7 @@
4
4
  * Implements the pm contracts 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]="e8f1efca-4e83-570f-8c33-96f0405035b0")}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]="428a19d2-be42-548a-a328-aa0e476b8a71")}catch(e){}}();
8
8
  import { EXIT_CODE, SETTINGS_DEFAULTS, PmCliError, activateExtensions, getActiveExtensionRegistrations, loadExtensions, pathExists, commandOptionFlagLabel, resolveCommandOptionPolicyState, resolveItemTypeRegistry, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
9
9
  import { buildMcpToolContracts, } from "../../mcp/tool-definitions.js";
10
10
  import { ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS, ACTIVITY_FLAG_CONTRACTS, AGGREGATE_FLAG_CONTRACTS, ASSURANCE_FLAG_CONTRACTS, APPEND_FLAG_CONTRACTS, CALENDAR_COMMANDER_STRING_OPTION_CONTRACTS, CALENDAR_FLAG_CONTRACTS, CLAIM_FLAG_CONTRACTS, CLOSE_TASK_FLAG_CONTRACTS, COMMENTS_FLAG_CONTRACTS, CLOSE_FLAG_CONTRACTS, CLOSE_MANY_FLAG_CONTRACTS, COMPLETION_FLAG_CONTRACTS, CONFIG_FLAG_CONTRACTS, CONTRACTS_FLAG_CONTRACTS, COPY_FLAG_CONTRACTS, CONTEXT_COMMANDER_STRING_OPTION_CONTRACTS, CONTEXT_FLAG_CONTRACTS, CREATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, CREATE_COMMANDER_STRING_OPTION_CONTRACTS, CREATE_FLAG_CONTRACTS, DELETE_FLAG_CONTRACTS, DEPS_FLAG_CONTRACTS, GRAPH_FLAG_CONTRACTS, DOCS_FLAG_CONTRACTS, EXTENSION_ACTIVATE_FLAG_CONTRACTS, EXTENSION_ADOPT_ALL_FLAG_CONTRACTS, EXTENSION_ADOPT_FLAG_CONTRACTS, EXTENSION_CATALOG_FLAG_CONTRACTS, EXTENSION_DEACTIVATE_FLAG_CONTRACTS, EXTENSION_DESCRIBE_FLAG_CONTRACTS, EXTENSION_DOCTOR_FLAG_CONTRACTS, EXTENSION_EXPLORE_FLAG_CONTRACTS, EXTENSION_FLAG_CONTRACTS, EXTENSION_INIT_FLAG_CONTRACTS, EXTENSION_INSTALL_FLAG_CONTRACTS, EXTENSION_MANAGE_FLAG_CONTRACTS, EXTENSION_MIGRATE_FLAG_CONTRACTS, EXTENSION_RELOAD_FLAG_CONTRACTS, EXTENSION_UNINSTALL_FLAG_CONTRACTS, FILES_FLAG_CONTRACTS, FOCUS_FLAG_CONTRACTS, GC_FLAG_CONTRACTS, GET_FLAG_CONTRACTS, GUIDE_FLAG_CONTRACTS, GLOBAL_FLAG_CONTRACTS, HEALTH_FLAG_CONTRACTS, HISTORY_FLAG_CONTRACTS, HISTORY_COMPACT_FLAG_CONTRACTS, HISTORY_REDACT_FLAG_CONTRACTS, HISTORY_REPAIR_FLAG_CONTRACTS, HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS, INSTALL_FLAG_CONTRACTS, INIT_FLAG_CONTRACTS, ITEM_COMPLETE_FLAG_CONTRACTS, ITEM_MUTATE_FLAG_CONTRACTS, ITEM_REOPEN_FLAG_CONTRACTS, LEARNINGS_FLAG_CONTRACTS, LIST_COMMANDER_STRING_OPTION_CONTRACTS, LIST_FILTER_FLAG_CONTRACTS, MERGE_FLAG_CONTRACTS, NOTES_FLAG_CONTRACTS, PACKAGE_FLAG_CONTRACTS, PACKAGE_INIT_FLAG_CONTRACTS, PM_EXTENSION_CAPABILITY_CONTRACTS, PM_EXTENSION_POLICY_MODE_CONTRACTS, PM_EXTENSION_POLICY_SURFACE_CONTRACTS, PM_EXTENSION_SANDBOX_PROFILE_CONTRACTS, PM_EXTENSION_SERVICE_NAME_CONTRACTS, PM_EXTENSION_TRUST_MODE_CONTRACTS, PM_OUTPUT_DEGRADATION_STEPS, PLAN_FLAG_CONTRACTS, PM_CORE_COMMAND_NAMES, PM_DEPRECATED_TOOL_ACTIONS, PM_TOOL_ACTIONS, PM_TOOL_PARAMETERS_SCHEMA, REINDEX_FLAG_CONTRACTS, RELEASE_FLAG_CONTRACTS, RESTORE_FLAG_CONTRACTS, SCHEMA_FLAG_CONTRACTS, PROFILE_FLAG_CONTRACTS, SEARCH_COMMANDER_STRING_OPTION_CONTRACTS, EVAL_FLAG_CONTRACTS, WORKSPACE_FLAG_CONTRACTS, NEXT_FLAG_CONTRACTS, SEARCH_FLAG_CONTRACTS, STATS_FLAG_CONTRACTS, DUPLICATES_FLAG_CONTRACTS, START_TASK_FLAG_CONTRACTS, PAUSE_TASK_FLAG_CONTRACTS, TELEMETRY_FLAG_CONTRACTS, TEST_ALL_FLAG_CONTRACTS, TEST_FLAG_CONTRACTS, TEST_RUNS_FLAG_CONTRACTS, UPDATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, UPDATE_COMMANDER_STRING_OPTION_CONTRACTS, UPDATE_FLAG_CONTRACTS, UPDATE_MANY_FLAG_CONTRACTS, UPGRADE_FLAG_CONTRACTS, VALIDATE_FLAG_CONTRACTS, compactFlagAliasContracts, PM_COMMAND_ALIAS_CONTRACTS, PM_DIAGNOSTIC_OUTPUT_BUDGET_CONTRACTS, resolvePmCommandOutputBudget, } from "../cli-contracts.js";
@@ -12,7 +12,7 @@ import { PM_POSITIONAL_ACTION_FLAG_CONTRACTS } from "./flag-contracts.js";
12
12
  import { GOVERNANCE_CLOSE_VALIDATION_DEFAULT_VALUES, GOVERNANCE_CREATE_MODE_DEFAULT_VALUES, GOVERNANCE_OWNERSHIP_ENFORCEMENT_VALUES, GOVERNANCE_WORKFLOW_ENFORCEMENT_VALUES, } from "../../types.js";
13
13
  import { BRIEF_LIST_FIELDS, DEFAULT_COMPACT_LIST_FIELDS, LIST_COMMAND_DEFAULT_PROJECTIONS, } from "../query/list.js";
14
14
  import { getActiveContextIntentContracts, } from "../context-intent-contracts.js";
15
- import { PM_READ_OUTPUT_SURFACE_CONTRACTS, } from "../read-output-contracts.js";
15
+ import { readOutputIncludeModeOptions, resolveReadOutputSurface, PM_READ_OUTPUT_SURFACE_CONTRACTS, } from "../read-output-contracts.js";
16
16
  import { enrichCliFlagInvocationContracts, } from "../flag-invocation-contracts.js";
17
17
  import { resolvePmCommandVisibilityTier, } from "../agent-capability-contracts.js";
18
18
  import { PM_ERROR_CODE_CATALOG } from "../generated-error-code-catalog.js";
@@ -1954,6 +1954,22 @@ function attachAgentCommandContractsResult(result, outputCommands, extensionComm
1954
1954
  degradation_ladder: [...PM_OUTPUT_DEGRADATION_STEPS],
1955
1955
  allows_unbounded_opt_out: true,
1956
1956
  };
1957
+ result.output_projection_contracts = {
1958
+ global_ladder_field: "output_policy.degradation_ladder",
1959
+ global_ladder_scope: "union_not_per_command",
1960
+ discovery: "pm contracts --command <command> --summary",
1961
+ ...(options.includeProjectionModeMatrix
1962
+ ? {
1963
+ commands: [...new Set(outputCommands.map(normalizeCommandPath))]
1964
+ .filter((command) => resolveReadOutputSurface(command) !== undefined)
1965
+ .sort((left, right) => left.localeCompare(right))
1966
+ .map((command) => ({
1967
+ command,
1968
+ modes: [...readOutputIncludeModeOptions(command).keys()],
1969
+ })),
1970
+ }
1971
+ : {}),
1972
+ };
1957
1973
  result.grammar_contracts = {
1958
1974
  nouns: PM_CLI_GRAMMAR_CONTRACT.nouns,
1959
1975
  shared_verbs: PM_CLI_GRAMMAR_CONTRACT.shared_verbs,
@@ -1989,6 +2005,7 @@ export async function runContracts(options, global) {
1989
2005
  includeFormatBudgets: includeCommandDetails,
1990
2006
  includeIntentProvenance: includeCommandDetails,
1991
2007
  includePositionalSignatures: includeCommandDetails,
2008
+ includeProjectionModeMatrix: includeCommandDetails,
1992
2009
  });
1993
2010
  }
1994
2011
  if (selection.summary) {
@@ -2065,4 +2082,4 @@ export const _testOnlyContractsCommand = {
2065
2082
  toRuntimeShortFlagToken,
2066
2083
  };
2067
2084
  //# sourceMappingURL=runtime-contracts.js.map
2068
- //# debugId=e8f1efca-4e83-570f-8c33-96f0405035b0
2085
+ //# debugId=428a19d2-be42-548a-a328-aa0e476b8a71
@@ -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]="030027d7-2703-56ea-9235-64bc602a25c3")}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]="d68e7da2-7390-5632-a3d1-375f622d5c87")}catch(e){}}();
4
4
  export const PM_ERROR_CODE_CATALOG_PART_1 = [
5
5
  {
6
6
  code: "acceptance_criteria_mutation_conflict",
@@ -1163,6 +1163,18 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
1163
1163
  canonical_code: "history_drift_hash_mismatch",
1164
1164
  aliases: ["validate_history_drift_hash_mismatches"],
1165
1165
  },
1166
+ {
1167
+ code: "history_drift_merge_receipt",
1168
+ meaning: "History drift merge receipt condition.",
1169
+ stability: "provisional",
1170
+ exit_code: 1,
1171
+ class: "generic_failure",
1172
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
1173
+ sources: ["core/diagnostics/remediation.ts"],
1174
+ emitting_commands: ["*"],
1175
+ canonical_code: "history_drift_merge_receipt",
1176
+ aliases: [],
1177
+ },
1166
1178
  {
1167
1179
  code: "history_drift_missing_stream",
1168
1180
  meaning: "History drift missing stream condition.",
@@ -2002,53 +2014,65 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
2002
2014
  aliases: [],
2003
2015
  },
2004
2016
  {
2005
- code: "merge_reconcile_discards_require_acceptance",
2006
- meaning: "Merge reconcile discards require acceptance condition.",
2017
+ code: "merge_receipt_evidence_invalid",
2018
+ meaning: "Merge receipt evidence invalid condition.",
2007
2019
  stability: "provisional",
2008
2020
  exit_code: 4,
2009
2021
  class: "conflict",
2010
2022
  recovery: "Inspect the structured error guidance and retry the suggested command.",
2011
- sources: ["sdk/merge/reconcile.ts"],
2023
+ sources: ["core/diagnostics/remediation.ts", "sdk/merge/reconcile.ts"],
2012
2024
  emitting_commands: ["*"],
2013
- canonical_code: "merge_reconcile_discards_require_acceptance",
2025
+ canonical_code: "merge_receipt_evidence_invalid",
2014
2026
  aliases: [],
2015
2027
  },
2016
2028
  {
2017
- code: "merge_root_not_found",
2018
- meaning: "Merge root not found condition.",
2019
- stability: "stable",
2020
- exit_code: 3,
2021
- class: "not_found",
2029
+ code: "merge_receipts_pending",
2030
+ meaning: "Merge receipts pending condition.",
2031
+ stability: "provisional",
2032
+ exit_code: 1,
2033
+ class: "generic_failure",
2022
2034
  recovery: "Inspect the structured error guidance and retry the suggested command.",
2023
- sources: ["sdk/merge/install.ts"],
2035
+ sources: ["core/diagnostics/remediation.ts"],
2024
2036
  emitting_commands: ["*"],
2025
- canonical_code: "merge_root_not_found",
2037
+ canonical_code: "merge_receipts_pending",
2026
2038
  aliases: [],
2027
2039
  },
2028
2040
  {
2029
- code: "missing_allowed_values",
2030
- meaning: "Missing allowed values condition.",
2041
+ code: "merge_reconcile_discards_require_acceptance",
2042
+ meaning: "Merge reconcile discards require acceptance condition.",
2031
2043
  stability: "provisional",
2032
- exit_code: 1,
2033
- class: "generic_failure",
2044
+ exit_code: 4,
2045
+ class: "conflict",
2034
2046
  recovery: "Inspect the structured error guidance and retry the suggested command.",
2035
- sources: ["sdk/agent/refusal-closure.ts"],
2047
+ sources: ["sdk/merge/reconcile.ts"],
2036
2048
  emitting_commands: ["*"],
2037
- canonical_code: "missing_allowed_values",
2049
+ canonical_code: "merge_reconcile_discards_require_acceptance",
2038
2050
  aliases: [],
2039
2051
  },
2040
2052
  {
2041
- code: "missing_budget",
2042
- meaning: "Missing budget condition.",
2053
+ code: "merge_reconcile_receipt_evidence_untrusted",
2054
+ meaning: "Merge reconcile receipt evidence untrusted condition.",
2043
2055
  stability: "provisional",
2044
- exit_code: 1,
2045
- class: "generic_failure",
2056
+ exit_code: 4,
2057
+ class: "conflict",
2046
2058
  recovery: "Inspect the structured error guidance and retry the suggested command.",
2047
- sources: ["sdk/cli-contracts/flag-lexicon-contracts.ts"],
2059
+ sources: ["sdk/history-repair.ts"],
2048
2060
  emitting_commands: ["*"],
2049
- canonical_code: "missing_budget",
2061
+ canonical_code: "merge_reconcile_receipt_evidence_untrusted",
2062
+ aliases: [],
2063
+ },
2064
+ {
2065
+ code: "merge_root_not_found",
2066
+ meaning: "Merge root not found condition.",
2067
+ stability: "stable",
2068
+ exit_code: 3,
2069
+ class: "not_found",
2070
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
2071
+ sources: ["sdk/merge/install.ts"],
2072
+ emitting_commands: ["*"],
2073
+ canonical_code: "merge_root_not_found",
2050
2074
  aliases: [],
2051
2075
  },
2052
2076
  ];
2053
2077
  //# sourceMappingURL=generated-error-code-catalog-part-1.js.map
2054
- //# debugId=030027d7-2703-56ea-9235-64bc602a25c3
2078
+ //# debugId=d68e7da2-7390-5632-a3d1-375f622d5c87
@@ -1,7 +1,31 @@
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]="8724f8ed-1236-5779-9e97-dc4b35866839")}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]="23e8e07d-84f2-54b6-98ad-2e33d996f09d")}catch(e){}}();
4
4
  export const PM_ERROR_CODE_CATALOG_PART_2 = [
5
+ {
6
+ code: "missing_allowed_values",
7
+ meaning: "Missing allowed values 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/agent/refusal-closure.ts"],
13
+ emitting_commands: ["*"],
14
+ canonical_code: "missing_allowed_values",
15
+ aliases: [],
16
+ },
17
+ {
18
+ code: "missing_budget",
19
+ meaning: "Missing budget condition.",
20
+ stability: "provisional",
21
+ exit_code: 1,
22
+ class: "generic_failure",
23
+ recovery: "Inspect the structured error guidance and retry the suggested command.",
24
+ sources: ["sdk/cli-contracts/flag-lexicon-contracts.ts"],
25
+ emitting_commands: ["*"],
26
+ canonical_code: "missing_budget",
27
+ aliases: [],
28
+ },
5
29
  {
6
30
  code: "missing_cli_flag",
7
31
  meaning: "Missing cli flag condition.",
@@ -2075,4 +2099,4 @@ export const PM_ERROR_CODE_CATALOG_PART_2 = [
2075
2099
  },
2076
2100
  ];
2077
2101
  //# sourceMappingURL=generated-error-code-catalog-part-2.js.map
2078
- //# debugId=8724f8ed-1236-5779-9e97-dc4b35866839
2102
+ //# debugId=23e8e07d-84f2-54b6-98ad-2e33d996f09d
@@ -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]="f7b3ff92-1fc7-55e9-aa76-af956714998f")}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]="5887be76-3d1d-56fb-9cae-cf972f0b73f8")}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";
@@ -45,7 +45,8 @@ import { buildCapabilityContractMetadata, buildRegistrationCollisionRemediation,
45
45
  import { scanStaleInProgressItems, } from "./stale-work.js";
46
46
  import { scanTrackedRuntimeCache } from "./tracked-runtime-cache.js";
47
47
  import { auditMergeDriverConfiguration, findGitWorkspaceRoot, } from "../merge/install.js";
48
- import { listMergeReceipts, partitionMergeReceipts, } from "../merge/receipts.js";
48
+ import { inspectMergeReceiptEvidence, partitionMergeReceipts, } from "../merge/receipts.js";
49
+ import { runHistoryRepair } from "../history-repair.js";
49
50
  import { resolveWorkspaceRelationshipKindRegistry } from "../graph/assembly.js";
50
51
  import { analyzeHierarchyIntegrity, } from "../graph/hierarchy-integrity.js";
51
52
  const PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
@@ -333,6 +334,11 @@ function buildHierarchyIntegrityWarnings(analysis) {
333
334
  : `integrity_hierarchy_divergence:${finding.child_id}`),
334
335
  ];
335
336
  }
337
+ function buildMergeReceiptEvidenceWarnings(invalidEvidenceCount) {
338
+ return invalidEvidenceCount === 0
339
+ ? []
340
+ : [`merge_receipt_evidence_invalid:${invalidEvidenceCount}`];
341
+ }
336
342
  async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDrivers, items) {
337
343
  const itemScan = await scanItemIntegrity(pmRoot, typeToFolder, schema);
338
344
  const historyScan = await scanHistoryIntegrity(pmRoot);
@@ -344,12 +350,11 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
344
350
  const mergeDriverAudit = gitWorkspaceRoot === null
345
351
  ? null
346
352
  : await auditMergeDriverConfiguration(gitWorkspaceRoot);
347
- const pendingMergeReceipts = gitWorkspaceRoot === null
348
- ? []
349
- : await listMergeReceipts(gitWorkspaceRoot, {
350
- includeLossless: true,
351
- pmRoot,
352
- });
353
+ const mergeReceiptEvidence = await inspectMergeReceiptEvidence(gitWorkspaceRoot ?? pmRoot, {
354
+ includeLossless: true,
355
+ pmRoot,
356
+ });
357
+ const pendingMergeReceipts = mergeReceiptEvidence.receipts;
353
358
  const { pendingDecisions: pendingMergeDecisions, lossless: losslessMergeReceipts, } = partitionMergeReceipts(pendingMergeReceipts);
354
359
  const mergeDriverInstallationMissing = mergeDriverAudit?.status === "missing" &&
355
360
  mergeDriverAudit.missing_keys.length === 5 &&
@@ -379,6 +384,10 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
379
384
  ...(pendingMergeDecisions.length > 0
380
385
  ? [`merge_decisions_unreviewed:${pendingMergeDecisions.length}`]
381
386
  : []),
387
+ ...(losslessMergeReceipts.length > 0
388
+ ? [`merge_receipts_pending:${losslessMergeReceipts.length}`]
389
+ : []),
390
+ ...buildMergeReceiptEvidenceWarnings(mergeReceiptEvidence.invalid_evidence_count),
382
391
  ];
383
392
  const normalizedWarnings = [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
384
393
  const actionableWarnings = normalizedWarnings.filter((warning) => !warning.startsWith("integrity_legacy_hierarchy_"));
@@ -409,6 +418,7 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
409
418
  mergeDriverAudit.drifted_keys.length,
410
419
  pending_merge_decisions: pendingMergeDecisions.length,
411
420
  lossless_merge_receipts: losslessMergeReceipts.length,
421
+ invalid_merge_receipt_evidence: mergeReceiptEvidence.invalid_evidence_count,
412
422
  },
413
423
  item_unreadable: itemScan.unreadable,
414
424
  item_conflict_markers: itemScan.conflictMarkers,
@@ -443,6 +453,8 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
443
453
  },
444
454
  },
445
455
  warnings: normalizedWarnings,
456
+ gitWorkspaceRoot,
457
+ pendingMergeReceipts,
446
458
  };
447
459
  }
448
460
  /* c8 ignore start -- activate export shape variants are exercised through integration load tests */
@@ -949,6 +961,7 @@ const HEALTH_DETAIL_SUMMARIZERS = {
949
961
  checked_items: details.checked_items,
950
962
  counts: details.counts,
951
963
  drifted_items: summarizeStringList(details.drifted_items, limit),
964
+ merge_receipt_attributed_items: summarizeStringList(details.merge_receipt_attributed_items, limit),
952
965
  missing_streams: summarizeStringList(details.missing_streams, limit),
953
966
  unreadable_streams: summarizeStringList(details.unreadable_streams, limit),
954
967
  hash_mismatches: summarizeStringList(details.hash_mismatches, limit),
@@ -1922,7 +1935,9 @@ function buildHealthFindings(params) {
1922
1935
  function rewriteBulkHealthRemediation(params) {
1923
1936
  if (params.check.name === "history_drift" && params.historyDriftedCount > 1) {
1924
1937
  for (const code of Object.keys(params.remediationMap)) {
1925
- params.remediationMap[code] = "pm history-repair --all";
1938
+ if (code !== "history_drift_merge_receipt") {
1939
+ params.remediationMap[code] = "pm history-repair --all";
1940
+ }
1926
1941
  }
1927
1942
  }
1928
1943
  if (params.check.name === "storage" && params.overThresholdCount > 1) {
@@ -1945,6 +1960,67 @@ function attachHealthRemediationMaps(params) {
1945
1960
  }
1946
1961
  }
1947
1962
  }
1963
+ async function correlateMergeReceiptHistoryDriftItems(params) {
1964
+ if (params.gitWorkspaceRoot === null ||
1965
+ params.pendingMergeReceipts.length === 0) {
1966
+ return [];
1967
+ }
1968
+ const details = params.historyDriftCheck.check.details;
1969
+ const hashMismatches = Array.isArray(details.hash_mismatches)
1970
+ ? details.hash_mismatches.filter((entry) => typeof entry === "string")
1971
+ : [];
1972
+ const unsafeStreamIds = new Set([
1973
+ details.missing_streams,
1974
+ details.unreadable_streams,
1975
+ details.chain_mismatches,
1976
+ ].flatMap((value) => (Array.isArray(value) ? value : [])));
1977
+ const cloneLocalReceiptsByItem = new Map();
1978
+ for (const receipt of params.pendingMergeReceipts) {
1979
+ if (receipt.evidence_source !== "clone_local")
1980
+ continue;
1981
+ const receipts = cloneLocalReceiptsByItem.get(receipt.item_id) ?? [];
1982
+ receipts.push(receipt);
1983
+ cloneLocalReceiptsByItem.set(receipt.item_id, receipts);
1984
+ }
1985
+ const attributed = [];
1986
+ for (const id of hashMismatches) {
1987
+ if (unsafeStreamIds.has(id))
1988
+ continue;
1989
+ const receipts = cloneLocalReceiptsByItem.get(id);
1990
+ if (!receipts || receipts.length === 0)
1991
+ continue;
1992
+ try {
1993
+ const repair = await runHistoryRepair(id, {
1994
+ dryRun: true,
1995
+ mergeReceiptProof: {
1996
+ gitWorkspaceRoot: params.gitWorkspaceRoot,
1997
+ receipts,
1998
+ },
1999
+ }, params.global);
2000
+ if (repair.merge_receipt_proof?.trusted)
2001
+ attributed.push(id);
2002
+ }
2003
+ catch {
2004
+ // Fail closed: generic history-repair guidance remains authoritative.
2005
+ }
2006
+ }
2007
+ return [...new Set(attributed)].sort((left, right) => left.localeCompare(right));
2008
+ }
2009
+ function applyMergeReceiptHistoryDriftAttribution(historyDriftCheck, attributedItems) {
2010
+ const attributed = new Set(attributedItems);
2011
+ historyDriftCheck.warnings = [
2012
+ ...historyDriftCheck.warnings.filter((warning) => {
2013
+ if (!warning.startsWith("history_drift_hash_mismatch:"))
2014
+ return true;
2015
+ return !attributed.has(warning.slice(warning.indexOf(":") + 1));
2016
+ }),
2017
+ ...attributedItems.map((id) => `history_drift_merge_receipt:${id}`),
2018
+ ].sort((left, right) => left.localeCompare(right));
2019
+ historyDriftCheck.check.details = {
2020
+ ...historyDriftCheck.check.details,
2021
+ merge_receipt_attributed_items: attributedItems,
2022
+ };
2023
+ }
1948
2024
  function projectHealthResult(result, options, summaryMode) {
1949
2025
  const warningCount = result.warning_count ?? result.warnings.length;
1950
2026
  const boundedResult = {
@@ -2030,11 +2106,22 @@ export async function runHealth(global, options = {}) {
2030
2106
  const provenanceWarnings = provenanceResolverHealth.warnings;
2031
2107
  const locksCheck = await buildLocksCheck(pmRoot);
2032
2108
  const integrityCheck = skipPolicy.skipIntegrity
2033
- ? buildSkippedHealthCheck("integrity")
2109
+ ? {
2110
+ ...buildSkippedHealthCheck("integrity"),
2111
+ gitWorkspaceRoot: null,
2112
+ pendingMergeReceipts: [],
2113
+ }
2034
2114
  : await buildIntegrityCheck(pmRoot, typeRegistry.type_to_folder, settings.schema, options.requireMergeDrivers === true, items);
2035
2115
  const historyDriftCheck = skipPolicy.skipDrift
2036
2116
  ? buildSkippedHealthCheck("history_drift")
2037
2117
  : await buildHistoryDriftCheck(pmRoot, itemsWithBody);
2118
+ const mergeReceiptAttributedHistoryDriftItems = await correlateMergeReceiptHistoryDriftItems({
2119
+ gitWorkspaceRoot: integrityCheck.gitWorkspaceRoot,
2120
+ pendingMergeReceipts: integrityCheck.pendingMergeReceipts,
2121
+ historyDriftCheck,
2122
+ global,
2123
+ });
2124
+ applyMergeReceiptHistoryDriftAttribution(historyDriftCheck, mergeReceiptAttributedHistoryDriftItems);
2038
2125
  const vectorizationCheck = skipPolicy.skipVectors
2039
2126
  ? buildSkippedHealthCheck("vectorization")
2040
2127
  : await buildVectorizationCheck(pmRoot, settings, itemsWithBody, refreshPolicy, options.verboseStaleItems === true);
@@ -2142,4 +2229,4 @@ export const _testOnlyHealthCommand = {
2142
2229
  warningCode,
2143
2230
  };
2144
2231
  //# sourceMappingURL=health.js.map
2145
- //# debugId=f7b3ff92-1fc7-55e9-aa76-af956714998f
2232
+ //# debugId=5887be76-3d1d-56fb-9cae-cf972f0b73f8
@@ -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]="aca69fd7-c47a-5424-b58f-f305f690edd9")}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]="3d7d6f15-7587-5c22-8deb-373bfd063d2b")}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";
@@ -34,7 +34,7 @@ import { buildMissingLinkedPathRows, summarizeMissingLinkedPathRows, } from "../
34
34
  import { assertProjectionModeChoice, } from "../output-projection.js";
35
35
  import { collectDanglingDependencyReferences } from "../graph/assembly.js";
36
36
  import { auditMergeAttributeFence, auditMergeDriverConfiguration, findGitWorkspaceRoot, resolveProjectMergeTypeFolders, } from "../merge/install.js";
37
- import { listMergeReceipts, partitionMergeReceipts, } from "../merge/receipts.js";
37
+ import { inspectMergeReceiptEvidence, partitionMergeReceipts, } from "../merge/receipts.js";
38
38
  import { scanStorageIntegrity } from "./storage-integrity.js";
39
39
  import { scanTrackedRuntimeCache } from "./tracked-runtime-cache.js";
40
40
  import { scanHistoryAuthorAttribution } from "../author-attribution.js";
@@ -1991,6 +1991,11 @@ export const _testOnlyValidateCommand = {
1991
1991
  summarizeDuplicateIssueCodes,
1992
1992
  toMeaningfulString,
1993
1993
  };
1994
+ function appendInvalidMergeReceiptEvidenceWarning(warnings, invalidEvidenceCount) {
1995
+ if (invalidEvidenceCount > 0) {
1996
+ warnings.push(`merge_receipt_evidence_invalid:${invalidEvidenceCount}`);
1997
+ }
1998
+ }
1994
1999
  /** Build the post-merge storage-integrity check (GH-603/GH-607/GH-609/GH-611): provably corrupted storage — unreadable item documents, on-disk-vs-parsed census mismatches, history conflict markers, resurrected deletes, and unparseable config/schema files — fails validate as an error instead of hiding behind ok:true. The `history_repair_reconciliations` count is informational: it surfaces post-repair divergence without permanently failing repaired workspaces. */
1995
2000
  async function buildStorageIntegrityCheck(pmRoot, items, typeToFolder, settings) {
1996
2001
  const scan = await scanStorageIntegrity(pmRoot, new Set(items.map((item) => item.id)), typeToFolder, {
@@ -2032,16 +2037,16 @@ async function buildStorageIntegrityCheck(pmRoot, items, typeToFolder, settings)
2032
2037
  if (mergeDriverAudit !== null && mergeDriverAudit.status !== "ok") {
2033
2038
  warnings.push(`validate_merge_driver_configuration:${mergeDriverAudit.missing_keys.length + mergeDriverAudit.drifted_keys.length}`);
2034
2039
  }
2035
- const pendingMergeReceipts = gitWorkspaceRoot === null
2036
- ? []
2037
- : await listMergeReceipts(gitWorkspaceRoot, {
2038
- includeLossless: true,
2039
- pmRoot,
2040
- });
2040
+ const mergeReceiptEvidence = await inspectMergeReceiptEvidence(gitWorkspaceRoot ?? pmRoot, {
2041
+ includeLossless: true,
2042
+ pmRoot,
2043
+ });
2044
+ const pendingMergeReceipts = mergeReceiptEvidence.receipts;
2041
2045
  const { pendingDecisions: pendingMergeDecisions, lossless: losslessMergeReceipts, } = partitionMergeReceipts(pendingMergeReceipts);
2042
2046
  if (pendingMergeDecisions.length > 0) {
2043
2047
  warnings.push(`validate_merge_decisions_unreviewed:${pendingMergeDecisions.length}`);
2044
2048
  }
2049
+ appendInvalidMergeReceiptEvidenceWarning(warnings, mergeReceiptEvidence.invalid_evidence_count);
2045
2050
  const status = errorCount > 0 ? "error" : warnings.length > 0 ? "warn" : "ok";
2046
2051
  return {
2047
2052
  check: {
@@ -2060,6 +2065,7 @@ async function buildStorageIntegrityCheck(pmRoot, items, typeToFolder, settings)
2060
2065
  ...new Set(pendingMergeDecisions.map((receipt) => receipt.item_id)),
2061
2066
  ].sort((left, right) => left.localeCompare(right)),
2062
2067
  lossless_merge_receipt_count: losslessMergeReceipts.length,
2068
+ invalid_merge_receipt_evidence_count: mergeReceiptEvidence.invalid_evidence_count,
2063
2069
  lossless_merge_receipt_items: [
2064
2070
  ...new Set(losslessMergeReceipts.map((receipt) => receipt.item_id)),
2065
2071
  ].sort((left, right) => left.localeCompare(right)),
@@ -2280,4 +2286,4 @@ export async function runValidate(options, global, services = {}) {
2280
2286
  }
2281
2287
  /* c8 ignore stop */
2282
2288
  //# sourceMappingURL=validate.js.map
2283
- //# debugId=aca69fd7-c47a-5424-b58f-f305f690edd9
2289
+ //# debugId=3d7d6f15-7587-5c22-8deb-373bfd063d2b
@@ -1,6 +1,7 @@
1
1
  import { type ReplayDocument } from "../core/history/replay.js";
2
2
  import type { GlobalOptions } from "../core/shared/command-types.js";
3
3
  import type { HistoryEntry } from "../types/index.js";
4
+ import { type MergeDecisionReceipt } from "./merge/receipts.js";
4
5
  import { type ProvenanceNormalizationReceipt } from "./governance/provenance-health.js";
5
6
  /** Documents the history repair command options payload exchanged by command, SDK, and package integrations. */
6
7
  export interface HistoryRepairCommandOptions {
@@ -22,6 +23,16 @@ export interface HistoryRepairCommandOptions {
22
23
  forceAuditEntry?: boolean;
23
24
  /** Remove bounded-domain-invalid provenance observations and record an aggregate privacy-safe audit receipt. */
24
25
  normalizeProvenance?: boolean;
26
+ /** Internal receipt evidence revalidated against the exact item snapshot used by this repair. */
27
+ mergeReceiptProof?: {
28
+ gitWorkspaceRoot: string | null;
29
+ receipts: MergeDecisionReceipt[];
30
+ };
31
+ /** Internal per-item receipt proof index used by bounded bulk reconciliation. */
32
+ mergeReceiptProofById?: Record<string, {
33
+ gitWorkspaceRoot: string | null;
34
+ receipts: MergeDecisionReceipt[];
35
+ }>;
25
36
  }
26
37
  /** Documents the history repair result payload exchanged by command, SDK, and package integrations. */
27
38
  export interface HistoryRepairResult {
@@ -60,11 +71,22 @@ export interface HistoryRepairResult {
60
71
  };
61
72
  /** Present when reconciling the chain with the on-disk item discards the replayed effect of earlier history events (GH-603): names the reverted fields and the authors whose mutations the reconciliation overwrites, so cross-author data loss after a lossy merge is loud instead of silent. */
62
73
  reconciliation?: HistoryRepairReconciliationReport;
74
+ /** Present when merge reconciliation supplied receipt evidence for this item. */
75
+ merge_receipt_proof?: MergeReceiptProofResult;
63
76
  /** Value that configures or reports warnings for this contract. */
64
77
  warnings: string[];
65
78
  /** ISO 8601 timestamp recording when generated occurred. */
66
79
  generated_at: string;
67
80
  }
81
+ /** Fail-closed proof that clone-local driver receipts exactly cover the current reconciliation fields and values. */
82
+ export interface MergeReceiptProofResult {
83
+ /** Whether exact receipt identity, path, field, and value-hash evidence proves the snapshot. */
84
+ trusted: boolean;
85
+ /** Stable explanation for the trust decision. */
86
+ reason: "trusted_clone_local_driver_evidence" | "git_workspace_unavailable" | "item_path_unavailable" | "no_item_receipts" | "no_receipt_set_proves_snapshot";
87
+ /** Exact receipt identities accepted as proof; empty when proof is refused. */
88
+ receipt_ids: string[];
89
+ }
68
90
  /** Documents one history event attributed to fields changed by reconciliation. */
69
91
  export interface HistoryRepairDiscardedEvent {
70
92
  /** 1-based index of the event in the (re-anchored) history stream. */
@@ -121,6 +143,8 @@ export interface HistoryRepairAllStreamResult {
121
143
  reconciled_with_item?: boolean;
122
144
  /** Cross-author data-loss detail when reconciliation overwrites replayed mutations. */
123
145
  reconciliation?: HistoryRepairReconciliationReport;
146
+ /** Exact receipt proof used to authorize this stream, when supplied. */
147
+ merge_receipt_proof?: MergeReceiptProofResult;
124
148
  /** Stream-specific repair warnings retained by the bulk workflow. */
125
149
  warnings?: string[];
126
150
  /** Value that configures or reports error for this contract. */