@tobi-or-not/quorum 0.3.0 → 0.5.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.
- package/README.md +2 -1
- package/dist/bench/attacks.d.ts +103 -0
- package/dist/bench/attacks.js +272 -0
- package/dist/bench/fingerprint.d.ts +7 -4
- package/dist/bench/fingerprint.js +22 -8
- package/dist/bench/independence.d.ts +28 -0
- package/dist/bench/independence.js +67 -0
- package/dist/bench/records.d.ts +241 -13
- package/dist/bench/records.js +64 -11
- package/dist/bench/report.d.ts +44 -11
- package/dist/bench/report.js +238 -32
- package/dist/bench/run-dir.d.ts +52 -26
- package/dist/bench/run-dir.js +124 -45
- package/dist/bench/runner.d.ts +47 -17
- package/dist/bench/runner.js +82 -21
- package/dist/bench/score.d.ts +38 -7
- package/dist/bench/score.js +64 -17
- package/dist/bench/stats.d.ts +61 -7
- package/dist/bench/stats.js +82 -7
- package/dist/bench/suite.d.ts +54 -9
- package/dist/bench/suite.js +264 -96
- package/dist/cli/bench.d.ts +27 -9
- package/dist/cli/bench.js +174 -83
- package/dist/cli/bin.js +2 -2
- package/dist/cli/io.d.ts +9 -2
- package/dist/cli/io.js +20 -2
- package/dist/cli/main.d.ts +34 -14
- package/dist/cli/main.js +100 -38
- package/dist/cli/print-config.d.ts +8 -6
- package/dist/cli/print-config.js +21 -8
- package/dist/cli/render.d.ts +2 -2
- package/dist/cli/render.js +21 -2
- package/dist/config/env.d.ts +32 -19
- package/dist/config/env.js +95 -32
- package/dist/config/from-config.js +15 -3
- package/dist/config/load.d.ts +3 -0
- package/dist/config/load.js +17 -8
- package/dist/config/resolve.d.ts +9 -1
- package/dist/config/resolve.js +17 -1
- package/dist/config/schema.d.ts +141 -5
- package/dist/config/schema.js +125 -12
- package/dist/core/clock.d.ts +17 -0
- package/dist/core/clock.js +14 -0
- package/dist/core/coverage.d.ts +49 -0
- package/dist/core/coverage.js +144 -0
- package/dist/core/diff.d.ts +34 -0
- package/dist/core/diff.js +140 -18
- package/dist/core/errors.d.ts +18 -3
- package/dist/core/errors.js +26 -2
- package/dist/core/exclude.d.ts +42 -0
- package/dist/core/exclude.js +189 -0
- package/dist/core/limits.d.ts +82 -0
- package/dist/core/limits.js +163 -0
- package/dist/core/output.d.ts +3 -2
- package/dist/core/output.js +3 -2
- package/dist/core/ports.d.ts +57 -2
- package/dist/core/ports.js +36 -1
- package/dist/core/quorum.d.ts +24 -8
- package/dist/core/quorum.js +187 -56
- package/dist/core/retry.d.ts +36 -0
- package/dist/core/retry.js +46 -0
- package/dist/core/stages/context.d.ts +126 -22
- package/dist/core/stages/context.js +319 -41
- package/dist/core/stages/panel.d.ts +5 -4
- package/dist/core/stages/panel.js +30 -11
- package/dist/core/stages/research.d.ts +15 -6
- package/dist/core/stages/research.js +75 -18
- package/dist/core/tokens.d.ts +31 -0
- package/dist/core/tokens.js +81 -0
- package/dist/core/types.d.ts +77 -10
- package/dist/index.d.ts +1 -1
- package/dist/providers/anthropic.d.ts +2 -1
- package/dist/providers/anthropic.js +14 -6
- package/dist/providers/claude-code.d.ts +51 -11
- package/dist/providers/claude-code.js +69 -33
- package/dist/providers/gemini.d.ts +4 -1
- package/dist/providers/gemini.js +72 -15
- package/dist/providers/http.d.ts +49 -4
- package/dist/providers/http.js +155 -14
- package/dist/providers/ollama.d.ts +3 -1
- package/dist/providers/ollama.js +17 -9
- package/dist/providers/openai-compatible.d.ts +3 -1
- package/dist/providers/openai-compatible.js +17 -9
- package/dist/providers/options.d.ts +12 -3
- package/dist/providers/options.js +30 -10
- package/dist/providers/reply.d.ts +6 -2
- package/dist/providers/reply.js +13 -3
- package/dist/providers/size.d.ts +10 -14
- package/dist/providers/size.js +15 -69
- package/package.json +1 -1
- package/schema/quorum.schema.json +34 -1
package/dist/cli/main.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createReadStream } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { parseArgs } from 'node:util';
|
|
4
3
|
import packageJson from '../../package.json' with { type: 'json' };
|
|
5
4
|
import { readEnv } from "../config/env.js";
|
|
6
5
|
import { fromConfig } from "../config/from-config.js";
|
|
@@ -8,8 +7,9 @@ import { loadConfig } from "../config/load.js";
|
|
|
8
7
|
import { decodeDiff } from "../core/diff.js";
|
|
9
8
|
import { ConfigError } from "../core/errors.js";
|
|
10
9
|
import { inertJson, inertLine } from "../core/sanitize.js";
|
|
10
|
+
import { ownData } from "../core/stages/context.js";
|
|
11
11
|
import { runBench } from "./bench.js";
|
|
12
|
-
import { errorLines, errorMessage, EXIT } from "./io.js";
|
|
12
|
+
import { errorLines, errorMessage, EXIT, parseFlags } from "./io.js";
|
|
13
13
|
import { printConfig } from "./print-config.js";
|
|
14
14
|
import { bannerLines, progressSink } from "./render.js";
|
|
15
15
|
export { errorMessage, EXIT };
|
|
@@ -21,12 +21,14 @@ const USAGE = [
|
|
|
21
21
|
'Options:',
|
|
22
22
|
' -c, --config <path> Read this config file, over QUORUM_CONFIG',
|
|
23
23
|
' -p, --profile <id> Run only this profile; repeat it to run several',
|
|
24
|
-
' --allow-incomplete Exit 0 instead of 4 when
|
|
24
|
+
' --allow-incomplete Exit 0 instead of 4 when every gap is a vote that failed in passing: a dropped connection, a timeout, or an HTTP 408, 409, 429 or 5xx',
|
|
25
25
|
' --print-config Print the resolved config, keys redacted, and exit',
|
|
26
26
|
' -h, --help Print this help and exit',
|
|
27
27
|
' -v, --version Print the version and exit',
|
|
28
28
|
'',
|
|
29
29
|
].join('\n');
|
|
30
|
+
/** The HTTP statuses, besides 5xx, that a call fails with in passing: a request timeout, a conflict and a rate limit. */
|
|
31
|
+
const PASSING_STATUSES = new Set([408, 409, 429]);
|
|
30
32
|
const OPTIONS = {
|
|
31
33
|
config: { type: 'string', short: 'c' },
|
|
32
34
|
profile: { type: 'string', short: 'p', multiple: true },
|
|
@@ -37,10 +39,12 @@ const OPTIONS = {
|
|
|
37
39
|
};
|
|
38
40
|
/**
|
|
39
41
|
* Run one review and return the process exit code. Never throws: usage and configuration problems
|
|
40
|
-
* exit 2, runtime failures exit 3, an interrupt exits
|
|
41
|
-
* failed votes left undecided, or a
|
|
42
|
-
* was kept by a gating profile, so CI can tell a broken run
|
|
43
|
-
* (exit 1) and from a clean one (exit 0). `
|
|
42
|
+
* exit 2, a gating profile's failed research and other runtime failures exit 3, an interrupt exits
|
|
43
|
+
* 130, and an incomplete review (a finding its failed votes left undecided, or a gap) of a gating
|
|
44
|
+
* profile exits 4 unless a `high` finding was kept by a gating profile, so CI can tell a broken run
|
|
45
|
+
* and a partial review from a real finding (exit 1) and from a clean one (exit 0). `--allow-incomplete`
|
|
46
|
+
* turns that exit 4 into 0 only when every failed vote behind it failed in passing (see `exitCodeFor`).
|
|
47
|
+
* `exitCodeFor` maps the result; advisory flags never change it.
|
|
44
48
|
*
|
|
45
49
|
* It reads at most 16 MiB of diff, from stdin or a file, counted in bytes: a larger diff is a usage error,
|
|
46
50
|
* and reading stops at the chunk that crosses the cap.
|
|
@@ -70,7 +74,7 @@ export async function runCli(io) {
|
|
|
70
74
|
return runBench(io, io.argv.slice(1));
|
|
71
75
|
let flags;
|
|
72
76
|
try {
|
|
73
|
-
flags = parseFlags(io.argv);
|
|
77
|
+
flags = parseFlags(io.argv, OPTIONS);
|
|
74
78
|
}
|
|
75
79
|
catch (error) {
|
|
76
80
|
return usageError(io, error);
|
|
@@ -148,7 +152,7 @@ function writeWarnings(io, warnings) {
|
|
|
148
152
|
}
|
|
149
153
|
/**
|
|
150
154
|
* The signal of one review, aborted by the first SIGINT or SIGTERM. The next one calls `exit(130)`: the
|
|
151
|
-
* way out
|
|
155
|
+
* way out when what a provider still runs, after the review settled its call, keeps the process alive.
|
|
152
156
|
*/
|
|
153
157
|
export function interruptSignal(source, exit) {
|
|
154
158
|
const controller = new AbortController();
|
|
@@ -166,43 +170,101 @@ export function interruptSignal(source, exit) {
|
|
|
166
170
|
}
|
|
167
171
|
/**
|
|
168
172
|
* The exit code of a finished review: 1 when a kept finding is `high` and its profile gates, 4 when
|
|
169
|
-
* an unreviewed finding or a gap belongs to a gating profile
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* as
|
|
173
|
+
* an unreviewed finding or a gap belongs to a gating profile, 0 otherwise. `allowIncomplete` turns
|
|
174
|
+
* that 4 into 0 only when every gap of a gating profile is a `vote-failed` one (an unreviewed finding
|
|
175
|
+
* is no gap) and, for each gating profile that has a gap, every failed vote of its own kept and
|
|
176
|
+
* unreviewed findings failed in passing, as `failedInPassing` says: a dropped connection, a timeout,
|
|
177
|
+
* or an HTTP 408, 409, 429 or 5xx. A gating profile with no gap blocks no other profile's lift. A gap
|
|
178
|
+
* with no failed vote behind it lifts nothing: an unreviewed finding whose votes hold none, or a
|
|
179
|
+
* `vote-failed` gap beside kept findings that hold none, which no review writes.
|
|
180
|
+
* A profile gates unless `meta.profiles` holds it with `gating: false`, so a profile missing from the
|
|
181
|
+
* result counts as gating and a gap never hides.
|
|
173
182
|
*
|
|
174
|
-
*
|
|
175
|
-
* request
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
183
|
+
* Why so narrow: a pull request causes the other gaps directly (ADR-0012). It pads the diff until a
|
|
184
|
+
* request is refused as too large, floods the research with decoy findings past `maxFindings`, or
|
|
185
|
+
* plants text that a voter refuses or that cuts its reply off or leaves it unusable, and one
|
|
186
|
+
* `.gitattributes` line, one NUL byte or a submodule's bump leaves a file's change out of the diff.
|
|
187
|
+
* The flag lifts only what the code names, so a reason added later is out of its reach by default,
|
|
188
|
+
* and so is what a result built by hand or by an older quorum leaves unsaid: a failed vote with no
|
|
189
|
+
* `failure`, a verdict whose `votes` is no array, a reason no quorum writes. A gating profile's
|
|
190
|
+
* `research-failed` gap, which no review records, is out too: a review that read nothing is never
|
|
191
|
+
* turned into exit 0. Planted text can still draw out a reply that ends in a lifted failure, a
|
|
192
|
+
* timeout of its own, so on a gating profile do not use the flag for a pull request you do not trust.
|
|
179
193
|
*/
|
|
180
194
|
export function exitCodeFor(result, options = {}) {
|
|
181
195
|
const gates = (profile) => !Object.hasOwn(result.meta.profiles, profile) || result.meta.profiles[profile].gating !== false;
|
|
182
196
|
if (result.kept.some(verdict => verdict.confidence === 'high' && gates(verdict.profile)))
|
|
183
197
|
return EXIT.finding;
|
|
184
|
-
if (result.meta.incomplete.some(entry => entry.reason === 'request-too-large' && gates(entry.profile)))
|
|
185
|
-
return EXIT.incomplete;
|
|
186
198
|
const incomplete = result.unreviewed.some(verdict => gates(verdict.profile)) || result.meta.incomplete.some(entry => gates(entry.profile));
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
if (!incomplete)
|
|
200
|
+
return EXIT.ok;
|
|
201
|
+
return options.allowIncomplete === true && liftable(result, gates)
|
|
202
|
+
? EXIT.ok
|
|
203
|
+
: EXIT.incomplete;
|
|
190
204
|
}
|
|
191
|
-
/**
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
/** True when every gap of a gating profile is a `vote-failed` one, and each gating profile that has a gap passes `liftsProfile`. */
|
|
206
|
+
function liftable(result, gates) {
|
|
207
|
+
const gaps = result.meta.incomplete.filter(entry => gates(entry.profile));
|
|
208
|
+
if (gaps.some(entry => entry.reason !== 'vote-failed'))
|
|
209
|
+
return false;
|
|
210
|
+
const unreviewed = result.unreviewed.filter(verdict => gates(verdict.profile));
|
|
211
|
+
const profiles = new Set([
|
|
212
|
+
...gaps,
|
|
213
|
+
...unreviewed,
|
|
214
|
+
].map(({ profile }) => profile));
|
|
215
|
+
return [...profiles].every(profile => liftsProfile(result, profile, gaps.some(entry => entry.profile === profile)));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* True when the failed votes behind `profile`'s gaps all failed in passing: those of its own kept and
|
|
219
|
+
* unreviewed findings, each finding's `votes` an array. Every unreviewed finding holds a failed vote, and
|
|
220
|
+
* so do the kept findings when the profile has a `vote-failed` gap (`gap`): a gap with no failed vote behind
|
|
221
|
+
* it lifts nothing.
|
|
222
|
+
*/
|
|
223
|
+
function liftsProfile(result, profile, gap) {
|
|
224
|
+
const kept = failedVotesOf(result.kept.filter(verdict => verdict.profile === profile));
|
|
225
|
+
const unreviewed = failedVotesOf(result.unreviewed.filter(verdict => verdict.profile === profile));
|
|
226
|
+
if (kept === undefined || unreviewed === undefined)
|
|
227
|
+
return false;
|
|
228
|
+
return [
|
|
229
|
+
...kept,
|
|
230
|
+
...unreviewed,
|
|
231
|
+
].every(failed => failed.every(lensVote => failedInPassing(ownData(lensVote, 'failure'))))
|
|
232
|
+
&& unreviewed.every(failed => failed.length > 0)
|
|
233
|
+
&& (!gap || kept.some(failed => failed.length > 0));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The failed votes of each verdict, in order, or undefined when the `votes` of one is no array. A vote is
|
|
237
|
+
* cast only when its own data `vote` is an object and its own data `failure` is `null` or absent: any other
|
|
238
|
+
* entry is failed, so a vote that records a failure never counts as cast.
|
|
239
|
+
*/
|
|
240
|
+
function failedVotesOf(verdicts) {
|
|
241
|
+
const lists = verdicts.map((verdict) => {
|
|
242
|
+
const votes = verdict.votes;
|
|
243
|
+
return Array.isArray(votes)
|
|
244
|
+
? votes.filter((lensVote) => {
|
|
245
|
+
const cast = ownData(lensVote, 'vote');
|
|
246
|
+
const failure = ownData(lensVote, 'failure');
|
|
247
|
+
return typeof cast !== 'object' || cast === null || (failure !== null && failure !== undefined);
|
|
248
|
+
})
|
|
249
|
+
: undefined;
|
|
250
|
+
});
|
|
251
|
+
return lists.every(list => list !== undefined)
|
|
252
|
+
? lists
|
|
253
|
+
: undefined;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* True for a vote's failure that is infrastructure's: its own data `kind` is `network` or `timeout`, or
|
|
257
|
+
* `http` with an own data `status` of 408, 409, 429 or an integer from 500 to 599. Anything else is false:
|
|
258
|
+
* a refusal, a reply cut off or unusable, a request too large, any other status, a status that is no
|
|
259
|
+
* number, a kind no provider has, `null` and a value that is no object. It reads own data only, never
|
|
260
|
+
* runs a getter and never throws.
|
|
261
|
+
*/
|
|
262
|
+
export function failedInPassing(failure) {
|
|
263
|
+
const kind = ownData(failure, 'kind');
|
|
264
|
+
if (kind === 'network' || kind === 'timeout')
|
|
265
|
+
return true;
|
|
266
|
+
const status = ownData(failure, 'status');
|
|
267
|
+
return kind === 'http' && typeof status === 'number' && Number.isInteger(status) && (PASSING_STATUSES.has(status) || (status >= 500 && status <= 599));
|
|
206
268
|
}
|
|
207
269
|
/** Write a usage error and the usage, and return its exit code. */
|
|
208
270
|
function usageError(io, error) {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ResolvedConfig } from '../config/resolve.ts';
|
|
2
2
|
/**
|
|
3
3
|
* The resolved config as the YAML `--print-config` writes, for a CI log that anyone can read: the file it
|
|
4
|
-
* came from (`null` for none), the providers, the profiles that run, the limits the review applies
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* came from (`null` for none), the providers, the profiles that run, the limits the review applies
|
|
5
|
+
* (`concurrency`, `maxFindings`, `maxReviewTokens` and `reviewTimeoutMs`, defaults filled in), the
|
|
6
|
+
* patterns it excludes, and the warnings. A key and every value of `headers`, `query` and `extraBody`
|
|
7
|
+
* print as `[redacted]`, a base URL as its origin, and a prompt as its SHA-256. A provider's `timeoutMs` and
|
|
8
|
+
* `retries` print when it sets them, a provider object's when it states them. A `claude-code` provider
|
|
9
|
+
* prints its protocol, command, model, context size, key (redacted), auth mode and args, and no origin:
|
|
10
|
+
* the command and the args are the user's own config. The view is an allowlist, so a field added to the
|
|
11
|
+
* config prints nothing until it is added here on purpose.
|
|
10
12
|
*
|
|
11
13
|
* The text ends with a newline, and each line passes through `inertLine`. It is YAML 1.1, so a reader of
|
|
12
14
|
* that version reads `off` as a string, and no line folds.
|
package/dist/cli/print-config.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { stringify } from 'yaml';
|
|
3
3
|
import { own } from "../config/profiles.js";
|
|
4
|
-
import { isProvider } from "../config/schema.js";
|
|
4
|
+
import { isProvider, statedFacts } from "../config/schema.js";
|
|
5
5
|
import { DEFAULT_CONCURRENCY } from "../core/concurrency.js";
|
|
6
|
+
import { DEFAULT_MAX_REVIEW_TOKENS, DEFAULT_REVIEW_TIMEOUT_MS } from "../core/limits.js";
|
|
6
7
|
import { thresholdsFor } from "../core/profile.js";
|
|
7
8
|
import { inertLine } from "../core/sanitize.js";
|
|
8
9
|
import { DEFAULT_MAX_FINDINGS } from "../core/stages/research.js";
|
|
@@ -66,16 +67,21 @@ function specView(spec) {
|
|
|
66
67
|
maxTokens: own(spec, 'maxTokens'),
|
|
67
68
|
maxTokensField: own(spec, 'maxTokensField'),
|
|
68
69
|
systemPrompt: systemPromptView(own(spec, 'systemPrompt')),
|
|
70
|
+
timeoutMs: own(spec, 'timeoutMs'),
|
|
71
|
+
retries: own(spec, 'retries'),
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
|
-
/** A provider object by what it implements
|
|
74
|
+
/** A provider object by what it implements, its model when that is a string, and the `timeoutMs` and `retries` it states; never its function. */
|
|
72
75
|
function objectView(provider) {
|
|
73
76
|
const model = own(provider, 'model');
|
|
77
|
+
const { timeoutMs, retries } = statedFacts(provider).stated;
|
|
74
78
|
return {
|
|
75
79
|
implements: 'Provider',
|
|
76
80
|
model: typeof model === 'string'
|
|
77
81
|
? model
|
|
78
82
|
: undefined,
|
|
83
|
+
timeoutMs,
|
|
84
|
+
retries,
|
|
79
85
|
};
|
|
80
86
|
}
|
|
81
87
|
/** A profile that runs: its providers, the votes its policy needs, and each prompt as its hash. */
|
|
@@ -93,12 +99,14 @@ function profileView({ profile, research, voters }) {
|
|
|
93
99
|
}
|
|
94
100
|
/**
|
|
95
101
|
* The resolved config as the YAML `--print-config` writes, for a CI log that anyone can read: the file it
|
|
96
|
-
* came from (`null` for none), the providers, the profiles that run, the limits the review applies
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
+
* came from (`null` for none), the providers, the profiles that run, the limits the review applies
|
|
103
|
+
* (`concurrency`, `maxFindings`, `maxReviewTokens` and `reviewTimeoutMs`, defaults filled in), the
|
|
104
|
+
* patterns it excludes, and the warnings. A key and every value of `headers`, `query` and `extraBody`
|
|
105
|
+
* print as `[redacted]`, a base URL as its origin, and a prompt as its SHA-256. A provider's `timeoutMs` and
|
|
106
|
+
* `retries` print when it sets them, a provider object's when it states them. A `claude-code` provider
|
|
107
|
+
* prints its protocol, command, model, context size, key (redacted), auth mode and args, and no origin:
|
|
108
|
+
* the command and the args are the user's own config. The view is an allowlist, so a field added to the
|
|
109
|
+
* config prints nothing until it is added here on purpose.
|
|
102
110
|
*
|
|
103
111
|
* The text ends with a newline, and each line passes through `inertLine`. It is YAML 1.1, so a reader of
|
|
104
112
|
* that version reads `off` as a string, and no line folds.
|
|
@@ -118,6 +126,11 @@ export function printConfig(config, source) {
|
|
|
118
126
|
])),
|
|
119
127
|
concurrency: config.concurrency ?? DEFAULT_CONCURRENCY,
|
|
120
128
|
maxFindings: config.maxFindings ?? DEFAULT_MAX_FINDINGS,
|
|
129
|
+
maxReviewTokens: config.maxReviewTokens ?? DEFAULT_MAX_REVIEW_TOKENS,
|
|
130
|
+
reviewTimeoutMs: config.reviewTimeoutMs ?? DEFAULT_REVIEW_TIMEOUT_MS,
|
|
131
|
+
exclude: [
|
|
132
|
+
...config.exclude ?? [],
|
|
133
|
+
],
|
|
121
134
|
warnings: [...config.warnings],
|
|
122
135
|
};
|
|
123
136
|
return stringify(view, { version: '1.1', lineWidth: 0, blockQuote: false }).split('\n').map(line => inertLine(line)).join('\n');
|
package/dist/cli/render.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import type { QuorumEvent } from '../core/types.ts';
|
|
|
6
6
|
* are the CLI's progress output on stderr, so a person follows a run without the full event stream.
|
|
7
7
|
* Each line passes through `inertLine` whole: the reasons, details and file names it carries come
|
|
8
8
|
* from the finder or the diff, and nothing in them can act on a terminal or a CI log. When `prefixed`,
|
|
9
|
-
* a line of an event that names a profile starts with `[<profile>] `: the `flag:` and totals
|
|
10
|
-
* belong to the whole review and never do.
|
|
9
|
+
* a line of an event that names a profile starts with `[<profile>] `: the `left out:`, `flag:` and totals
|
|
10
|
+
* lines belong to the whole review and never do.
|
|
11
11
|
*/
|
|
12
12
|
export declare function renderEvent(event: QuorumEvent, prefixed?: boolean): string | undefined;
|
|
13
13
|
/**
|
package/dist/cli/render.js
CHANGED
|
@@ -9,8 +9,8 @@ import { presetOf } from "../providers/presets.js";
|
|
|
9
9
|
* are the CLI's progress output on stderr, so a person follows a run without the full event stream.
|
|
10
10
|
* Each line passes through `inertLine` whole: the reasons, details and file names it carries come
|
|
11
11
|
* from the finder or the diff, and nothing in them can act on a terminal or a CI log. When `prefixed`,
|
|
12
|
-
* a line of an event that names a profile starts with `[<profile>] `: the `flag:` and totals
|
|
13
|
-
* belong to the whole review and never do.
|
|
12
|
+
* a line of an event that names a profile starts with `[<profile>] `: the `left out:`, `flag:` and totals
|
|
13
|
+
* lines belong to the whole review and never do.
|
|
14
14
|
*/
|
|
15
15
|
export function renderEvent(event, prefixed = false) {
|
|
16
16
|
const line = progressLine(event, prefixed);
|
|
@@ -19,6 +19,8 @@ export function renderEvent(event, prefixed = false) {
|
|
|
19
19
|
: inertLine(line);
|
|
20
20
|
}
|
|
21
21
|
const profilePrefix = (profile) => `[${profile}] `;
|
|
22
|
+
/** How many of the files left out the progress line names; the JSON result lists every one. */
|
|
23
|
+
const LISTED_FILES = 5;
|
|
22
24
|
function progressLine(event, prefixed) {
|
|
23
25
|
const of = (profile, line) => prefixed
|
|
24
26
|
? `${profilePrefix(profile)}${line}`
|
|
@@ -32,6 +34,8 @@ function progressLine(event, prefixed) {
|
|
|
32
34
|
return of(event.profile, `invalid finding dropped: ${event.reason}`);
|
|
33
35
|
case 'incomplete':
|
|
34
36
|
return of(event.entry.profile, `incomplete: ${event.entry.reason} (${event.entry.detail})`);
|
|
37
|
+
case 'left-out':
|
|
38
|
+
return leftOutLine(event.files);
|
|
35
39
|
case 'flag':
|
|
36
40
|
return `flag: ${event.flag.code}${where(event.flag)} (${event.flag.detail})`;
|
|
37
41
|
case 'run:end':
|
|
@@ -40,6 +44,21 @@ function progressLine(event, prefixed) {
|
|
|
40
44
|
return undefined;
|
|
41
45
|
}
|
|
42
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The line that names the files a review left out: their count, the first `LISTED_FILES` of them as
|
|
49
|
+
* `<file> (<reason>)`, then how many more. A file is a JSON string, as a flag's is; the empty name, which
|
|
50
|
+
* stands for a part of the diff no header names, is `<no path>`.
|
|
51
|
+
*/
|
|
52
|
+
function leftOutLine(files) {
|
|
53
|
+
const named = (file) => file === ''
|
|
54
|
+
? '<no path>'
|
|
55
|
+
: JSON.stringify(file);
|
|
56
|
+
const entries = files.slice(0, LISTED_FILES).map(({ file, reason }) => `${named(file)} (${reason})`);
|
|
57
|
+
const more = files.length > LISTED_FILES
|
|
58
|
+
? ` and ${files.length - LISTED_FILES} more`
|
|
59
|
+
: '';
|
|
60
|
+
return `left out: ${files.length} file(s): ${entries.join(', ')}${more}`;
|
|
61
|
+
}
|
|
43
62
|
/** Where a flag points: the file as a JSON string, with the line when it has one, else the line alone. */
|
|
44
63
|
function where({ file, line }) {
|
|
45
64
|
if (file !== undefined && line !== undefined)
|
package/dist/config/env.d.ts
CHANGED
|
@@ -8,13 +8,18 @@ export type Env = Readonly<Record<string, string | undefined>>;
|
|
|
8
8
|
* not break a key. A blank variable is unset, and so is one the environment only inherits from its prototype.
|
|
9
9
|
*/
|
|
10
10
|
export declare function envValue(env: Env, name: string): string | undefined;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* What the variables of one role set: only the variables that are set. `contextTokens`, `timeoutMs` and
|
|
13
|
+
* `retries` are `QUORUM_<ROLE>_CONTEXT_TOKENS`, `_TIMEOUT_MS` and `_RETRIES`, each read as a whole number.
|
|
14
|
+
*/
|
|
12
15
|
export interface RoleOverrides {
|
|
13
16
|
readonly preset?: string;
|
|
14
17
|
readonly protocol?: string;
|
|
15
18
|
readonly baseUrl?: string;
|
|
16
19
|
readonly model?: string;
|
|
17
20
|
readonly contextTokens?: number;
|
|
21
|
+
readonly timeoutMs?: number;
|
|
22
|
+
readonly retries?: number;
|
|
18
23
|
readonly apiKey?: string;
|
|
19
24
|
}
|
|
20
25
|
/** What the environment holds for the config layer. */
|
|
@@ -25,6 +30,10 @@ export interface EnvLayer {
|
|
|
25
30
|
readonly voter: RoleOverrides;
|
|
26
31
|
/** `QUORUM_CLAUDE_CODE_COMMAND`, trimmed: present only when it is set and `commandProblem` finds nothing wrong with it. */
|
|
27
32
|
readonly claudeCodeCommand?: string;
|
|
33
|
+
/** `QUORUM_MAX_REVIEW_TOKENS`: present only when it is set and in range. */
|
|
34
|
+
readonly maxReviewTokens?: number;
|
|
35
|
+
/** `QUORUM_REVIEW_TIMEOUT_MS`: present only when it is set and in range. */
|
|
36
|
+
readonly reviewTimeoutMs?: number;
|
|
28
37
|
/** The deprecation line, when an alias is set, then the line naming the `QUORUM_` variables nothing reads. */
|
|
29
38
|
readonly warnings: readonly string[];
|
|
30
39
|
readonly issues: readonly ConfigIssue[];
|
|
@@ -37,17 +46,20 @@ export declare const VARIABLE_NAME: RegExp;
|
|
|
37
46
|
export declare const CLAUDE_CODE_COMMAND = "QUORUM_CLAUDE_CODE_COMMAND";
|
|
38
47
|
/**
|
|
39
48
|
* Every variable the environment layer reads: `QUORUM_CONFIG`, `QUORUM_PROFILES`, `QUORUM_CLAUDE_CODE_COMMAND`, the
|
|
40
|
-
* `QUORUM_` form of each role's variables and the deprecated aliases of those that have one.
|
|
41
|
-
* variable added to `VARIABLES` joins it.
|
|
49
|
+
* review's two limits, the `QUORUM_` form of each role's variables and the deprecated aliases of those that have one.
|
|
50
|
+
* The one list: a variable added to `VARIABLES` or `LIMIT_VARIABLES` joins it.
|
|
42
51
|
*/
|
|
43
52
|
export declare const READ_VARIABLES: ReadonlySet<string>;
|
|
44
53
|
/**
|
|
45
|
-
* Read the `QUORUM_*` variables: the preset, protocol, base URL, model, context size and key
|
|
46
|
-
* which are `QUORUM_RESEARCH_*` and `QUORUM_VOTER_*`, `QUORUM_PROFILES`, and
|
|
47
|
-
* executable of the `claude-code` protocol: an absolute path, or a name to
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
54
|
+
* Read the `QUORUM_*` variables: the preset, protocol, base URL, model, context size, deadline, retries and key
|
|
55
|
+
* of each role, which are `QUORUM_RESEARCH_*` and `QUORUM_VOTER_*`, `QUORUM_PROFILES`, and
|
|
56
|
+
* `QUORUM_CLAUDE_CODE_COMMAND`, the executable of the `claude-code` protocol: an absolute path, or a name to
|
|
57
|
+
* find on `PATH`; and the review's two limits, the run-level `QUORUM_MAX_REVIEW_TOKENS` and
|
|
58
|
+
* `QUORUM_REVIEW_TIMEOUT_MS`, which belong to no role and are read as strictly as a role's numbers.
|
|
59
|
+
* `RESEARCH_*` and `VOTER_*` are read as deprecated aliases of the base URL, model and key, and
|
|
60
|
+
* the `QUORUM_` form wins; the context size (`QUORUM_RESEARCH_CONTEXT_TOKENS`, `QUORUM_VOTER_CONTEXT_TOKENS`),
|
|
61
|
+
* the deadline (`_TIMEOUT_MS`) and the retries (`_RETRIES`) have no alias. Any other variable set under a
|
|
62
|
+
* `QUORUM_` name is named in one warning. No message repeats a value.
|
|
51
63
|
*/
|
|
52
64
|
export declare function readEnv(env: Env): EnvLayer;
|
|
53
65
|
/** A provider of a config: its settings, or an object implementing `Provider`. */
|
|
@@ -69,16 +81,17 @@ export declare function setsOnlyBaseUrl(overrides: RoleOverrides): boolean;
|
|
|
69
81
|
* Set the variables of each role on its provider. The research variables go on the provider research is
|
|
70
82
|
* bound to. The voter variables go on the voter's own provider, or, when the voter shares the research
|
|
71
83
|
* provider, derive a provider named `voter` from it: a copy on the same endpoint, and on another one a copy
|
|
72
|
-
* with no key, header, query, body field, model or context size (ADR-0013)
|
|
73
|
-
* builds the role's provider from its variables alone.
|
|
74
|
-
* so it crosses to neither: a role's variables that name a
|
|
75
|
-
* context size of the provider they are set on, the
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* is
|
|
80
|
-
*
|
|
81
|
-
*
|
|
84
|
+
* with no key, header, query, body field, model or context size (ADR-0013); its deadline and retries stay, as
|
|
85
|
+
* its `maxTokens` does. A preset or a protocol variable builds the role's provider from its variables alone.
|
|
86
|
+
* A context size describes one model on one endpoint, so it crosses to neither: a role's variables that name a
|
|
87
|
+
* preset, a protocol, a base URL or a model drop the context size of the provider they are set on, the
|
|
88
|
+
* derived voter's included, unless they set one; a variable that sets only a key, a deadline or a retry
|
|
89
|
+
* count leaves it. A provider object cannot be changed: each variable aimed at one is an issue. Nothing it
|
|
90
|
+
* is given changes; nested objects are shared. A role bound to a name that is not an own key of `providers`
|
|
91
|
+
* is an issue at that role, and nothing is applied. `builtIn` is true when `providers` is the built-in
|
|
92
|
+
* default alone: while the research variables name no preset or protocol, a voter derived from it whose
|
|
93
|
+
* variables set a base URL alone speaks OpenAI-compatible to it, as that variable always meant, and does not
|
|
94
|
+
* inherit the default's own protocol. A provider of a config keeps what it names.
|
|
82
95
|
*/
|
|
83
96
|
export declare function applyRoleOverrides(providers: Readonly<Record<string, ProviderEntry>>, roles: RoleBinding, layer: Pick<EnvLayer, 'research' | 'voter'>, builtIn?: boolean): {
|
|
84
97
|
providers: Record<string, ProviderEntry>;
|