@unbrained/pm-lint 0.0.0-stage → 2026.10.28
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 +32 -0
- package/LICENSE +21 -0
- package/README.md +446 -2
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/src/baseline-file.d.ts +7 -0
- package/dist/src/baseline-file.d.ts.map +1 -0
- package/dist/src/baseline-file.js +79 -0
- package/dist/src/baseline-file.js.map +1 -0
- package/dist/src/baseline.d.ts +39 -0
- package/dist/src/baseline.d.ts.map +1 -0
- package/dist/src/baseline.js +68 -0
- package/dist/src/baseline.js.map +1 -0
- package/dist/src/commands.d.ts +33 -0
- package/dist/src/commands.d.ts.map +1 -0
- package/dist/src/commands.js +94 -0
- package/dist/src/commands.js.map +1 -0
- package/dist/src/engine.d.ts +48 -0
- package/dist/src/engine.d.ts.map +1 -0
- package/dist/src/engine.js +124 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/incremental-command.d.ts +6 -0
- package/dist/src/incremental-command.d.ts.map +1 -0
- package/dist/src/incremental-command.js +27 -0
- package/dist/src/incremental-command.js.map +1 -0
- package/dist/src/incremental-contract.d.ts +72 -0
- package/dist/src/incremental-contract.d.ts.map +1 -0
- package/dist/src/incremental-contract.js +142 -0
- package/dist/src/incremental-contract.js.map +1 -0
- package/dist/src/incremental-file.d.ts +13 -0
- package/dist/src/incremental-file.d.ts.map +1 -0
- package/dist/src/incremental-file.js +119 -0
- package/dist/src/incremental-file.js.map +1 -0
- package/dist/src/incremental.d.ts +41 -0
- package/dist/src/incremental.d.ts.map +1 -0
- package/dist/src/incremental.js +116 -0
- package/dist/src/incremental.js.map +1 -0
- package/dist/src/repair-command.d.ts +6 -0
- package/dist/src/repair-command.d.ts.map +1 -0
- package/dist/src/repair-command.js +26 -0
- package/dist/src/repair-command.js.map +1 -0
- package/dist/src/repair-snapshot.d.ts +5 -0
- package/dist/src/repair-snapshot.d.ts.map +1 -0
- package/dist/src/repair-snapshot.js +66 -0
- package/dist/src/repair-snapshot.js.map +1 -0
- package/dist/src/repairs.d.ts +64 -0
- package/dist/src/repairs.d.ts.map +1 -0
- package/dist/src/repairs.js +129 -0
- package/dist/src/repairs.js.map +1 -0
- package/dist/src/rule-pack-command.d.ts +8 -0
- package/dist/src/rule-pack-command.d.ts.map +1 -0
- package/dist/src/rule-pack-command.js +30 -0
- package/dist/src/rule-pack-command.js.map +1 -0
- package/dist/src/rule-pack.d.ts +79 -0
- package/dist/src/rule-pack.d.ts.map +1 -0
- package/dist/src/rule-pack.js +174 -0
- package/dist/src/rule-pack.js.map +1 -0
- package/dist/src/rules.d.ts +28 -0
- package/dist/src/rules.d.ts.map +1 -0
- package/dist/src/rules.js +153 -0
- package/dist/src/rules.js.map +1 -0
- package/dist/src/settings.d.ts +31 -0
- package/dist/src/settings.d.ts.map +1 -0
- package/dist/src/settings.js +109 -0
- package/dist/src/settings.js.map +1 -0
- package/dist/src/sidecar-publication.d.ts +39 -0
- package/dist/src/sidecar-publication.d.ts.map +1 -0
- package/dist/src/sidecar-publication.js +105 -0
- package/dist/src/sidecar-publication.js.map +1 -0
- package/dist/src/statuses.d.ts +8 -0
- package/dist/src/statuses.d.ts.map +1 -0
- package/dist/src/statuses.js +10 -0
- package/dist/src/statuses.js.map +1 -0
- package/dist/src/types.d.ts +44 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/witness-command.d.ts +6 -0
- package/dist/src/witness-command.d.ts.map +1 -0
- package/dist/src/witness-command.js +27 -0
- package/dist/src/witness-command.js.map +1 -0
- package/dist/src/witnesses.d.ts +74 -0
- package/dist/src/witnesses.d.ts.map +1 -0
- package/dist/src/witnesses.js +171 -0
- package/dist/src/witnesses.js.map +1 -0
- package/docs/incremental-example.md +64 -0
- package/docs/incremental-validation.md +99 -0
- package/docs/portable-rule-packs-validation.md +86 -0
- package/docs/repair-preview-example.md +43 -0
- package/docs/repair-preview-validation.md +42 -0
- package/examples/authoring-rules.json +30 -0
- package/manifest.json +13 -0
- package/package.json +150 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Stable diagnostic severities ordered from informational to gating errors. */
|
|
2
|
+
export type Severity = 'info' | 'warn' | 'error';
|
|
3
|
+
/** Stable authoring-quality rule identifiers. */
|
|
4
|
+
export type RuleCode = `PML00${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}` | 'PML010';
|
|
5
|
+
/**
|
|
6
|
+
* Default lifecycle slice each rule judges.
|
|
7
|
+
*
|
|
8
|
+
* `non_terminal` and `active` both cover every item that is neither closed nor
|
|
9
|
+
* canceled, so unfinished statuses such as blocked or draft keep being judged
|
|
10
|
+
* while closed history stays silent. Single-status scopes and `terminal` exist
|
|
11
|
+
* for settings overrides and `--status` selections.
|
|
12
|
+
*/
|
|
13
|
+
export type RuleScope = 'all' | 'non_terminal' | 'active' | 'terminal' | 'closed' | 'canceled' | 'open' | 'in_progress' | 'blocked';
|
|
14
|
+
/** One diagnostic with the offending context: the item title and a bounded excerpt. */
|
|
15
|
+
export interface Finding {
|
|
16
|
+
/** Rule semantics version used to validate acknowledgment evidence. */
|
|
17
|
+
rule_version: string;
|
|
18
|
+
/** SHA-256 over the full canonical source item, never the bounded excerpt. */
|
|
19
|
+
source_digest: string;
|
|
20
|
+
/** Acknowledged findings stay in output but do not fail a baseline gate. */
|
|
21
|
+
disposition: 'debt' | 'new';
|
|
22
|
+
item_id: string;
|
|
23
|
+
rule: RuleCode;
|
|
24
|
+
severity: Severity;
|
|
25
|
+
field: string;
|
|
26
|
+
hint: string;
|
|
27
|
+
/** Title of the offending item so agents do not need a follow-up read. */
|
|
28
|
+
title: string;
|
|
29
|
+
/** The offending text, at most 160 characters; empty when the rule flags an absence rather than text. */
|
|
30
|
+
excerpt: string;
|
|
31
|
+
}
|
|
32
|
+
/** One rule's effective enablement, severity, judged lifecycle scope and numeric tuning parameters. */
|
|
33
|
+
export interface RuleConfig {
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
severity: Severity;
|
|
36
|
+
scope: RuleScope;
|
|
37
|
+
parameters: Record<string, number>;
|
|
38
|
+
}
|
|
39
|
+
/** Fully resolved configuration consumed by the lint engine. */
|
|
40
|
+
export interface LintConfig {
|
|
41
|
+
rules: Record<RuleCode, RuleConfig>;
|
|
42
|
+
failOn: Severity;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,iDAAiD;AACjD,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,QAAQ,CAAC;AAC9E;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;AACpI,uFAAuF;AACvF,MAAM,WAAW,OAAO;IACtB,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,aAAa,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,yGAAyG;IACzG,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,uGAAuG;AACvG,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AACD,gEAAgE;AAChE,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,MAAM,EAAE,QAAQ,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandHandlerContext, ExtensionApi } from '@unbrained/pm-cli/sdk/authoring';
|
|
2
|
+
/** Render typed refusals and let the host paginate evidence rows in TOON or JSON. */
|
|
3
|
+
export declare function runWitnessCommand(ctx: CommandHandlerContext): Promise<Record<string, unknown>>;
|
|
4
|
+
/** Register an observational command without linked-test execution or git discovery. */
|
|
5
|
+
export declare function registerWitnessCommand(api: ExtensionApi): void;
|
|
6
|
+
//# sourceMappingURL=witness-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"witness-command.d.ts","sourceRoot":"","sources":["../../src/witness-command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG3F,qFAAqF;AACrF,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAapG;AAED,wFAAwF;AACxF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAE9D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { PmClient, defineCommand } from '@unbrained/pm-cli/sdk';
|
|
3
|
+
import { lintWitnesses, readWitnessContract, WitnessRefusal } from './witnesses.js';
|
|
4
|
+
/** Render typed refusals and let the host paginate evidence rows in TOON or JSON. */
|
|
5
|
+
export async function runWitnessCommand(ctx) {
|
|
6
|
+
try {
|
|
7
|
+
if (typeof ctx.options.contract !== 'string' || ctx.options.contract.trim() === '')
|
|
8
|
+
throw new WitnessRefusal('invalid_contract', 'One --contract file is required.', 'Supply --contract criterion-witnesses.json; use an empty bindings array to audit undeclared proof.');
|
|
9
|
+
const root = ctx.source_workspace_root ?? ctx.repo_root;
|
|
10
|
+
if (typeof root !== 'string')
|
|
11
|
+
throw new WitnessRefusal('invalid_contract', 'The evidence workspace is missing.', 'Run the command from a tracker workspace or supply the SDK evidence root.');
|
|
12
|
+
const contract = await readWitnessContract(resolve(root, ctx.options.contract));
|
|
13
|
+
const client = new PmClient({ cwd: root, pmRoot: ctx.pm_root, author: ctx.global.author, noExtensions: true });
|
|
14
|
+
const { exit_code, ...result } = await lintWitnesses(client, contract, root);
|
|
15
|
+
return { ...result, ...(exit_code === 0 ? {} : { exit_code }) };
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (!(error instanceof WitnessRefusal))
|
|
19
|
+
throw error;
|
|
20
|
+
return { ok: false, findings: [], count: 0, refusal: { code: error.code, message: error.message, remedy: error.remedy }, exit_code: 2 };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Register an observational command without linked-test execution or git discovery. */
|
|
24
|
+
export function registerWitnessCommand(api) {
|
|
25
|
+
api.registerCommand(defineCommand({ name: 'lint witnesses', description: 'Validate declared criterion witnesses without executing code', intent: 'Keep acceptance proof explicit, current and traceable', read_output: { row_keys: ['findings'] }, flags: [{ long: '--contract', value_name: 'file', value_type: 'string', description: 'Required version 1 JSON criterion-to-witness contract' }], examples: ['pm lint witnesses --contract criterion-witnesses.json --json'], run: runWitnessCommand }));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=witness-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"witness-command.js","sourceRoot":"","sources":["../../src/witness-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEpF,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAA0B;IAChE,IAAI,CAAC;QACH,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,MAAM,IAAI,cAAc,CAAC,kBAAkB,EAAE,kCAAkC,EAAE,oGAAoG,CAAC,CAAC;QAC3Q,MAAM,IAAI,GAAG,GAAG,CAAC,qBAAqB,IAAI,GAAG,CAAC,SAAS,CAAC;QACxD,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,MAAM,IAAI,cAAc,CAAC,kBAAkB,EAAE,oCAAoC,EAAE,2EAA2E,CAAC,CAAC;QAC9L,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChF,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/G,MAAM,EAAE,SAAS,EAAE,GAAG,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CriterionWitness = {
|
|
4
|
+
kind: 'test';
|
|
5
|
+
command: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
sha256: string;
|
|
8
|
+
outcome: 'pass' | 'fail';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'test';
|
|
11
|
+
path: string;
|
|
12
|
+
command?: string;
|
|
13
|
+
sha256: string;
|
|
14
|
+
outcome: 'pass' | 'fail';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'observation';
|
|
17
|
+
path: string;
|
|
18
|
+
sha256: string;
|
|
19
|
+
outcome: 'pass' | 'fail';
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'pending';
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
/** Exact criterion text avoids unstable ordinal links after criteria are reordered. */
|
|
25
|
+
export interface CriterionBinding {
|
|
26
|
+
item_id: string;
|
|
27
|
+
criterion: string;
|
|
28
|
+
witnesses: CriterionWitness[];
|
|
29
|
+
}
|
|
30
|
+
/** Portable sidecar contract; every criterion in the complete tracker is judged. */
|
|
31
|
+
export interface WitnessContract {
|
|
32
|
+
version: 1;
|
|
33
|
+
bindings: CriterionBinding[];
|
|
34
|
+
}
|
|
35
|
+
/** Stable lint outcomes distinguish absent proof from invalid proof. */
|
|
36
|
+
export type WitnessState = 'supported' | 'pending' | 'missing' | 'dangling' | 'stale' | 'contradictory';
|
|
37
|
+
/** Compact citation preserves the exact declared spelling, including line anchors. */
|
|
38
|
+
export interface WitnessFinding {
|
|
39
|
+
item_id: string;
|
|
40
|
+
criterion: string;
|
|
41
|
+
state: WitnessState;
|
|
42
|
+
citation: string;
|
|
43
|
+
remedy: string;
|
|
44
|
+
}
|
|
45
|
+
/** Complete counts accompany host-paginatable rows; pending proof cannot pass a gate. */
|
|
46
|
+
export interface WitnessResult {
|
|
47
|
+
findings: WitnessFinding[];
|
|
48
|
+
count: number;
|
|
49
|
+
corpus_count: number;
|
|
50
|
+
criteria_count: number;
|
|
51
|
+
summary: Record<WitnessState, number>;
|
|
52
|
+
complete_list: PmCompleteListCertificate;
|
|
53
|
+
exit_code: number;
|
|
54
|
+
}
|
|
55
|
+
/** Stable input and I/O refusals preserve actionable recovery across SDK and CLI. */
|
|
56
|
+
export type WitnessRefusalCode = 'invalid_contract' | 'contract_io' | 'evidence_io' | 'unsafe_citation';
|
|
57
|
+
/** Fail closed without echoing filesystem details or untrusted input. */
|
|
58
|
+
export declare class WitnessRefusal extends Error {
|
|
59
|
+
/** Machine-readable failure category. */
|
|
60
|
+
readonly code: WitnessRefusalCode;
|
|
61
|
+
/** Concrete recovery action safe to render in agent receipts. */
|
|
62
|
+
readonly remedy: string;
|
|
63
|
+
/** Carry a machine code and a concrete next action. */
|
|
64
|
+
constructor(code: WitnessRefusalCode, message: string, remedy: string);
|
|
65
|
+
}
|
|
66
|
+
/** Validate and detach all external input before any tracker or evidence read. */
|
|
67
|
+
export declare function parseWitnessContract(value: unknown): WitnessContract;
|
|
68
|
+
/** Hash exact file bytes so whitespace and content drift remain observable. */
|
|
69
|
+
export declare function observationDigest(bytes: string | Uint8Array): string;
|
|
70
|
+
/** Load only the explicit sidecar; never discover a git root or infer links from prose. */
|
|
71
|
+
export declare function readWitnessContract(path: string): Promise<WitnessContract>;
|
|
72
|
+
/** Check declared contracts against certified tracker state; never execute a linked test. */
|
|
73
|
+
export declare function lintWitnesses(client: PmClient, contract: WitnessContract, evidenceRoot: string): Promise<WitnessResult>;
|
|
74
|
+
//# sourceMappingURL=witnesses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"witnesses.d.ts","sourceRoot":"","sources":["../../src/witnesses.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGjF,oEAAoE;AACpE,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAA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AC;IACvB,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACtC,aAAa,EAAE,yBAAyB,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,qFAAqF;AACrF,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,CAAC;AACxG,yEAAyE;AACzE,qBAAa,cAAe,SAAQ,KAAK;IACvC,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,YAAY,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAKpE;CACF;AAYD,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAepE;AASD,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAA6D;AAClI,2FAA2F;AAC3F,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAMhF;AAuCD,6FAA6F;AAC7F,wBAAsB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA0C7H"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
3
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { certifyCompleteListResult, splitAcceptanceCriteria } from '@unbrained/pm-cli/sdk';
|
|
5
|
+
import { sourceDigest } from './baseline.js';
|
|
6
|
+
/** Fail closed without echoing filesystem details or untrusted input. */
|
|
7
|
+
export class WitnessRefusal extends Error {
|
|
8
|
+
/** Machine-readable failure category. */
|
|
9
|
+
code;
|
|
10
|
+
/** Concrete recovery action safe to render in agent receipts. */
|
|
11
|
+
remedy;
|
|
12
|
+
/** Carry a machine code and a concrete next action. */
|
|
13
|
+
constructor(code, message, remedy) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'WitnessRefusal';
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.remedy = remedy;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Require an exact key set on a plain JSON object. */
|
|
21
|
+
function keys(value, expected) {
|
|
22
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).sort().join(',') === expected;
|
|
23
|
+
}
|
|
24
|
+
/** Require bounded nonblank strings without changing their exact citation spelling. */
|
|
25
|
+
function text(value) { return typeof value === 'string' && value.trim().length > 0 && value.length <= 4096; }
|
|
26
|
+
/** Refuse malformed contracts instead of silently treating them as an empty scan. */
|
|
27
|
+
function invalid() {
|
|
28
|
+
throw new WitnessRefusal('invalid_contract', 'Invalid version 1 witness contract.', 'Use version 1, unique item_id/criterion bindings, and nonempty typed witnesses with exact keys and SHA-256 evidence.');
|
|
29
|
+
}
|
|
30
|
+
/** Validate and detach all external input before any tracker or evidence read. */
|
|
31
|
+
export function parseWitnessContract(value) {
|
|
32
|
+
if (!keys(value, 'bindings,version') || value.version !== 1 || !Array.isArray(value.bindings))
|
|
33
|
+
invalid();
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
for (const binding of value.bindings) {
|
|
36
|
+
if (!keys(binding, 'criterion,item_id,witnesses') || !text(binding.item_id) || !text(binding.criterion) || !Array.isArray(binding.witnesses) || binding.witnesses.length === 0)
|
|
37
|
+
invalid();
|
|
38
|
+
const identity = JSON.stringify([binding.item_id, binding.criterion]);
|
|
39
|
+
if (seen.has(identity))
|
|
40
|
+
invalid();
|
|
41
|
+
seen.add(identity);
|
|
42
|
+
for (const witness of binding.witnesses) {
|
|
43
|
+
if (keys(witness, 'kind,reason') && witness.kind === 'pending' && text(witness.reason))
|
|
44
|
+
continue;
|
|
45
|
+
if (!validEvidence(witness))
|
|
46
|
+
invalid();
|
|
47
|
+
if ((witness.outcome !== 'pass' && witness.outcome !== 'fail') || typeof witness.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(witness.sha256))
|
|
48
|
+
invalid();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return structuredClone(value);
|
|
52
|
+
}
|
|
53
|
+
/** Accept exact core test identities, including path-only tests, and file observations. */
|
|
54
|
+
function validEvidence(value) {
|
|
55
|
+
if (keys(value, 'kind,outcome,path,sha256'))
|
|
56
|
+
return (value.kind === 'test' || value.kind === 'observation') && text(value.path);
|
|
57
|
+
if (keys(value, 'command,kind,outcome,sha256'))
|
|
58
|
+
return value.kind === 'test' && text(value.command);
|
|
59
|
+
return keys(value, 'command,kind,outcome,path,sha256') && value.kind === 'test' && text(value.command) && text(value.path);
|
|
60
|
+
}
|
|
61
|
+
/** Hash exact file bytes so whitespace and content drift remain observable. */
|
|
62
|
+
export function observationDigest(bytes) { return createHash('sha256').update(bytes).digest('hex'); }
|
|
63
|
+
/** Load only the explicit sidecar; never discover a git root or infer links from prose. */
|
|
64
|
+
export async function readWitnessContract(path) {
|
|
65
|
+
let value;
|
|
66
|
+
try {
|
|
67
|
+
value = JSON.parse(await readFile(path, 'utf8'));
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new WitnessRefusal('contract_io', 'Cannot read witness JSON.', 'Supply --contract with a readable version 1 JSON document.');
|
|
71
|
+
}
|
|
72
|
+
return parseWitnessContract(value);
|
|
73
|
+
}
|
|
74
|
+
/** Test a resolved path against the caller-selected evidence root. */
|
|
75
|
+
function within(root, path) {
|
|
76
|
+
const tail = relative(root, path);
|
|
77
|
+
return tail !== '..' && !tail.startsWith(`..${sep}`) && !isAbsolute(tail);
|
|
78
|
+
}
|
|
79
|
+
/** Read a repository-relative citation without following escapes or invoking git. */
|
|
80
|
+
async function observationState(root, witness) {
|
|
81
|
+
// A line suffix is a citation only; the digest binds the entire file.
|
|
82
|
+
const path = witness.path.replace(/#L\d+(?:-L\d+)?$|:\d+(?::\d+)?$/, '');
|
|
83
|
+
if (isAbsolute(path) || !within(resolve(root), resolve(root, path)))
|
|
84
|
+
throw new WitnessRefusal('unsafe_citation', 'Observation escapes the evidence root.', 'Use a relative file citation inside the selected evidence root.');
|
|
85
|
+
try {
|
|
86
|
+
const canonicalRoot = await realpath(root);
|
|
87
|
+
const target = await realpath(resolve(root, path));
|
|
88
|
+
if (!within(canonicalRoot, target))
|
|
89
|
+
throw new WitnessRefusal('unsafe_citation', 'Observation symlink escapes the evidence root.', 'Use a file whose resolved target remains inside the evidence root.');
|
|
90
|
+
return observationDigest(await readFile(target)) === witness.sha256 ? 'supported' : 'stale';
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error instanceof WitnessRefusal)
|
|
94
|
+
throw error;
|
|
95
|
+
const code = error.code;
|
|
96
|
+
if (code === 'ENOENT' || code === 'ENOTDIR')
|
|
97
|
+
return 'dangling';
|
|
98
|
+
throw new WitnessRefusal('evidence_io', 'Cannot read observation evidence.', 'Make the cited artifact a readable regular file, then retry.');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Recovery messages are stable and bounded instead of copying source evidence. */
|
|
102
|
+
const REMEDIES = {
|
|
103
|
+
supported: '', pending: 'Collect the explicitly pending proof, then replace its declaration.',
|
|
104
|
+
missing: 'Declare a test, observation or explicit pending proof for this exact criterion.',
|
|
105
|
+
dangling: 'Restore the cited item, linked test or observation, or correct the declaration.',
|
|
106
|
+
stale: 'Review changed criteria or evidence and refresh the exact declaration and digest.',
|
|
107
|
+
contradictory: 'Resolve failing or conflicting outcome declarations before claiming support.',
|
|
108
|
+
};
|
|
109
|
+
/** Compare exact UTF-16 code units without locale collation or Unicode normalization. */
|
|
110
|
+
function compareWitnessText(left, right) {
|
|
111
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
112
|
+
}
|
|
113
|
+
/** Check declared contracts against certified tracker state; never execute a linked test. */
|
|
114
|
+
export async function lintWitnesses(client, contract, evidenceRoot) {
|
|
115
|
+
const checked = parseWitnessContract(contract);
|
|
116
|
+
const corpus = certifyCompleteListResult(await client.listAllComplete());
|
|
117
|
+
const items = new Map(corpus.items.map(/** Index certified items once. */ /** Index certified items once. */ item => [item.id, item]));
|
|
118
|
+
const criteria = new Map(corpus.items.map(/** Let core own criterion boundary semantics. */ /** Let core own criterion boundary semantics. */ item => [item.id, splitAcceptanceCriteria(item.acceptance_criteria)]));
|
|
119
|
+
const findings = [];
|
|
120
|
+
const summary = { supported: 0, pending: 0, missing: 0, dangling: 0, stale: 0, contradictory: 0 };
|
|
121
|
+
/** Record every declaration separately so stale evidence never conceals contradiction. */
|
|
122
|
+
function add(item_id, criterion, state, citation = '') {
|
|
123
|
+
findings.push({ item_id, criterion, state, citation, remedy: REMEDIES[state] });
|
|
124
|
+
summary[state] += 1;
|
|
125
|
+
}
|
|
126
|
+
const bound = new Set();
|
|
127
|
+
for (const binding of checked.bindings) {
|
|
128
|
+
const { item_id, criterion } = binding;
|
|
129
|
+
bound.add(JSON.stringify([item_id, criterion]));
|
|
130
|
+
const item = items.get(item_id);
|
|
131
|
+
if (item === undefined) {
|
|
132
|
+
add(item_id, criterion, 'dangling');
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (!criteria.get(item_id).includes(criterion)) {
|
|
136
|
+
add(item_id, criterion, 'stale');
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
for (const witness of binding.witnesses) {
|
|
140
|
+
if (witness.kind === 'pending') {
|
|
141
|
+
add(item_id, criterion, 'pending');
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
let state;
|
|
145
|
+
let citation;
|
|
146
|
+
if (witness.kind === 'observation') {
|
|
147
|
+
citation = witness.path;
|
|
148
|
+
state = await observationState(evidenceRoot, witness);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
citation = witness.path ?? witness.command;
|
|
152
|
+
const matches = (item.tests ?? []).filter(/** Every supplied identity field must match exactly. */ /** Every supplied identity field must match exactly. */ entry => (witness.command === undefined || entry.command === witness.command) && (witness.path === undefined || entry.path === witness.path));
|
|
153
|
+
state = matches.length === 0 ? 'dangling' : matches.length > 1 ? 'contradictory' : sourceDigest(matches[0]) === witness.sha256 ? 'supported' : 'stale';
|
|
154
|
+
}
|
|
155
|
+
if (state !== 'supported' || witness.outcome !== 'fail')
|
|
156
|
+
add(item_id, criterion, state, citation);
|
|
157
|
+
if (witness.outcome === 'fail')
|
|
158
|
+
add(item_id, criterion, 'contradictory', citation);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
let criteriaCount = 0;
|
|
162
|
+
for (const [id, entries] of criteria) {
|
|
163
|
+
criteriaCount += entries.length;
|
|
164
|
+
for (const criterion of entries)
|
|
165
|
+
if (!bound.has(JSON.stringify([id, criterion])))
|
|
166
|
+
add(id, criterion, 'missing');
|
|
167
|
+
}
|
|
168
|
+
findings.sort(/** Exact identity ordering ignores scan order, declaration order and host locale. */ (a, b) => compareWitnessText(a.item_id, b.item_id) || compareWitnessText(a.criterion, b.criterion) || compareWitnessText(a.citation, b.citation) || compareWitnessText(a.state, b.state));
|
|
169
|
+
return { findings, count: findings.length, corpus_count: corpus.items.length, criteria_count: criteriaCount, summary, complete_list: corpus.complete_list, exit_code: findings.some(/** Explicit pending proof remains unfinished. */ /** Explicit pending proof remains unfinished. */ row => row.state !== 'supported') ? 1 : 0 };
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=witnesses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"witnesses.js","sourceRoot":"","sources":["../../src/witnesses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAA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,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpR,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Complete incremental lint through the SDK
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import {
|
|
5
|
+
filesystemLintSource, lintIncrementalFile,
|
|
6
|
+
lintIncremental, parseIncrementalCheckpoint,
|
|
7
|
+
} from '@unbrained/pm-lint';
|
|
8
|
+
import type { IncrementalLintSource } from '@unbrained/pm-lint';
|
|
9
|
+
|
|
10
|
+
const source = filesystemLintSource('.agents/pm');
|
|
11
|
+
const first = await lintIncrementalFile(source, 'lint.local.json', true);
|
|
12
|
+
const next = await lintIncrementalFile(source, 'lint.local.json');
|
|
13
|
+
console.log(next.result.count, next.incremental.evaluated, next.incremental.reused);
|
|
14
|
+
|
|
15
|
+
// A service supplies native SDK capabilities and a stable workspace identity.
|
|
16
|
+
const serviceSource: IncrementalLintSource = source;
|
|
17
|
+
const scan = await lintIncremental(serviceSource, {
|
|
18
|
+
checkpoint: parseIncrementalCheckpoint(first.checkpoint),
|
|
19
|
+
});
|
|
20
|
+
// Persist scan.checkpoint with the service's revision-based compare-and-set.
|
|
21
|
+
// On conflict, read the winner and rerun against CURRENT SDK state.
|
|
22
|
+
console.log(scan.result.findings);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`lintIncremental` performs no native item writes or checkpoint I/O. The caller
|
|
26
|
+
owns checkpoint persistence. Read its previous checkpoint inside a lease or
|
|
27
|
+
compare-and-set loop, revalidate source revisions before publication and release
|
|
28
|
+
ownership last. Never replay an old saved result as an item mutation plan.
|
|
29
|
+
`lintIncrementalFile` provides these checks for local storage and uses core's
|
|
30
|
+
owned lease and a guarded atomic publisher. State must be a regular file in an existing
|
|
31
|
+
writable directory; peers using directory aliases share the same lock.
|
|
32
|
+
|
|
33
|
+
The CLI returns the normal complete lint verdict plus an `incremental` receipt:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{"mode":"update","changed_items":1,"evaluated":30003,"reused":49997}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This excerpt omits the full receipt's SDK event/page counts and ten `by_rule`
|
|
40
|
+
rows. The 10,000-item fixture uses all default rules: three applicable global
|
|
41
|
+
checks run for every active item, three title-sensitive local pairs rerun, and
|
|
42
|
+
49,997 local pairs are reused. PML004 and PML009 are out of scope in that fixture.
|
|
43
|
+
|
|
44
|
+
Expected refusals throw `IncrementalRefusal` in the SDK; the CLI renders
|
|
45
|
+
`{ok:false, refusal:{code,message,remedy}}` with exit 2. Ordinary findings retain
|
|
46
|
+
lint's severity policy and exit 0/1. Resource exhaustion, policy drift and cursor
|
|
47
|
+
loss never become a passing partial scan. Whole-corpus SDK certification errors
|
|
48
|
+
retain the host diagnostic.
|
|
49
|
+
|
|
50
|
+
Dependency declarations are public via `RULE_DEPENDENCIES`. Whenever predicate
|
|
51
|
+
semantics change, increment `RULE_VERSION`; its digest and the dependency table
|
|
52
|
+
bind each checkpoint. Source identity, complete native metadata and status-role
|
|
53
|
+
policy are also bound. Saved excerpts are limited to the existing 160-character
|
|
54
|
+
finding ceiling and are reused only with identical declared predicate inputs.
|
|
55
|
+
|
|
56
|
+
The feature works without git. It neither launches git nor writes native item
|
|
57
|
+
fields, scope, relationships, claims or journals. `--since`, item filters and
|
|
58
|
+
baseline acknowledgments remain available on the ordinary lint command.
|
|
59
|
+
|
|
60
|
+
Local checkpoint and baseline updates use one publisher: private staging,
|
|
61
|
+
permission/ownership preservation and a final synchronous target-generation
|
|
62
|
+
check immediately before replacement. A competing replacement during an SDK
|
|
63
|
+
read, stage write, sync, close or lease-fence preparation is refused and retained.
|
|
64
|
+
Callers and other writer processes must honor the sidecar's lease/lock protocol.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Incremental lint validation
|
|
2
|
+
|
|
3
|
+
The implementation is checked against fresh certified full scans, genuine SDK
|
|
4
|
+
trackers outside git, checkpoint transport properties and concurrent writers.
|
|
5
|
+
Results and measured numbers are recorded here before review.
|
|
6
|
+
|
|
7
|
+
Public source: `unbraind/pm-lint` at `a813e56`, exported from `origin/main`.
|
|
8
|
+
Authoritative source SHA-256:
|
|
9
|
+
`16b7a56ee139b2681ce3ece7e468d9caea102b1cd32a38f9aee4ee638ffaa7d1`.
|
|
10
|
+
|
|
11
|
+
| Dataset / transition | Items | Findings | Predicates evaluated | Pairs reused | Complete equality |
|
|
12
|
+
| --- | ---: | ---: | ---: | ---: | --- |
|
|
13
|
+
| Immutable public copy, no-op | 21 | 0 | 12 | 54 | yes |
|
|
14
|
+
| Public derivative, one title edit | 21 | 0 | 15 | 51 | yes |
|
|
15
|
+
| Synthetic active corpus, one title edit | 10,000 | 0 | 30,003 | 49,997 | yes |
|
|
16
|
+
|
|
17
|
+
On the shared host, the public-copy rebuild took 3,650 ms, no-op 694 ms,
|
|
18
|
+
title edit 288 ms and warm full scan 98 ms. Its checkpoint was 13,121 bytes.
|
|
19
|
+
The synthetic run under coverage measured 29,761 ms for rebuild and 6,864 ms
|
|
20
|
+
for update, with a 5,959,530-byte checkpoint. These are observations under
|
|
21
|
+
load, not speed guarantees. Public authoritative file names and bytes were
|
|
22
|
+
unchanged; the title edit occurred only in the disposable derivative.
|
|
23
|
+
|
|
24
|
+
The read-only public-data harness is `test/public-incremental-validation.ts`.
|
|
25
|
+
It copies a public tracker into a non-git scratch directory, makes authoritative
|
|
26
|
+
files read only, compares rebuild/no-op results with full lint and fingerprints
|
|
27
|
+
all authoritative names and bytes before/after. A separate disposable derivative
|
|
28
|
+
receives one SDK title edit and is compared with a fresh scan. SDK caches remain
|
|
29
|
+
disposable and are excluded from the authoritative fingerprint.
|
|
30
|
+
|
|
31
|
+
The 10,000-item fixture uses native SDK serialization for seeding and the SDK for
|
|
32
|
+
the title edit and all reads. It asserts complete result equality and exact
|
|
33
|
+
per-rule predicate counts. Performance figures include complete reads and SDK
|
|
34
|
+
certification; they do not assert a universal wall-time speedup.
|
|
35
|
+
|
|
36
|
+
`test/incremental-model.test.ts` uses seed `0x1ace2026` for 500 sequences of native
|
|
37
|
+
document imports, old input/checkpoint replays, JSON/TOON exports, whitespace/CRLF
|
|
38
|
+
variants, complete scans and retry. An independent SDK-read tracker is the
|
|
39
|
+
normalization oracle. Each observational step is an identity transition on
|
|
40
|
+
native state; every result is compared with a fresh full scan. Relationships,
|
|
41
|
+
native authoring fields and bounded excerpts remain covered. A second seeded
|
|
42
|
+
property checks 500 randomly named custom status registries against role-equivalent
|
|
43
|
+
built-in statuses.
|
|
44
|
+
|
|
45
|
+
The interleaving test injects a real competing file writer at all eleven exposed
|
|
46
|
+
boundaries on one non-git tracker, including publication and release. Another
|
|
47
|
+
injects SDK source edits at all nine prepublication boundaries. A lost actual
|
|
48
|
+
core lease cannot publish, a changed source cannot advance the saved checkpoint,
|
|
49
|
+
and foreign or peer state remains untouched. No SDK mocks are used.
|
|
50
|
+
|
|
51
|
+
Review follow-up audits both durable sidecar writers, including baseline
|
|
52
|
+
acknowledgments. `test/publication.test.ts` injects a foreign target after every
|
|
53
|
+
actual SDK read and each staging await, including the final SDK policy read and
|
|
54
|
+
durable sync. It covers staging-inode replacement, identical-byte replacement,
|
|
55
|
+
creation/deletion/mode drift, in-place foreign staging edits, torn reads, owner/group preservation and private
|
|
56
|
+
creation in a traversable directory under a permissive umask. Both JSON and TOON
|
|
57
|
+
CLI paths and packed npm/Bun consumers check that `0600` stays `0600`.
|
|
58
|
+
|
|
59
|
+
Function-only revert proofs fail for each writer: the old checkpoint publisher
|
|
60
|
+
overwrites a final-policy replacement and creates `0666` under umask `000`; the
|
|
61
|
+
old baseline publisher overwrites a replacement during sync and changes an
|
|
62
|
+
existing `0400` file to `0600`. No original regressions were weakened or removed.
|
|
63
|
+
Restoring only inode-based staging cleanup also deletes the in-place foreign
|
|
64
|
+
payload; the corrected cleanup retains it. The final focused set includes all
|
|
65
|
+
original incremental regressions and adapter metadata-failure checks: 31/31
|
|
66
|
+
passed, with 100/100/100/100 measured for both writer adapters and the shared
|
|
67
|
+
publisher.
|
|
68
|
+
|
|
69
|
+
The complete local release gates passed serially at source commit `208f70f`,
|
|
70
|
+
using isolated home directories and Git configuration, Node 24.19.0, npm 11.17.0
|
|
71
|
+
and Bun 1.3.5. Test concurrency remained at most two; thresholds were unchanged.
|
|
72
|
+
|
|
73
|
+
| Command | Main tests | Packed acceptance | Coverage | Total measured time |
|
|
74
|
+
| --- | ---: | ---: | --- | ---: |
|
|
75
|
+
| `npm run release:check` | 179/179 | 1/1 | 100/100/100/100 | 1,804,238 ms |
|
|
76
|
+
| `bun run release:check` | 179/179 | 1/1 | 100/100/100/100 | 2,292,750 ms |
|
|
77
|
+
|
|
78
|
+
Both runs had zero failures, skips, cancellations or todo cases. All 30 measured
|
|
79
|
+
source files met every coverage threshold. Typecheck, lint, zero-duplication,
|
|
80
|
+
docstrings, identity, production audit, dry packing, changelog and publication
|
|
81
|
+
attestation checks passed. Packed acceptance covers npm and Bun global hosts,
|
|
82
|
+
npx/native bunx, direct project-local CLI entrypoints and the packed incremental
|
|
83
|
+
SDK. Its final-policy replacement and permission assertions use the packed SDK;
|
|
84
|
+
the two packed runs took 454,550 ms and 424,134 ms respectively.
|
|
85
|
+
|
|
86
|
+
The subsequent merge of `815ec63` changes only another tracker item's closure
|
|
87
|
+
evidence. Product source, tests, scripts and dependency files remain identical
|
|
88
|
+
to the full-gate source commit. Final tracker/docs receipts are checked with
|
|
89
|
+
tracker health, identity, changelog and diff validation. Pushed-head CI results
|
|
90
|
+
are linked from [PR 32 checks](https://github.com/unbraind/pm-lint/pull/32/checks);
|
|
91
|
+
local source-gate results and CI results are separate receipts.
|
|
92
|
+
|
|
93
|
+
The bounded CI watch at `74774ab` reached approximately 30 minutes with both
|
|
94
|
+
Node 22 and Node 26 jobs still queued and zero executed steps in
|
|
95
|
+
[run 40499927461](https://github.com/unbraind/pm-lint/actions/runs/40499927461).
|
|
96
|
+
[CodeQL](https://github.com/unbraind/pm-lint/actions/runs/40499927369) was also
|
|
97
|
+
queued. No new CI gate pass is claimed. This final tracker/docs receipt does
|
|
98
|
+
not change implementation or tests; its own CI remains separate at PR checks.
|
|
99
|
+
The orchestrator pipeline continues final-head checks and re-review.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Portable rule-pack validation
|
|
2
|
+
|
|
3
|
+
The overlap check used the installed CLI 2026.10.23 contract, the package-pinned
|
|
4
|
+
SDK 2026.10.20, pm-presets export/upgrade, pm-review workflows, and existing
|
|
5
|
+
pm-lint rules, baselines and witnesses. Core owns schema types and mutation
|
|
6
|
+
workflow governance (required fields, transitions, authors, field writers and
|
|
7
|
+
approvals). Presets distributes schemas/settings/templates. Portable packs add
|
|
8
|
+
read-only literal text and length authoring assertions with organization-owned
|
|
9
|
+
explanations; they do not replace or install governance policies.
|
|
10
|
+
|
|
11
|
+
## Public read-only measurement
|
|
12
|
+
|
|
13
|
+
Source: public [pm-presets tracker at
|
|
14
|
+
470c2b2](https://github.com/unbraind/pm-presets/tree/470c2b2a367c36dbf19513b4db2f84fa979a057c/.agents/pm).
|
|
15
|
+
Repository visibility and the exact commit were verified through GitHub before
|
|
16
|
+
measurement. Only committed tracker files were copied to a disposable directory
|
|
17
|
+
outside git. Snapshot files and directories were made read-only. Extensions were
|
|
18
|
+
disabled, and git discovery was fenced at the snapshot's parent directory.
|
|
19
|
+
|
|
20
|
+
Reproduce after preparing an equivalent read-only snapshot:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
GIT_CEILING_DIRECTORIES="$SNAPSHOT_PARENT" node test/public-rule-pack-validation.ts "$SNAPSHOT_PM_ROOT"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Measurement | Result |
|
|
27
|
+
| --- | ---: |
|
|
28
|
+
| Certified items, including terminal work | 76 |
|
|
29
|
+
| Rules in shipped example | 3 |
|
|
30
|
+
| Potential item/rule pairs | 228 |
|
|
31
|
+
| Applicable checks after exact selectors | 157 |
|
|
32
|
+
| Findings | 25 |
|
|
33
|
+
| Error / warning / informational findings | 0 / 25 / 0 |
|
|
34
|
+
| `ORG.acceptance` / `ORG.context` / `ORG.title` findings | 0 / 25 / 0 |
|
|
35
|
+
| Complete SDK JSON receipt size | 6,193 bytes |
|
|
36
|
+
| Gate exit code | 0 |
|
|
37
|
+
|
|
38
|
+
Reversing the rule declaration order produced an identical complete receipt.
|
|
39
|
+
Hashing all snapshot filenames and bytes before and after both runs proved no
|
|
40
|
+
source changes. No source item text or operational data is reproduced here.
|
|
41
|
+
|
|
42
|
+
## Regression and adapter evidence
|
|
43
|
+
|
|
44
|
+
The focused suite uses real initialized temporary trackers, core serialization,
|
|
45
|
+
and actual built CLI processes. It checks every predicate, exact selectors,
|
|
46
|
+
strict parsing and unknown keys, duplicate identities, unsafe pattern modes,
|
|
47
|
+
all resource dimensions, stable ordering, typed remedies, read failures, and
|
|
48
|
+
TOON/JSON host output. TOON and legacy JSON Markdown readers produce identical
|
|
49
|
+
complete diagnostic receipts from the same canonical metadata. The pinned SDK
|
|
50
|
+
migrates legacy Markdown during reads; that compatibility test uses a disposable
|
|
51
|
+
writable fixture. It does not establish hosted Postgres or network deployment.
|
|
52
|
+
|
|
53
|
+
The git-free CLI tests set a git discovery ceiling and run with a PATH containing
|
|
54
|
+
no git executable. Packed acceptance exercises the shipped example and public SDK
|
|
55
|
+
through real npm/npx and native Bun/bunx consumers in CI.
|
|
56
|
+
|
|
57
|
+
## Full release-gate receipt
|
|
58
|
+
|
|
59
|
+
Implementation commit `3b6a590809aa72f82e1e83f742542731f732e09f` passed
|
|
60
|
+
[CI run 40014216019](https://github.com/unbraind/pm-lint/actions/runs/40014216019).
|
|
61
|
+
The subsequent evidence commit changes documentation and tracker receipts only.
|
|
62
|
+
|
|
63
|
+
| Gate | Suite | Packed acceptance | Coverage |
|
|
64
|
+
| --- | ---: | ---: | --- |
|
|
65
|
+
| `npm run release:check`, Node 22 | 106/106 | 1/1 | 100/100/100/100 |
|
|
66
|
+
| `npm run release:check`, Node 26 | 106/106 | 1/1 | 100/100/100/100 |
|
|
67
|
+
| `bun run release:check`, Node 26 | 106/106 | 1/1 | 100/100/100/100 |
|
|
68
|
+
|
|
69
|
+
Coverage reconciled all 21 configured authored sources, with unchanged 100%
|
|
70
|
+
thresholds in each dimension. Each packed acceptance test ran npm/npx and native
|
|
71
|
+
Bun/bunx SDK/CLI consumers. All three gates had zero failed, skipped or canceled
|
|
72
|
+
top-level tests. Fresh-checkout tracker health, privacy/identity, duplication,
|
|
73
|
+
typecheck, lint, docstrings, production dependency audit, package contents,
|
|
74
|
+
changelog and release-attestation checks passed. CodeQL also passed.
|
|
75
|
+
|
|
76
|
+
Behavioral revert proof removed only semantic evaluation, rebuilt, and made both
|
|
77
|
+
selected semantic/CLI tests fail (0/2 pass). Independently bypassing strict parsing
|
|
78
|
+
and rebuilding made both parser/resource tests fail (0/2 pass). Restoring the
|
|
79
|
+
implementation returned the focused suite to 22/22; the final pack-only coverage
|
|
80
|
+
run passed 8/8 and measured both new runtime modules at 100/100/100/100.
|
|
81
|
+
|
|
82
|
+
The package worktree's separate local strict-health check reported ignored
|
|
83
|
+
managed-extension host-version skew and pre-existing merge-fence drift. Neither
|
|
84
|
+
was changed by this feature; both fresh CI jobs passed tracker health. No hosted
|
|
85
|
+
backend acceptance or external review approval is claimed. Automated review
|
|
86
|
+
services reported unavailable/skipped/neutral review states, not approvals.
|