@diffci.com/diffci 0.3.21 → 0.3.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/dist-client/src/client/agent-identity.d.ts +26 -0
- package/dist-client/src/client/agent-identity.js +62 -0
- package/dist-client/src/client/agent-selection.d.ts +55 -0
- package/dist-client/src/client/cli.d.ts +2 -0
- package/dist-client/src/client/cli.js +75 -4
- package/dist-client/src/client/command-batches.d.ts +27 -0
- package/dist-client/src/client/command-batches.js +8 -1
- package/dist-client/src/client/context.d.ts +47 -0
- package/dist-client/src/client/delivery-warning.d.ts +1 -0
- package/dist-client/src/client/economics.d.ts +17 -0
- package/dist-client/src/client/enforce-misses-collect.d.ts +49 -0
- package/dist-client/src/client/enforce-misses.d.ts +124 -0
- package/dist-client/src/client/enforce-policy.d.ts +33 -0
- package/dist-client/src/client/failure-baseline.d.ts +67 -0
- package/dist-client/src/client/failure-baseline.js +43 -19
- package/dist-client/src/client/feedback-prompt.d.ts +6 -0
- package/dist-client/src/client/full-command.d.ts +16 -0
- package/dist-client/src/client/gate-checks.d.ts +54 -0
- package/dist-client/src/client/gate-checks.js +16 -4
- package/dist-client/src/client/gate.d.ts +154 -0
- package/dist-client/src/client/hook.d.ts +27 -0
- package/dist-client/src/client/install.d.ts +19 -0
- package/dist-client/src/client/mcp.d.ts +2 -0
- package/dist-client/src/client/observe.d.ts +52 -0
- package/dist-client/src/client/observe.js +25 -3
- package/dist-client/src/client/package-identity.d.ts +14 -0
- package/dist-client/src/client/pilot-packet.d.ts +6 -0
- package/dist-client/src/client/report.d.ts +265 -0
- package/dist-client/src/client/selected-coverage.d.ts +39 -0
- package/dist-client/src/client/selected-coverage.js +159 -0
- package/dist-client/src/client/shared-graph-cache.d.ts +113 -0
- package/dist-client/src/client/shared-graph-cache.js +347 -0
- package/dist-client/src/client/spec-conflicts.d.ts +19 -0
- package/dist-client/src/client/submit.d.ts +61 -0
- package/dist-client/src/client/telemetry.d.ts +13 -0
- package/dist-client/src/client/usage-signal.d.ts +19 -0
- package/dist-client/src/client/verify-savings.d.ts +188 -0
- package/dist-client/src/client/verify-savings.js +4 -0
- package/dist-client/src/client/verify.d.ts +113 -0
- package/dist-client/src/client/verify.js +56 -16
- package/dist-client/src/client/workflow-guard.d.ts +59 -0
- package/dist-client/src/client/workflow-guard.js +267 -0
- package/dist-client/src/client/workflow-templates.d.ts +8 -0
- package/dist-client/src/client/working-tree.d.ts +26 -0
- package/dist-client/src/preflight/fingerprint.d.ts +29 -0
- package/dist-client/src/preflight/taxonomy.d.ts +10 -0
- package/node_modules/@diffci.com/core/README.md +4 -0
- package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +3 -0
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +110 -10
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/types.d.ts +6 -2
- package/node_modules/@diffci.com/core/dist/planner/test-command.d.ts +2 -0
- package/node_modules/@diffci.com/core/dist/planner/test-command.js +53 -1
- package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +1 -0
- package/node_modules/@diffci.com/core/dist/repo/impact.js +17 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/pnpm-lockfile.d.ts +6 -0
- package/node_modules/@diffci.com/core/dist/repo/pnpm-lockfile.js +161 -0
- package/node_modules/@diffci.com/core/dist/repo/pnpm-lockfile.js.map +1 -0
- package/node_modules/@diffci.com/core/package.json +1 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +95 -9
- package/node_modules/@diffci.com/core/src/git/types.ts +6 -2
- package/node_modules/@diffci.com/core/src/planner/test-command.ts +52 -1
- package/node_modules/@diffci.com/core/src/repo/impact.ts +16 -1
- package/node_modules/@diffci.com/core/src/repo/pnpm-lockfile.ts +147 -0
- package/package.json +9 -2
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type FailureBaseline } from "./failure-baseline.js";
|
|
2
|
+
import { type EnforcementDecision } from "./enforce-policy.js";
|
|
3
|
+
import { type CheckResult } from "./gate-checks.js";
|
|
4
|
+
import type { ObservationCommitRange, ObservationReport } from "./report.js";
|
|
5
|
+
import type { CommandMeasurement } from "./verify-savings.js";
|
|
6
|
+
import { type SnapshotChange } from "./working-tree.js";
|
|
7
|
+
export declare const VERIFICATION_SCHEMA: "diffci.verification.v1";
|
|
8
|
+
export type VerificationStatus = "passed" | "failed" | "blocked";
|
|
9
|
+
export type VerificationScope = "working-tree" | "commit-range";
|
|
10
|
+
export interface VerificationReport {
|
|
11
|
+
schema: typeof VERIFICATION_SCHEMA;
|
|
12
|
+
schema_version: "1";
|
|
13
|
+
produced_at: string;
|
|
14
|
+
/** The DiffCI package that produced the receipt, so cohorts can be split by selector version. */
|
|
15
|
+
diffci_version?: string;
|
|
16
|
+
scope: VerificationScope;
|
|
17
|
+
verification: VerificationStatus;
|
|
18
|
+
safe_to_continue: boolean;
|
|
19
|
+
reason: string;
|
|
20
|
+
changed_files: number;
|
|
21
|
+
tests_available: number;
|
|
22
|
+
tests_selected: number;
|
|
23
|
+
/** Affected tests the full test command does not run; executed after the selection (2026-10-21). */
|
|
24
|
+
tests_outside_full_suite?: number;
|
|
25
|
+
selection: "none" | "selected" | "full";
|
|
26
|
+
/** The test files the selected command ran, when `selection` is "selected". The miss detector reads it. */
|
|
27
|
+
selected_tests?: string[];
|
|
28
|
+
command?: string;
|
|
29
|
+
/** The parts `command` was run as, when one invocation would exceed the shell's command-line limit. */
|
|
30
|
+
commands?: string[];
|
|
31
|
+
execution?: CommandMeasurement;
|
|
32
|
+
/** The rest of the repository's gate (lint, typecheck, check scripts), run before the tests. When one
|
|
33
|
+
* fails, the tests do not run and `execution` is that check's run (2026-10-29). */
|
|
34
|
+
checks?: CheckResult[];
|
|
35
|
+
commit_range?: {
|
|
36
|
+
base_sha: string;
|
|
37
|
+
head_sha: string;
|
|
38
|
+
source: ObservationCommitRange["source"];
|
|
39
|
+
merge_base_sha?: string;
|
|
40
|
+
};
|
|
41
|
+
snapshot: {
|
|
42
|
+
base_sha: string;
|
|
43
|
+
before_tree_sha: string;
|
|
44
|
+
after_base_sha?: string;
|
|
45
|
+
after_tree_sha?: string;
|
|
46
|
+
/** The verified files were not changed. New files the run wrote (`written_during_verification`) don't count. */
|
|
47
|
+
unchanged: boolean;
|
|
48
|
+
/** New, non-ignored files that appeared during the checks and tests, at most 20. */
|
|
49
|
+
written_during_verification?: string[];
|
|
50
|
+
/** Files that existed before the run and changed during it, at most 20. Their presence blocks the verdict. */
|
|
51
|
+
changed_during_verification?: SnapshotChange[];
|
|
52
|
+
};
|
|
53
|
+
analysis: {
|
|
54
|
+
status: "not_needed" | ObservationReport["status"];
|
|
55
|
+
stage?: ObservationReport["stage"];
|
|
56
|
+
mode?: ObservationReport["result"] extends infer T ? (T extends {
|
|
57
|
+
mode: infer M;
|
|
58
|
+
} ? M : never) : never;
|
|
59
|
+
fallback_reasons: string[];
|
|
60
|
+
error?: string;
|
|
61
|
+
/** Wall time of the analysis that chose the verification command. */
|
|
62
|
+
duration_ms?: number;
|
|
63
|
+
/** The graph's own confidence and the confidence after narrowing to this change. */
|
|
64
|
+
graph_confidence?: string;
|
|
65
|
+
effective_graph_confidence?: string;
|
|
66
|
+
};
|
|
67
|
+
required_actions: string[];
|
|
68
|
+
/** Present when a failed verification was rerun at the base commit (`--baseline-on-failure`). */
|
|
69
|
+
failure_baseline?: FailureBaseline;
|
|
70
|
+
/** Present only under `--policy enforce`. `applied` is true when the selected tests replaced the full suite. */
|
|
71
|
+
enforcement?: EnforcementDecision & {
|
|
72
|
+
applied: boolean;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
interface VerifyOptions {
|
|
76
|
+
repoPath: string;
|
|
77
|
+
env: Record<string, string | undefined>;
|
|
78
|
+
version: string;
|
|
79
|
+
engineSha?: string;
|
|
80
|
+
timeoutMs: number;
|
|
81
|
+
tailBytes: number;
|
|
82
|
+
redactPaths?: boolean;
|
|
83
|
+
/** Rerun a failed verification at the base commit to tell new failures from existing ones. */
|
|
84
|
+
baselineOnFailure?: boolean;
|
|
85
|
+
/** Run only the tests, not the gate's other checks (`--no-checks`). */
|
|
86
|
+
skipChecks?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface VerifyChangedOptions extends VerifyOptions {
|
|
89
|
+
}
|
|
90
|
+
export interface VerifyRangeOptions extends VerifyOptions {
|
|
91
|
+
baseOverride?: string;
|
|
92
|
+
headOverride?: string;
|
|
93
|
+
/** Opt-in enforce mode (docs/enforce-mode-01-plan.md). Absent means today's behaviour, unchanged. */
|
|
94
|
+
policy?: "enforce";
|
|
95
|
+
}
|
|
96
|
+
/** Verify exactly the staged, unstaged, and non-ignored untracked content currently on disk. */
|
|
97
|
+
export declare function verifyChanged(options: VerifyChangedOptions): Promise<VerificationReport>;
|
|
98
|
+
/** Verify a real commit range and bind the receipt to the clean commit that was actually executed. */
|
|
99
|
+
export declare function verifyRange(options: VerifyRangeOptions): Promise<VerificationReport>;
|
|
100
|
+
export declare function verificationExitCode(report: VerificationReport): number;
|
|
101
|
+
export declare function formatVerificationSummary(report: VerificationReport): string;
|
|
102
|
+
/** Shared executable plan for read-only agent selection and verification. */
|
|
103
|
+
export declare function executableSelection(repoPath: string, result: NonNullable<ObservationReport["result"]>): {
|
|
104
|
+
selection: "full" | "selected";
|
|
105
|
+
command: string | undefined;
|
|
106
|
+
commands: string[];
|
|
107
|
+
reason: string;
|
|
108
|
+
outsideSuite: number;
|
|
109
|
+
};
|
|
110
|
+
/** A test-script phase as a standalone command. `npm test` puts `node_modules/.bin` on PATH; outside
|
|
111
|
+
* it a repository-local runner such as tsx is reached the way selected TypeScript tests are. */
|
|
112
|
+
export declare function phaseCommand(phase: string): string;
|
|
113
|
+
export {};
|
|
@@ -2,11 +2,12 @@ import { mkdtempSync, rmSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { batchCommand, measureCommands } from "./command-batches.js";
|
|
5
|
-
import { compareWithBaseline } from "./failure-baseline.js";
|
|
5
|
+
import { checkAtBaseline, compareWithBaseline } from "./failure-baseline.js";
|
|
6
6
|
import { collectEnforcementContext, evaluateEnforcement } from "./enforce-policy.js";
|
|
7
7
|
import { inferFullCommand, inferSelectedCommand } from "./full-command.js";
|
|
8
8
|
import { plannedChecks, runChecks } from "./gate-checks.js";
|
|
9
9
|
import { makeGitRunner, observe } from "./observe.js";
|
|
10
|
+
import { selectedNodeTests, traceNodeTestFiles, unmatchedNodeTests, unstartedNodeTests } from "./selected-coverage.js";
|
|
10
11
|
import { captureWorkingTreeSnapshot, snapshotChanges } from "./working-tree.js";
|
|
11
12
|
export const VERIFICATION_SCHEMA = "diffci.verification.v1";
|
|
12
13
|
function receiptRange(range) {
|
|
@@ -116,12 +117,32 @@ async function executeWithPolicy(options, scope, before, observation, enforcemen
|
|
|
116
117
|
const checkBase = scope === "commit-range" ? range?.baseSha : before.baseSha;
|
|
117
118
|
const checkHead = scope === "commit-range" ? range?.headSha : before.commitSha;
|
|
118
119
|
const planned = options.skipChecks ? [] : plannedChecks(options.repoPath, checkBase && checkHead ? { baseSha: checkBase, headSha: checkHead } : undefined);
|
|
119
|
-
const
|
|
120
|
+
const checkBaseline = options.baselineOnFailure && checkBase && checkHead
|
|
121
|
+
? (check, remainingMs) => checkAtBaseline({ repoPath: options.repoPath, baseSha: checkBase, headSha: checkHead, command: check.command, timeoutMs: Math.max(remainingMs, 0) })
|
|
122
|
+
: undefined;
|
|
123
|
+
const checkRun = options.skipChecks ? undefined : runChecks(planned, { cwd: options.repoPath, timeoutMs: options.timeoutMs, tailBytes: options.tailBytes, baseline: checkBaseline });
|
|
120
124
|
const checks = checkRun?.results.length ? checkRun.results : undefined;
|
|
121
125
|
const failedCheck = checkRun?.failure?.check;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
// Checks that also fail at the base: still a failed verdict (required CI fails either way), but they
|
|
127
|
+
// no longer stop the run before the change's own failures.
|
|
128
|
+
const preexistingChecks = checkRun?.preexisting ?? [];
|
|
129
|
+
const preexistingNote = preexistingChecks.length
|
|
130
|
+
? `; gate check(s) ${preexistingChecks.map((check) => check.id).join(", ")} also fail at the base commit (already broken before this change)`
|
|
131
|
+
: "";
|
|
132
|
+
// Selected `node --test` files run under a probe that records which of them actually started.
|
|
133
|
+
const expectedNodeTests = selection === "selected" && result ? selectedNodeTests(command, result.selectedTests) : [];
|
|
134
|
+
const trace = expectedNodeTests.length && !checkRun?.failure ? traceNodeTestFiles(options.repoPath) : undefined;
|
|
135
|
+
let startedNodeTests;
|
|
136
|
+
let execution;
|
|
137
|
+
try {
|
|
138
|
+
execution = checkRun?.failure
|
|
139
|
+
? checkRun.failure.measurement
|
|
140
|
+
: measureCommands(commands, { cwd: options.repoPath, timeoutMs: Math.max(options.timeoutMs - (checkRun?.wallMs ?? 0), 0), tailBytes: options.tailBytes, env: trace?.env });
|
|
141
|
+
startedNodeTests = trace?.read();
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
trace?.dispose();
|
|
145
|
+
}
|
|
125
146
|
let after;
|
|
126
147
|
try {
|
|
127
148
|
after = captureWorkingTreeSnapshot(options.repoPath);
|
|
@@ -152,19 +173,33 @@ async function executeWithPolicy(options, scope, before, observation, enforcemen
|
|
|
152
173
|
const written = changes.filter((change) => change.status === "added").map((change) => change.path);
|
|
153
174
|
const altered = changes.filter((change) => change.status !== "added");
|
|
154
175
|
const unchanged = before.baseSha === after.baseSha && altered.length === 0;
|
|
155
|
-
const
|
|
156
|
-
const
|
|
176
|
+
const testsPassed = !failedCheck && execution.exitCode === 0 && !execution.timedOut;
|
|
177
|
+
const succeeded = testsPassed && preexistingChecks.length === 0;
|
|
178
|
+
// Every selected file contributes at least one test (node:test) or test file (vitest, jest) to the
|
|
179
|
+
// runner's summary; a smaller count means some selected tests never ran, which is not a pass.
|
|
180
|
+
const selectedCount = selection === "selected" && result ? result.selectedTests.length : 0;
|
|
181
|
+
// A count of 120 cannot show one missing file (2026-11-02); the probe's record of started files can.
|
|
182
|
+
const unstarted = succeeded ? unstartedNodeTests(expectedNodeTests, startedNodeTests) : [];
|
|
183
|
+
const undercounted = succeeded && execution.runnerTestCount !== undefined && execution.runnerTestCount < selectedCount;
|
|
184
|
+
const unexecuted = unstarted.length > 0 || undercounted;
|
|
185
|
+
const verification = !unchanged || unexecuted ? "blocked" : succeeded ? "passed" : "failed";
|
|
157
186
|
const finalReason = !unchanged
|
|
158
187
|
? before.baseSha !== after.baseSha
|
|
159
188
|
? "HEAD moved while verification was running; rerun DiffCI for the new snapshot"
|
|
160
189
|
: `the working tree changed while verification was running (${altered.slice(0, 5).map((change) => `${change.status} ${change.path}`).join(", ")}${altered.length > 5 ? `, ${altered.length - 5} more` : ""}); rerun DiffCI for the new snapshot`
|
|
161
|
-
:
|
|
162
|
-
?
|
|
163
|
-
:
|
|
164
|
-
? `
|
|
165
|
-
:
|
|
166
|
-
?
|
|
167
|
-
:
|
|
190
|
+
: unstarted.length
|
|
191
|
+
? `node --test never started ${unstarted.length} selected test file(s), such as ${unstarted[0]}, so the selection did not run as written; run the full test command instead`
|
|
192
|
+
: unexecuted
|
|
193
|
+
? `the runner reported ${String(execution.runnerTestCount)} test(s) for ${selectedCount} selected test file(s), so some selected tests did not run; run the full test command instead`
|
|
194
|
+
: succeeded
|
|
195
|
+
? checks ? `${reason}; ${checkSummary(checks)}` : reason
|
|
196
|
+
: failedCheck
|
|
197
|
+
? `gate check ${failedCheck.id} ${failedCheck.status === "timed_out" ? "timed out" : `failed with exit code ${String(failedCheck.exit_code)}`}; tests were not run (${failedCheck.command})`
|
|
198
|
+
: execution.timedOut
|
|
199
|
+
? `verification timed out after ${options.timeoutMs}ms${preexistingNote}`
|
|
200
|
+
: testsPassed
|
|
201
|
+
? `${preexistingChecks.length} gate check(s) failed that also fail at the base commit; nothing this change introduced failed (${preexistingChecks.map((check) => check.id).join(", ")})`
|
|
202
|
+
: `verification command failed with exit code ${String(execution.exitCode)}${preexistingNote}`;
|
|
168
203
|
const baselineSha = scope === "commit-range" ? range?.baseSha : before.baseSha;
|
|
169
204
|
const failureBaseline = verification === "failed" && !failedCheck && !execution.timedOut && options.baselineOnFailure && baselineSha
|
|
170
205
|
? compareWithBaseline({ repoPath: options.repoPath, baseSha: baselineSha, headSha: scope === "commit-range" ? before.baseSha : before.commitSha, commands, headFailures: execution.failingTests ?? [], timeoutMs: options.timeoutMs })
|
|
@@ -321,7 +356,7 @@ export function formatVerificationSummary(report) {
|
|
|
321
356
|
if (written?.length)
|
|
322
357
|
lines.push(` written by the run (not in .gitignore): ${written.slice(0, 5).join(", ")}${written.length > 5 ? ", ..." : ""}`);
|
|
323
358
|
if (report.checks)
|
|
324
|
-
lines.push(` checks: ${report.checks.map((check) => `${check.id} ${check.status}`).join(", ")}`);
|
|
359
|
+
lines.push(` checks: ${report.checks.map((check) => `${check.id} ${check.status}${check.baseline?.status === "preexisting" ? " (also fails at base)" : ""}`).join(", ")}`);
|
|
325
360
|
if (report.command)
|
|
326
361
|
lines.push(` command: ${report.command}`);
|
|
327
362
|
// A blocked push has to say what broke, not only that something did (2026-10-30 demo rehearsal: the
|
|
@@ -354,7 +389,12 @@ export function executableSelection(repoPath, result) {
|
|
|
354
389
|
let reason;
|
|
355
390
|
let primaryPhases = [];
|
|
356
391
|
if (result.mode === "SELECTIVE" && !result.commandRefusalReason && result.proposedCommands.length === 1) {
|
|
357
|
-
const
|
|
392
|
+
const inferred = inferSelectedCommand(repoPath, result.proposedCommands[0], result.selectedTests);
|
|
393
|
+
// A selected file the runner's glob would not match never runs, and the rest still pass (2026-11-01).
|
|
394
|
+
const unmatched = inferred.command ? unmatchedNodeTests(inferred.command, result.selectedTests) : [];
|
|
395
|
+
const selected = unmatched.length
|
|
396
|
+
? { reason: `node --test would not match ${unmatched.length} selected test file(s), such as ${unmatched[0]}` }
|
|
397
|
+
: inferred;
|
|
358
398
|
const phases = result.testPhases ?? [];
|
|
359
399
|
if (selected.command && phases.length) {
|
|
360
400
|
// The selection covers some changed files only through these test-script phases, so they run
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { WorkflowFinding } from "./report.js";
|
|
2
|
+
export interface WorkflowGuardOptions {
|
|
3
|
+
/**
|
|
4
|
+
* How a step is recognised as the DiffCI action. Defaults to any `uses:` mentioning "diffci",
|
|
5
|
+
* which covers `DiffCI/core@sha`, a local `./.github/actions/diffci`, and a future npm-published
|
|
6
|
+
* action alike.
|
|
7
|
+
*/
|
|
8
|
+
actionPattern?: RegExp;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkflowGuardResult {
|
|
11
|
+
/** "<workflow file>#<job id>" for every job that runs the DiffCI action. */
|
|
12
|
+
observerJobs: string[];
|
|
13
|
+
findings: WorkflowFinding[];
|
|
14
|
+
/** Workflow files that were read. Zero means nothing was checked, which is not a pass. */
|
|
15
|
+
workflowsScanned: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function auditWorkflows(repoPath: string, options?: WorkflowGuardOptions): WorkflowGuardResult;
|
|
18
|
+
/**
|
|
19
|
+
* Enforce mode audit (docs/enforce-mode-01-plan.md, step 4).
|
|
20
|
+
*
|
|
21
|
+
* The non-interference audit above proves an observer cannot change CI. Enforce mode deliberately does
|
|
22
|
+
* change it - pull requests stop running the full suite - so it needs the opposite guarantees:
|
|
23
|
+
*
|
|
24
|
+
* 1. There is an enforcing job, and it is a real gate (not continue-on-error, nothing like the dry run).
|
|
25
|
+
* 2. Its kill switch is wired to the repository variable. A hardcoded "on" would mean flipping the
|
|
26
|
+
* variable no longer stops enforcement, and the plan's main rollback silently stops working.
|
|
27
|
+
* 3. The full suite still runs on every push to main. That run is the safety net and the ground truth
|
|
28
|
+
* the miss detector reads; an installation without it skips tests with nothing checking the skips.
|
|
29
|
+
*
|
|
30
|
+
* "Cannot tell" is a finding, never a pass: an `if:` this module cannot evaluate, or a full command it
|
|
31
|
+
* cannot infer, is BLOCKING, because the whole point of the audit is to prove (3) rather than assume it.
|
|
32
|
+
*/
|
|
33
|
+
export interface EnforceAuditOptions {
|
|
34
|
+
/** The branch whose pushes must run the full suite. */
|
|
35
|
+
defaultBranch?: string;
|
|
36
|
+
/** Overrides the full command inferred from the repository (`npm test` and its equivalents). */
|
|
37
|
+
fullCommand?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface EnforceAuditResult {
|
|
40
|
+
/** "<workflow file>#<job id>" for every job that enforces (runs `verify --policy enforce` as a gate). */
|
|
41
|
+
enforceJobs: string[];
|
|
42
|
+
/** "<workflow file>#<job id>" for every job that runs the full suite on push to the default branch. */
|
|
43
|
+
fullSuiteJobs: string[];
|
|
44
|
+
/** The command recognised as the full suite, or undefined when none could be inferred. */
|
|
45
|
+
fullCommand?: string;
|
|
46
|
+
findings: WorkflowFinding[];
|
|
47
|
+
workflowsScanned: string[];
|
|
48
|
+
}
|
|
49
|
+
type Truth = "TRUE" | "FALSE" | "UNKNOWN";
|
|
50
|
+
/**
|
|
51
|
+
* Evaluates an `if:` for a push to `branch` with Kleene logic. `vars.*`, `inputs.*` and anything else
|
|
52
|
+
* not fixed by "this is a push to the default branch" are UNKNOWN, so a condition only counts as TRUE
|
|
53
|
+
* when it holds whatever those are. Unsupported syntax is UNKNOWN as well, never FALSE or TRUE.
|
|
54
|
+
*/
|
|
55
|
+
export declare function evaluatePushCondition(expression: string, branch: string): Truth;
|
|
56
|
+
export declare function auditEnforceWorkflows(repoPath: string, options?: EnforceAuditOptions): EnforceAuditResult;
|
|
57
|
+
/** True when nothing found would let the observation change what the rest of CI does. */
|
|
58
|
+
export declare function isNonInterfering(result: Pick<WorkflowGuardResult, "findings">): boolean;
|
|
59
|
+
export {};
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
28
28
|
import { join } from "node:path";
|
|
29
29
|
import YAML from "yaml";
|
|
30
|
+
import { inferFullCommand } from "./full-command.js";
|
|
30
31
|
/** Steps a dedicated observation job may legitimately contain besides the DiffCI action itself. */
|
|
31
32
|
const ALLOWED_STEP_ACTIONS = [
|
|
32
33
|
"actions/checkout",
|
|
@@ -102,11 +103,25 @@ function runInvokesDiffCiVerification(run) {
|
|
|
102
103
|
* product generates keeps matching: `npm install … @diffci/observer@1.4.2`,
|
|
103
104
|
* `"${RUNNER_TEMP}/diffci/node_modules/.bin/diffci" observe`, `docker run … <image>@sha256:… observe`,
|
|
104
105
|
* `npx @diffci/observer observe` all name DiffCI outside any URL.
|
|
106
|
+
*
|
|
107
|
+
* The same holds for four other kinds of data (2026-11-02): plain `echo`/`printf` messages, `gh api`
|
|
108
|
+
* fields and `repos/...` paths, SCREAMING_SNAKE environment variable names, and `.json` paths, which
|
|
109
|
+
* are read rather than run. Core's own release workflow mentions `DIFFCI_PRODUCT_DISPATCH_TOKEN` in an
|
|
110
|
+
* error message, dispatches `-f event_type=diffci-core-release` to `repos/DiffCI/DiffCI.com`, and reads
|
|
111
|
+
* `./packages/diffci-cli/package.json`, and `check` reported both of those jobs as badly installed
|
|
112
|
+
* observers. An echo line with a substitution, pipe or command separator is kept, because it can run
|
|
113
|
+
* something.
|
|
105
114
|
*/
|
|
106
115
|
function commandText(run) {
|
|
107
116
|
return run
|
|
108
117
|
.split("\n")
|
|
109
118
|
.map((line) => line.replace(/(^|\s)#.*$/, "$1").replace(/[a-z][a-z0-9+.-]*:\/\/\S+/gi, " "))
|
|
119
|
+
.map((line) => (/^\s*(?:echo|printf)\s/.test(line) && !/\$\(|`|\||&&|;/.test(line) ? "" : line))
|
|
120
|
+
.map((line) => line
|
|
121
|
+
.replace(/(^|\s)(?:-[fF]|--(?:raw-)?field)\s+(?:"[^"]*"|'[^']*'|\S+)/g, "$1")
|
|
122
|
+
.replace(/(^|[\s"'])repos\/[^\s"']+/g, "$1")
|
|
123
|
+
.replace(/\$?\{?\b[A-Z][A-Z0-9]*_[A-Z0-9_]+\b\}?/g, " ")
|
|
124
|
+
.replace(/[^\s"'()]*\.json\b/g, " "))
|
|
110
125
|
// A literal npm registry tag removal neither installs nor invokes the observer. Match the
|
|
111
126
|
// entire line, with only a literal `|| true` allowed, so appended observer commands and shell
|
|
112
127
|
// substitutions still take the conservative inspection path. Other script lines remain intact.
|
|
@@ -307,6 +322,258 @@ export function auditWorkflows(repoPath, options = {}) {
|
|
|
307
322
|
}
|
|
308
323
|
return { observerJobs, findings, workflowsScanned };
|
|
309
324
|
}
|
|
325
|
+
/** Where repository-wide findings (no single workflow to blame) point. */
|
|
326
|
+
const WORKFLOWS_DIR = join(".github", "workflows");
|
|
327
|
+
const ENFORCE_VARIABLE_EXPRESSION = /^\$\{\{\s*vars\.DIFFCI_ENFORCE\s*\}\}$/;
|
|
328
|
+
function runInvokesEnforcePolicy(run) {
|
|
329
|
+
return runInvokesDiffCiVerification(run) && /--policy[=\s]+["']?enforce\b/.test(commandText(run));
|
|
330
|
+
}
|
|
331
|
+
/** `npm run test` and `npm test` are the same command; so are the pnpm/yarn/bun pairs. */
|
|
332
|
+
function normalizeTestCommand(command) {
|
|
333
|
+
return command.trim().replace(/\s+/g, " ").replace(/^(npm|pnpm|yarn|bun) run test$/, "$1 test");
|
|
334
|
+
}
|
|
335
|
+
function runInvokesFullCommand(run, fullCommand) {
|
|
336
|
+
const target = normalizeTestCommand(fullCommand);
|
|
337
|
+
return commandText(run).split("\n").some((line) => normalizeTestCommand(line) === target);
|
|
338
|
+
}
|
|
339
|
+
function globToRegExp(glob) {
|
|
340
|
+
const pattern = glob
|
|
341
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
342
|
+
.replace(/\*\*/g, "\u0000")
|
|
343
|
+
.replace(/\*/g, "[^/]*")
|
|
344
|
+
.replace(/\?/g, "[^/]")
|
|
345
|
+
.replace(/\u0000/g, ".*");
|
|
346
|
+
return new RegExp(`^${pattern}$`);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Does this workflow run on every push to `branch`? A `paths` or `paths-ignore` filter means some pushes
|
|
350
|
+
* do not trigger it, and those are exactly the pushes nothing would check, so it does not count.
|
|
351
|
+
*/
|
|
352
|
+
function triggersOnEveryPush(on, branch) {
|
|
353
|
+
if (on === "push")
|
|
354
|
+
return { ok: true };
|
|
355
|
+
if (Array.isArray(on))
|
|
356
|
+
return { ok: on.includes("push") };
|
|
357
|
+
if (!isRecord(on) || !("push" in on))
|
|
358
|
+
return { ok: false };
|
|
359
|
+
const push = on.push;
|
|
360
|
+
if (push === null || push === undefined)
|
|
361
|
+
return { ok: true };
|
|
362
|
+
if (!isRecord(push))
|
|
363
|
+
return { ok: false };
|
|
364
|
+
if (push.paths !== undefined || push["paths-ignore"] !== undefined) {
|
|
365
|
+
return { ok: false, reason: "its push trigger has a paths filter, so some pushes do not run it" };
|
|
366
|
+
}
|
|
367
|
+
const branches = asArray(push.branches).filter((value) => typeof value === "string");
|
|
368
|
+
const ignored = asArray(push["branches-ignore"]).filter((value) => typeof value === "string");
|
|
369
|
+
if (ignored.some((glob) => globToRegExp(glob).test(branch)))
|
|
370
|
+
return { ok: false };
|
|
371
|
+
if (push.branches === undefined) {
|
|
372
|
+
// `tags:` alone restricts push to tags; branches are then not covered.
|
|
373
|
+
return { ok: push.tags === undefined && push["tags-ignore"] === undefined };
|
|
374
|
+
}
|
|
375
|
+
let included = false;
|
|
376
|
+
for (const glob of branches) {
|
|
377
|
+
if (glob.startsWith("!")) {
|
|
378
|
+
if (globToRegExp(glob.slice(1)).test(branch))
|
|
379
|
+
included = false;
|
|
380
|
+
}
|
|
381
|
+
else if (globToRegExp(glob).test(branch)) {
|
|
382
|
+
included = true;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return { ok: included };
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Evaluates an `if:` for a push to `branch` with Kleene logic. `vars.*`, `inputs.*` and anything else
|
|
389
|
+
* not fixed by "this is a push to the default branch" are UNKNOWN, so a condition only counts as TRUE
|
|
390
|
+
* when it holds whatever those are. Unsupported syntax is UNKNOWN as well, never FALSE or TRUE.
|
|
391
|
+
*/
|
|
392
|
+
export function evaluatePushCondition(expression, branch) {
|
|
393
|
+
const source = expression.trim().replace(/^\$\{\{\s*|\s*\}\}$/g, "").trim();
|
|
394
|
+
const known = {
|
|
395
|
+
"github.event_name": "push",
|
|
396
|
+
"github.ref": `refs/heads/${branch}`,
|
|
397
|
+
"github.ref_name": branch,
|
|
398
|
+
"github.ref_type": "branch",
|
|
399
|
+
};
|
|
400
|
+
const tokens = source.match(/'(?:[^']|'')*'|"[^"]*"|&&|\|\||==|!=|!|\(|\)|[A-Za-z_][\w.-]*\(\)|[A-Za-z_][\w.-]*/g);
|
|
401
|
+
if (!tokens || tokens.join("").replace(/\s/g, "") !== source.replace(/\s/g, ""))
|
|
402
|
+
return "UNKNOWN";
|
|
403
|
+
let index = 0;
|
|
404
|
+
const peek = () => tokens[index];
|
|
405
|
+
const truth = (value) => (!value.known ? "UNKNOWN" : value.value === false || value.value === "" ? "FALSE" : "TRUE");
|
|
406
|
+
const fromTruth = (value) => (value === "UNKNOWN" ? { known: false } : { known: true, value: value === "TRUE" });
|
|
407
|
+
const operand = () => {
|
|
408
|
+
const token = tokens[index++];
|
|
409
|
+
if (token === undefined)
|
|
410
|
+
return { known: false };
|
|
411
|
+
if (token === "(") {
|
|
412
|
+
const inner = or();
|
|
413
|
+
if (tokens[index++] !== ")")
|
|
414
|
+
return { known: false };
|
|
415
|
+
return fromTruth(inner);
|
|
416
|
+
}
|
|
417
|
+
if (token.startsWith("'"))
|
|
418
|
+
return { known: true, value: token.slice(1, -1).replace(/''/g, "'") };
|
|
419
|
+
if (token.startsWith('"'))
|
|
420
|
+
return { known: true, value: token.slice(1, -1) };
|
|
421
|
+
if (token === "true" || token === "false")
|
|
422
|
+
return { known: true, value: token === "true" };
|
|
423
|
+
if (token === "always()" || token === "success()")
|
|
424
|
+
return { known: true, value: true };
|
|
425
|
+
if (token === "failure()" || token === "cancelled()")
|
|
426
|
+
return { known: true, value: false };
|
|
427
|
+
if (token in known)
|
|
428
|
+
return { known: true, value: known[token] };
|
|
429
|
+
return { known: false };
|
|
430
|
+
};
|
|
431
|
+
const comparison = () => {
|
|
432
|
+
if (peek() === "!") {
|
|
433
|
+
index++;
|
|
434
|
+
const inner = comparison();
|
|
435
|
+
return inner === "UNKNOWN" ? "UNKNOWN" : inner === "TRUE" ? "FALSE" : "TRUE";
|
|
436
|
+
}
|
|
437
|
+
const left = operand();
|
|
438
|
+
const operator = peek();
|
|
439
|
+
if (operator !== "==" && operator !== "!=")
|
|
440
|
+
return truth(left);
|
|
441
|
+
index++;
|
|
442
|
+
const right = operand();
|
|
443
|
+
if (!left.known || !right.known)
|
|
444
|
+
return "UNKNOWN";
|
|
445
|
+
// GitHub compares strings case-insensitively.
|
|
446
|
+
const equal = String(left.value).toLowerCase() === String(right.value).toLowerCase();
|
|
447
|
+
return (operator === "==") === equal ? "TRUE" : "FALSE";
|
|
448
|
+
};
|
|
449
|
+
const and = () => {
|
|
450
|
+
let result = comparison();
|
|
451
|
+
while (peek() === "&&") {
|
|
452
|
+
index++;
|
|
453
|
+
const next = comparison();
|
|
454
|
+
result = result === "FALSE" || next === "FALSE" ? "FALSE" : result === "UNKNOWN" || next === "UNKNOWN" ? "UNKNOWN" : "TRUE";
|
|
455
|
+
}
|
|
456
|
+
return result;
|
|
457
|
+
};
|
|
458
|
+
function or() {
|
|
459
|
+
let result = and();
|
|
460
|
+
while (peek() === "||") {
|
|
461
|
+
index++;
|
|
462
|
+
const next = and();
|
|
463
|
+
result = result === "TRUE" || next === "TRUE" ? "TRUE" : result === "UNKNOWN" || next === "UNKNOWN" ? "UNKNOWN" : "FALSE";
|
|
464
|
+
}
|
|
465
|
+
return result;
|
|
466
|
+
}
|
|
467
|
+
const result = or();
|
|
468
|
+
return index === tokens.length ? result : "UNKNOWN";
|
|
469
|
+
}
|
|
470
|
+
function conditionHolds(condition, branch) {
|
|
471
|
+
if (condition === undefined)
|
|
472
|
+
return "TRUE";
|
|
473
|
+
if (typeof condition === "boolean")
|
|
474
|
+
return condition ? "TRUE" : "FALSE";
|
|
475
|
+
if (typeof condition !== "string")
|
|
476
|
+
return "UNKNOWN";
|
|
477
|
+
return evaluatePushCondition(condition, branch);
|
|
478
|
+
}
|
|
479
|
+
export function auditEnforceWorkflows(repoPath, options = {}) {
|
|
480
|
+
const branch = options.defaultBranch ?? "main";
|
|
481
|
+
const findings = [];
|
|
482
|
+
const enforceJobs = [];
|
|
483
|
+
const fullSuiteJobs = [];
|
|
484
|
+
const workflowsScanned = [];
|
|
485
|
+
const unprovable = [];
|
|
486
|
+
const inferred = options.fullCommand ? { command: options.fullCommand, reason: "--full-command" } : inferFullCommand(repoPath);
|
|
487
|
+
const fullCommand = inferred.command;
|
|
488
|
+
if (!fullCommand) {
|
|
489
|
+
findings.push({
|
|
490
|
+
severity: "BLOCKING",
|
|
491
|
+
code: "FULL_COMMAND_UNKNOWN",
|
|
492
|
+
workflow: WORKFLOWS_DIR,
|
|
493
|
+
message: `could not infer the full test command (${inferred.reason}), so it cannot be shown that the full suite still runs on ${branch}. Pass --full-command.`,
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
for (const relativePath of listWorkflowFiles(repoPath)) {
|
|
497
|
+
let document;
|
|
498
|
+
try {
|
|
499
|
+
document = YAML.parse(readFileSync(join(repoPath, relativePath), "utf8"));
|
|
500
|
+
}
|
|
501
|
+
catch {
|
|
502
|
+
// The non-interference audit reports unparseable workflows; here they simply prove nothing.
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
workflowsScanned.push(relativePath);
|
|
506
|
+
if (!isRecord(document))
|
|
507
|
+
continue;
|
|
508
|
+
const jobs = isRecord(document.jobs) ? document.jobs : {};
|
|
509
|
+
const workflowEnv = isRecord(document.env) ? document.env : {};
|
|
510
|
+
const trigger = triggersOnEveryPush(document.on, branch);
|
|
511
|
+
for (const [jobId, rawJob] of Object.entries(jobs)) {
|
|
512
|
+
if (!isRecord(rawJob))
|
|
513
|
+
continue;
|
|
514
|
+
const steps = asArray(rawJob.steps).filter(isRecord);
|
|
515
|
+
const where = `${relativePath}#${jobId}`;
|
|
516
|
+
// 1 + 2. Enforcing jobs. A continue-on-error job is a dry run whatever it calls itself.
|
|
517
|
+
const enforceSteps = steps.filter((step) => typeof step.run === "string" && runInvokesEnforcePolicy(step.run));
|
|
518
|
+
if (enforceSteps.length > 0 && rawJob["continue-on-error"] !== true) {
|
|
519
|
+
enforceJobs.push(where);
|
|
520
|
+
const jobEnv = isRecord(rawJob.env) ? rawJob.env : {};
|
|
521
|
+
for (const step of enforceSteps) {
|
|
522
|
+
const stepEnv = isRecord(step.env) ? step.env : {};
|
|
523
|
+
const value = stepEnv.DIFFCI_ENFORCE ?? jobEnv.DIFFCI_ENFORCE ?? workflowEnv.DIFFCI_ENFORCE;
|
|
524
|
+
if (typeof value !== "string" || !ENFORCE_VARIABLE_EXPRESSION.test(value.trim())) {
|
|
525
|
+
findings.push({
|
|
526
|
+
severity: "BLOCKING",
|
|
527
|
+
code: "ENFORCE_KILL_SWITCH_NOT_WIRED",
|
|
528
|
+
message: `job "${jobId}" runs verify --policy enforce with DIFFCI_ENFORCE ${value === undefined ? "unset" : `set to ${JSON.stringify(value)}`} - set it to \${{ vars.DIFFCI_ENFORCE }} so turning the repository variable off stops enforcement.`,
|
|
529
|
+
workflow: relativePath,
|
|
530
|
+
job: jobId,
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
// 3. The full suite on push to the default branch.
|
|
536
|
+
if (!fullCommand || !trigger.ok)
|
|
537
|
+
continue;
|
|
538
|
+
const jobCondition = conditionHolds(rawJob.if, branch);
|
|
539
|
+
if (jobCondition === "FALSE")
|
|
540
|
+
continue;
|
|
541
|
+
for (const step of steps) {
|
|
542
|
+
if (typeof step.run !== "string" || !runInvokesFullCommand(step.run, fullCommand))
|
|
543
|
+
continue;
|
|
544
|
+
if (step["working-directory"] !== undefined && step["working-directory"] !== ".")
|
|
545
|
+
continue;
|
|
546
|
+
const stepCondition = conditionHolds(step.if, branch);
|
|
547
|
+
if (jobCondition === "TRUE" && stepCondition === "TRUE") {
|
|
548
|
+
fullSuiteJobs.push(where);
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
if (stepCondition !== "FALSE")
|
|
552
|
+
unprovable.push(where);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (enforceJobs.length === 0) {
|
|
557
|
+
findings.push({
|
|
558
|
+
severity: "BLOCKING",
|
|
559
|
+
code: "ENFORCE_JOB_MISSING",
|
|
560
|
+
workflow: WORKFLOWS_DIR,
|
|
561
|
+
message: "no job runs `diffci verify --policy enforce` as a gate. A continue-on-error job is a dry run and does not count.",
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
if (fullCommand && fullSuiteJobs.length === 0) {
|
|
565
|
+
const detail = unprovable.length > 0
|
|
566
|
+
? ` ${unprovable.join(", ")} might, but its if: could not be shown to hold for every push to ${branch}.`
|
|
567
|
+
: "";
|
|
568
|
+
findings.push({
|
|
569
|
+
severity: "BLOCKING",
|
|
570
|
+
code: "FULL_SUITE_NOT_ON_DEFAULT_BRANCH",
|
|
571
|
+
workflow: WORKFLOWS_DIR,
|
|
572
|
+
message: `no job provably runs "${fullCommand}" on every push to ${branch}.${detail} Enforce mode skips tests on pull requests; without that run nothing checks what was skipped.`,
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
return { enforceJobs, fullSuiteJobs, fullCommand, findings, workflowsScanned };
|
|
576
|
+
}
|
|
310
577
|
/** True when nothing found would let the observation change what the rest of CI does. */
|
|
311
578
|
export function isNonInterfering(result) {
|
|
312
579
|
return result.findings.every((finding) => finding.severity !== "BLOCKING");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** GitHub-hosted runner and Node 24 action pins shared by every workflow the CLI generates. */
|
|
2
|
+
export declare const RUNNER = "ubuntu-26.04";
|
|
3
|
+
export declare const CHECKOUT_SHA = "3d3c42e5aac5ba805825da76410c181273ba90b1";
|
|
4
|
+
export declare const SETUP_NODE_SHA = "820762786026740c76f36085b0efc47a31fe5020";
|
|
5
|
+
export declare const UPLOAD_ARTIFACT_SHA = "043fb46d1a93c77aae656e7c1c64a875d1fc6a0a";
|
|
6
|
+
export declare function diffciWorkflow(version: string): string;
|
|
7
|
+
export declare function diffciVerificationWorkflow(version: string): string;
|
|
8
|
+
export declare function buildPilotWorkflow(version: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface WorkingTreeSnapshot {
|
|
2
|
+
/** The real checked-out commit this snapshot is relative to. */
|
|
3
|
+
baseSha: string;
|
|
4
|
+
/** Git tree identity covering tracked, staged, unstaged, and non-ignored untracked files. */
|
|
5
|
+
treeSha: string;
|
|
6
|
+
/** Unreachable commit used only so the existing commit-range analyzer can inspect the tree. */
|
|
7
|
+
commitSha: string;
|
|
8
|
+
changed: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** One path that differs between two snapshots. A rename is a deletion plus an addition. */
|
|
11
|
+
export interface SnapshotChange {
|
|
12
|
+
path: string;
|
|
13
|
+
status: "added" | "modified" | "deleted";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Materialize the current worktree as a Git tree without changing the user's index or checkout.
|
|
17
|
+
*
|
|
18
|
+
* A temporary index begins at HEAD and stages the working tree into that isolated index. Git therefore
|
|
19
|
+
* applies the repository's normal ignore rules, executable-bit handling, symlink handling, and clean
|
|
20
|
+
* filters, while the real index and every source file stay untouched. The resulting tree SHA is a
|
|
21
|
+
* content-addressed verification identity. The synthetic commit is intentionally unreachable and is
|
|
22
|
+
* used only by DiffCI's existing commit-to-commit analyzer.
|
|
23
|
+
*/
|
|
24
|
+
export declare function captureWorkingTreeSnapshot(repoPathInput: string): WorkingTreeSnapshot;
|
|
25
|
+
/** The paths that differ between two snapshot trees of the same repository. */
|
|
26
|
+
export declare function snapshotChanges(repoPathInput: string, beforeTreeSha: string, afterTreeSha: string): SnapshotChange[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure classification (from raw evidence) and normalized fingerprinting (Part 1/3). Deliberately does
|
|
3
|
+
* NOT hash raw log text - timestamps, absolute paths, container ids, and incidental byte offsets would
|
|
4
|
+
* make two occurrences of the exact same underlying failure look different. Every normalization step
|
|
5
|
+
* below strips or generalizes exactly one such source of incidental variance; the corpus of patterns is
|
|
6
|
+
* intentionally small and explicit rather than a black-box regex pile, so a wrong classification is easy
|
|
7
|
+
* to find and fix by reading this file.
|
|
8
|
+
*/
|
|
9
|
+
import type { FailureClass } from "./taxonomy.js";
|
|
10
|
+
export interface FailureEvidence {
|
|
11
|
+
jobName: string;
|
|
12
|
+
stepName?: string;
|
|
13
|
+
command?: string;
|
|
14
|
+
errorText: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function classifyFailureFromEvidence(evidence: FailureEvidence): FailureClass;
|
|
17
|
+
/**
|
|
18
|
+
* failure_fingerprint (Part 3): failureClass + job/step class + a normalized error signature + (when
|
|
19
|
+
* known) the specific failing test/module identifier - deliberately NOT the raw log. Two occurrences of
|
|
20
|
+
* "the same" failure (identical error class, same test, same normalized message) produce the identical
|
|
21
|
+
* fingerprint even if timestamps/paths/durations differ between the two CI runs.
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeFailureFingerprint(input: {
|
|
24
|
+
failureClass: FailureClass;
|
|
25
|
+
jobName: string;
|
|
26
|
+
stepName?: string;
|
|
27
|
+
failingTest?: string;
|
|
28
|
+
errorText: string;
|
|
29
|
+
}): string;
|