@vaultcompass/conductor 0.11.0 → 0.13.0

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.
@@ -18,8 +18,8 @@ import { mkdirSync, realpathSync, writeFileSync } from 'node:fs';
18
18
  import path from 'node:path';
19
19
  import { realPathInside, runGit } from './git.js';
20
20
  import { normalizeOsvScanner } from './normalize.js';
21
- import { ABSENT_ON_BASE, baseReader } from './osv-coverage.js';
22
- import { osvLockfileKind } from './products.js';
21
+ import { ABSENT_ON_BASE, baseReader, packageCounts } from './osv-coverage.js';
22
+ import { osvLockfileKind, sameOsvFamily } from './products.js';
23
23
  import { checkRequirementsPins } from './requirements-pin.js';
24
24
  import { readFileAtRefBytes, treeEntryAt } from './trust-base.js';
25
25
  /** The comparison key: advisory id, ecosystem, package, installed version, lockfile path. */
@@ -148,6 +148,142 @@ export function comparisonFailed(args, reason) {
148
148
  diagnostics: unavailableNotes(unavailable),
149
149
  };
150
150
  }
151
+ /**
152
+ * Whether `file` is a regular file (mode 100644 or 100755, stage 0) in the
153
+ * head's index: the listing the gate's handed files come from (`git
154
+ * ls-files`). A symbolic link (120000), a submodule, a conflicted or missing
155
+ * entry, and an index git cannot read are all false (fail closed). The path
156
+ * is passed as a literal pathspec, so no character in it is a glob.
157
+ */
158
+ export function regularInHeadIndex(repoRoot, file) {
159
+ const out = runGit(repoRoot, ['ls-files', '--stage', '-z', '--', `:(literal)${file}`]);
160
+ if (out.error !== undefined || out.status !== 0) {
161
+ return false;
162
+ }
163
+ const entries = out.stdout.split('\0').filter((entry) => entry !== '');
164
+ if (entries.length !== 1) {
165
+ return false;
166
+ }
167
+ const match = /^(\d{6}) [0-9a-f]+ (\d)\t(.*)$/s.exec(entries[0]);
168
+ return (match !== null &&
169
+ (match[1] === '100644' || match[1] === '100755') &&
170
+ match[2] === '0' &&
171
+ match[3] === file);
172
+ }
173
+ /**
174
+ * The emptied-lockfile base check (design
175
+ * docs/superpowers/specs/2026-10-18-emptied-lockfile-under-trust-base.md,
176
+ * audit 2026-10-18 N1). On a decided trust base, a handed lockfile that read
177
+ * no packages at the head, and a base lockfile the head deleted or moved,
178
+ * is copied from the base and osv-scanner is run once on those copies; a
179
+ * copy with packages means the head removed what the gate judges. A removed
180
+ * file is cleared only by a head-handed lockfile in the SAME directory that
181
+ * read packages, is not a requirements file, is absent from the base tree,
182
+ * is of the removed file's ecosystem family, and is a regular file in the
183
+ * head's index (a migration, say npm to pnpm, beside the same manifest).
184
+ *
185
+ * FAIL CLOSED, unlike compareWithBase, whose labels only ever move toward
186
+ * introduced. This check exists only to stop a head from removing what the
187
+ * gate judges, so anything that keeps it from clearing the head (a base
188
+ * copy that cannot be read, an asymmetric command line, a base run that
189
+ * fails, times out or prints no count for a copy) is a failure the caller
190
+ * turns into could-not-run. Requirements files are not checked (known-open).
191
+ */
192
+ export function checkEmptiedAgainstBase(args) {
193
+ const baseDir = path.join(args.workDir, 'osv-base', 'emptied');
194
+ const removed = new Set(args.removed);
195
+ const candidates = [...new Set([...args.emptied, ...args.removed])].filter((file) => osvLockfileKind(path.posix.basename(file)) !== 'requirements');
196
+ const copies = [];
197
+ const copied = [];
198
+ for (const file of candidates) {
199
+ const read = readFileAtRefBytes(args.repoRoot, args.ref, file);
200
+ if (read.kind === 'absent') {
201
+ continue;
202
+ }
203
+ if (read.kind === 'error') {
204
+ return { kind: 'unverified', detail: `the base copy of ${file} cannot be read (${read.detail})` };
205
+ }
206
+ if (realPathInside(args.repoRoot, args.workDir)) {
207
+ return {
208
+ kind: 'unverified',
209
+ detail: 'the temporary directory is inside the repository, so no base copy can be kept outside the ' +
210
+ 'tree being judged',
211
+ };
212
+ }
213
+ try {
214
+ copies.push(placeCopy(baseDir, file, read.bytes));
215
+ }
216
+ catch (err) {
217
+ return { kind: 'unverified', detail: err instanceof Error ? err.message : String(err) };
218
+ }
219
+ copied.push(file);
220
+ }
221
+ if (copies.length === 0) {
222
+ return { kind: 'clear' };
223
+ }
224
+ const baseArgv = args.baseArgv(copies);
225
+ const headRest = args.headArgv === null ? null : withoutLockfiles(args.headArgv);
226
+ const baseRest = withoutLockfiles(baseArgv);
227
+ if (headRest !== null && JSON.stringify(headRest) !== JSON.stringify(baseRest)) {
228
+ return {
229
+ kind: 'unverified',
230
+ detail: `the base run's command line would differ from the head run's at ${firstDifference(headRest, baseRest)}`,
231
+ };
232
+ }
233
+ if (args.budgetMs <= 0) {
234
+ return { kind: 'timed-out', elapsedMs: 0, signal: null };
235
+ }
236
+ const started = Date.now();
237
+ const child = args.spawn(baseArgv, baseDir, args.budgetMs);
238
+ if (child.failure !== null) {
239
+ return child.failure.reason === 'timed-out'
240
+ ? { kind: 'timed-out', elapsedMs: Date.now() - started, signal: child.failure.signal }
241
+ : { kind: 'unverified', detail: `osv-scanner could not be run on the base copies (${child.failure.message})` };
242
+ }
243
+ if (child.status === null) {
244
+ return { kind: 'unverified', detail: 'osv-scanner did not finish on the base copies' };
245
+ }
246
+ // Exit 128: every copy parsed to nothing, so the base had nothing either.
247
+ if (child.status === 128) {
248
+ return { kind: 'clear' };
249
+ }
250
+ if (child.status !== 0 && child.status !== 1) {
251
+ return { kind: 'unverified', detail: `osv-scanner exited ${child.status} on the base copies` };
252
+ }
253
+ const counts = packageCounts(child.stderr, copies, baseDir);
254
+ const unread = copied.filter((_, index) => !counts.has(copies[index]));
255
+ if (unread.length > 0) {
256
+ return {
257
+ kind: 'unverified',
258
+ detail: `osv-scanner printed no package count for the base copy of ${unread.join(', ')}`,
259
+ };
260
+ }
261
+ // A removed file is replaced only by a head-handed lockfile in the same
262
+ // directory that read packages, that is not a requirements file, and that
263
+ // the base tree does not have: one elsewhere, or one the base already had
264
+ // (a Cargo.lock beside the deleted package-lock.json), carries another
265
+ // manifest's packages. A base listing that errors is not absent, so that
266
+ // file does not count (fail closed).
267
+ //
268
+ // 0.13.0, operator ruling of 2026-10-18: also of the removed file's
269
+ // ecosystem family (a NEW Cargo.lock carries a Rust manifest's packages,
270
+ // not the npm ones the head removed; an unknown family matches nothing),
271
+ // and a regular file in the head's index (a symbolic link to a populated
272
+ // lockfile elsewhere reads that file's packages). The cheap checks first,
273
+ // so git is asked only about a candidate that could otherwise count.
274
+ const newOnHead = (other) => treeEntryAt(args.repoRoot, args.ref, other).kind === 'absent';
275
+ const replaced = (file) => [...args.headCounts].some(([other, count]) => other !== file &&
276
+ count > 0 &&
277
+ path.posix.dirname(other) === path.posix.dirname(file) &&
278
+ osvLockfileKind(path.posix.basename(other)) !== 'requirements' &&
279
+ sameOsvFamily(other, file) &&
280
+ regularInHeadIndex(args.repoRoot, other) &&
281
+ newOnHead(other));
282
+ const emptied = copied
283
+ .map((file, index) => ({ path: file, packages: counts.get(copies[index]) ?? 0, removed: removed.has(file) }))
284
+ .filter((entry) => entry.packages > 0 && !(entry.removed && replaced(entry.path)));
285
+ return emptied.length === 0 ? { kind: 'clear' } : { kind: 'emptied', files: emptied };
286
+ }
151
287
  /**
152
288
  * Runs the comparison. Assumes the caller has established section 3.1: a
153
289
  * decided trust base, a head run that exited blocked, at least one finding.
@@ -50,10 +50,18 @@ export declare function selectOsvInputs(args: {
50
50
  * Notes for every basename-matched file tracked on the base and absent from
51
51
  * the head (section 3.2): deleted, moved, or renamed to a name the matcher
52
52
  * does not take. Such a file is not scanned on either side, and saying so is
53
- * all this does: it never blocks. A base listing git could not make yields no
54
- * note rather than a guess.
53
+ * all this says: the note never blocks. A base listing git could not make
54
+ * yields no note rather than a guess. Whether the removal blocks is the
55
+ * emptied-lockfile base check's decision (src/osv-baseline.ts), which reads
56
+ * the same list through noLongerScannedFiles.
55
57
  */
56
58
  export declare function noLongerScanned(repoRoot: string, ref: string, tracked: ReadonlySet<string>): Diagnostic[];
59
+ /**
60
+ * The base lockfiles the head no longer tracks, sorted. Null when the base
61
+ * tree could not be listed, which the emptied-lockfile check treats as
62
+ * unverified rather than as none.
63
+ */
64
+ export declare function noLongerScannedFiles(repoRoot: string, ref: string, tracked: ReadonlySet<string>): string[] | null;
57
65
  /** The nothing-to-scan sentence when every candidate was a requirements file left out. */
58
66
  export declare function nothingScannableMessage(notScanned: readonly string[]): string;
59
67
  /** The run detail beside `lockfiles`: how many requirements files were left out, and which. */
@@ -76,5 +84,13 @@ export declare function notScannedDetail(notScanned: readonly string[]): string;
76
84
  * that lowers osv-scanner's verbosity hides every line), not a finding.
77
85
  */
78
86
  export declare function emptiedLockfiles(stderr: string, handed: readonly string[], cwd: string): string[];
87
+ /**
88
+ * The package count osv-scanner printed for each handed file, read by the
89
+ * same SCANNED_LINE and the same two-spelling path match as
90
+ * emptiedLockfiles. A file with no count line is absent from the map. Read
91
+ * by the emptied-lockfile base check (src/osv-baseline.ts), where a missing
92
+ * line fails closed.
93
+ */
94
+ export declare function packageCounts(stderr: string, handed: readonly string[], cwd: string): Map<string, number>;
79
95
  /** The note when a policy's no-resolve was dropped from an invocation. */
80
96
  export declare const NO_RESOLVE_OVERRIDDEN: string;
@@ -135,27 +135,36 @@ export function selectOsvInputs(args) {
135
135
  * Notes for every basename-matched file tracked on the base and absent from
136
136
  * the head (section 3.2): deleted, moved, or renamed to a name the matcher
137
137
  * does not take. Such a file is not scanned on either side, and saying so is
138
- * all this does: it never blocks. A base listing git could not make yields no
139
- * note rather than a guess.
138
+ * all this says: the note never blocks. A base listing git could not make
139
+ * yields no note rather than a guess. Whether the removal blocks is the
140
+ * emptied-lockfile base check's decision (src/osv-baseline.ts), which reads
141
+ * the same list through noLongerScannedFiles.
140
142
  */
141
143
  export function noLongerScanned(repoRoot, ref, tracked) {
144
+ return (noLongerScannedFiles(repoRoot, ref, tracked) ?? []).map((file) => ({
145
+ code: 'conductor/lockfile-no-longer-scanned',
146
+ message: `${file} is tracked on the base and not in this pull request, so it is no longer scanned ` +
147
+ '(by either run). Its removal is visible in the diff.',
148
+ }));
149
+ }
150
+ /**
151
+ * The base lockfiles the head no longer tracks, sorted. Null when the base
152
+ * tree could not be listed, which the emptied-lockfile check treats as
153
+ * unverified rather than as none.
154
+ */
155
+ export function noLongerScannedFiles(repoRoot, ref, tracked) {
142
156
  if (ref.startsWith('-')) {
143
- return [];
157
+ return null;
144
158
  }
145
159
  const listing = runGit(repoRoot, ['ls-tree', '-r', '-z', '--name-only', ref], { maxBuffer: 64 * 1024 * 1024 });
146
160
  if (listing.error !== undefined || listing.status !== 0) {
147
- return [];
161
+ return null;
148
162
  }
149
163
  return listing.stdout
150
164
  .split('\0')
151
165
  .filter((file) => file !== '' && !file.split('/').includes('node_modules'))
152
166
  .filter((file) => osvLockfileKind(file) !== null && !tracked.has(file))
153
- .sort()
154
- .map((file) => ({
155
- code: 'conductor/lockfile-no-longer-scanned',
156
- message: `${file} is tracked on the base and not in this pull request, so it is no longer scanned ` +
157
- '(by either run). Its removal is visible in the diff.',
158
- }));
167
+ .sort();
159
168
  }
160
169
  /** The nothing-to-scan sentence when every candidate was a requirements file left out. */
161
170
  export function nothingScannableMessage(notScanned) {
@@ -218,6 +227,34 @@ export function emptiedLockfiles(stderr, handed, cwd) {
218
227
  }
219
228
  return handed.filter((file) => spellings(path.resolve(cwd, file)).some((spelling) => empty.has(spelling)));
220
229
  }
230
+ /**
231
+ * The package count osv-scanner printed for each handed file, read by the
232
+ * same SCANNED_LINE and the same two-spelling path match as
233
+ * emptiedLockfiles. A file with no count line is absent from the map. Read
234
+ * by the emptied-lockfile base check (src/osv-baseline.ts), where a missing
235
+ * line fails closed.
236
+ */
237
+ export function packageCounts(stderr, handed, cwd) {
238
+ const bySpelling = new Map();
239
+ for (const raw of stderr.split('\n')) {
240
+ const match = SCANNED_LINE.exec(raw.trim());
241
+ if (match !== null) {
242
+ for (const spelling of spellings(match[1])) {
243
+ bySpelling.set(spelling, Number(match[2]));
244
+ }
245
+ }
246
+ }
247
+ const out = new Map();
248
+ for (const file of handed) {
249
+ const count = spellings(path.resolve(cwd, file))
250
+ .map((spelling) => bySpelling.get(spelling))
251
+ .find((value) => value !== undefined);
252
+ if (count !== undefined) {
253
+ out.set(file, count);
254
+ }
255
+ }
256
+ return out;
257
+ }
221
258
  /** The note when a policy's no-resolve was dropped from an invocation. */
222
259
  export const NO_RESOLVE_OVERRIDDEN = 'options.no-resolve in .guardrails.yaml was not passed: requirements files are always scanned ' +
223
260
  'with --no-resolve (direct requirements only).';
@@ -120,6 +120,7 @@
120
120
  import { gateExitBlocks } from './exit-codes.js';
121
121
  import { NATIVE_CONTRACT_PATH, isLegacyContractPath } from './intent-prepare.js';
122
122
  import { INTENT_WARNING } from './normalize.js';
123
+ import { skewFound, skewPlace } from './output-text.js';
123
124
  import { POLICY_FILE_NAME } from './policy.js';
124
125
  const SARIF_SCHEMA = 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json';
125
126
  export const UMBRELLA_DRIVER_NAME = 'conductor';
@@ -829,6 +830,41 @@ function nodeModulesSkippedNotifications(result) {
829
830
  },
830
831
  ];
831
832
  }
833
+ /**
834
+ * A gate whose resolved binary reported a version other than the one the
835
+ * run was pinned to (the Action's CONDUCTOR_EXPECTED_* variables), from any
836
+ * location: a node_modules/.bin devDependency, PATH, or a policy command.
837
+ * A NOTE: it says which build was found, a statement in the same shape as
838
+ * node-modules-skipped, and the gate's own outcome (a version-skew
839
+ * could-not-run since 0.13.0) is reported on its own, at its own level.
840
+ * The path is carried only when it is repository-relative (node_modules);
841
+ * a PATH binary's absolute machine path stays in the job log line.
842
+ */
843
+ function versionSkewNotifications(result) {
844
+ return result.gates.flatMap((gate) => {
845
+ const skew = gate.versionSkew;
846
+ if (skew === undefined) {
847
+ return [];
848
+ }
849
+ const found = skewFound(skew);
850
+ return [
851
+ {
852
+ id: 'conductor/version-skew',
853
+ message: `The ${gate.role} gate (${gate.product}) reported version ${found}, but this run expects ` +
854
+ `${skew.expected} (the version the action pinned); it was resolved from ${skewPlace(skew)}. ` +
855
+ 'Resolution is unchanged; the gate was not run and is could-not-run (version-skew).',
856
+ details: {
857
+ role: gate.role,
858
+ product: gate.product,
859
+ expected: skew.expected,
860
+ found,
861
+ source: skew.source,
862
+ ...(skew.source === 'node_modules' ? { path: skew.path } : {}),
863
+ },
864
+ },
865
+ ];
866
+ });
867
+ }
832
868
  /**
833
869
  * A passthrough option that is a gate's own setting under a name conductor
834
870
  * also uses (gitleaks' `options.timeout`), as notifications. A NOTE: nothing
@@ -1003,6 +1039,7 @@ export function renderSarif(result, umbrellaVersion) {
1003
1039
  ...proposalNotifications(result),
1004
1040
  ...trustBaseWithheldNotifications(result),
1005
1041
  ...nodeModulesSkippedNotifications(result),
1042
+ ...versionSkewNotifications(result),
1006
1043
  ...intentWarningNotifications(result),
1007
1044
  ...gateOwnOptionNotifications(result),
1008
1045
  ];
@@ -77,17 +77,32 @@ export declare function jobLogSummary(result: RunResult): string;
77
77
  export declare function gateLogLines(result: RunResult, options?: {
78
78
  terminal?: boolean;
79
79
  }): string[];
80
+ type VersionSkew = NonNullable<GateOutcome['versionSkew']>;
81
+ /** Where a skewed binary came from, in words. Never a machine path. */
82
+ export declare function skewPlace(skew: VersionSkew): string;
83
+ /** The reported version as it may be printed: version characters only (`versionCharacters`). */
84
+ export declare function skewFound(skew: VersionSkew): string;
80
85
  /**
81
- * One warning per gate that was found on PATH at a version other than the one
82
- * this run expected (the Action's pin).
86
+ * One error line per gate whose resolved binary reported a version other
87
+ * than the one this run expected (the Action's pin), wherever it was found:
88
+ * node_modules/.bin, PATH or a policy command. Since 0.13.0 every such gate
89
+ * is could-not-run, so the line says so.
83
90
  *
84
- * For the job log only: it names where the binary was found, and an absolute
85
- * path has no business in a published SARIF log or a pull request comment, so
86
- * this is never part of either report. A warning and nothing more. Resolution
87
- * is unchanged and the gate ran (or was refused) exactly as it would have
88
- * without it.
91
+ * For the job log: it names the file the binary was found at, which for PATH
92
+ * is an absolute machine path, so this exact line is never part of a report.
93
+ * The reports carry the same fact without that path (gateSection here, the
94
+ * conductor/version-skew notification in SARIF). Resolution is unchanged.
89
95
  */
90
96
  export declare function versionSkewWarnings(result: RunResult): string[];
97
+ /**
98
+ * The same lines as GitHub Actions `::error::` annotations (a could-not-run
99
+ * since 0.13.0, a `::warning::` before), so a skew shows on the run's summary
100
+ * page without anybody opening the log. No machine path: the location is
101
+ * named in words.
102
+ */
103
+ export declare function versionSkewAnnotations(result: RunResult): string[];
104
+ /** The step-summary lines for the same errors, one paragraph each. */
105
+ export declare function versionSkewSummaryLines(result: RunResult): string[];
91
106
  /**
92
107
  * The verdict token: a label for the umbrella's OWN exit decision, in a
93
108
  * closed set, so a person or a script reading a report or a job summary gets
@@ -201,3 +216,4 @@ export declare const INTENT_SPEC_LINES: readonly ["intent-spec: none chosen, two
201
216
  */
202
217
  export declare const DEP_GUARD_DEADLINE_CODE = "online-deadline-exceeded";
203
218
  export declare function renderText(result: RunResult, options?: TextOptions): string;
219
+ export {};
@@ -23,7 +23,7 @@
23
23
  // everywhere is worth more here than a nicer-looking terminal.
24
24
  import { compareFindings } from './envelope.js';
25
25
  import { EXIT_BLOCKED, EXIT_COULD_NOT_RUN, gateExitBlocks } from './exit-codes.js';
26
- import { CONDUCTOR_OWN_REASONS, cleanOutputLine, conductorStatedReason, } from './gate-runner.js';
26
+ import { CONDUCTOR_OWN_REASONS, cleanOutputLine, conductorStatedReason, resolutionPlace, versionCharacters, versionSkewRemedy, } from './gate-runner.js';
27
27
  import { isLegacyContractPath, legacyChangedSentence } from './intent-prepare.js';
28
28
  import { SPEC_DIR } from './intent-spec.js';
29
29
  function subjectLabel(finding) {
@@ -316,6 +316,12 @@ function gateSection(gate, verbose, refusedOnTerminal = false) {
316
316
  if (gate.gateOwnOption !== undefined) {
317
317
  lines.push(` note conductor/option-is-gate-own: ${gate.gateOwnOption}`);
318
318
  }
319
+ // Under the header too: the header names the version and the location,
320
+ // and this says that version is not the one the run was pinned to.
321
+ const skew = versionSkewLine(gate);
322
+ if (skew !== null) {
323
+ lines.push(skew);
324
+ }
319
325
  const contract = contractLine(gate);
320
326
  if (contract !== null) {
321
327
  lines.push(contract);
@@ -740,26 +746,80 @@ export function gateLogLines(result, options = {}) {
740
746
  }
741
747
  return lines;
742
748
  }
749
+ /** Where a skewed binary came from, in words. Never a machine path. */
750
+ export function skewPlace(skew) {
751
+ return resolutionPlace(skew.source);
752
+ }
753
+ /** The reported version as it may be printed: version characters only (`versionCharacters`). */
754
+ export function skewFound(skew) {
755
+ return versionCharacters(skew.found);
756
+ }
757
+ /** The remedy, which depends on where the binary came from. One source: `versionSkewRemedy`. */
758
+ function skewFix(product, skew) {
759
+ return versionSkewRemedy(product, skew.source, skew.expected);
760
+ }
743
761
  /**
744
- * One warning per gate that was found on PATH at a version other than the one
745
- * this run expected (the Action's pin).
762
+ * The sentence every GitHub surface shares (0.13.0): what was found, what was
763
+ * expected, and that the gate was therefore not run. No machine path.
764
+ */
765
+ function skewSentence(product, skew) {
766
+ return (`${product} resolved from ${skewPlace(skew)} reports version ${skewFound(skew)}, but this run expects ` +
767
+ `${skew.expected} (the version the action pinned), so conductor did not run it: the gate is ` +
768
+ 'could-not-run (version-skew).');
769
+ }
770
+ /**
771
+ * One error line per gate whose resolved binary reported a version other
772
+ * than the one this run expected (the Action's pin), wherever it was found:
773
+ * node_modules/.bin, PATH or a policy command. Since 0.13.0 every such gate
774
+ * is could-not-run, so the line says so.
746
775
  *
747
- * For the job log only: it names where the binary was found, and an absolute
748
- * path has no business in a published SARIF log or a pull request comment, so
749
- * this is never part of either report. A warning and nothing more. Resolution
750
- * is unchanged and the gate ran (or was refused) exactly as it would have
751
- * without it.
776
+ * For the job log: it names the file the binary was found at, which for PATH
777
+ * is an absolute machine path, so this exact line is never part of a report.
778
+ * The reports carry the same fact without that path (gateSection here, the
779
+ * conductor/version-skew notification in SARIF). Resolution is unchanged.
752
780
  */
753
781
  export function versionSkewWarnings(result) {
754
782
  return result.gates.flatMap((gate) => gate.versionSkew === undefined
755
783
  ? []
756
784
  : [
757
- `conductor: warning: ${gate.product} resolved from PATH reports version ${gate.versionSkew.found}, ` +
758
- `but this run expects ${gate.versionSkew.expected} (the version the action pinned). ` +
759
- `It was found at ${gate.versionSkew.path}. Resolution is unchanged and that binary was used. ` +
760
- `Fix: remove the other ${gate.product} from PATH, or install ${gate.versionSkew.expected}.`,
785
+ `conductor: error: ${skewSentence(gate.product, gate.versionSkew)} It was found at ` +
786
+ `${gate.versionSkew.path}. ${skewFix(gate.product, gate.versionSkew)}`,
761
787
  ]);
762
788
  }
789
+ /** A workflow-command message: `%`, CR and LF escaped, as the runner requires. */
790
+ function workflowCommandData(text) {
791
+ return text.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A');
792
+ }
793
+ /**
794
+ * The same lines as GitHub Actions `::error::` annotations (a could-not-run
795
+ * since 0.13.0, a `::warning::` before), so a skew shows on the run's summary
796
+ * page without anybody opening the log. No machine path: the location is
797
+ * named in words.
798
+ */
799
+ export function versionSkewAnnotations(result) {
800
+ return result.gates.flatMap((gate) => gate.versionSkew === undefined
801
+ ? []
802
+ : [
803
+ '::error title=conductor version skew::' +
804
+ workflowCommandData(`${skewSentence(gate.product, gate.versionSkew)} ${skewFix(gate.product, gate.versionSkew)}`),
805
+ ]);
806
+ }
807
+ /** The step-summary lines for the same errors, one paragraph each. */
808
+ export function versionSkewSummaryLines(result) {
809
+ return result.gates.flatMap((gate) => gate.versionSkew === undefined
810
+ ? []
811
+ : [`conductor error: ${skewSentence(gate.product, gate.versionSkew)} ${skewFix(gate.product, gate.versionSkew)}`]);
812
+ }
813
+ /** The gate-block line of the text report. Repository-relative paths only. */
814
+ function versionSkewLine(gate) {
815
+ const skew = gate.versionSkew;
816
+ if (skew === undefined) {
817
+ return null;
818
+ }
819
+ const from = skew.source === 'node_modules' ? skew.path : skewPlace(skew);
820
+ return (` ! conductor/version-skew: ${gate.product} ${skewFound(skew)}, from ${from}, was not run: this run expects ` +
821
+ `${skew.expected} (the version the action pinned). Resolution is unchanged. ${skewFix(gate.product, skew)}`);
822
+ }
763
823
  /**
764
824
  * How many blocking findings one gate that RAN is carrying, for the token.
765
825
  *
@@ -117,7 +117,43 @@ export type LockfileKind = 'bare' | 'requirements';
117
117
  * named by the unread-manifests note instead). gradle's
118
118
  * verification-metadata.xml is read only inside a `gradle` directory and is
119
119
  * matched by `osvLockfileKind` rather than listed here.
120
+ *
121
+ * ONE TABLE, name to ecosystem family (0.13.0): its keys ARE the name list,
122
+ * so a name cannot be handed to osv-scanner without a family. The family is
123
+ * read by the emptied-lockfile replacement rule (src/osv-baseline.ts), where
124
+ * a replacement must be of the removed file's family; see
125
+ * `osvLockfileFamily`.
120
126
  */
127
+ export declare const OSV_LOCKFILE_ECOSYSTEMS: {
128
+ readonly 'package-lock.json': "javascript";
129
+ readonly 'npm-shrinkwrap.json': "javascript";
130
+ readonly 'pnpm-lock.yaml': "javascript";
131
+ readonly 'yarn.lock': "javascript";
132
+ readonly 'bun.lock': "javascript";
133
+ readonly 'go.mod': "go";
134
+ readonly 'poetry.lock': "python";
135
+ readonly 'Pipfile.lock': "python";
136
+ readonly 'uv.lock': "python";
137
+ readonly 'pdm.lock': "python";
138
+ readonly 'Cargo.lock': "rust";
139
+ readonly 'Gemfile.lock': "ruby";
140
+ readonly 'composer.lock': "php";
141
+ readonly 'gradle.lockfile': "jvm";
142
+ readonly 'packages.lock.json': "dotnet";
143
+ readonly 'mix.lock': "hex";
144
+ readonly 'pubspec.lock': "dart";
145
+ readonly 'Package.resolved': "swift";
146
+ readonly 'conan.lock': "conan";
147
+ readonly 'renv.lock': "r";
148
+ readonly 'packages.config': "dotnet";
149
+ readonly 'buildscript-gradle.lockfile': "jvm";
150
+ readonly 'gems.locked': "ruby";
151
+ readonly 'pylock.toml': "python";
152
+ readonly 'cabal.project.freeze': "haskell";
153
+ readonly 'stack.yaml.lock': "haskell";
154
+ };
155
+ /** An ecosystem family, as the replacement rule compares them. */
156
+ export type OsvEcosystemFamily = (typeof OSV_LOCKFILE_ECOSYSTEMS)[keyof typeof OSV_LOCKFILE_ECOSYSTEMS];
121
157
  export declare const OSV_LOCKFILE_NAMES: readonly string[];
122
158
  /**
123
159
  * What osv-scanner is handed for a tracked file, or null. Takes the
@@ -127,6 +163,17 @@ export declare const OSV_LOCKFILE_NAMES: readonly string[];
127
163
  * parent is part of the match for that one file.
128
164
  */
129
165
  export declare function osvLockfileKind(file: string): LockfileKind | null;
166
+ /**
167
+ * The ecosystem family of a tracked file, or null. DERIVED FROM
168
+ * `osvLockfileKind`, never a second list: a file with no kind has no family,
169
+ * a requirements file is python, gradle's verification-metadata.xml (matched
170
+ * by kind on its parent) is jvm, and every other bare name is looked up in
171
+ * the one table above. Null means unknown, and an unknown family matches
172
+ * nothing, itself included: callers compare with `sameOsvFamily`.
173
+ */
174
+ export declare function osvLockfileFamily(file: string): OsvEcosystemFamily | null;
175
+ /** Whether two tracked files are of one known ecosystem family. Fail closed: unknown never matches. */
176
+ export declare function sameOsvFamily(a: string, b: string): boolean;
130
177
  /**
131
178
  * The npm gates print a bare version. No capture group on purpose: the runner
132
179
  * has always reported the whole first line minus a leading v, prerelease
package/dist/products.js CHANGED
@@ -34,35 +34,42 @@ function raiseTheLimit(role) {
34
34
  * named by the unread-manifests note instead). gradle's
35
35
  * verification-metadata.xml is read only inside a `gradle` directory and is
36
36
  * matched by `osvLockfileKind` rather than listed here.
37
+ *
38
+ * ONE TABLE, name to ecosystem family (0.13.0): its keys ARE the name list,
39
+ * so a name cannot be handed to osv-scanner without a family. The family is
40
+ * read by the emptied-lockfile replacement rule (src/osv-baseline.ts), where
41
+ * a replacement must be of the removed file's family; see
42
+ * `osvLockfileFamily`.
37
43
  */
38
- export const OSV_LOCKFILE_NAMES = [
39
- 'package-lock.json',
40
- 'npm-shrinkwrap.json',
41
- 'pnpm-lock.yaml',
42
- 'yarn.lock',
43
- 'bun.lock',
44
- 'go.mod',
45
- 'poetry.lock',
46
- 'Pipfile.lock',
47
- 'uv.lock',
48
- 'pdm.lock',
49
- 'Cargo.lock',
50
- 'Gemfile.lock',
51
- 'composer.lock',
52
- 'gradle.lockfile',
53
- 'packages.lock.json',
54
- 'mix.lock',
55
- 'pubspec.lock',
56
- 'Package.resolved',
57
- 'conan.lock',
58
- 'renv.lock',
59
- 'packages.config',
60
- 'buildscript-gradle.lockfile',
61
- 'gems.locked',
62
- 'pylock.toml',
63
- 'cabal.project.freeze',
64
- 'stack.yaml.lock',
65
- ];
44
+ export const OSV_LOCKFILE_ECOSYSTEMS = {
45
+ 'package-lock.json': 'javascript',
46
+ 'npm-shrinkwrap.json': 'javascript',
47
+ 'pnpm-lock.yaml': 'javascript',
48
+ 'yarn.lock': 'javascript',
49
+ 'bun.lock': 'javascript',
50
+ 'go.mod': 'go',
51
+ 'poetry.lock': 'python',
52
+ 'Pipfile.lock': 'python',
53
+ 'uv.lock': 'python',
54
+ 'pdm.lock': 'python',
55
+ 'Cargo.lock': 'rust',
56
+ 'Gemfile.lock': 'ruby',
57
+ 'composer.lock': 'php',
58
+ 'gradle.lockfile': 'jvm',
59
+ 'packages.lock.json': 'dotnet',
60
+ 'mix.lock': 'hex',
61
+ 'pubspec.lock': 'dart',
62
+ 'Package.resolved': 'swift',
63
+ 'conan.lock': 'conan',
64
+ 'renv.lock': 'r',
65
+ 'packages.config': 'dotnet',
66
+ 'buildscript-gradle.lockfile': 'jvm',
67
+ 'gems.locked': 'ruby',
68
+ 'pylock.toml': 'python',
69
+ 'cabal.project.freeze': 'haskell',
70
+ 'stack.yaml.lock': 'haskell',
71
+ };
72
+ export const OSV_LOCKFILE_NAMES = Object.keys(OSV_LOCKFILE_ECOSYSTEMS);
66
73
  /** gradle's dependency verification file, which 2.4.0 reads only under a `gradle` directory. */
67
74
  const GRADLE_VERIFICATION_METADATA = 'verification-metadata.xml';
68
75
  /**
@@ -96,6 +103,35 @@ export function osvLockfileKind(file) {
96
103
  }
97
104
  return REQUIREMENTS_PATTERNS.some((pattern) => pattern.test(basename)) ? 'requirements' : null;
98
105
  }
106
+ /**
107
+ * The ecosystem family of a tracked file, or null. DERIVED FROM
108
+ * `osvLockfileKind`, never a second list: a file with no kind has no family,
109
+ * a requirements file is python, gradle's verification-metadata.xml (matched
110
+ * by kind on its parent) is jvm, and every other bare name is looked up in
111
+ * the one table above. Null means unknown, and an unknown family matches
112
+ * nothing, itself included: callers compare with `sameOsvFamily`.
113
+ */
114
+ export function osvLockfileFamily(file) {
115
+ const kind = osvLockfileKind(file);
116
+ if (kind === null) {
117
+ return null;
118
+ }
119
+ if (kind === 'requirements') {
120
+ return 'python';
121
+ }
122
+ const basename = file.split('/').pop() ?? '';
123
+ if (basename === GRADLE_VERIFICATION_METADATA) {
124
+ return 'jvm';
125
+ }
126
+ return Object.hasOwn(OSV_LOCKFILE_ECOSYSTEMS, basename)
127
+ ? OSV_LOCKFILE_ECOSYSTEMS[basename]
128
+ : null;
129
+ }
130
+ /** Whether two tracked files are of one known ecosystem family. Fail closed: unknown never matches. */
131
+ export function sameOsvFamily(a, b) {
132
+ const left = osvLockfileFamily(a);
133
+ return left !== null && left === osvLockfileFamily(b);
134
+ }
99
135
  /**
100
136
  * The npm gates print a bare version. No capture group on purpose: the runner
101
137
  * has always reported the whole first line minus a leading v, prerelease