@unbrained/pm-cli 2026.8.14 → 2026.8.16
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +51 -11
- package/dist/cli/commander-usage.js +17 -4
- package/dist/cli/error-guidance.d.ts +7 -0
- package/dist/cli/error-guidance.js +65 -25
- package/dist/cli/main.js +3 -2
- package/dist/cli/register-history-author.js +16 -11
- package/dist/cli/register-mutation.js +4 -2
- package/dist/cli/register-operations.js +5 -5
- package/dist/cli-bundle/bundle-manifest.json +148 -148
- package/dist/cli-bundle/chunks/chunk-47OQEOQB.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-XAVMOK6B.js → chunk-73UGEBRS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HCIYWD6M.js +35 -0
- package/dist/cli-bundle/chunks/{chunk-FIW4P64F.js → chunk-I2LUWWR5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SBRKH6OR.js → chunk-IC5W2T34.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TMJ7URWS.js → chunk-PANOOBIS.js} +9 -9
- package/dist/cli-bundle/chunks/{chunk-BFALV3YP.js → chunk-RIS565OA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TXMEUUUY.js → chunk-TK6N7HGM.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-TOFG2URD.js +197 -0
- package/dist/cli-bundle/chunks/{chunk-G5JUB66K.js → chunk-URW4QRMI.js} +65 -59
- package/dist/cli-bundle/chunks/{register-list-query-T3EHHNNV.js → register-list-query-EYCXHZAG.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-7YVIG54J.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-KGDNRMCL.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-3YXZ444E.js → register-setup-NVXBOD5I.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PPFGQDSI.js → chunk-4JPEBFFC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5NMFSX26.js +155 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YOOI3UZX.js → chunk-6ROKKT4X.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-725JSCMP.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-XDNAW5OI.js → chunk-C7JUBRFP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4DQ2YERC.js → chunk-CODV5LUT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-DQ6SMTBF.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-HAACPSUW.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-WCVE2NIG.js → chunk-J4UFYHOD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-JX5Z344Q.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-L4RDYBIQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KSEDUWVZ.js → chunk-NJ5RLEFD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-K7RWWOAG.js → chunk-QYZERYR5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SSNDYZTM.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-T46KLOIB.js +50 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KFSZ3BP6.js → chunk-TZATVC4G.js} +6 -6
- package/dist/cli-bundle/focused-chunks/chunk-WY3WRPVN.js +2 -0
- package/dist/cli-bundle/main.js +13 -13
- 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 +32 -35
- 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 +32 -31
- 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 +2 -2
- package/dist/core/diagnostics/remediation.js +7 -2
- package/dist/core/extensions/reserved-host-flags.js +3 -2
- package/dist/core/history/replay.d.ts +14 -1
- package/dist/core/history/replay.js +45 -8
- package/dist/core/history/workspace-history.js +32 -10
- package/dist/core/output/output.d.ts +2 -0
- package/dist/core/output/output.js +7 -3
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/core/shared/errors.d.ts +14 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/store/item-store.js +28 -2
- package/dist/mcp/tool-definitions.js +9 -5
- package/dist/sdk/agent/refusal-reachability.d.ts +69 -0
- package/dist/sdk/agent/refusal-reachability.js +159 -3
- package/dist/sdk/author-attribution.d.ts +56 -11
- package/dist/sdk/author-attribution.js +174 -50
- package/dist/sdk/cli-bootstrap.d.ts +2 -0
- package/dist/sdk/cli-bootstrap.js +7 -2
- package/dist/sdk/cli-contracts/completeness.js +3 -2
- package/dist/sdk/cli-contracts/flag-contracts.js +6 -2
- package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +5 -0
- package/dist/sdk/cli-contracts/runtime-contracts.js +23 -7
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +22 -5
- package/dist/sdk/cli-contracts/tool-schema.js +20 -5
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/completion.js +11 -4
- package/dist/sdk/core.d.ts +2 -2
- package/dist/sdk/core.js +3 -3
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +50 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +74 -14
- package/dist/sdk/governance/assurance-action.d.ts +7 -1
- package/dist/sdk/governance/assurance-action.js +7 -6
- package/dist/sdk/governance/assurance-mutation-error.d.ts +42 -1
- package/dist/sdk/governance/assurance-mutation-error.js +27 -3
- package/dist/sdk/governance/assurance-runtime.js +12 -11
- package/dist/sdk/governance/assurance.d.ts +9 -0
- package/dist/sdk/governance/assurance.js +80 -14
- package/dist/sdk/governance/coverage-assurance.d.ts +24 -0
- package/dist/sdk/governance/coverage-assurance.js +61 -0
- package/dist/sdk/governance/extension-host-version.d.ts +25 -0
- package/dist/sdk/governance/extension-host-version.js +116 -0
- package/dist/sdk/governance/health.d.ts +32 -1
- package/dist/sdk/governance/health.js +119 -27
- package/dist/sdk/governance/provenance-health.d.ts +27 -0
- package/dist/sdk/governance/provenance-health.js +95 -3
- package/dist/sdk/governance/validate.js +7 -8
- package/dist/sdk/governance.d.ts +6 -0
- package/dist/sdk/governance.js +8 -2
- package/dist/sdk/history-repair.d.ts +13 -1
- package/dist/sdk/history-repair.js +62 -18
- package/dist/sdk/index.d.ts +2 -1
- package/dist/sdk/index.js +4 -3
- package/dist/sdk/linked-artifacts.js +16 -5
- package/dist/sdk/pagination.d.ts +15 -0
- package/dist/sdk/pagination.js +9 -5
- package/dist/sdk/query/context.d.ts +5 -1
- package/dist/sdk/query/context.js +14 -5
- package/dist/sdk/read-output/continuation.d.ts +11 -0
- package/dist/sdk/read-output/continuation.js +132 -0
- package/dist/sdk/read-output-budget.d.ts +1 -1
- package/dist/sdk/read-output-budget.js +14 -10
- package/dist/sdk/read-output-contracts.d.ts +66 -2
- package/dist/sdk/read-output-contracts.js +185 -19
- package/dist/sdk/read-output-rows.d.ts +2 -0
- package/dist/sdk/read-output-rows.js +15 -2
- package/dist/sdk/runtime-input.js +4 -2
- package/dist/sdk/runtime.d.ts +2 -5
- package/dist/sdk/runtime.js +3 -2
- package/docs/ASSURANCE.md +59 -2
- package/docs/COMMANDS.md +8 -2
- package/docs/READ_OUTPUT_CONTRACTS.md +55 -8
- package/docs/RELEASING.md +54 -11
- package/docs/SDK_CONTEXT_INTEGRITY.md +94 -4
- package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +13 -5
- package/marketplace.json +2 -2
- package/package.json +3 -3
- 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-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +1241 -180
- package/dist/cli-bundle/chunks/chunk-BBOFSVAK.js +0 -197
- package/dist/cli-bundle/chunks/chunk-YAMTJL6Y.js +0 -34
- package/dist/cli-bundle/chunks/chunk-YSVSMJ2B.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-E27WCLSZ.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-4R6I7CPY.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-F43TT2QQ.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-KYUQGTSB.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LZ4MV3RH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PGXJQLCT.js +0 -155
- package/dist/cli-bundle/focused-chunks/chunk-Q4YY3XNF.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QK753U3U.js +0 -46
- package/dist/cli-bundle/focused-chunks/chunk-QUMB2J27.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-SM7MTG27.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZM6TZVHC.js +0 -2
package/dist/sdk/governance.d.ts
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export * from "./governance/gc.js";
|
|
7
7
|
export * from "./governance/health.js";
|
|
8
|
+
export * from "./governance/extension-host-version.js";
|
|
9
|
+
export * from "./governance/assurance.js";
|
|
10
|
+
export * from "./governance/assurance-action.js";
|
|
11
|
+
export * from "./governance/assurance-mutation-error.js";
|
|
12
|
+
export * from "./governance/assurance-presets.js";
|
|
13
|
+
export * from "./governance/assurance-runtime.js";
|
|
8
14
|
export { runReindex, type ReindexOptions, type ReindexResult, } from "./governance/reindex.js";
|
|
9
15
|
export * from "./governance/stale-work.js";
|
|
10
16
|
export * from "./governance/storage-integrity.js";
|
package/dist/sdk/governance.js
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
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]="
|
|
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]="0baaaf38-2a32-5d6e-92bc-9919d2393f86")}catch(e){}}();
|
|
8
8
|
export * from "./governance/gc.js";
|
|
9
9
|
export * from "./governance/health.js";
|
|
10
|
+
export * from "./governance/extension-host-version.js";
|
|
11
|
+
export * from "./governance/assurance.js";
|
|
12
|
+
export * from "./governance/assurance-action.js";
|
|
13
|
+
export * from "./governance/assurance-mutation-error.js";
|
|
14
|
+
export * from "./governance/assurance-presets.js";
|
|
15
|
+
export * from "./governance/assurance-runtime.js";
|
|
10
16
|
export { runReindex, } from "./governance/reindex.js";
|
|
11
17
|
export * from "./governance/stale-work.js";
|
|
12
18
|
export * from "./governance/storage-integrity.js";
|
|
@@ -17,4 +23,4 @@ export * from "./mutation-guard.js";
|
|
|
17
23
|
export * from "./governance/provenance-health.js";
|
|
18
24
|
export * from "./similarity.js";
|
|
19
25
|
//# sourceMappingURL=governance.js.map
|
|
20
|
-
//# debugId=
|
|
26
|
+
//# debugId=0baaaf38-2a32-5d6e-92bc-9919d2393f86
|
|
@@ -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 ProvenanceNormalizationReceipt } from "./governance/provenance-health.js";
|
|
4
5
|
/** Documents the history repair command options payload exchanged by command, SDK, and package integrations. */
|
|
5
6
|
export interface HistoryRepairCommandOptions {
|
|
6
7
|
/** Value that configures or reports dry run for this contract. */
|
|
@@ -19,6 +20,8 @@ export interface HistoryRepairCommandOptions {
|
|
|
19
20
|
auditContextById?: Record<string, Record<string, unknown>>;
|
|
20
21
|
/** Add an audit event even when replay and the current item already match. */
|
|
21
22
|
forceAuditEntry?: boolean;
|
|
23
|
+
/** Remove bounded-domain-invalid provenance observations and record an aggregate privacy-safe audit receipt. */
|
|
24
|
+
normalizeProvenance?: boolean;
|
|
22
25
|
}
|
|
23
26
|
/** Documents the history repair result payload exchanged by command, SDK, and package integrations. */
|
|
24
27
|
export interface HistoryRepairResult {
|
|
@@ -41,6 +44,9 @@ export interface HistoryRepairResult {
|
|
|
41
44
|
audit_entry_added: boolean;
|
|
42
45
|
verify_ok: boolean;
|
|
43
46
|
verify_errors: string[];
|
|
47
|
+
item_hash_version_before: number | null;
|
|
48
|
+
item_hash_version_after: number;
|
|
49
|
+
version_disposition: "preserved" | "selected_for_ambiguous_stream";
|
|
44
50
|
};
|
|
45
51
|
/** Value that configures or reports item for this contract. */
|
|
46
52
|
item: {
|
|
@@ -48,6 +54,10 @@ export interface HistoryRepairResult {
|
|
|
48
54
|
path: string | null;
|
|
49
55
|
matched_chain_before: boolean | null;
|
|
50
56
|
};
|
|
57
|
+
/** Privacy-safe receipt for the explicitly requested provenance normalization mode. */
|
|
58
|
+
provenance_normalization: ProvenanceNormalizationReceipt & {
|
|
59
|
+
requested: boolean;
|
|
60
|
+
};
|
|
51
61
|
/** 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. */
|
|
52
62
|
reconciliation?: HistoryRepairReconciliationReport;
|
|
53
63
|
/** Value that configures or reports warnings for this contract. */
|
|
@@ -126,7 +136,9 @@ export interface HistoryRepairAllResult {
|
|
|
126
136
|
scanned_streams: number;
|
|
127
137
|
/** Value that configures or reports drifted streams for this contract. */
|
|
128
138
|
drifted_streams: number;
|
|
129
|
-
/**
|
|
139
|
+
/** Streams selected only because invalid provenance required normalization. */
|
|
140
|
+
provenance_invalid_streams: number;
|
|
141
|
+
/** One compact row per drifted or provenance-normalization target. */
|
|
130
142
|
streams: HistoryRepairAllStreamResult[];
|
|
131
143
|
/** Value that configures or reports totals for this contract. */
|
|
132
144
|
totals: {
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Implements the pm history repair 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]="de9b7f82-0f51-599d-b1fa-2d54e3acbdbc")}catch(e){}}();
|
|
8
8
|
import jsonPatch from "fast-json-patch";
|
|
9
9
|
import { patchPathToChangedField } from "../core/history/history-diff.js";
|
|
10
10
|
import { pathExists, readFileIfExists } from "../core/fs/fs-utils.js";
|
|
11
11
|
import { executeHistoryRewrite, writeHistoryRawWithRollback, } from "../core/history/history-rewrite.js";
|
|
12
|
-
import { historyEntriesToRaw, normalizeReplayPatchOps, reanchorHistoryEntries, replayHash, toReplayDocument, verifyHistoryChain, } from "../core/history/replay.js";
|
|
12
|
+
import { historyEntriesToRaw, normalizeReplayPatchOps, reanchorHistoryEntries, replayHash, resolveHistoryRepairItemHashVersion, toReplayDocument, verifyHistoryChain, verifyHistoryChainWithVersion, } from "../core/history/replay.js";
|
|
13
13
|
import { scanHistoryDrift } from "../core/history/drift-scan.js";
|
|
14
14
|
import { invalidateHistoryDriftCache } from "../core/history/drift-cache.js";
|
|
15
15
|
import { readHistoryEntries } from "../core/history/read.js";
|
|
@@ -23,6 +23,7 @@ import { listAllItemMetadataWithBody, readLocatedItem, } from "../core/store/ite
|
|
|
23
23
|
import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
|
|
24
24
|
import { readSettings } from "../core/store/settings.js";
|
|
25
25
|
import { resolveHistorySubject } from "./history-redact.js";
|
|
26
|
+
import { listInvalidProvenanceHistoryStreamIds, normalizeInvalidHistoryProvenance, } from "./governance/provenance-health.js";
|
|
26
27
|
function replayFieldValue(document, field) {
|
|
27
28
|
return field === "body"
|
|
28
29
|
? document.body
|
|
@@ -133,7 +134,7 @@ export function analyzeReconciliationDiscard(entries, finalReplay, currentItemRe
|
|
|
133
134
|
: null,
|
|
134
135
|
};
|
|
135
136
|
}
|
|
136
|
-
async function loadHistoryRepairItemReplay(subject, settings, historyEntries) {
|
|
137
|
+
async function loadHistoryRepairItemReplay(subject, settings, historyEntries, itemHashVersion) {
|
|
137
138
|
const currentItemPath = subject.located?.itemPath ?? null;
|
|
138
139
|
const loadedItem = subject.located
|
|
139
140
|
? await readLocatedItem(subject.located, { schema: settings.schema })
|
|
@@ -152,7 +153,7 @@ async function loadHistoryRepairItemReplay(subject, settings, historyEntries) {
|
|
|
152
153
|
return {
|
|
153
154
|
currentItemReplay,
|
|
154
155
|
currentItemPath,
|
|
155
|
-
matchedChainBefore: replayHash(currentItemReplay) === lastOriginalAfterHash,
|
|
156
|
+
matchedChainBefore: replayHash(currentItemReplay, itemHashVersion) === lastOriginalAfterHash,
|
|
156
157
|
currentItemRawBeforeLock: loadedItem.raw,
|
|
157
158
|
loadedItem,
|
|
158
159
|
};
|
|
@@ -180,16 +181,19 @@ function buildHistoryRepairEntries(params) {
|
|
|
180
181
|
patch: params.reconcileNeeded && params.currentItemReplay
|
|
181
182
|
? jsonPatch.compare(params.finalReplay, params.currentItemReplay)
|
|
182
183
|
: [],
|
|
183
|
-
before_hash: replayHash(params.finalReplay),
|
|
184
|
-
after_hash: replayHash(afterReplay),
|
|
184
|
+
before_hash: replayHash(params.finalReplay, params.itemHashVersion),
|
|
185
|
+
after_hash: replayHash(afterReplay, params.itemHashVersion),
|
|
185
186
|
message: params.message,
|
|
187
|
+
...(params.explicitItemHashVersion
|
|
188
|
+
? { item_hash_version: params.itemHashVersion }
|
|
189
|
+
: {}),
|
|
186
190
|
...(params.auditContext === undefined
|
|
187
191
|
? {}
|
|
188
192
|
: { context: params.auditContext }),
|
|
189
193
|
});
|
|
190
194
|
return { rewrittenEntries, auditEntryAdded: true };
|
|
191
195
|
}
|
|
192
|
-
function collectHistoryRepairWarnings(changed, skippedOps) {
|
|
196
|
+
function collectHistoryRepairWarnings(changed, skippedOps, reconciliation) {
|
|
193
197
|
const warnings = [];
|
|
194
198
|
if (!changed) {
|
|
195
199
|
warnings.push("history_repair_no_changes");
|
|
@@ -197,6 +201,9 @@ function collectHistoryRepairWarnings(changed, skippedOps) {
|
|
|
197
201
|
if (skippedOps > 0) {
|
|
198
202
|
warnings.push(`history_repair_skipped_unresolvable_ops:${skippedOps}`);
|
|
199
203
|
}
|
|
204
|
+
if (reconciliation && reconciliation.discarded_events.length > 0) {
|
|
205
|
+
warnings.push(`history_repair_reconcile_discards_events:${reconciliation.discarded_events.length}`, `history_repair_discarded_authors:${reconciliation.discarded_authors.join(",")}`);
|
|
206
|
+
}
|
|
200
207
|
return warnings;
|
|
201
208
|
}
|
|
202
209
|
async function applyHistoryRepairRewrite(params) {
|
|
@@ -241,11 +248,28 @@ export async function runHistoryRepair(id, options, global) {
|
|
|
241
248
|
throw new PmCliError(`No history entries exist for ${subject.id}; nothing to repair.`, EXIT_CODE.USAGE);
|
|
242
249
|
}
|
|
243
250
|
const chainBefore = verifyHistoryChain(historyEntries);
|
|
244
|
-
const
|
|
245
|
-
const
|
|
251
|
+
const chainVersionBefore = verifyHistoryChainWithVersion(historyEntries);
|
|
252
|
+
const provenanceNormalization = options.normalizeProvenance
|
|
253
|
+
? normalizeInvalidHistoryProvenance(historyEntries)
|
|
254
|
+
: {
|
|
255
|
+
entries: historyEntries,
|
|
256
|
+
receipt: {
|
|
257
|
+
changed: false,
|
|
258
|
+
events_changed: 0,
|
|
259
|
+
observations_removed: 0,
|
|
260
|
+
invalid_values: [],
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
const itemHashVersion = resolveHistoryRepairItemHashVersion(provenanceNormalization.entries);
|
|
264
|
+
const explicitVersionsBefore = new Set(provenanceNormalization.entries
|
|
265
|
+
.map((entry) => entry.item_hash_version)
|
|
266
|
+
.filter((version) => version !== undefined));
|
|
267
|
+
const reanchor = reanchorHistoryEntries(provenanceNormalization.entries, itemHashVersion);
|
|
268
|
+
const itemReplayContext = await loadHistoryRepairItemReplay(subject, settings, historyEntries, itemHashVersion);
|
|
246
269
|
const finalReplay = reanchor.finalDocument;
|
|
247
270
|
const reconcileNeeded = itemReplayContext.currentItemReplay !== null &&
|
|
248
|
-
replayHash(finalReplay) !==
|
|
271
|
+
replayHash(finalReplay, itemHashVersion) !==
|
|
272
|
+
replayHash(itemReplayContext.currentItemReplay, itemHashVersion);
|
|
249
273
|
// GH-603: reconciling toward the on-disk item can silently overwrite the
|
|
250
274
|
// replayed effect of other authors' events (classic after a lossy merge).
|
|
251
275
|
// Surface exactly what is being discarded before any write happens.
|
|
@@ -257,6 +281,7 @@ export async function runHistoryRepair(id, options, global) {
|
|
|
257
281
|
reanchor.entriesPatchRepaired > 0,
|
|
258
282
|
reconcileNeeded,
|
|
259
283
|
options.forceAuditEntry === true,
|
|
284
|
+
provenanceNormalization.receipt.changed,
|
|
260
285
|
].some(Boolean);
|
|
261
286
|
const author = resolveAuthor(options.author, settings.author_default);
|
|
262
287
|
const dryRun = Boolean(options.dryRun);
|
|
@@ -275,17 +300,20 @@ export async function runHistoryRepair(id, options, global) {
|
|
|
275
300
|
author,
|
|
276
301
|
message: repairMessage,
|
|
277
302
|
auditOperation: options.auditOperation ?? "history_repair",
|
|
278
|
-
auditContext:
|
|
303
|
+
auditContext: provenanceNormalization.receipt.changed
|
|
304
|
+
? {
|
|
305
|
+
...options.auditContext,
|
|
306
|
+
provenance_normalization: provenanceNormalization.receipt,
|
|
307
|
+
}
|
|
308
|
+
: options.auditContext,
|
|
309
|
+
itemHashVersion,
|
|
310
|
+
explicitItemHashVersion: reanchor.explicitItemHashVersion,
|
|
279
311
|
});
|
|
280
312
|
const historyVerify = verifyHistoryChain(rewrittenEntries);
|
|
281
313
|
if (!historyVerify.ok) {
|
|
282
314
|
throw new PmCliError(`history-repair produced an invalid rewritten chain (${historyVerify.errors.join(", ")}).`, EXIT_CODE.GENERIC_FAILURE);
|
|
283
315
|
}
|
|
284
|
-
const warnings = collectHistoryRepairWarnings(changed, reanchor.skippedOps);
|
|
285
|
-
if (reconciliation && reconciliation.discarded_events.length > 0) {
|
|
286
|
-
warnings.push(`history_repair_reconcile_discards_events:${reconciliation.discarded_events.length}`);
|
|
287
|
-
warnings.push(`history_repair_discarded_authors:${reconciliation.discarded_authors.join(",")}`);
|
|
288
|
-
}
|
|
316
|
+
const warnings = collectHistoryRepairWarnings(changed, reanchor.skippedOps, reconciliation);
|
|
289
317
|
if (changed && !dryRun) {
|
|
290
318
|
warnings.push(...(await applyHistoryRepairRewrite({
|
|
291
319
|
pmRoot,
|
|
@@ -317,12 +345,21 @@ export async function runHistoryRepair(id, options, global) {
|
|
|
317
345
|
audit_entry_added: auditEntryAdded,
|
|
318
346
|
verify_ok: historyVerify.ok,
|
|
319
347
|
verify_errors: historyVerify.errors,
|
|
348
|
+
item_hash_version_before: chainVersionBefore.item_hash_version ?? null,
|
|
349
|
+
item_hash_version_after: itemHashVersion,
|
|
350
|
+
version_disposition: explicitVersionsBefore.size > 1
|
|
351
|
+
? "selected_for_ambiguous_stream"
|
|
352
|
+
: "preserved",
|
|
320
353
|
},
|
|
321
354
|
item: {
|
|
322
355
|
exists: itemReplayContext.currentItemPath !== null,
|
|
323
356
|
path: itemReplayContext.currentItemPath,
|
|
324
357
|
matched_chain_before: itemReplayContext.matchedChainBefore,
|
|
325
358
|
},
|
|
359
|
+
provenance_normalization: {
|
|
360
|
+
requested: options.normalizeProvenance === true,
|
|
361
|
+
...provenanceNormalization.receipt,
|
|
362
|
+
},
|
|
326
363
|
...(reconciliation ? { reconciliation } : {}),
|
|
327
364
|
warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),
|
|
328
365
|
generated_at: nowIso(),
|
|
@@ -348,10 +385,16 @@ export async function runHistoryRepairAll(options, global) {
|
|
|
348
385
|
const itemReadWarnings = [];
|
|
349
386
|
const items = await listAllItemMetadataWithBody(pmRoot, settings.item_format, typeRegistry.type_to_folder, itemReadWarnings, settings.schema, { forceSourceScan: true });
|
|
350
387
|
const drift = await scanHistoryDrift(pmRoot, items);
|
|
388
|
+
const invalidProvenanceIds = options.normalizeProvenance
|
|
389
|
+
? await listInvalidProvenanceHistoryStreamIds(pmRoot)
|
|
390
|
+
: [];
|
|
391
|
+
const targetedIds = [
|
|
392
|
+
...new Set([...drift.driftedItems, ...invalidProvenanceIds]),
|
|
393
|
+
].sort((left, right) => left.localeCompare(right));
|
|
351
394
|
const streams = [];
|
|
352
395
|
const repairWarnings = [];
|
|
353
396
|
const totals = { repaired: 0, skipped_clean: 0, failed: 0 };
|
|
354
|
-
for (const driftedId of
|
|
397
|
+
for (const driftedId of targetedIds) {
|
|
355
398
|
try {
|
|
356
399
|
const result = await runHistoryRepair(driftedId, {
|
|
357
400
|
...options,
|
|
@@ -392,6 +435,7 @@ export async function runHistoryRepairAll(options, global) {
|
|
|
392
435
|
dry_run: Boolean(options.dryRun),
|
|
393
436
|
scanned_streams: items.length,
|
|
394
437
|
drifted_streams: drift.driftedItems.length,
|
|
438
|
+
provenance_invalid_streams: invalidProvenanceIds.length,
|
|
395
439
|
streams,
|
|
396
440
|
totals,
|
|
397
441
|
warnings: [...new Set([...itemReadWarnings, ...repairWarnings])].sort((left, right) => left.localeCompare(right)),
|
|
@@ -399,4 +443,4 @@ export async function runHistoryRepairAll(options, global) {
|
|
|
399
443
|
};
|
|
400
444
|
}
|
|
401
445
|
//# sourceMappingURL=history-repair.js.map
|
|
402
|
-
//# debugId=
|
|
446
|
+
//# debugId=de9b7f82-0f51-599d-b1fa-2d54e3acbdbc
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { PM_COMMAND_VISIBILITY_CONTRACTS, PM_MCP_PROMPT_CONTRACTS, PM_MCP_RESOUR
|
|
|
7
7
|
export * from "./agent-session-context.js";
|
|
8
8
|
export type { PmCommandVisibilityContract, PmCommandVisibilityTier, PmMcpPromptArgumentContract, PmMcpPromptContract, PmMcpResourceContract, PmMcpToolProfile, } from "./agent-capability-contracts.js";
|
|
9
9
|
export { isErrnoError, limitAnnotationEntries, parseAnnotationTextInput, readAnnotationEntries, normalizeAnnotationTransportOptions, resolveAnnotationInput, resolveAnnotationIndex, runAnnotationCommand, wrapOwnershipConflict, type AnnotationCommandConfig, type AnnotationCommandOptions, type AnnotationCommandResult, type AnnotationEntry, type AnnotationInput, type AnnotationHistoryRestoration, type AnnotationMutationReceipt, type AnnotationOmissionReceipt, type AnnotationSourceOptions, type OwnershipConflictGuidance, } from "./annotations.js";
|
|
10
|
-
export { acknowledgeUnknownAuthorHistoryEvents, acknowledgeUnknownAuthorHistoryEventsFromTransport, inspectHistoryAuthorStream, parseUnknownAuthorHistoryEventCoordinates, resolveUnknownAuthorAcknowledgmentSelector, scanHistoryAuthorAttribution, type AcknowledgeUnknownAuthorEventsOptions, type HistoryAuthorAttributionScan, type UnknownAuthorHistoryEvent, } from "./author-attribution.js";
|
|
10
|
+
export { acknowledgeUnknownAuthorHistoryEvents, acknowledgeUnknownAuthorHistoryEventsFromTransport, inspectHistoryAuthorStream, parseUnknownAuthorHistoryEventCoordinates, planUnknownAuthorHistoryAcknowledgment, resolveUnknownAuthorAcknowledgmentSelector, scanHistoryAuthorAttribution, type AcknowledgeUnknownAuthorEventsOptions, type HistoryAuthorAttributionScan, type UnknownAuthorAcknowledgmentPlan, type UnknownAuthorAcknowledgmentPlanCoordinate, type UnknownAuthorAcknowledgmentResult, type UnknownAuthorHistoryEvent, } from "./author-attribution.js";
|
|
11
11
|
export { BUILTIN_CORPUS_SHAPES, PM_CORPUS_SHAPE_SCHEMA, buildCorpusShapeItemPlan, createCorpusShapeMeasurement, defineCorpusShape, listBuiltinCorpusShapes, measureCorpusShapePlan, resolveBuiltinCorpusShape, type BuiltinCorpusShapeName, type CorpusShape, type CorpusShapeEdgeWeight, type CorpusShapeItemPlan, type CorpusShapeMeasurement, type CorpusShapeProfile, } from "./corpus-shape.js";
|
|
12
12
|
export * from "./core-governance.js";
|
|
13
13
|
export { createPmCliProgram } from "./cli-program.js";
|
|
@@ -22,6 +22,7 @@ export * from "./agent/command-suggestions.js";
|
|
|
22
22
|
export * from "./agent/item-addressing.js";
|
|
23
23
|
export * from "./agent/create-option-policy.js";
|
|
24
24
|
export { runGc, type GcCheckpointsSummary, type GcLocksSummary, } from "./governance/gc.js";
|
|
25
|
+
export { PM_EXACT_COVERAGE_METRICS, findCoverageDeficits, type PmCoverageDeficit, type PmExactCoverageMetric, } from "./governance/coverage-assurance.js";
|
|
25
26
|
export { _testOnlyHealthCommand, runHealth, type HealthCheck, } from "./governance/health.js";
|
|
26
27
|
export { _testOnlyValidateCommand, projectValidateCounts, runValidate, type ValidateCheck, type ValidateCountsFixesSummary, type ValidateCountsResult, type ValidateFixesSummary, type ValidateMutationServices, } from "./governance/validate.js";
|
|
27
28
|
export { runExtension, type ExtensionCommandAction } from "./extension.js";
|
package/dist/sdk/index.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Defines public SDK APIs and package-author helpers for Index.
|
|
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]="9ec91496-fc1e-5be5-a8e8-145d884b0ef7")}catch(e){}}();
|
|
8
8
|
export { PM_COMMAND_VISIBILITY_CONTRACTS, PM_MCP_PROMPT_CONTRACTS, PM_MCP_RESOURCE_CONTRACTS, PM_MCP_TOOL_COMMAND_CONTRACTS, listPmCommandsForTier, listPmMcpToolsForProfile, renderPmCommandVisibilityMarkdown, resolvePmCommandVisibilityTier, } from "./agent-capability-contracts.js";
|
|
9
9
|
export * from "./agent-session-context.js";
|
|
10
10
|
export { isErrnoError, limitAnnotationEntries, parseAnnotationTextInput, readAnnotationEntries, normalizeAnnotationTransportOptions, resolveAnnotationInput, resolveAnnotationIndex, runAnnotationCommand, wrapOwnershipConflict, } from "./annotations.js";
|
|
11
|
-
export { acknowledgeUnknownAuthorHistoryEvents, acknowledgeUnknownAuthorHistoryEventsFromTransport, inspectHistoryAuthorStream, parseUnknownAuthorHistoryEventCoordinates, resolveUnknownAuthorAcknowledgmentSelector, scanHistoryAuthorAttribution, } from "./author-attribution.js";
|
|
11
|
+
export { acknowledgeUnknownAuthorHistoryEvents, acknowledgeUnknownAuthorHistoryEventsFromTransport, inspectHistoryAuthorStream, parseUnknownAuthorHistoryEventCoordinates, planUnknownAuthorHistoryAcknowledgment, resolveUnknownAuthorAcknowledgmentSelector, scanHistoryAuthorAttribution, } from "./author-attribution.js";
|
|
12
12
|
export { BUILTIN_CORPUS_SHAPES, PM_CORPUS_SHAPE_SCHEMA, buildCorpusShapeItemPlan, createCorpusShapeMeasurement, defineCorpusShape, listBuiltinCorpusShapes, measureCorpusShapePlan, resolveBuiltinCorpusShape, } from "./corpus-shape.js";
|
|
13
13
|
export * from "./core-governance.js";
|
|
14
14
|
export { createPmCliProgram } from "./cli-program.js";
|
|
@@ -23,6 +23,7 @@ export * from "./agent/command-suggestions.js";
|
|
|
23
23
|
export * from "./agent/item-addressing.js";
|
|
24
24
|
export * from "./agent/create-option-policy.js";
|
|
25
25
|
export { runGc, } from "./governance/gc.js";
|
|
26
|
+
export { PM_EXACT_COVERAGE_METRICS, findCoverageDeficits, } from "./governance/coverage-assurance.js";
|
|
26
27
|
export { _testOnlyHealthCommand, runHealth, } from "./governance/health.js";
|
|
27
28
|
export { _testOnlyValidateCommand, projectValidateCounts, runValidate, } from "./governance/validate.js";
|
|
28
29
|
export { runExtension } from "./extension.js";
|
|
@@ -151,4 +152,4 @@ export * from "./governance.js";
|
|
|
151
152
|
export * from "./query.js";
|
|
152
153
|
export * from "./testing.js";
|
|
153
154
|
//# sourceMappingURL=index.js.map
|
|
154
|
-
//# debugId=
|
|
155
|
+
//# debugId=9ec91496-fc1e-5be5-a8e8-145d884b0ef7
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implements the pm linked artifacts 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]="256b39b7-882e-553c-9dea-813bfd363dd7")}catch(e){}}();
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import fg from "fast-glob";
|
|
@@ -57,9 +57,20 @@ export function looksLikeStructuredPathEntry(raw) {
|
|
|
57
57
|
if (/^(?:[-*+]\s+)?(?:path|scope|note)\s*[:=]/i.test(raw)) {
|
|
58
58
|
return true;
|
|
59
59
|
}
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
60
|
+
// An equals sign is valid inside filesystem paths and URL query strings.
|
|
61
|
+
// Preserve unmistakable whitespace-free path/URL shapes while routing
|
|
62
|
+
// leading assignment syntax through the structured-key allowlist so typos
|
|
63
|
+
// and malformed URL-plus-note input remain atomic failures (GH-258,
|
|
64
|
+
// GH-1000).
|
|
65
|
+
const equalsIndex = raw.indexOf("=");
|
|
66
|
+
if (equalsIndex >= 0 &&
|
|
67
|
+
!/\s/u.test(raw) &&
|
|
68
|
+
(/^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(raw) ||
|
|
69
|
+
/^(?:[A-Za-z]:[\\/]|[\\/]{1,2}|\.\.?(?:[\\/]))/u.test(raw) ||
|
|
70
|
+
[raw.indexOf("/"), raw.indexOf("\\")].some((separatorIndex) => separatorIndex >= 0 && separatorIndex < equalsIndex))) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return raw.includes("=") || looksLikeGenericKeyValueEntry(raw);
|
|
63
74
|
}
|
|
64
75
|
function expandBareCommaSeparatedAddEntries(raw) {
|
|
65
76
|
return raw.flatMap((entry) => {
|
|
@@ -479,4 +490,4 @@ export function renameArtifactsResultKey(result, key) {
|
|
|
479
490
|
return out;
|
|
480
491
|
}
|
|
481
492
|
//# sourceMappingURL=linked-artifacts.js.map
|
|
482
|
-
//# debugId=
|
|
493
|
+
//# debugId=256b39b7-882e-553c-9dea-813bfd363dd7
|
package/dist/sdk/pagination.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { CliFlagContract } from "./cli-contracts/flag-contracts.js";
|
|
2
|
+
/** Validated transport envelope carried by an opaque query cursor. */
|
|
3
|
+
export interface QueryCursorEnvelope {
|
|
4
|
+
/** Serialized cursor contract version. */
|
|
5
|
+
version: number;
|
|
6
|
+
/** Stable fingerprint of the query semantics that produced the cursor. */
|
|
7
|
+
fingerprint: string;
|
|
8
|
+
/** Stable id of the last row emitted by the producer. */
|
|
9
|
+
after_id: string;
|
|
10
|
+
/** Zero-based position of the last emitted row when available. */
|
|
11
|
+
after_index?: number;
|
|
12
|
+
/** Opaque producer-defined snapshot token for stable continuation. */
|
|
13
|
+
snapshot?: string;
|
|
14
|
+
}
|
|
2
15
|
/** Decoded cursor state for advanced package and retrieval-window integrations. */
|
|
3
16
|
export interface QueryCursorState {
|
|
4
17
|
/** Stable id of the last row emitted by the previous page. */
|
|
@@ -27,6 +40,8 @@ export declare function selectCursorSemanticOptions(options: Readonly<Record<str
|
|
|
27
40
|
export declare function createQueryFingerprint(command: string, contract: unknown): string;
|
|
28
41
|
/** Encode the last emitted item id into a versioned opaque base64url cursor. */
|
|
29
42
|
export declare function encodeQueryCursor(fingerprint: string, afterId: string, afterIndex?: number, snapshot?: string): string;
|
|
43
|
+
/** Decode and validate an opaque cursor without imposing caller query identity. */
|
|
44
|
+
export declare function decodeQueryCursorEnvelope(cursor: unknown): QueryCursorEnvelope;
|
|
30
45
|
/** Decode and validate complete cursor state against a query fingerprint. */
|
|
31
46
|
export declare function decodeQueryCursorState(cursor: unknown, expectedFingerprint: string): QueryCursorState;
|
|
32
47
|
/** Decode and validate a cursor against the normalized query fingerprint. */
|
package/dist/sdk/pagination.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* package-authored query surfaces.
|
|
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]="d3329fac-693d-566c-a30a-43f8fb37938f")}catch(e){}}();
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { PmCliError } from "../core/shared/errors.js";
|
|
11
11
|
import { EXIT_CODE } from "../core/shared/constants.js";
|
|
@@ -78,8 +78,8 @@ function isQueryCursorEnvelope(value) {
|
|
|
78
78
|
(envelope.snapshot === undefined ||
|
|
79
79
|
(typeof envelope.snapshot === "string" && envelope.snapshot.length > 0)));
|
|
80
80
|
}
|
|
81
|
-
/** Decode and validate
|
|
82
|
-
export function
|
|
81
|
+
/** Decode and validate an opaque cursor without imposing caller query identity. */
|
|
82
|
+
export function decodeQueryCursorEnvelope(cursor) {
|
|
83
83
|
if (typeof cursor !== "string") {
|
|
84
84
|
throw invalidCursor("Query cursor is malformed.");
|
|
85
85
|
}
|
|
@@ -99,7 +99,11 @@ export function decodeQueryCursorState(cursor, expectedFingerprint) {
|
|
|
99
99
|
if (!isQueryCursorEnvelope(parsed)) {
|
|
100
100
|
throw invalidCursor("Query cursor version or payload is unsupported.");
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
return parsed;
|
|
103
|
+
}
|
|
104
|
+
/** Decode and validate complete cursor state against a query fingerprint. */
|
|
105
|
+
export function decodeQueryCursorState(cursor, expectedFingerprint) {
|
|
106
|
+
const envelope = decodeQueryCursorEnvelope(cursor);
|
|
103
107
|
if (envelope.fingerprint !== expectedFingerprint) {
|
|
104
108
|
throw invalidCursor(`Query cursor does not match the current filters, sort, or query (${envelope.fingerprint} != ${expectedFingerprint}).`);
|
|
105
109
|
}
|
|
@@ -156,4 +160,4 @@ export const QUERY_CURSOR_CONTRACT = Object.freeze({
|
|
|
156
160
|
max_length: MAX_CURSOR_LENGTH,
|
|
157
161
|
});
|
|
158
162
|
//# sourceMappingURL=pagination.js.map
|
|
159
|
-
//# debugId=
|
|
163
|
+
//# debugId=d3329fac-693d-566c-a30a-43f8fb37938f
|
|
@@ -399,6 +399,10 @@ export interface ContextRankingSummary {
|
|
|
399
399
|
score: number;
|
|
400
400
|
contributions: ContextRelevanceContributions;
|
|
401
401
|
}>;
|
|
402
|
+
/** Number of candidates considered before answer-sized projection. */
|
|
403
|
+
candidate_count: number;
|
|
404
|
+
/** Number of candidate explanations omitted because their rows were not served. */
|
|
405
|
+
omitted_count: number;
|
|
402
406
|
/** Rebuildable feature-store freshness and provenance. */
|
|
403
407
|
feature_store?: {
|
|
404
408
|
source: "derived_index" | "scan_fallback";
|
|
@@ -462,7 +466,7 @@ export declare function packRankedContextItems(report: ContextRelevanceReport<It
|
|
|
462
466
|
/** Projects the SDK packer report onto the stable low-token command envelope. */
|
|
463
467
|
export declare function toContextPackingSummary(report: ContextPackingReport<ItemMetadata>): ContextPackingSummary;
|
|
464
468
|
/** Project a full scorer report onto the low-token command explanation shape. */
|
|
465
|
-
export declare function toContextRankingSummary<TItem>(report: ContextRelevanceReport<TItem>, featureStore?: ContextSignalStoreReadResult): ContextRankingSummary;
|
|
469
|
+
export declare function toContextRankingSummary<TItem>(report: ContextRelevanceReport<TItem>, featureStore?: ContextSignalStoreReadResult, servedItemIds?: ReadonlySet<string>): ContextRankingSummary;
|
|
466
470
|
declare function completionPct(closed: number, total: number): number;
|
|
467
471
|
/** Indexes items by their parent id, yielding a parent→direct-children map used by the hierarchy/progress rollups and by focus-row child completion. Items without a parent are skipped. Exported so sibling read commands reuse the same index. */
|
|
468
472
|
export declare function buildChildrenByParent(allItems: ItemMetadata[]): Map<string, ItemMetadata[]>;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implements the pm context 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]="ee5279f2-7489-59fb-8f96-f2e035434cce")}catch(e){}}();
|
|
8
8
|
import { SETTINGS_DEFAULTS, EXIT_CODE, PmCliError, compareTimestampStrings, nowIso, isTerminalStatus, normalizeStatusForRegistry, normalizeStatusInput, resolveRuntimeStatusRegistry, resolvePmRoot, readSettings, resolveAuthor, discoverExtensions, } from "../runtime-primitives.js";
|
|
9
9
|
import { collectDependencyBlockedIds, resolveItemBlockers, } from "../actionability.js";
|
|
10
10
|
import { CONTEXT_DEPTH_VALUES, CONTEXT_SECTION_VALUES, } from "../../types/index.js";
|
|
@@ -455,17 +455,22 @@ export function toContextPackingSummary(report) {
|
|
|
455
455
|
};
|
|
456
456
|
}
|
|
457
457
|
/** Project a full scorer report onto the low-token command explanation shape. */
|
|
458
|
-
export function toContextRankingSummary(report, featureStore) {
|
|
458
|
+
export function toContextRankingSummary(report, featureStore, servedItemIds) {
|
|
459
|
+
const ranked = servedItemIds === undefined
|
|
460
|
+
? report.ranked
|
|
461
|
+
: report.ranked.filter((entry) => servedItemIds.has(entry.id));
|
|
459
462
|
return {
|
|
460
463
|
model: report.model,
|
|
461
464
|
available_signals: report.available_signals,
|
|
462
|
-
items:
|
|
465
|
+
items: ranked.map((entry) => ({
|
|
463
466
|
id: entry.id,
|
|
464
467
|
rank: entry.rank,
|
|
465
468
|
baseline_rank: entry.baseline_rank,
|
|
466
469
|
score: entry.score,
|
|
467
470
|
contributions: entry.contributions,
|
|
468
471
|
})),
|
|
472
|
+
candidate_count: report.ranked.length,
|
|
473
|
+
omitted_count: report.ranked.length - ranked.length,
|
|
469
474
|
...(featureStore
|
|
470
475
|
? {
|
|
471
476
|
feature_store: {
|
|
@@ -1659,7 +1664,11 @@ export async function runContext(options, global) {
|
|
|
1659
1664
|
attachOptionalContextSections(result, sections, focusGroups.featureStore.warning_details);
|
|
1660
1665
|
applyContextTagProjection(result, options.noTags === true);
|
|
1661
1666
|
if (options.explainRanking === true) {
|
|
1662
|
-
result.ranking = toContextRankingSummary(focusGroups.ranking, focusGroups.featureStore
|
|
1667
|
+
result.ranking = toContextRankingSummary(focusGroups.ranking, focusGroups.featureStore, new Set([
|
|
1668
|
+
...focusGroups.highLevel,
|
|
1669
|
+
...focusGroups.lowLevel,
|
|
1670
|
+
...focusGroups.blockedFallback,
|
|
1671
|
+
].map((entry) => entry.id)));
|
|
1663
1672
|
result.packing = toContextPackingSummary(focusGroups.packing);
|
|
1664
1673
|
}
|
|
1665
1674
|
applyContextFocusProjection(result, runtime.focusFields);
|
|
@@ -1670,4 +1679,4 @@ export async function runContext(options, global) {
|
|
|
1670
1679
|
return result;
|
|
1671
1680
|
}
|
|
1672
1681
|
//# sourceMappingURL=context.js.map
|
|
1673
|
-
//# debugId=
|
|
1682
|
+
//# debugId=ee5279f2-7489-59fb-8f96-f2e035434cce
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PmReadOutputCursorEnvelope, PmReadOutputSurface } from "../read-output-contracts.js";
|
|
2
|
+
/** Fingerprint stable row identities without including volatile observation fields. */
|
|
3
|
+
export declare function readOutputCollectionFingerprint(path: string, value: unknown[] | Record<string, unknown>): string;
|
|
4
|
+
/** Encode one stable declared-row continuation for CLI, SDK, and MCP callers. */
|
|
5
|
+
export declare function encodeReadOutputContinuationCursor(cursor: Omit<PmReadOutputCursorEnvelope, "version">): string;
|
|
6
|
+
/** Decode and validate one universal declared-row continuation cursor. */
|
|
7
|
+
export declare function decodeReadOutputContinuationCursor(raw: string): PmReadOutputCursorEnvelope;
|
|
8
|
+
/** Place every non-passing assurance assertion before passing evidence. */
|
|
9
|
+
export declare function prioritizeAssuranceAssertions(result: Record<string, unknown>): Record<string, unknown>;
|
|
10
|
+
/** Validate and apply a continuation suffix to its declared row collection. */
|
|
11
|
+
export declare function applyReadOutputContinuation(result: Record<string, unknown>, command: PmReadOutputSurface, cursor: PmReadOutputCursorEnvelope | undefined): Record<string, unknown>;
|