pm-ops 2026.10.21 → 2026.10.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +182 -5
- package/dist/backend-capabilities.d.ts +83 -0
- package/dist/backend-capabilities.d.ts.map +1 -0
- package/dist/backend-capabilities.js +255 -0
- package/dist/backend-capabilities.js.map +1 -0
- package/dist/evidence-expiry.d.ts +101 -0
- package/dist/evidence-expiry.d.ts.map +1 -0
- package/dist/evidence-expiry.js +194 -0
- package/dist/evidence-expiry.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -12
- package/dist/index.js.map +1 -1
- package/manifest.json +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { type AssuranceGateVerdict, type AssuranceScope } from "@unbrained/pm-cli/sdk";
|
|
2
|
+
/** Stable outcomes; fresh means reusable evidence, never a new operational test. */
|
|
3
|
+
export type EvidenceStatus = "fresh" | "revalidate" | "unavailable";
|
|
4
|
+
/** Typed diagnostics shared by SDK and CLI. */
|
|
5
|
+
export type EvidenceCode = "fresh" | "evidence_missing" | "evidence_unavailable" | "receipt_not_accepted" | "scope_mismatch" | "version_unavailable" | "version_changed" | "evidence_expired" | "evidence_future";
|
|
6
|
+
/** Named exact package, backend or deployment identities; keys define the change boundary. */
|
|
7
|
+
export type EvidenceVersions = Readonly<Record<string, string>>;
|
|
8
|
+
/** A retained claim attached to one exact core assertion receipt. */
|
|
9
|
+
export interface OperationalEvidenceClaim {
|
|
10
|
+
/** Public stable claim label. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Independent assurance dimension. */
|
|
13
|
+
kind: "health" | "coverage" | "recovery";
|
|
14
|
+
/** Exact receipt identity; a newer unrelated verdict cannot replace it. */
|
|
15
|
+
receipt: {
|
|
16
|
+
gate_id: string;
|
|
17
|
+
tree_id: string;
|
|
18
|
+
evaluated_at: string;
|
|
19
|
+
assertion_id: string;
|
|
20
|
+
};
|
|
21
|
+
/** Required population scope, validated by the core assertion contract. */
|
|
22
|
+
scope: AssuranceScope;
|
|
23
|
+
/** Positive integer time-to-live, in seconds from receipt evaluation. */
|
|
24
|
+
max_age_seconds: number;
|
|
25
|
+
/** Relevant identities captured when the receipt was accepted; never inferred from current versions. */
|
|
26
|
+
versions: EvidenceVersions;
|
|
27
|
+
}
|
|
28
|
+
/** Versioned policy persisted by the consumer alongside its operational evidence. */
|
|
29
|
+
export interface EvidenceExpiryPolicy {
|
|
30
|
+
/** Policy format. */
|
|
31
|
+
version: 1;
|
|
32
|
+
/** Unique claim labels; 1-1000 claims. */
|
|
33
|
+
claims: readonly OperationalEvidenceClaim[];
|
|
34
|
+
}
|
|
35
|
+
/** Safe actionable refusal, excluding paths, receipt content and raw backend errors. */
|
|
36
|
+
export declare class EvidenceExpiryRefusal extends Error {
|
|
37
|
+
/** Stable machine-readable classification. */
|
|
38
|
+
readonly code: "invalid_policy" | "invalid_versions" | "invalid_options" | "evidence_unavailable";
|
|
39
|
+
/** Safe next action. */
|
|
40
|
+
readonly remedy: string;
|
|
41
|
+
/** CLI usage failures are distinct from unavailable evidence. */
|
|
42
|
+
readonly exitCode: number;
|
|
43
|
+
/** Construct a refusal that agents can recover from without parsing raw exceptions. */
|
|
44
|
+
constructor(code: EvidenceExpiryRefusal["code"], remedy: string);
|
|
45
|
+
}
|
|
46
|
+
/** One bounded diagnostic row, without observed values or connection details. */
|
|
47
|
+
export interface EvidenceExpiryRow {
|
|
48
|
+
/** Claim id. */
|
|
49
|
+
id: string;
|
|
50
|
+
/** Independent assurance dimension. */
|
|
51
|
+
kind: OperationalEvidenceClaim["kind"];
|
|
52
|
+
/** Reusability classification. */
|
|
53
|
+
status: EvidenceStatus;
|
|
54
|
+
/** First failing requirement, using deterministic precedence. */
|
|
55
|
+
code: EvidenceCode;
|
|
56
|
+
/** Relevant keys changed or absent; never version values. */
|
|
57
|
+
affected: string[];
|
|
58
|
+
/** Exclusive expiration boundary, or null if evidence is unavailable. */
|
|
59
|
+
expires_at: string | null;
|
|
60
|
+
/** Safe next action. */
|
|
61
|
+
remedy: string;
|
|
62
|
+
}
|
|
63
|
+
/** Compact report; counts cover all claims even when rows are bounded. */
|
|
64
|
+
export interface EvidenceExpiryReport {
|
|
65
|
+
/** Report schema. */
|
|
66
|
+
version: 1;
|
|
67
|
+
/** True only if every claim has fresh accepted evidence. */
|
|
68
|
+
ok: boolean;
|
|
69
|
+
/** Stable evaluation instant. */
|
|
70
|
+
evaluated_at: string;
|
|
71
|
+
/** Total claims evaluated before row projection. */
|
|
72
|
+
total: number;
|
|
73
|
+
/** Counts across the entire policy. */
|
|
74
|
+
counts: Record<EvidenceStatus, number>;
|
|
75
|
+
/** Refusals precede fresh claims; original order is retained within each group. */
|
|
76
|
+
rows: EvidenceExpiryRow[];
|
|
77
|
+
/** Exact omitted row count; use a larger limit to restore. */
|
|
78
|
+
omitted: number;
|
|
79
|
+
}
|
|
80
|
+
/** Deterministic evaluation and explicit bounded output. */
|
|
81
|
+
export interface EvidenceExpiryOptions {
|
|
82
|
+
/** ISO UTC instant; defaults to the actual current time. */
|
|
83
|
+
now?: string;
|
|
84
|
+
/** Maximum rows, 1-1000; default 20. */
|
|
85
|
+
limit?: number;
|
|
86
|
+
}
|
|
87
|
+
/** Validate version maps without inferring or normalizing exact identity strings. */
|
|
88
|
+
export declare function parseEvidenceVersions(value: unknown): EvidenceVersions;
|
|
89
|
+
/** Validate attachment policy while delegating assertion scope semantics to the core SDK. */
|
|
90
|
+
export declare function parseEvidenceExpiryPolicy(value: unknown): EvidenceExpiryPolicy;
|
|
91
|
+
/**
|
|
92
|
+
* Evaluate caller-supplied durable receipts from any backend, without I/O.
|
|
93
|
+
* The caller owns receipt authenticity; use auditEvidenceExpiry for a directory tracker.
|
|
94
|
+
* null represents unavailable evidence and never an empty successful observation.
|
|
95
|
+
*/
|
|
96
|
+
export declare function evaluateEvidenceExpiry(policy: EvidenceExpiryPolicy, currentVersions: EvidenceVersions, receipts: readonly AssuranceGateVerdict[] | null, options?: EvidenceExpiryOptions): EvidenceExpiryReport;
|
|
97
|
+
/** Evaluate a directory tracker with side-effect-free public SDK reads; works outside Git. */
|
|
98
|
+
export declare function auditEvidenceExpiry(pmRoot: string, policy: EvidenceExpiryPolicy, versions: EvidenceVersions, options?: EvidenceExpiryOptions): Promise<EvidenceExpiryReport>;
|
|
99
|
+
/** CLI-friendly file inputs; the selected tracker remains host-owned. */
|
|
100
|
+
export declare function auditEvidenceExpiryFiles(pmRoot: string, policyFile: string, versionsFile: string, options?: EvidenceExpiryOptions): Promise<EvidenceExpiryReport>;
|
|
101
|
+
//# sourceMappingURL=evidence-expiry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-expiry.d.ts","sourceRoot":"","sources":["../evidence-expiry.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAC/C,MAAM,uBAAuB,CAAC;AAE/B,oFAAoF;AACpF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,YAAY,GAAG,aAAa,CAAC;AACpE,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,kBAAkB,GAAG,sBAAsB,GAAG,sBAAsB,GACrG,gBAAgB,GAAG,qBAAqB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAC1G,8FAA8F;AAC9F,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAChE,qEAAqE;AACrE,MAAM,WAAW,wBAAwB;IACvC,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,uCAAuC;IACvC,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;IACzC,2EAA2E;IAC3E,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,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evidence freshness over core assurance receipts; no Git or writes. */
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { getWorkspaceHistoryPath, listAssuranceVerdicts, readHistorySnapshot, validateAssertionDefinition, verifyHistoryRecordHash, WORKSPACE_HISTORY_ID, } from "@unbrained/pm-cli/sdk";
|
|
4
|
+
/** Safe actionable refusal, excluding paths, receipt content and raw backend errors. */
|
|
5
|
+
export class EvidenceExpiryRefusal extends Error {
|
|
6
|
+
/** Stable machine-readable classification. */
|
|
7
|
+
code;
|
|
8
|
+
/** Safe next action. */
|
|
9
|
+
remedy;
|
|
10
|
+
/** CLI usage failures are distinct from unavailable evidence. */
|
|
11
|
+
exitCode;
|
|
12
|
+
/** Construct a refusal that agents can recover from without parsing raw exceptions. */
|
|
13
|
+
constructor(code, remedy) {
|
|
14
|
+
super(`${code}: ${remedy}`);
|
|
15
|
+
this.name = "EvidenceExpiryRefusal";
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.remedy = remedy;
|
|
18
|
+
this.exitCode = code === "evidence_unavailable" ? 1 : 2;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Narrow an untrusted value to an object. */
|
|
22
|
+
function record(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
/** Public labels have bounded agent output and no filesystem semantics. */
|
|
26
|
+
function label(value) {
|
|
27
|
+
return typeof value === "string" && /^[a-zA-Z0-9@][a-zA-Z0-9@._:/-]{0,127}$/.test(value);
|
|
28
|
+
}
|
|
29
|
+
/** Accept canonical UTC timestamps, refusing ambiguous dates and rollover. */
|
|
30
|
+
function instant(value) {
|
|
31
|
+
return typeof value === "string" && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(value)
|
|
32
|
+
&& Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value;
|
|
33
|
+
}
|
|
34
|
+
/** Validate version maps without inferring or normalizing exact identity strings. */
|
|
35
|
+
export function parseEvidenceVersions(value) {
|
|
36
|
+
if (!record(value) || Object.keys(value).length > 100 || Object.entries(value).some(([key, version]) => !label(key) || typeof version !== "string" || !version.trim() || version.length > 128)) {
|
|
37
|
+
throw new EvidenceExpiryRefusal("invalid_versions", "Provide an object of at most 100 public identity keys and nonempty exact version strings.");
|
|
38
|
+
}
|
|
39
|
+
return { ...value };
|
|
40
|
+
}
|
|
41
|
+
/** Validate attachment policy while delegating assertion scope semantics to the core SDK. */
|
|
42
|
+
export function parseEvidenceExpiryPolicy(value) {
|
|
43
|
+
const refuse = () => { throw new EvidenceExpiryRefusal("invalid_policy", "Provide version 1, 1-1000 uniquely named claims with kind, exact receipt, core scope, positive max_age_seconds and nonempty captured versions."); };
|
|
44
|
+
if (!record(value) || value.version !== 1 || !Array.isArray(value.claims) || value.claims.length < 1 || value.claims.length > 1000)
|
|
45
|
+
return refuse();
|
|
46
|
+
const ids = new Set();
|
|
47
|
+
const claims = value.claims.map((claim) => {
|
|
48
|
+
if (!record(claim) || !label(claim.id) || ids.has(claim.id) || typeof claim.kind !== "string" || !["health", "coverage", "recovery"].includes(claim.kind)
|
|
49
|
+
|| !record(claim.receipt) || !label(claim.receipt.gate_id) || !label(claim.receipt.assertion_id)
|
|
50
|
+
|| !label(claim.receipt.tree_id) || !instant(claim.receipt.evaluated_at)
|
|
51
|
+
|| !record(claim.scope) || typeof claim.scope.kind !== "string" || !["all", "active", "filter"].includes(claim.scope.kind)
|
|
52
|
+
|| (claim.scope.kind === "filter" && !label(claim.scope.measurement_id))
|
|
53
|
+
|| !Number.isSafeInteger(claim.max_age_seconds) || Number(claim.max_age_seconds) < 1
|
|
54
|
+
|| Number(claim.max_age_seconds) > 315_360_000)
|
|
55
|
+
return refuse();
|
|
56
|
+
let scope;
|
|
57
|
+
let versions;
|
|
58
|
+
try {
|
|
59
|
+
scope = validateAssertionDefinition({ id: "expiry-scope", measurement_id: "expiry-scope", owner_item_id: "expiry-scope",
|
|
60
|
+
scope: claim.scope, zero: true, enforcement: "block",
|
|
61
|
+
negative_control: { cases: [{ observed: 0, expected: "pass" }, { observed: 1, expected: "fail" }] }, }).scope;
|
|
62
|
+
versions = parseEvidenceVersions(claim.versions);
|
|
63
|
+
if (Object.keys(versions).length === 0)
|
|
64
|
+
return refuse();
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return refuse();
|
|
68
|
+
}
|
|
69
|
+
ids.add(claim.id);
|
|
70
|
+
return { id: claim.id, kind: claim.kind, receipt: { ...claim.receipt },
|
|
71
|
+
scope, max_age_seconds: Number(claim.max_age_seconds), versions };
|
|
72
|
+
});
|
|
73
|
+
return { version: 1, claims };
|
|
74
|
+
}
|
|
75
|
+
/** Scope comparison uses only the discriminants accepted by the core validator. */
|
|
76
|
+
function sameScope(left, right) {
|
|
77
|
+
return record(right) && left.kind === right.kind && (left.kind !== "filter" || (right.kind === "filter" && left.measurement_id === right.measurement_id));
|
|
78
|
+
}
|
|
79
|
+
/** Safe remedies do not disclose backend data or filesystem locations. */
|
|
80
|
+
const REMEDIES = {
|
|
81
|
+
fresh: "",
|
|
82
|
+
evidence_missing: "Record accepted evidence and bind its exact identity; only the newest 1000 durable gate verdicts are searched.",
|
|
83
|
+
evidence_unavailable: "Restore readable, sealed core assurance history on a stable snapshot, then retry.",
|
|
84
|
+
receipt_not_accepted: "Rerun the operational check and persist a complete passing assertion with proven negative controls and a nonempty population.",
|
|
85
|
+
scope_mismatch: "Collect evidence for the required core population scope and update the attachment.",
|
|
86
|
+
version_unavailable: "Supply current identities for every version key required by this claim.",
|
|
87
|
+
version_changed: "Revalidate this claim against its changed identities, then attach the new receipt and captured versions.",
|
|
88
|
+
evidence_expired: "Rerun this operational check and attach its new receipt; do not extend an old receipt timestamp.",
|
|
89
|
+
evidence_future: "Correct the evaluation clock or collect evidence with a valid timestamp.",
|
|
90
|
+
};
|
|
91
|
+
/** Evaluate one exact receipt; missing or non-passing evidence cannot be promoted by a version match. */
|
|
92
|
+
function evaluateClaim(claim, versions, receipts, now) {
|
|
93
|
+
const row = { id: claim.id, kind: claim.kind, status: "unavailable", code: "evidence_missing", affected: [], expires_at: null, remedy: "" };
|
|
94
|
+
const matches = receipts?.filter((receipt) => record(receipt) && receipt.gate_id === claim.receipt.gate_id && receipt.tree_id === claim.receipt.tree_id && receipt.evaluated_at === claim.receipt.evaluated_at);
|
|
95
|
+
const gate = matches?.length === 1 ? matches[0] : undefined;
|
|
96
|
+
const assertions = Array.isArray(gate?.assertions) ? gate.assertions.filter((assertion) => record(assertion) && assertion.assertion_id === claim.receipt.assertion_id) : undefined;
|
|
97
|
+
const assertion = assertions?.length === 1 ? assertions[0] : undefined;
|
|
98
|
+
if (receipts === null)
|
|
99
|
+
row.code = "evidence_unavailable";
|
|
100
|
+
else if (!gate || !assertion)
|
|
101
|
+
row.code = "evidence_missing";
|
|
102
|
+
else if (gate.dry_run !== false || gate.assertions_total !== gate.assertions.length || assertion.verdict !== "pass"
|
|
103
|
+
|| assertion.negative_control_proven !== true || !Number.isSafeInteger(assertion.population_size) || assertion.population_size < 1)
|
|
104
|
+
row.code = "receipt_not_accepted";
|
|
105
|
+
else if (!sameScope(claim.scope, assertion.scope))
|
|
106
|
+
row.code = "scope_mismatch";
|
|
107
|
+
else {
|
|
108
|
+
const captured = Date.parse(gate.evaluated_at);
|
|
109
|
+
const expires = captured + claim.max_age_seconds * 1000;
|
|
110
|
+
row.expires_at = new Date(expires).toISOString();
|
|
111
|
+
const keys = Object.keys(claim.versions).sort();
|
|
112
|
+
const missing = keys.filter((key) => !Object.hasOwn(versions, key));
|
|
113
|
+
const changed = keys.filter((key) => Object.hasOwn(versions, key) && claim.versions[key] !== versions[key]);
|
|
114
|
+
if (missing.length) {
|
|
115
|
+
row.code = "version_unavailable";
|
|
116
|
+
row.affected = missing;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
row.status = "revalidate";
|
|
120
|
+
if (captured > now)
|
|
121
|
+
row.code = "evidence_future";
|
|
122
|
+
else if (changed.length) {
|
|
123
|
+
row.code = "version_changed";
|
|
124
|
+
row.affected = changed;
|
|
125
|
+
}
|
|
126
|
+
else if (now >= expires)
|
|
127
|
+
row.code = "evidence_expired";
|
|
128
|
+
else {
|
|
129
|
+
row.status = "fresh";
|
|
130
|
+
row.code = "fresh";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
row.remedy = REMEDIES[row.code];
|
|
135
|
+
return row;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Evaluate caller-supplied durable receipts from any backend, without I/O.
|
|
139
|
+
* The caller owns receipt authenticity; use auditEvidenceExpiry for a directory tracker.
|
|
140
|
+
* null represents unavailable evidence and never an empty successful observation.
|
|
141
|
+
*/
|
|
142
|
+
export function evaluateEvidenceExpiry(policy, currentVersions, receipts, options = {}) {
|
|
143
|
+
const parsed = parseEvidenceExpiryPolicy(policy);
|
|
144
|
+
const versions = parseEvidenceVersions(currentVersions);
|
|
145
|
+
const now = options.now ?? new Date().toISOString();
|
|
146
|
+
const limit = options.limit ?? 20;
|
|
147
|
+
if (!instant(now) || !Number.isInteger(limit) || limit < 1 || limit > 1000) {
|
|
148
|
+
throw new EvidenceExpiryRefusal("invalid_options", "Use a canonical UTC ISO timestamp and an integer row limit from 1 through 1000.");
|
|
149
|
+
}
|
|
150
|
+
const rows = parsed.claims.map((claim) => evaluateClaim(claim, versions, receipts, Date.parse(now)));
|
|
151
|
+
const counts = { fresh: 0, revalidate: 0, unavailable: 0 };
|
|
152
|
+
for (const row of rows)
|
|
153
|
+
counts[row.status]++;
|
|
154
|
+
const ordered = [...rows.filter((row) => row.status !== "fresh"), ...rows.filter((row) => row.status === "fresh")];
|
|
155
|
+
return { version: 1, ok: counts.fresh === rows.length, evaluated_at: now, total: rows.length, counts, rows: ordered.slice(0, limit), omitted: Math.max(0, rows.length - limit) };
|
|
156
|
+
}
|
|
157
|
+
/** Read core receipts and verify record envelopes through SDK primitives, refusing concurrent history changes. */
|
|
158
|
+
async function readEvidence(pmRoot) {
|
|
159
|
+
try {
|
|
160
|
+
const path = getWorkspaceHistoryPath(pmRoot);
|
|
161
|
+
const before = await readHistorySnapshot(path, WORKSPACE_HISTORY_ID);
|
|
162
|
+
for (const entry of before.entries.filter((entry) => entry.op === "assurance:gate:verdict")) {
|
|
163
|
+
const integrity = verifyHistoryRecordHash(entry);
|
|
164
|
+
if (!integrity.ok || integrity.coverage !== "record_and_item_state")
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const receipts = await listAssuranceVerdicts(pmRoot, { limit: 1000 });
|
|
168
|
+
const after = await readHistorySnapshot(path, WORKSPACE_HISTORY_ID);
|
|
169
|
+
return before.raw === after.raw ? receipts : null;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Evaluate a directory tracker with side-effect-free public SDK reads; works outside Git. */
|
|
176
|
+
export async function auditEvidenceExpiry(pmRoot, policy, versions, options = {}) {
|
|
177
|
+
return evaluateEvidenceExpiry(policy, versions, await readEvidence(pmRoot), options);
|
|
178
|
+
}
|
|
179
|
+
/** Parse a JSON input without leaking paths or raw parser diagnostics. */
|
|
180
|
+
async function readInput(path, code) {
|
|
181
|
+
try {
|
|
182
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
throw new EvidenceExpiryRefusal(code, "Provide a readable JSON input file matching the documented schema.");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** CLI-friendly file inputs; the selected tracker remains host-owned. */
|
|
189
|
+
export async function auditEvidenceExpiryFiles(pmRoot, policyFile, versionsFile, options = {}) {
|
|
190
|
+
const policy = parseEvidenceExpiryPolicy(await readInput(policyFile, "invalid_policy"));
|
|
191
|
+
const versions = parseEvidenceVersions(await readInput(versionsFile, "invalid_versions"));
|
|
192
|
+
return auditEvidenceExpiry(pmRoot, policy, versions, options);
|
|
193
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EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,wEAAwE;IACxE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,sDAAsD;IACtD,yBAAyB,EAAE,MAAM,CAAC;IAClC,4EAA4E;IAC5E,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wFAAwF;IACxF,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AA6KD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI,CA0BvE;;;;kBAqNe,YAAY"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
import { encode } from "@toon-format/toon";
|
|
8
8
|
import { listMergeReceipts, auditMergeDriverConfiguration, auditMergeAttributeFence, findGitWorkspaceRoot, } from "@unbrained/pm-cli/sdk/merge";
|
|
9
9
|
import { analyzeDocstringCoverage } from "./docstrings.js";
|
|
10
|
+
import { auditBackendConfigFile, auditConfiguredBackends } from "./backend-capabilities.js";
|
|
11
|
+
import { auditEvidenceExpiryFiles, EvidenceExpiryRefusal } from "./evidence-expiry.js";
|
|
10
12
|
import { qualityMeasurementProvider } from "./assurance.js";
|
|
11
13
|
import { defaultCanonicalTagResolver, inspectReleaseCaller, isPmOpsOffline } from "./release-caller.js";
|
|
12
14
|
// ---------------------------------------------------------------------------
|
|
@@ -68,6 +70,8 @@ function asArray(value) {
|
|
|
68
70
|
return value.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
69
71
|
}
|
|
70
72
|
const OPS_COMMAND_PATHS = [
|
|
73
|
+
"ops capabilities",
|
|
74
|
+
"ops evidence-expiry",
|
|
71
75
|
"ops scan",
|
|
72
76
|
"ops policy",
|
|
73
77
|
"ops verify-release",
|
|
@@ -2111,7 +2115,7 @@ function renderDocstringsMarkdown(result) {
|
|
|
2111
2115
|
const defineExtension = (module) => module;
|
|
2112
2116
|
export default defineExtension({
|
|
2113
2117
|
name: "pm-ops",
|
|
2114
|
-
version: "2026.10.
|
|
2118
|
+
version: "2026.10.23",
|
|
2115
2119
|
activate(api) {
|
|
2116
2120
|
if (typeof api.registerRenderer === "function") {
|
|
2117
2121
|
// Derived from OPS_COMMAND_PATHS rather than restated. A literal copy is
|
|
@@ -2136,6 +2140,39 @@ export default defineExtension({
|
|
|
2136
2140
|
// same `authorization_decision` as any other bound regression. See
|
|
2137
2141
|
// `./assurance.ts` for the key contract and the staleness refusal.
|
|
2138
2142
|
api.registerAssuranceMeasurementProvider(qualityMeasurementProvider);
|
|
2143
|
+
api.registerCommand({
|
|
2144
|
+
name: "ops capabilities",
|
|
2145
|
+
description: "Verify configured backend list/get/schema read contracts without Git or tracker writes. Reports typed refusals and remedies; remote adapters require a read-only bridge.",
|
|
2146
|
+
examples: ["pm ops capabilities", "pm ops capabilities --config backends.json --json"],
|
|
2147
|
+
flags: [
|
|
2148
|
+
{ long: "--config", value_name: "file", description: "JSON adapter array; default: current directory tracker" },
|
|
2149
|
+
],
|
|
2150
|
+
async run(ctx) {
|
|
2151
|
+
const config = readString(ctx.options, "config");
|
|
2152
|
+
return config ? auditBackendConfigFile(config) : auditConfiguredBackends([
|
|
2153
|
+
{ id: "tracker", kind: "directory", root: ctx.pm_root, operations: ["list", "get", "schema"] },
|
|
2154
|
+
], process.cwd());
|
|
2155
|
+
},
|
|
2156
|
+
});
|
|
2157
|
+
api.registerCommand({
|
|
2158
|
+
name: "ops evidence-expiry",
|
|
2159
|
+
description: "Check retained health, coverage and recovery receipts for scope, freshness and relevant version changes. Read-only, without Git; counts include omitted rows. Diagnostic ok is authoritative.",
|
|
2160
|
+
examples: ["pm ops evidence-expiry --policy evidence-policy.json --versions evidence-versions.json --json"],
|
|
2161
|
+
flags: [
|
|
2162
|
+
{ long: "--policy", value_name: "file", description: "Version 1 claim attachment policy (required)" },
|
|
2163
|
+
{ long: "--versions", value_name: "file", description: "Current package/backend identity map (required)" },
|
|
2164
|
+
{ long: "--now", value_name: "iso", description: "Canonical UTC evaluation instant (default: current time)" },
|
|
2165
|
+
{ long: "--limit", value_name: "n", description: "Diagnostic rows, 1-1000 (default: 20)" },
|
|
2166
|
+
],
|
|
2167
|
+
async run(ctx) {
|
|
2168
|
+
const policy = readString(ctx.options, "policy");
|
|
2169
|
+
const versions = readString(ctx.options, "versions");
|
|
2170
|
+
if (!policy || !versions)
|
|
2171
|
+
throw new EvidenceExpiryRefusal("invalid_policy", "Supply --policy and --versions JSON input files.");
|
|
2172
|
+
const limit = readString(ctx.options, "limit");
|
|
2173
|
+
return auditEvidenceExpiryFiles(ctx.pm_root, policy, versions, { now: readString(ctx.options, "now"), limit: limit === undefined ? undefined : Number(limit) });
|
|
2174
|
+
},
|
|
2175
|
+
});
|
|
2139
2176
|
api.registerCommand({
|
|
2140
2177
|
name: "ops scan",
|
|
2141
2178
|
description: "Scan a set of pm repositories and produce a per-repo release-readiness snapshot " +
|
|
@@ -2428,17 +2465,11 @@ export default defineExtension({
|
|
|
2428
2465
|
}
|
|
2429
2466
|
return renderedCommandResult(body);
|
|
2430
2467
|
}
|
|
2431
|
-
//
|
|
2432
|
-
//
|
|
2433
|
-
//
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
// in renderedCommandResult here would double-wrap the payload as
|
|
2437
|
-
// { pmOpsRendered, output } and hide `repos` from `pm ops metrics
|
|
2438
|
-
// --json | jq .repos`. Deferring to the global format keeps the fleet
|
|
2439
|
-
// routing contract (payload.repos[].path) directly scrapeable.
|
|
2440
|
-
if (outputPath) {
|
|
2441
|
-
return emitResult(result, format === "json" ? "json" : "toon", outputPath, () => renderMetricsPrometheus(result));
|
|
2468
|
+
// Host-owned --json keeps the bare payload. An explicit command format
|
|
2469
|
+
// uses the same renderer contract as sibling ops commands, so the host's
|
|
2470
|
+
// default TOON setting cannot silently replace requested JSON stdout.
|
|
2471
|
+
if (outputPath || !wantsJson) {
|
|
2472
|
+
return emitResult(result, format, outputPath, () => renderMetricsPrometheus(result));
|
|
2442
2473
|
}
|
|
2443
2474
|
return result;
|
|
2444
2475
|
},
|