@unbrained/pm-cli 2026.9.3 → 2026.9.5
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.
- package/.agents/skills/HARNESS_COMPATIBILITY.md +1 -1
- package/.agents/skills/README.md +2 -2
- package/.agents/skills/pm-developer/SKILL.md +4 -1
- package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +10 -0
- package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +3 -1
- package/.agents/skills/pm-extensions/SKILL.md +2 -2
- package/.agents/skills/pm-extensions/references/LIFECYCLE.md +3 -3
- package/.agents/skills/pm-extensions/references/TROUBLESHOOTING.md +3 -3
- package/.agents/skills/pm-user/SKILL.md +2 -0
- package/.agents/skills/pm-user/references/BACKLOG_SHAPING.md +5 -0
- package/.agents/skills/pm-user/references/WORKFLOWS.md +20 -5
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +52 -0
- package/dist/cli/commander-usage.d.ts +2 -0
- package/dist/cli/commander-usage.js +15 -12
- package/dist/cli/help-json-payload.js +12 -7
- package/dist/cli/main.js +15 -6
- package/dist/cli/register-list-query.js +4 -2
- package/dist/cli/register-mutation.js +4 -2
- package/dist/cli/register-operations.js +6 -2
- package/dist/cli-bundle/bundle-manifest.json +154 -154
- package/dist/cli-bundle/chunks/{chunk-EDPIS7EB.js → chunk-3HBDTJRK.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-66VPKFP2.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-Y4PJ6HPK.js → chunk-HUAQITVW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DKGP3QLE.js → chunk-IBYREGSP.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LUI4E32I.js +231 -0
- package/dist/cli-bundle/chunks/{chunk-UPPM2FOZ.js → chunk-QPZHQY2O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-34HASX3S.js → chunk-SF6SM6U5.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-SVK5Y64D.js +40 -0
- package/dist/cli-bundle/chunks/chunk-V5GBD5KV.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-LENC656S.js → chunk-WWAEGW4V.js} +67 -70
- package/dist/cli-bundle/chunks/chunk-ZRAQS3UA.js +8 -0
- package/dist/cli-bundle/chunks/{register-list-query-W2ZTOMKP.js → register-list-query-AYKGODWT.js} +3 -3
- package/dist/cli-bundle/chunks/{register-mutation-RVND5NCG.js → register-mutation-YZYG53SQ.js} +4 -4
- package/dist/cli-bundle/chunks/register-operations-KFSCC7QV.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-D3ZFHY3L.js → register-setup-UJCRVGBG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-24IG6ONG.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-M5M6SVHS.js → chunk-3ASU6WGI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3ITLIBKS.js +56 -0
- package/dist/cli-bundle/focused-chunks/chunk-3NQD5YDG.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-S27XMBIN.js → chunk-4OSHLNUE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-65N6JHAN.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-5RFXUPN5.js → chunk-B2TTQGFG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GUBM3RGY.js +20 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Q45NHPF2.js → chunk-H5FOGAVD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-JX3RCVCX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-D7KXFBXV.js → chunk-KWWCBWFO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MV752SUC.js +12 -0
- package/dist/cli-bundle/focused-chunks/chunk-PKIPMCFS.js +6 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4HJFY4MB.js → chunk-QL66QNWG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RJMR2JIF.js +9 -0
- package/dist/cli-bundle/focused-chunks/chunk-WIUPWIZR.js +177 -0
- package/dist/cli-bundle/focused-chunks/chunk-WOCIPMW7.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-GT7MXDLW.js → chunk-YEF5PQQ2.js} +2 -2
- package/dist/cli-bundle/main.js +22 -15
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +29 -32
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +45 -37
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +10 -10
- package/dist/core/diagnostics/remediation.js +4 -4
- package/dist/core/extensions/extension-types.d.ts +2 -0
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/history/drift-scan.d.ts +5 -0
- package/dist/core/history/drift-scan.js +16 -6
- package/dist/core/history/event-classification.d.ts +1 -1
- package/dist/core/history/event-classification.js +3 -2
- package/dist/core/history/history.d.ts +37 -1
- package/dist/core/history/history.js +311 -59
- package/dist/core/history/identity.d.ts +15 -0
- package/dist/core/history/identity.js +31 -0
- package/dist/core/history/projection.js +50 -17
- package/dist/core/history/read.js +6 -3
- package/dist/core/history/replay.d.ts +1 -2
- package/dist/core/history/replay.js +70 -36
- package/dist/core/history/version-address.d.ts +13 -0
- package/dist/core/history/version-address.js +33 -0
- package/dist/core/item/actionability.d.ts +21 -1
- package/dist/core/item/actionability.js +45 -10
- package/dist/core/item/id.js +8 -4
- package/dist/core/item/item-type-definition.d.ts +2 -0
- package/dist/core/item/item-type-definition.js +9 -2
- package/dist/core/item/type-registry.d.ts +5 -1
- package/dist/core/item/type-registry.js +9 -4
- package/dist/core/lock/lock.d.ts +10 -0
- package/dist/core/lock/lock.js +42 -3
- package/dist/core/shared/author.d.ts +3 -1
- package/dist/core/shared/author.js +111 -23
- package/dist/core/shared/errors.d.ts +8 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/store/item-store.d.ts +14 -0
- package/dist/core/store/item-store.js +48 -10
- package/dist/core/store/settings-validator.js +3 -2
- package/dist/sdk/actionability.d.ts +1 -1
- package/dist/sdk/actionability.js +3 -3
- package/dist/sdk/cli-contracts/command-aliases.js +11 -2
- package/dist/sdk/cli-contracts/completeness.js +4 -3
- package/dist/sdk/cli-contracts/flag-contracts.js +29 -5
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +19 -12
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +14 -2
- package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
- package/dist/sdk/cli-contracts/tool-schema.js +19 -6
- package/dist/sdk/context-intent-contracts.js +3 -3
- package/dist/sdk/context-usage.js +9 -11
- package/dist/sdk/define.d.ts +1 -1
- package/dist/sdk/define.js +2 -2
- package/dist/sdk/environment/agent-environment.d.ts +296 -0
- package/dist/sdk/environment/agent-environment.js +467 -0
- package/dist/sdk/environment/project-runtime-compatibility.d.ts +19 -1
- package/dist/sdk/environment/project-runtime-compatibility.js +118 -21
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +98 -38
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +50 -2
- package/dist/sdk/governance/health.js +13 -44
- package/dist/sdk/governance/merge-receipt-history.d.ts +62 -0
- package/dist/sdk/governance/merge-receipt-history.js +207 -0
- package/dist/sdk/governance/provenance-health.js +9 -3
- package/dist/sdk/governance/validate-history-drift.js +16 -5
- package/dist/sdk/guide-topics.js +116 -2
- package/dist/sdk/history/salvage.d.ts +35 -0
- package/dist/sdk/history/salvage.js +248 -0
- package/dist/sdk/history-compact.js +41 -37
- package/dist/sdk/history-read.d.ts +3 -2
- package/dist/sdk/history-read.js +6 -3
- package/dist/sdk/history-redact.js +58 -23
- package/dist/sdk/history-repair.d.ts +5 -0
- package/dist/sdk/history-repair.js +28 -6
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +4 -2
- package/dist/sdk/lifecycle/claim.d.ts +4 -0
- package/dist/sdk/lifecycle/claim.js +9 -3
- package/dist/sdk/lifecycle/restore.d.ts +1 -0
- package/dist/sdk/lifecycle/restore.js +19 -7
- package/dist/sdk/merge/driver.d.ts +3 -1
- package/dist/sdk/merge/driver.js +9 -9
- package/dist/sdk/merge/index.d.ts +1 -1
- package/dist/sdk/merge/index.js +3 -3
- package/dist/sdk/merge/receipts.d.ts +17 -6
- package/dist/sdk/merge/receipts.js +246 -75
- package/dist/sdk/merge/reconcile.d.ts +9 -7
- package/dist/sdk/merge/reconcile.js +175 -12
- package/dist/sdk/merge/three-way.d.ts +22 -2
- package/dist/sdk/merge/three-way.js +92 -25
- package/dist/sdk/output-projection.d.ts +3 -1
- package/dist/sdk/output-projection.js +11 -3
- package/dist/sdk/public-surface.json +1 -0
- package/dist/sdk/query/context.d.ts +9 -0
- package/dist/sdk/query/context.js +33 -21
- package/dist/sdk/query/get.d.ts +2 -2
- package/dist/sdk/query/get.js +4 -3
- package/dist/sdk/query/history.d.ts +11 -0
- package/dist/sdk/query/history.js +34 -10
- package/dist/sdk/query/next.d.ts +15 -1
- package/dist/sdk/query/next.js +43 -20
- package/dist/sdk/query.d.ts +1 -0
- package/dist/sdk/query.js +3 -2
- package/dist/sdk/runtime-primitives.d.ts +3 -3
- package/dist/sdk/runtime-primitives.js +5 -5
- package/dist/types.d.ts +27 -0
- package/dist/types.js +2 -2
- package/docs/AGENT_ENVIRONMENTS.md +47 -0
- package/docs/AGENT_GUIDE.md +36 -0
- package/docs/AGENT_PROVENANCE_ADR.md +17 -2
- package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +38 -1
- package/docs/HISTORY_RECOVERY.md +146 -0
- package/docs/MERGE_SAFETY.md +119 -23
- package/docs/README.md +2 -0
- package/docs/RELEASING.md +25 -11
- package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +24 -2
- package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +24 -1
- package/docs/SDK_EXECUTION_CONTRACTS.md +105 -0
- package/docs/SDK_RUNTIME_BOUNDARIES.md +17 -1
- package/docs/TESTING.md +5 -0
- package/docs/agent-task-token-baseline.json +17 -17
- package/docs/agent-task-transcripts.json +2 -1
- package/docs/examples/sdk-agent-environment/README.md +14 -0
- package/docs/examples/sdk-agent-environment/package.json +8 -0
- package/docs/examples/sdk-agent-environment/run-agent-environment.mjs +154 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +10 -10
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +12 -3
- package/marketplace.json +2 -2
- package/package.json +5 -6
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/skills/pm-audit/SKILL.md +2 -2
- package/plugins/pm-claude/skills/pm-developer/SKILL.md +2 -2
- package/plugins/pm-claude/skills/pm-planner/SKILL.md +2 -2
- package/plugins/pm-claude/skills/pm-release/SKILL.md +2 -2
- package/plugins/pm-claude/skills/pm-workflow/SKILL.md +3 -3
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/skills/pm-auditor/SKILL.md +2 -2
- package/plugins/pm-codex/skills/pm-native/SKILL.md +3 -4
- package/plugins/pm-codex/skills/pm-release/SKILL.md +2 -2
- package/scripts/finalize-build.mjs +13 -1
- package/dist/cli-bundle/chunks/chunk-AY324UJ5.js +0 -9
- package/dist/cli-bundle/chunks/chunk-E5RBBCXO.js +0 -230
- package/dist/cli-bundle/chunks/chunk-IEHHE6GA.js +0 -5
- package/dist/cli-bundle/chunks/chunk-L7B7343B.js +0 -8
- package/dist/cli-bundle/chunks/chunk-LISESA7W.js +0 -35
- package/dist/cli-bundle/chunks/register-operations-TTROIVC4.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3ZBI35HU.js +0 -176
- package/dist/cli-bundle/focused-chunks/chunk-4RRHC3S4.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-4WR46RMG.js +0 -9
- package/dist/cli-bundle/focused-chunks/chunk-BWKHEIVF.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-GHCZ3YFR.js +0 -20
- package/dist/cli-bundle/focused-chunks/chunk-KBLZRU62.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-KZ2NB3ET.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OL5EH6I3.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QKHCSUGJ.js +0 -51
- package/dist/cli-bundle/focused-chunks/chunk-TXE4TSHM.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-UCLO3XDU.js +0 -2
- package/sdk/public-surface.json +0 -32524
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* leaving diagnosis reads available.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
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]="f9737b75-b285-5fe9-a9ce-63e7c07626cb")}catch(e){}}();
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { EXIT_CODE } from "../../core/shared/constants.js";
|
|
@@ -80,6 +80,8 @@ const GLOBAL_VALUE_FLAGS = new Set([
|
|
|
80
80
|
"--pm-path",
|
|
81
81
|
]);
|
|
82
82
|
const VERSION_PATTERN = /\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u;
|
|
83
|
+
/** First pm release whose history writer and reader support item-hash epoch 3. */
|
|
84
|
+
export const HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN = "2026.8.31";
|
|
83
85
|
/** Return whether an invocation includes one of the exact mutation switches. */
|
|
84
86
|
function hasAnyToken(argv, tokens) {
|
|
85
87
|
return argv.some((token) => tokens.includes(token.split("=", 1)[0]));
|
|
@@ -194,6 +196,21 @@ export function comparePmDateVersions(left, right) {
|
|
|
194
196
|
}
|
|
195
197
|
return 0;
|
|
196
198
|
}
|
|
199
|
+
/** Resolve the item-hash epoch written by a known pm runtime release. */
|
|
200
|
+
export function historyItemHashVersionForRuntime(version) {
|
|
201
|
+
return comparePmDateVersions(version, HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN) !== -1
|
|
202
|
+
? 3
|
|
203
|
+
: 2;
|
|
204
|
+
}
|
|
205
|
+
/** Find the oldest declaration that cannot select a reader for the executing writer epoch. */
|
|
206
|
+
function findIncompatibleHistoryEpochPin(pins, writerItemHashVersion) {
|
|
207
|
+
if (writerItemHashVersion !== 3)
|
|
208
|
+
return undefined;
|
|
209
|
+
return pins
|
|
210
|
+
.filter((pin) => pin.history_epoch_compatible === false)
|
|
211
|
+
.map((pin) => ({ ...pin, declaration: pin.declaration ?? pin.version }))
|
|
212
|
+
.sort((left, right) => comparePmDateVersions(left.version, right.version))[0];
|
|
213
|
+
}
|
|
197
214
|
/** Read one optional JSON object without turning absence or corruption into startup failure. */
|
|
198
215
|
function readJsonRecord(filePath) {
|
|
199
216
|
try {
|
|
@@ -208,27 +225,61 @@ function readJsonRecord(filePath) {
|
|
|
208
225
|
return null;
|
|
209
226
|
}
|
|
210
227
|
}
|
|
211
|
-
/** Extract
|
|
212
|
-
function
|
|
213
|
-
const
|
|
214
|
-
|
|
228
|
+
/** Extract explicit comparator and hyphen upper bounds from one range branch. */
|
|
229
|
+
function rangeUpperBounds(alternative) {
|
|
230
|
+
const comparators = [
|
|
231
|
+
...alternative.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu),
|
|
232
|
+
].map((match) => ({ inclusive: match[1] === "<=", version: match[2] }));
|
|
233
|
+
const hyphen = alternative.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);
|
|
234
|
+
return hyphen
|
|
235
|
+
? [...comparators, { inclusive: true, version: hyphen[1] }]
|
|
236
|
+
: comparators;
|
|
237
|
+
}
|
|
238
|
+
/** Classify whether a range is bounded and can select an epoch-3 reader. */
|
|
239
|
+
function analyzeHistoryEpochRange(specification) {
|
|
240
|
+
const alternativeBounds = specification
|
|
241
|
+
.split("||")
|
|
242
|
+
.map((alternative) => rangeUpperBounds(alternative));
|
|
243
|
+
return {
|
|
244
|
+
bounded: alternativeBounds.some((bounds) => bounds.length > 0),
|
|
245
|
+
compatible: alternativeBounds.some((bounds) => bounds.every((bound) => {
|
|
246
|
+
const comparison = comparePmDateVersions(HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN, bound.version);
|
|
247
|
+
return (comparison !== null &&
|
|
248
|
+
(bound.inclusive ? comparison !== 1 : comparison === -1));
|
|
249
|
+
})),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/** Extract every supported pm declaration without letting one section hide another. */
|
|
253
|
+
function dependencyPins(packageJson) {
|
|
254
|
+
return [
|
|
215
255
|
"dependencies",
|
|
216
256
|
"devDependencies",
|
|
217
257
|
"optionalDependencies",
|
|
218
258
|
"peerDependencies",
|
|
219
|
-
]) {
|
|
259
|
+
].flatMap((field) => {
|
|
220
260
|
const dependencies = packageJson[field];
|
|
221
261
|
if (typeof dependencies !== "object" || dependencies === null)
|
|
222
|
-
|
|
262
|
+
return [];
|
|
223
263
|
const value = dependencies[PACKAGE_NAME];
|
|
224
264
|
const specification = typeof value === "string" ? value.trim() : "";
|
|
225
265
|
const version = /^[<!]/u.test(specification)
|
|
226
266
|
? undefined
|
|
227
267
|
: specification.match(VERSION_PATTERN)?.[0];
|
|
228
|
-
if (version)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
268
|
+
if (!version)
|
|
269
|
+
return [];
|
|
270
|
+
const exact = /^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(specification);
|
|
271
|
+
const range = analyzeHistoryEpochRange(specification);
|
|
272
|
+
return [
|
|
273
|
+
{
|
|
274
|
+
version,
|
|
275
|
+
constraint: exact ? "exact" : range.bounded ? "range" : "minimum",
|
|
276
|
+
...(exact ? {} : { declaration: specification }),
|
|
277
|
+
history_epoch_compatible: exact
|
|
278
|
+
? comparePmDateVersions(version, HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN) !== -1
|
|
279
|
+
: range.compatible,
|
|
280
|
+
},
|
|
281
|
+
];
|
|
282
|
+
});
|
|
232
283
|
}
|
|
233
284
|
/** Read npm's exact installed package coordinate from package-lock.json. */
|
|
234
285
|
function packageLockPin(projectRoot) {
|
|
@@ -273,23 +324,42 @@ function textLockPin(projectRoot, file) {
|
|
|
273
324
|
export function discoverProjectRuntimeVersionPins(projectRoot) {
|
|
274
325
|
const pins = [];
|
|
275
326
|
const projectPackage = readJsonRecord(path.join(projectRoot, "package.json"));
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
327
|
+
if (projectPackage) {
|
|
328
|
+
pins.push(...dependencyPins(projectPackage).map((pin) => ({
|
|
329
|
+
...pin,
|
|
330
|
+
source: "package.json",
|
|
331
|
+
})));
|
|
332
|
+
}
|
|
279
333
|
const installedPackage = readJsonRecord(path.join(projectRoot, "node_modules", "@unbrained", "pm-cli", "package.json"));
|
|
280
334
|
const installedVersion = installedPackage?.version;
|
|
281
335
|
if (typeof installedVersion === "string" &&
|
|
282
336
|
parseDateVersion(installedVersion)) {
|
|
283
|
-
pins.push({
|
|
337
|
+
pins.push({
|
|
338
|
+
version: installedVersion,
|
|
339
|
+
source: "installed-package",
|
|
340
|
+
constraint: "exact",
|
|
341
|
+
history_epoch_compatible: historyItemHashVersionForRuntime(installedVersion) === 3,
|
|
342
|
+
});
|
|
284
343
|
}
|
|
285
344
|
const packageLockVersion = packageLockPin(projectRoot);
|
|
286
345
|
if (packageLockVersion && parseDateVersion(packageLockVersion)) {
|
|
287
|
-
pins.push({
|
|
346
|
+
pins.push({
|
|
347
|
+
version: packageLockVersion,
|
|
348
|
+
source: "package-lock.json",
|
|
349
|
+
constraint: "exact",
|
|
350
|
+
history_epoch_compatible: historyItemHashVersionForRuntime(packageLockVersion) === 3,
|
|
351
|
+
});
|
|
288
352
|
}
|
|
289
353
|
for (const file of ["pnpm-lock.yaml", "yarn.lock"]) {
|
|
290
354
|
const version = textLockPin(projectRoot, file);
|
|
291
|
-
if (version)
|
|
292
|
-
pins.push({
|
|
355
|
+
if (version) {
|
|
356
|
+
pins.push({
|
|
357
|
+
version,
|
|
358
|
+
source: file,
|
|
359
|
+
constraint: "exact",
|
|
360
|
+
history_epoch_compatible: historyItemHashVersionForRuntime(version) === 3,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
293
363
|
}
|
|
294
364
|
return pins;
|
|
295
365
|
}
|
|
@@ -339,6 +409,9 @@ export function inspectProjectRuntimeCompatibility(options) {
|
|
|
339
409
|
const newest = pins[0];
|
|
340
410
|
const stale = newest !== undefined &&
|
|
341
411
|
comparePmDateVersions(options.executingVersion, newest.version) === -1;
|
|
412
|
+
const writerItemHashVersion = historyItemHashVersionForRuntime(options.executingVersion);
|
|
413
|
+
const incompatibleEpochPin = findIncompatibleHistoryEpochPin(pins, writerItemHashVersion);
|
|
414
|
+
const historyEpochIncompatible = mutating && incompatibleEpochPin !== undefined;
|
|
342
415
|
const warning = stale && !mutating
|
|
343
416
|
? {
|
|
344
417
|
code: "project_runtime_stale_read",
|
|
@@ -353,7 +426,9 @@ export function inspectProjectRuntimeCompatibility(options) {
|
|
|
353
426
|
}
|
|
354
427
|
: undefined;
|
|
355
428
|
return {
|
|
356
|
-
compatible: !mutating ||
|
|
429
|
+
compatible: !mutating ||
|
|
430
|
+
(!stale && !historyEpochIncompatible) ||
|
|
431
|
+
options.allowStale === true,
|
|
357
432
|
executing_version: options.executingVersion,
|
|
358
433
|
...(newest
|
|
359
434
|
? { project_version: newest.version, source: newest.source }
|
|
@@ -361,8 +436,18 @@ export function inspectProjectRuntimeCompatibility(options) {
|
|
|
361
436
|
...(command ? { command } : {}),
|
|
362
437
|
mutating,
|
|
363
438
|
stale,
|
|
439
|
+
history_epoch_incompatible: historyEpochIncompatible,
|
|
440
|
+
writer_item_hash_version: writerItemHashVersion,
|
|
441
|
+
...(incompatibleEpochPin
|
|
442
|
+
? {
|
|
443
|
+
incompatible_project_version: incompatibleEpochPin.declaration,
|
|
444
|
+
incompatible_source: incompatibleEpochPin.source,
|
|
445
|
+
}
|
|
446
|
+
: {}),
|
|
364
447
|
...(warning ? { warning } : {}),
|
|
365
|
-
override_applied:
|
|
448
|
+
override_applied: mutating &&
|
|
449
|
+
(stale || historyEpochIncompatible) &&
|
|
450
|
+
options.allowStale === true,
|
|
366
451
|
};
|
|
367
452
|
}
|
|
368
453
|
/** Refuse stale mutations with a stable SDK error and package-neutral recovery. */
|
|
@@ -370,6 +455,18 @@ export function assertProjectRuntimeCompatibility(options) {
|
|
|
370
455
|
const result = inspectProjectRuntimeCompatibility(options);
|
|
371
456
|
if (result.compatible)
|
|
372
457
|
return result;
|
|
458
|
+
if (result.history_epoch_incompatible) {
|
|
459
|
+
throw new PmCliError(`pm ${result.executing_version} cannot write item-hash epoch ${result.writer_item_hash_version} into a project pinned to pm ${result.incompatible_project_version}.`, EXIT_CODE.CONFLICT, {
|
|
460
|
+
code: "project_runtime_history_epoch_incompatible",
|
|
461
|
+
reason: result.incompatible_source,
|
|
462
|
+
why: `The pinned runtime cannot read item_hash_version ${result.writer_item_hash_version}; allowing the write would break its health and validation gates.`,
|
|
463
|
+
nextSteps: [
|
|
464
|
+
`Upgrade the project's ${PACKAGE_NAME} pin to ${HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN} or newer before mutating tracker history.`,
|
|
465
|
+
"For an intentional coordinated migration only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.",
|
|
466
|
+
"Read-only commands remain available without an override.",
|
|
467
|
+
],
|
|
468
|
+
});
|
|
469
|
+
}
|
|
373
470
|
throw new PmCliError(`pm ${result.executing_version} cannot mutate a project pinned to newer pm ${result.project_version}.`, EXIT_CODE.CONFLICT, {
|
|
374
471
|
code: "project_runtime_stale_mutation",
|
|
375
472
|
reason: result.source,
|
|
@@ -382,4 +479,4 @@ export function assertProjectRuntimeCompatibility(options) {
|
|
|
382
479
|
});
|
|
383
480
|
}
|
|
384
481
|
//# sourceMappingURL=project-runtime-compatibility.js.map
|
|
385
|
-
//# debugId=
|
|
482
|
+
//# debugId=f9737b75-b285-5fe9-a9ce-63e7c07626cb
|
|
@@ -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]="
|
|
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]="2d5b7e84-f6a6-5c48-a72b-a929ab2186f7")}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_author_acknowledge_target_unreadable",
|
|
1164
1164
|
aliases: [],
|
|
1165
1165
|
},
|
|
1166
|
+
{
|
|
1167
|
+
code: "history_baseline_unavailable",
|
|
1168
|
+
meaning: "History baseline unavailable 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/history/projection.ts"],
|
|
1174
|
+
emitting_commands: ["*"],
|
|
1175
|
+
canonical_code: "history_baseline_unavailable",
|
|
1176
|
+
aliases: [],
|
|
1177
|
+
},
|
|
1166
1178
|
{
|
|
1167
1179
|
code: "history_drift_chain_mismatch",
|
|
1168
1180
|
meaning: "History drift chain mismatch condition.",
|
|
@@ -1235,6 +1247,18 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
|
|
|
1235
1247
|
canonical_code: "history_drift_version_skew",
|
|
1236
1248
|
aliases: ["validate_history_drift_version_skews"],
|
|
1237
1249
|
},
|
|
1250
|
+
{
|
|
1251
|
+
code: "history_json_invalid",
|
|
1252
|
+
meaning: "History json invalid condition.",
|
|
1253
|
+
stability: "provisional",
|
|
1254
|
+
exit_code: 1,
|
|
1255
|
+
class: "generic_failure",
|
|
1256
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
1257
|
+
sources: ["core/history/read.ts"],
|
|
1258
|
+
emitting_commands: ["*"],
|
|
1259
|
+
canonical_code: "history_json_invalid",
|
|
1260
|
+
aliases: [],
|
|
1261
|
+
},
|
|
1238
1262
|
{
|
|
1239
1263
|
code: "history_merge_conflict_markers_detected",
|
|
1240
1264
|
meaning: "History merge conflict markers detected condition.",
|
|
@@ -1247,6 +1271,30 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
|
|
|
1247
1271
|
canonical_code: "merge_conflict_markers_detected",
|
|
1248
1272
|
aliases: [],
|
|
1249
1273
|
},
|
|
1274
|
+
{
|
|
1275
|
+
code: "history_replay_invalid",
|
|
1276
|
+
meaning: "History replay invalid condition.",
|
|
1277
|
+
stability: "provisional",
|
|
1278
|
+
exit_code: 1,
|
|
1279
|
+
class: "generic_failure",
|
|
1280
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
1281
|
+
sources: ["core/history/projection.ts"],
|
|
1282
|
+
emitting_commands: ["*"],
|
|
1283
|
+
canonical_code: "history_replay_invalid",
|
|
1284
|
+
aliases: [],
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
code: "history_salvage_refused",
|
|
1288
|
+
meaning: "History salvage refused condition.",
|
|
1289
|
+
stability: "provisional",
|
|
1290
|
+
exit_code: 4,
|
|
1291
|
+
class: "conflict",
|
|
1292
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
1293
|
+
sources: ["sdk/history/salvage.ts"],
|
|
1294
|
+
emitting_commands: ["*"],
|
|
1295
|
+
canonical_code: "history_salvage_refused",
|
|
1296
|
+
aliases: [],
|
|
1297
|
+
},
|
|
1250
1298
|
{
|
|
1251
1299
|
code: "history_stream_over_compact_threshold",
|
|
1252
1300
|
meaning: "History stream over compact threshold condition.",
|
|
@@ -1295,6 +1343,30 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
|
|
|
1295
1343
|
canonical_code: "history_unknown_author_events",
|
|
1296
1344
|
aliases: ["validate_history_unknown_author_events"],
|
|
1297
1345
|
},
|
|
1346
|
+
{
|
|
1347
|
+
code: "history_version_mapping_unavailable",
|
|
1348
|
+
meaning: "History version mapping unavailable condition.",
|
|
1349
|
+
stability: "provisional",
|
|
1350
|
+
exit_code: 2,
|
|
1351
|
+
class: "usage",
|
|
1352
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
1353
|
+
sources: ["core/history/version-address.ts"],
|
|
1354
|
+
emitting_commands: ["*"],
|
|
1355
|
+
canonical_code: "history_version_mapping_unavailable",
|
|
1356
|
+
aliases: [],
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
code: "history_version_pruned",
|
|
1360
|
+
meaning: "History version pruned condition.",
|
|
1361
|
+
stability: "provisional",
|
|
1362
|
+
exit_code: 2,
|
|
1363
|
+
class: "usage",
|
|
1364
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
1365
|
+
sources: ["core/history/projection.ts"],
|
|
1366
|
+
emitting_commands: ["*"],
|
|
1367
|
+
canonical_code: "history_version_pruned",
|
|
1368
|
+
aliases: [],
|
|
1369
|
+
},
|
|
1298
1370
|
{
|
|
1299
1371
|
code: "host_environment_capacity_fault",
|
|
1300
1372
|
meaning: "Host environment capacity fault condition.",
|
|
@@ -1797,6 +1869,18 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
|
|
|
1797
1869
|
canonical_code: "item_already_active",
|
|
1798
1870
|
aliases: [],
|
|
1799
1871
|
},
|
|
1872
|
+
{
|
|
1873
|
+
code: "item_document_encoding_invalid",
|
|
1874
|
+
meaning: "Item document encoding invalid condition.",
|
|
1875
|
+
stability: "provisional",
|
|
1876
|
+
exit_code: 4,
|
|
1877
|
+
class: "conflict",
|
|
1878
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
1879
|
+
sources: ["core/store/item-store.ts"],
|
|
1880
|
+
emitting_commands: ["*"],
|
|
1881
|
+
canonical_code: "item_document_encoding_invalid",
|
|
1882
|
+
aliases: [],
|
|
1883
|
+
},
|
|
1800
1884
|
{
|
|
1801
1885
|
code: "item_document_invalid",
|
|
1802
1886
|
meaning: "Item document invalid condition.",
|
|
@@ -1833,6 +1917,18 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
|
|
|
1833
1917
|
canonical_code: "item_id_collision",
|
|
1834
1918
|
aliases: [],
|
|
1835
1919
|
},
|
|
1920
|
+
{
|
|
1921
|
+
code: "item_identity_reserved",
|
|
1922
|
+
meaning: "Item identity reserved condition.",
|
|
1923
|
+
stability: "provisional",
|
|
1924
|
+
exit_code: 4,
|
|
1925
|
+
class: "conflict",
|
|
1926
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
1927
|
+
sources: ["core/history/history.ts"],
|
|
1928
|
+
emitting_commands: ["*"],
|
|
1929
|
+
canonical_code: "item_identity_reserved",
|
|
1930
|
+
aliases: [],
|
|
1931
|
+
},
|
|
1836
1932
|
{
|
|
1837
1933
|
code: "item_not_found",
|
|
1838
1934
|
meaning: "Item not found condition.",
|
|
@@ -2124,42 +2220,6 @@ export const PM_ERROR_CODE_CATALOG_PART_1 = [
|
|
|
2124
2220
|
canonical_code: "merge_reconcile_receipt_evidence_untrusted",
|
|
2125
2221
|
aliases: [],
|
|
2126
2222
|
},
|
|
2127
|
-
{
|
|
2128
|
-
code: "merge_root_not_found",
|
|
2129
|
-
meaning: "Merge root not found condition.",
|
|
2130
|
-
stability: "stable",
|
|
2131
|
-
exit_code: 3,
|
|
2132
|
-
class: "not_found",
|
|
2133
|
-
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
2134
|
-
sources: ["sdk/merge/install.ts"],
|
|
2135
|
-
emitting_commands: ["*"],
|
|
2136
|
-
canonical_code: "merge_root_not_found",
|
|
2137
|
-
aliases: [],
|
|
2138
|
-
},
|
|
2139
|
-
{
|
|
2140
|
-
code: "missing_allowed_values",
|
|
2141
|
-
meaning: "Missing allowed values condition.",
|
|
2142
|
-
stability: "provisional",
|
|
2143
|
-
exit_code: 1,
|
|
2144
|
-
class: "generic_failure",
|
|
2145
|
-
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
2146
|
-
sources: ["sdk/agent/refusal-closure.ts"],
|
|
2147
|
-
emitting_commands: ["*"],
|
|
2148
|
-
canonical_code: "missing_allowed_values",
|
|
2149
|
-
aliases: [],
|
|
2150
|
-
},
|
|
2151
|
-
{
|
|
2152
|
-
code: "missing_budget",
|
|
2153
|
-
meaning: "Missing budget condition.",
|
|
2154
|
-
stability: "provisional",
|
|
2155
|
-
exit_code: 1,
|
|
2156
|
-
class: "generic_failure",
|
|
2157
|
-
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
2158
|
-
sources: ["sdk/cli-contracts/flag-lexicon-contracts.ts"],
|
|
2159
|
-
emitting_commands: ["*"],
|
|
2160
|
-
canonical_code: "missing_budget",
|
|
2161
|
-
aliases: [],
|
|
2162
|
-
},
|
|
2163
2223
|
];
|
|
2164
2224
|
//# sourceMappingURL=generated-error-code-catalog-part-1.js.map
|
|
2165
|
-
//# debugId=
|
|
2225
|
+
//# debugId=2d5b7e84-f6a6-5c48-a72b-a929ab2186f7
|
|
@@ -1,7 +1,43 @@
|
|
|
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]="
|
|
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]="aa8f034d-d4b6-595b-af76-f7203d062971")}catch(e){}}();
|
|
4
4
|
export const PM_ERROR_CODE_CATALOG_PART_2 = [
|
|
5
|
+
{
|
|
6
|
+
code: "merge_root_not_found",
|
|
7
|
+
meaning: "Merge root not found condition.",
|
|
8
|
+
stability: "stable",
|
|
9
|
+
exit_code: 3,
|
|
10
|
+
class: "not_found",
|
|
11
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
12
|
+
sources: ["sdk/merge/install.ts"],
|
|
13
|
+
emitting_commands: ["*"],
|
|
14
|
+
canonical_code: "merge_root_not_found",
|
|
15
|
+
aliases: [],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
code: "missing_allowed_values",
|
|
19
|
+
meaning: "Missing allowed values 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/agent/refusal-closure.ts"],
|
|
25
|
+
emitting_commands: ["*"],
|
|
26
|
+
canonical_code: "missing_allowed_values",
|
|
27
|
+
aliases: [],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
code: "missing_budget",
|
|
31
|
+
meaning: "Missing budget condition.",
|
|
32
|
+
stability: "provisional",
|
|
33
|
+
exit_code: 1,
|
|
34
|
+
class: "generic_failure",
|
|
35
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
36
|
+
sources: ["sdk/cli-contracts/flag-lexicon-contracts.ts"],
|
|
37
|
+
emitting_commands: ["*"],
|
|
38
|
+
canonical_code: "missing_budget",
|
|
39
|
+
aliases: [],
|
|
40
|
+
},
|
|
5
41
|
{
|
|
6
42
|
code: "missing_cli_flag",
|
|
7
43
|
meaning: "Missing cli flag condition.",
|
|
@@ -499,6 +535,18 @@ export const PM_ERROR_CODE_CATALOG_PART_2 = [
|
|
|
499
535
|
canonical_code: "profile_title_empty",
|
|
500
536
|
aliases: [],
|
|
501
537
|
},
|
|
538
|
+
{
|
|
539
|
+
code: "project_runtime_history_epoch_incompatible",
|
|
540
|
+
meaning: "Project runtime history epoch incompatible condition.",
|
|
541
|
+
stability: "provisional",
|
|
542
|
+
exit_code: 4,
|
|
543
|
+
class: "conflict",
|
|
544
|
+
recovery: "Inspect the structured error guidance and retry the suggested command.",
|
|
545
|
+
sources: ["sdk/environment/project-runtime-compatibility.ts"],
|
|
546
|
+
emitting_commands: ["*"],
|
|
547
|
+
canonical_code: "project_runtime_history_epoch_incompatible",
|
|
548
|
+
aliases: [],
|
|
549
|
+
},
|
|
502
550
|
{
|
|
503
551
|
code: "project_runtime_stale_mutation",
|
|
504
552
|
meaning: "Project runtime stale mutation condition.",
|
|
@@ -2186,4 +2234,4 @@ export const PM_ERROR_CODE_CATALOG_PART_2 = [
|
|
|
2186
2234
|
},
|
|
2187
2235
|
];
|
|
2188
2236
|
//# sourceMappingURL=generated-error-code-catalog-part-2.js.map
|
|
2189
|
-
//# debugId=
|
|
2237
|
+
//# debugId=aa8f034d-d4b6-595b-af76-f7203d062971
|
|
@@ -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]="
|
|
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]="9f0077a4-4f0a-540f-9951-2e8a640629c9")}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";
|
|
@@ -28,7 +28,6 @@ import { EXIT_CODE, PM_CORE_REQUIRED_SUBDIRS, TYPE_TO_FOLDER, } from "../../core
|
|
|
28
28
|
import { findFirstMergeConflictMarker } from "../../core/shared/conflict-markers.js";
|
|
29
29
|
import { PmCliError } from "../../core/shared/errors.js";
|
|
30
30
|
import { toNonEmptyStringOrUndefined } from "../../core/shared/primitives.js";
|
|
31
|
-
import { sha256Hex } from "../../core/shared/serialization.js";
|
|
32
31
|
import { nowIso } from "../../core/shared/time.js";
|
|
33
32
|
import { parseItemDocument } from "../../core/item/item-format.js";
|
|
34
33
|
import { effectiveItemFormatVersion, scanItemFormatVersions, } from "../../core/item/item-format-version.js";
|
|
@@ -47,7 +46,8 @@ import { buildCapabilityContractMetadata, buildRegistrationCollisionRemediation,
|
|
|
47
46
|
import { scanStaleInProgressItems, } from "./stale-work.js";
|
|
48
47
|
import { scanTrackedRuntimeCache } from "./tracked-runtime-cache.js";
|
|
49
48
|
import { auditMergeDriverConfiguration, findGitWorkspaceRoot, } from "../merge/install.js";
|
|
50
|
-
import { inspectMergeReceiptEvidence,
|
|
49
|
+
import { inspectMergeReceiptEvidence, partitionMergeReceipts, } from "../merge/receipts.js";
|
|
50
|
+
import { classifyHistoryMergeReceiptReferences, extractHistoryMergeReceiptDispositions, extractHistoryMergeReceiptReferences, } from "./merge-receipt-history.js";
|
|
51
51
|
import { runHistoryRepair } from "../history-repair.js";
|
|
52
52
|
import { resolveWorkspaceRelationshipKindRegistry } from "../graph/assembly.js";
|
|
53
53
|
import { analyzeHierarchyIntegrity, } from "../graph/hierarchy-integrity.js";
|
|
@@ -279,41 +279,13 @@ async function scanItemIntegrity(pmRoot, typeToFolder, schema) {
|
|
|
279
279
|
}
|
|
280
280
|
return { paths, unreadable, conflictMarkers, parseFailures, formatVersions };
|
|
281
281
|
}
|
|
282
|
-
function mergeReceiptIdsFromHistoryEntry(value) {
|
|
283
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
284
|
-
return [];
|
|
285
|
-
}
|
|
286
|
-
const context = value.context;
|
|
287
|
-
if (typeof context !== "object" ||
|
|
288
|
-
context === null ||
|
|
289
|
-
Array.isArray(context)) {
|
|
290
|
-
return [];
|
|
291
|
-
}
|
|
292
|
-
const merge = context.merge;
|
|
293
|
-
if (typeof merge !== "object" || merge === null || Array.isArray(merge)) {
|
|
294
|
-
return [];
|
|
295
|
-
}
|
|
296
|
-
const receipts = merge.receipts;
|
|
297
|
-
if (!Array.isArray(receipts))
|
|
298
|
-
return [];
|
|
299
|
-
return receipts.flatMap((receipt) => {
|
|
300
|
-
if (typeof receipt !== "object" ||
|
|
301
|
-
receipt === null ||
|
|
302
|
-
Array.isArray(receipt)) {
|
|
303
|
-
return [];
|
|
304
|
-
}
|
|
305
|
-
const receiptId = receipt.receipt_id;
|
|
306
|
-
return typeof receiptId === "string" && receiptId.length > 0
|
|
307
|
-
? [receiptId]
|
|
308
|
-
: [];
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
282
|
async function scanHistoryIntegrity(pmRoot) {
|
|
312
283
|
const historyDir = path.join(pmRoot, "history");
|
|
313
284
|
const unreadable = [];
|
|
314
285
|
const conflictMarkers = [];
|
|
315
286
|
const invalidJson = [];
|
|
316
287
|
const mergeReceiptReferences = [];
|
|
288
|
+
const mergeReceiptDispositions = [];
|
|
317
289
|
let files = [];
|
|
318
290
|
try {
|
|
319
291
|
files = (await fs.readdir(historyDir))
|
|
@@ -346,11 +318,12 @@ async function scanHistoryIntegrity(pmRoot) {
|
|
|
346
318
|
return;
|
|
347
319
|
try {
|
|
348
320
|
const parsed = JSON.parse(line);
|
|
349
|
-
mergeReceiptReferences.push(...
|
|
321
|
+
mergeReceiptReferences.push(...extractHistoryMergeReceiptReferences(parsed, itemId).map((reference) => ({
|
|
350
322
|
itemId,
|
|
351
323
|
line: index + 1,
|
|
352
|
-
|
|
324
|
+
...reference,
|
|
353
325
|
})));
|
|
326
|
+
mergeReceiptDispositions.push(...extractHistoryMergeReceiptDispositions(parsed, itemId, index + 1));
|
|
354
327
|
}
|
|
355
328
|
catch {
|
|
356
329
|
invalidJson.push({ id: itemId, line: index + 1 });
|
|
@@ -363,6 +336,7 @@ async function scanHistoryIntegrity(pmRoot) {
|
|
|
363
336
|
conflictMarkers,
|
|
364
337
|
invalidJson,
|
|
365
338
|
mergeReceiptReferences,
|
|
339
|
+
mergeReceiptDispositions,
|
|
366
340
|
};
|
|
367
341
|
}
|
|
368
342
|
function buildHierarchyIntegrityWarnings(analysis) {
|
|
@@ -405,15 +379,8 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
|
|
|
405
379
|
pmRoot,
|
|
406
380
|
});
|
|
407
381
|
const availableMergeReceiptIds = new Set(mergeReceiptEvidence.receipts.map((receipt) => receipt.id));
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
.map((reference) => ({
|
|
411
|
-
item_id: reference.itemId,
|
|
412
|
-
history_line: reference.line,
|
|
413
|
-
...(isSafeReceiptId(reference.receiptId)
|
|
414
|
-
? { receipt_id: reference.receiptId }
|
|
415
|
-
: { receipt_reference_hash: sha256Hex(reference.receiptId) }),
|
|
416
|
-
}));
|
|
382
|
+
const historyReceiptClassification = classifyHistoryMergeReceiptReferences(historyScan.mergeReceiptReferences, availableMergeReceiptIds, historyScan.mergeReceiptDispositions);
|
|
383
|
+
const missingMergeReceiptReferences = historyReceiptClassification.missing;
|
|
417
384
|
const pendingMergeReceipts = mergeReceiptEvidence.receipts.filter((receipt) => receipt.state === "pending");
|
|
418
385
|
const { pendingDecisions: pendingMergeDecisions, lossless: losslessMergeReceipts, } = partitionMergeReceipts(pendingMergeReceipts);
|
|
419
386
|
const mergeDriverInstallationMissing = mergeDriverAudit?.status === "missing" &&
|
|
@@ -483,6 +450,8 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema, requireMergeDri
|
|
|
483
450
|
lossless_merge_receipts: losslessMergeReceipts.length,
|
|
484
451
|
invalid_merge_receipt_evidence: mergeReceiptEvidence.invalid_evidence_count,
|
|
485
452
|
missing_merge_receipt_history_references: missingMergeReceiptReferences.length,
|
|
453
|
+
accepted_legacy_merge_receipt_references: historyReceiptClassification.acceptedLegacyCount,
|
|
454
|
+
accepted_missing_merge_receipt_dispositions: historyReceiptClassification.acceptedDispositionCount,
|
|
486
455
|
},
|
|
487
456
|
item_unreadable: itemScan.unreadable,
|
|
488
457
|
item_conflict_markers: itemScan.conflictMarkers,
|
|
@@ -2375,4 +2344,4 @@ export const _testOnlyHealthCommand = {
|
|
|
2375
2344
|
warningCode,
|
|
2376
2345
|
};
|
|
2377
2346
|
//# sourceMappingURL=health.js.map
|
|
2378
|
-
//# debugId=
|
|
2347
|
+
//# debugId=9f0077a4-4f0a-540f-9951-2e8a640629c9
|