@humanbased/crosscheck 1.2.0-beta.79 → 1.2.0-beta.81
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 +51 -5
- package/crosscheck.config.example.yml +39 -8
- package/dist/__tests__/board.test.js +11 -0
- package/dist/__tests__/board.test.js.map +1 -1
- package/dist/__tests__/onboard-preservation.test.js +54 -3
- package/dist/__tests__/onboard-preservation.test.js.map +1 -1
- package/dist/__tests__/repository-guidance.test.js +1 -1
- package/dist/__tests__/repository-guidance.test.js.map +1 -1
- package/dist/__tests__/review-models.test.js +5 -2
- package/dist/__tests__/review-models.test.js.map +1 -1
- package/dist/__tests__/review-strategy.test.d.ts +2 -0
- package/dist/__tests__/review-strategy.test.d.ts.map +1 -0
- package/dist/__tests__/review-strategy.test.js +397 -0
- package/dist/__tests__/review-strategy.test.js.map +1 -0
- package/dist/commands/onboard.d.ts +25 -3
- package/dist/commands/onboard.d.ts.map +1 -1
- package/dist/commands/onboard.js +151 -46
- package/dist/commands/onboard.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +22 -4
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +38 -6
- package/dist/commands/watch.js.map +1 -1
- package/dist/config/review-model-tiers.json +3 -3
- package/dist/config/review-strategy.json +204 -0
- package/dist/config/schema.d.ts +7 -5
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +29 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/github/client.d.ts +16 -1
- package/dist/github/client.d.ts.map +1 -1
- package/dist/github/client.js +32 -1
- package/dist/github/client.js.map +1 -1
- package/dist/github/webhook.d.ts +4 -0
- package/dist/github/webhook.d.ts.map +1 -1
- package/dist/github/webhook.js.map +1 -1
- package/dist/lib/annotation.d.ts +7 -0
- package/dist/lib/annotation.d.ts.map +1 -1
- package/dist/lib/annotation.js +11 -1
- package/dist/lib/annotation.js.map +1 -1
- package/dist/lib/board.d.ts +3 -0
- package/dist/lib/board.d.ts.map +1 -1
- package/dist/lib/board.js +4 -2
- package/dist/lib/board.js.map +1 -1
- package/dist/lib/comment-bodies.d.ts +2 -0
- package/dist/lib/comment-bodies.d.ts.map +1 -1
- package/dist/lib/comment-bodies.js +5 -1
- package/dist/lib/comment-bodies.js.map +1 -1
- package/dist/lib/review-models.d.ts +15 -2
- package/dist/lib/review-models.d.ts.map +1 -1
- package/dist/lib/review-models.js +19 -6
- package/dist/lib/review-models.js.map +1 -1
- package/dist/lib/review-strategy.d.ts +92 -0
- package/dist/lib/review-strategy.d.ts.map +1 -0
- package/dist/lib/review-strategy.js +282 -0
- package/dist/lib/review-strategy.js.map +1 -0
- package/dist/lib/runner.d.ts +80 -0
- package/dist/lib/runner.d.ts.map +1 -1
- package/dist/lib/runner.js +289 -17
- package/dist/lib/runner.js.map +1 -1
- package/docs/dynamic-thoroughness.md +738 -0
- package/get-started.md +68 -7
- package/package.json +4 -3
package/dist/lib/runner.js
CHANGED
|
@@ -3,6 +3,7 @@ import { randomUUID } from 'crypto';
|
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
|
+
import { filterStepsByTypes } from './repo-workflow.js';
|
|
6
7
|
import { runCodexReview } from '../reviewers/codex.js';
|
|
7
8
|
import { runClaudeReview } from '../reviewers/claude.js';
|
|
8
9
|
import { runFixStep, runCodexFixStep } from '../reviewers/fix.js';
|
|
@@ -17,6 +18,8 @@ import { acquireRemoteLock, releaseRemoteLock } from '../github/review-status.js
|
|
|
17
18
|
import { log as fileLog, logError, classifyError } from '../lib/logger.js';
|
|
18
19
|
import { buildCommitTrailers } from '../lib/annotation.js';
|
|
19
20
|
import { resolveClaudeModel, resolveCodexModel } from '../lib/review-models.js';
|
|
21
|
+
import { resolveReviewStrategy, escalate, clampToLevels } from './review-strategy.js';
|
|
22
|
+
import { CLAUDE_EFFORT_LEVELS, CODEX_EFFORT_LEVELS } from '../config/schema.js';
|
|
20
23
|
import { buildStepIdentityFields } from '../lib/event-fields.js';
|
|
21
24
|
import { buildAttributionFooter, buildFixAppliedCommentBody, buildFixFailedCommentBody, buildConflictResolvedCommentBody, buildRetriedReviewBanner } from '../lib/comment-bodies.js';
|
|
22
25
|
import { linearWritePossible, loadWorkflow, loadHarnessSection, evaluateWhen } from '../lib/workflow.js';
|
|
@@ -239,8 +242,173 @@ function diffBucket(totalLines) {
|
|
|
239
242
|
return 'large';
|
|
240
243
|
return 'xlarge';
|
|
241
244
|
}
|
|
242
|
-
|
|
243
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Builds the input the review strategy classifies on, from the already-cloned
|
|
247
|
+
* working copy rather than the API — the runner has the repo on disk, so this
|
|
248
|
+
* costs one `git diff` instead of a round trip.
|
|
249
|
+
*
|
|
250
|
+
* Returns null when the diff can't be read. Callers then fall back to the
|
|
251
|
+
* configured tier, which is why `quality.tier` stays meaningful under smart mode.
|
|
252
|
+
*/
|
|
253
|
+
export function buildPRContext(ctx) {
|
|
254
|
+
const { tmpDir, pr } = ctx;
|
|
255
|
+
try {
|
|
256
|
+
// execFileSync, not execSync: a git ref may legally contain `;`, `$( )` and
|
|
257
|
+
// backticks, and this value drives routing rather than best-effort logging.
|
|
258
|
+
const raw = execFileSync('git', ['diff', '--numstat', `origin/${pr.base.ref}...HEAD`], { cwd: tmpDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
259
|
+
if (!raw)
|
|
260
|
+
return null;
|
|
261
|
+
const files = [];
|
|
262
|
+
let additions = 0;
|
|
263
|
+
let deletions = 0;
|
|
264
|
+
for (const line of raw.split('\n')) {
|
|
265
|
+
// numstat: <added>\t<deleted>\t<path>. Binary files report '-' for both.
|
|
266
|
+
const [add, del, ...rest] = line.split('\t');
|
|
267
|
+
const path = rest.join('\t').trim();
|
|
268
|
+
if (!path)
|
|
269
|
+
continue;
|
|
270
|
+
files.push(path);
|
|
271
|
+
additions += parseInt(add, 10) || 0;
|
|
272
|
+
deletions += parseInt(del, 10) || 0;
|
|
273
|
+
}
|
|
274
|
+
if (files.length === 0)
|
|
275
|
+
return null;
|
|
276
|
+
return {
|
|
277
|
+
files,
|
|
278
|
+
additions,
|
|
279
|
+
deletions,
|
|
280
|
+
labels: pr.labels?.map(l => l.name) ?? [],
|
|
281
|
+
title: pr.title,
|
|
282
|
+
baseRef: pr.base.ref,
|
|
283
|
+
...(pr.base.repo.default_branch !== undefined && { defaultBranch: pr.base.repo.default_branch }),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Folds a resolved strategy into the quality config the reviewers receive, so
|
|
292
|
+
* every downstream `quality.tier` read picks up the per-PR decision without
|
|
293
|
+
* threading a new parameter through each vendor signature.
|
|
294
|
+
*
|
|
295
|
+
* A null strategy — fixed mode, or an unreadable diff — returns the config
|
|
296
|
+
* untouched, which is why `quality.tier` remains the documented fallback.
|
|
297
|
+
*/
|
|
298
|
+
export function strategyQuality(quality, strategy) {
|
|
299
|
+
if (!strategy?.tier)
|
|
300
|
+
return quality;
|
|
301
|
+
return { ...quality, tier: strategy.tier };
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Applies the class's effort alongside its tier. Without this the strategy's
|
|
305
|
+
* effort was resolved and logged but never sent, so the run line named a level
|
|
306
|
+
* the CLI was never given.
|
|
307
|
+
*
|
|
308
|
+
* `accepted` is the vendor CLI's vocabulary, which is narrower than the model's:
|
|
309
|
+
* the strategy escalates to `xhigh` on round 3 and claude-opus-5 reasons at that
|
|
310
|
+
* level, but the claude CLI has no flag for it, so claudeEffort() mapped the
|
|
311
|
+
* unknown value to `medium` — a round 3 weaker than round 2. Clamp here, where
|
|
312
|
+
* the strategy meets the config, rather than at each CLI.
|
|
313
|
+
*/
|
|
314
|
+
export function strategyVendor(vendor, strategy, accepted) {
|
|
315
|
+
if (!strategy?.effort)
|
|
316
|
+
return vendor;
|
|
317
|
+
const effort = clampToLevels(strategy.effort, accepted);
|
|
318
|
+
if (effort === null)
|
|
319
|
+
return vendor;
|
|
320
|
+
return { ...vendor, effort };
|
|
321
|
+
}
|
|
322
|
+
// NOTE on the asymmetry with `model`: an explicit vendors.*.model is honored
|
|
323
|
+
// over the strategy, but vendors.*.effort is not. That is deliberate rather than
|
|
324
|
+
// an oversight — `effort` carries a schema default, so a parsed config cannot
|
|
325
|
+
// distinguish "the user chose medium" from "nobody set it", and treating the
|
|
326
|
+
// default as a user choice would disable effort escalation for everyone. The
|
|
327
|
+
// override is documented in crosscheck.config.example.yml next to the model
|
|
328
|
+
// note; set `quality.mode: fixed` to keep a hand-set effort on every call.
|
|
329
|
+
/**
|
|
330
|
+
* True when the strategy actually determined the model that ran.
|
|
331
|
+
*
|
|
332
|
+
* Judged from the resolved model rather than from config shape, because two
|
|
333
|
+
* different configs defeat the tier map:
|
|
334
|
+
* - an explicit `vendors.*.model` outranks it, and
|
|
335
|
+
* - codex under subscription auth with no `model`/`model_tiers` resolves every
|
|
336
|
+
* tier to the CLI's own `default`, so fast/balanced/thorough are the same run.
|
|
337
|
+
* In both cases the strategy's tier is not what happened, and citing it would
|
|
338
|
+
* assert a routing decision that never took place — the exact auditability
|
|
339
|
+
* property this feature exists to provide.
|
|
340
|
+
*/
|
|
341
|
+
export function strategyDeterminedModel(vendor, strategy, resolvedModel) {
|
|
342
|
+
if (strategy === null || vendor.model)
|
|
343
|
+
return false;
|
|
344
|
+
// 'default' means the vendor CLI chose, not us.
|
|
345
|
+
return resolvedModel !== 'default';
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Classifies the PR and resolves the strategy, or returns null under
|
|
349
|
+
* `quality.mode: fixed` so the single configured tier applies unchanged.
|
|
350
|
+
*/
|
|
351
|
+
export function resolveStrategyForPR(ctx) {
|
|
352
|
+
if (ctx.config.quality.mode !== 'smart')
|
|
353
|
+
return null;
|
|
354
|
+
const prContext = buildPRContext(ctx);
|
|
355
|
+
if (!prContext)
|
|
356
|
+
return null;
|
|
357
|
+
return resolveReviewStrategy(prContext);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* The tier, effort, and vendor configs every step of one round runs under.
|
|
361
|
+
*
|
|
362
|
+
* One function rather than a fold at each use site: the review step ran the
|
|
363
|
+
* escalated strategy while the fix step re-folded the base class, so a promoted
|
|
364
|
+
* round reviewed with the stronger model and then fixed with the weaker one —
|
|
365
|
+
* and took the weaker tier's subprocess timeout with it.
|
|
366
|
+
*
|
|
367
|
+
* Rounds beyond the first escalate: the class tier was already tried and did not
|
|
368
|
+
* resolve the PR, so difficulty is now measured rather than predicted. escalate()
|
|
369
|
+
* raises effort where the model supports it and promotes a tier where it does
|
|
370
|
+
* not, and never weakens the model.
|
|
371
|
+
*/
|
|
372
|
+
export function resolveRoundExecution(config, strategy, round) {
|
|
373
|
+
if (!strategy) {
|
|
374
|
+
return {
|
|
375
|
+
strategy: null,
|
|
376
|
+
quality: config.quality,
|
|
377
|
+
claudeVendor: config.vendors.claude,
|
|
378
|
+
codexVendor: config.vendors.codex,
|
|
379
|
+
roundConfig: config,
|
|
380
|
+
escalated: false,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
// The vendors that may actually run this round, each with the model it would
|
|
384
|
+
// use and the vocabulary its CLI accepts. Keyed to the enabled vendors rather
|
|
385
|
+
// than to claude alone: on a codex-only install the claude tier model is never
|
|
386
|
+
// called, so judging escalation by its effort ladder promoted a tier every
|
|
387
|
+
// round while codex sat at the effort it started on.
|
|
388
|
+
const baseQuality = strategyQuality(config.quality, strategy);
|
|
389
|
+
const lanes = [];
|
|
390
|
+
if (config.vendors.claude.enabled) {
|
|
391
|
+
lanes.push({ model: resolveClaudeModel(baseQuality, config.vendors.claude), accepted: CLAUDE_EFFORT_LEVELS });
|
|
392
|
+
}
|
|
393
|
+
if (config.vendors.codex.enabled) {
|
|
394
|
+
lanes.push({ model: resolveCodexModel(baseQuality, config.vendors.codex), accepted: CODEX_EFFORT_LEVELS });
|
|
395
|
+
}
|
|
396
|
+
const escalated = escalate({ tier: strategy.tier ?? config.quality.tier, effort: strategy.effort }, round, lanes);
|
|
397
|
+
const roundStrategy = { ...strategy, tier: escalated.tier, effort: escalated.effort };
|
|
398
|
+
const quality = strategyQuality(config.quality, roundStrategy);
|
|
399
|
+
const claudeVendor = strategyVendor(config.vendors.claude, roundStrategy, CLAUDE_EFFORT_LEVELS);
|
|
400
|
+
const codexVendor = strategyVendor(config.vendors.codex, roundStrategy, CODEX_EFFORT_LEVELS);
|
|
401
|
+
return {
|
|
402
|
+
strategy: roundStrategy,
|
|
403
|
+
quality,
|
|
404
|
+
claudeVendor,
|
|
405
|
+
codexVendor,
|
|
406
|
+
roundConfig: { ...config, quality, vendors: { ...config.vendors, claude: claudeVendor, codex: codexVendor } },
|
|
407
|
+
escalated: escalated.tier !== strategy.tier || escalated.effort !== strategy.effort,
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function emitPRComplexity(ctx, triggerField, effectiveTierForRun) {
|
|
411
|
+
const { owner, repoName, prNumber, tmpDir, pr } = ctx;
|
|
244
412
|
try {
|
|
245
413
|
const raw = execSync(`git diff --stat origin/${pr.base.ref}...HEAD`, { cwd: tmpDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
246
414
|
if (!raw)
|
|
@@ -271,7 +439,7 @@ function emitPRComplexity(ctx, triggerField) {
|
|
|
271
439
|
diff_bucket: diffBucket(insertions + deletions),
|
|
272
440
|
file_mix: mix,
|
|
273
441
|
languages: [...langSet],
|
|
274
|
-
quality_tier:
|
|
442
|
+
quality_tier: effectiveTierForRun,
|
|
275
443
|
...triggerField,
|
|
276
444
|
});
|
|
277
445
|
}
|
|
@@ -340,12 +508,68 @@ async function pushWithNonFastForwardHandling(params) {
|
|
|
340
508
|
export async function runWorkflow(ctx) {
|
|
341
509
|
const { owner, repoName, prNumber, pr, tmpDir, token, config, origin, log, onPhaseChange, trigger } = ctx;
|
|
342
510
|
const triggerField = trigger !== undefined ? { trigger } : {};
|
|
343
|
-
const
|
|
511
|
+
const configuredSteps = (ctx.steps ?? loadWorkflow(process.cwd())).map(step => {
|
|
344
512
|
if (!step.harness || step.instructions)
|
|
345
513
|
return step;
|
|
346
514
|
const resolved = loadHarnessSection(step.harness, process.cwd());
|
|
347
515
|
return resolved ? { ...step, instructions: resolved } : step;
|
|
348
516
|
});
|
|
517
|
+
// Resolved once per runWorkflow call: the fix step pushes commits, so
|
|
518
|
+
// re-classifying per step could yield a different class and make the review
|
|
519
|
+
// and recheck comments cite different tiers for the same PR.
|
|
520
|
+
//
|
|
521
|
+
// Not once per PR: --crazy/--halfcrazy re-enter runWorkflow per round, and by
|
|
522
|
+
// then the diff includes crosscheck's own fix commits, so a later round can
|
|
523
|
+
// legitimately classify differently. Each comment cites the class that
|
|
524
|
+
// produced it, so the record stays accurate either way.
|
|
525
|
+
const strategy = resolveStrategyForPR(ctx);
|
|
526
|
+
if (config.quality.mode === 'smart' && !strategy) {
|
|
527
|
+
// A smart-mode install quietly behaving as fixed is otherwise invisible.
|
|
528
|
+
fileLog({ level: 'warn', event: 'strategy_unresolved', repo: `${owner}/${repoName}`, pr: prNumber, reason: 'pr_context_unavailable', fallback_tier: config.quality.tier });
|
|
529
|
+
}
|
|
530
|
+
else if (strategy) {
|
|
531
|
+
// A config written before `mode` existed parses as smart on upgrade, so a
|
|
532
|
+
// hand-set `quality.tier` can be silently overridden. onboard preserves the
|
|
533
|
+
// old tier by reading raw yaml, but that only helps users who re-run it —
|
|
534
|
+
// so record it here for everyone else.
|
|
535
|
+
//
|
|
536
|
+
// info, not warn: `config.quality.tier` carries a schema default of
|
|
537
|
+
// `balanced` on every install, so the parsed config cannot tell a hand-set
|
|
538
|
+
// tier from an unset one. Five of the eight classes resolve to something
|
|
539
|
+
// other than balanced, which made this fire on the majority of PRs — and
|
|
540
|
+
// recommend a `mode: fixed` opt-out to users who never chose a tier at all.
|
|
541
|
+
// Only the raw yaml can draw that distinction (thoroughnessDefaults), and it
|
|
542
|
+
// is not available on this path.
|
|
543
|
+
if (strategy.tier && strategy.tier !== config.quality.tier) {
|
|
544
|
+
fileLog({ level: 'info', event: 'strategy_overrode_configured_tier', repo: `${owner}/${repoName}`, pr: prNumber, configured_tier: config.quality.tier, applied_tier: strategy.tier, pr_class: strategy.classId });
|
|
545
|
+
}
|
|
546
|
+
fileLog({ level: 'info', event: 'strategy_resolved', repo: `${owner}/${repoName}`, pr: prNumber, strategy_version: strategy.version, pr_class: strategy.classId, tier: strategy.tier, effort: strategy.effort, steps: strategy.steps, domain: strategy.domain });
|
|
547
|
+
}
|
|
548
|
+
// The class's step set NARROWS the configured pipeline; it never widens it.
|
|
549
|
+
// A repo set to review-only stays review-only whatever the class says, which
|
|
550
|
+
// matches how per-repo `crosscheck alter` overrides compose. Reuses
|
|
551
|
+
// filterStepsByTypes so the conflict-resolve rule (orthogonal to the depth
|
|
552
|
+
// ladder, kept only when the depth permits code modification) stays in one
|
|
553
|
+
// place rather than being re-derived here.
|
|
554
|
+
const steps = (() => {
|
|
555
|
+
if (!strategy || strategy.steps.length === 0)
|
|
556
|
+
return configuredSteps;
|
|
557
|
+
const classTypes = strategy.steps.filter((t) => t === 'review' || t === 'fix' || t === 'recheck');
|
|
558
|
+
if (classTypes.length === 0)
|
|
559
|
+
return configuredSteps;
|
|
560
|
+
const narrowed = filterStepsByTypes(configuredSteps, classTypes);
|
|
561
|
+
const dropped = configuredSteps.length - narrowed.length;
|
|
562
|
+
if (dropped > 0) {
|
|
563
|
+
log(chalk.dim(` strategy v${strategy.version}: ${strategy.classId} → ${classTypes.join(', ')} (${dropped} step${dropped === 1 ? '' : 's'} dropped)`));
|
|
564
|
+
fileLog({ level: 'info', event: 'strategy_steps_narrowed', repo: `${owner}/${repoName}`, pr: prNumber, pr_class: strategy.classId, configured: configuredSteps.map((x) => x.type), applied: narrowed.map((x) => x.type), strategy_version: strategy.version });
|
|
565
|
+
}
|
|
566
|
+
return narrowed;
|
|
567
|
+
})();
|
|
568
|
+
if (strategy && strategy.tier === null) {
|
|
569
|
+
log(chalk.dim(` strategy v${strategy.version}: ${strategy.classId} → skipped (${strategy.reason})`));
|
|
570
|
+
fileLog({ level: 'info', event: 'pr_skipped', repo: `${owner}/${repoName}`, pr: prNumber, reason: 'strategy_class_skip', pr_class: strategy.classId, strategy_version: strategy.version });
|
|
571
|
+
return { verdict: null, strategySkipped: strategy.classId };
|
|
572
|
+
}
|
|
349
573
|
const results = {};
|
|
350
574
|
// SHAs the workflow pushed AND set a `crosscheck/review` pending status on.
|
|
351
575
|
// Each one must be released in the finally below — otherwise the pending
|
|
@@ -426,7 +650,15 @@ export async function runWorkflow(ctx) {
|
|
|
426
650
|
const workflowStart = Date.now();
|
|
427
651
|
const stepsRun = [];
|
|
428
652
|
let currentStepName;
|
|
429
|
-
|
|
653
|
+
// Class picks tier AND effort under smart; untouched config under fixed.
|
|
654
|
+
// Every step of this round reads from here — review, fix, and recheck alike —
|
|
655
|
+
// so a promoted round cannot review with one model and fix with another.
|
|
656
|
+
//
|
|
657
|
+
// Above the try, and above emitPRComplexity, because both the complexity event
|
|
658
|
+
// and workflow_complete report the tier that ran: an escalated round reporting
|
|
659
|
+
// the base class tier is the same defect as a comment citing one.
|
|
660
|
+
const { strategy: roundStrategy, quality, claudeVendor, codexVendor, roundConfig, escalated } = resolveRoundExecution(config, strategy, ctx.round ?? 1);
|
|
661
|
+
emitPRComplexity(ctx, triggerField, quality.tier);
|
|
430
662
|
try {
|
|
431
663
|
// Inside the try so a preflight failure still reaches the completion handler in
|
|
432
664
|
// the finally — resolving above it meant a failed mint skipped workflow_complete
|
|
@@ -438,6 +670,22 @@ export async function runWorkflow(ctx) {
|
|
|
438
670
|
linearAuth = await resolveLinearAuth(config.linear, getLinearCredentials(config.linear.auth));
|
|
439
671
|
fileLog({ level: 'info', event: 'linear_auth_resolved', repo: `${owner}/${repoName}`, pr: prNumber, mode: linearAuth.mode, actor: linearAuth.actor });
|
|
440
672
|
}
|
|
673
|
+
// Logged once per run, not per step: nothing here depends on `step`, and
|
|
674
|
+
// recomputing inside the loop printed the same line for review and recheck.
|
|
675
|
+
if (strategy && roundStrategy) {
|
|
676
|
+
// Report the effort each vendor was actually GIVEN, not the level the round
|
|
677
|
+
// asked for. The two CLI vocabularies differ, so one round can send codex
|
|
678
|
+
// `xhigh` and claude `high`; printing the request names a level nobody ran.
|
|
679
|
+
const appliedEffort = [...new Set([
|
|
680
|
+
...(config.vendors.claude.enabled ? [claudeVendor.effort] : []),
|
|
681
|
+
...(config.vendors.codex.enabled ? [codexVendor.effort] : []),
|
|
682
|
+
])].join('/');
|
|
683
|
+
const escalatedNote = escalated ? ` · round ${ctx.round} escalated` : '';
|
|
684
|
+
log(chalk.dim(` strategy v${strategy.version}: ${strategy.classId} → ${roundStrategy.tier ?? 'skip'} tier${appliedEffort ? ` (${appliedEffort})` : ''}${escalatedNote}`));
|
|
685
|
+
if (escalatedNote) {
|
|
686
|
+
fileLog({ level: 'info', event: 'strategy_escalated', repo: `${owner}/${repoName}`, pr: prNumber, round: ctx.round, from_tier: strategy.tier, to_tier: roundStrategy.tier, from_effort: strategy.effort, to_effort: roundStrategy.effort, applied_effort_claude: config.vendors.claude.enabled ? claudeVendor.effort : null, applied_effort_codex: config.vendors.codex.enabled ? codexVendor.effort : null, strategy_version: strategy.version });
|
|
687
|
+
}
|
|
688
|
+
}
|
|
441
689
|
for (const step of steps) {
|
|
442
690
|
currentStepName = step.name;
|
|
443
691
|
stepsRun.push(step.name);
|
|
@@ -503,16 +751,18 @@ export async function runWorkflow(ctx) {
|
|
|
503
751
|
let effort;
|
|
504
752
|
let retried;
|
|
505
753
|
const skillSession = skillSessionFor(step.name, effectiveType);
|
|
754
|
+
// Under `quality.mode: smart` the PR's class picks the tier; under fixed
|
|
755
|
+
// this is config.quality untouched.
|
|
506
756
|
const runReviewWithVendor = async (candidate) => {
|
|
507
757
|
if (candidate === 'codex') {
|
|
508
758
|
;
|
|
509
|
-
({ review: rawReview, tokensUsed, model, effort, retried } = await runCodexReview(tmpDir, pr.base.ref, pr.title,
|
|
759
|
+
({ review: rawReview, tokensUsed, model, effort, retried } = await runCodexReview(tmpDir, pr.base.ref, pr.title, quality, codexVendor, step.instructions, undefined, ctx.overrideTimeoutMs ?? vendorTimeoutMs(config.vendors.codex.timeout_sec), log, ctx.issueContext, skillSession));
|
|
510
760
|
inputTokens = undefined;
|
|
511
761
|
outputTokens = undefined;
|
|
512
762
|
}
|
|
513
763
|
else {
|
|
514
764
|
;
|
|
515
|
-
({ review: rawReview, tokensUsed, inputTokens, outputTokens, model, effort, retried } = await runClaudeReview(tmpDir, pr.base.ref, pr.title,
|
|
765
|
+
({ review: rawReview, tokensUsed, inputTokens, outputTokens, model, effort, retried } = await runClaudeReview(tmpDir, pr.base.ref, pr.title, quality, claudeVendor, config.budget.per_review_usd, step.instructions, undefined, ctx.overrideTimeoutMs ?? vendorTimeoutMs(config.vendors.claude.timeout_sec), !!ctx.roundMode, log, ctx.issueContext, skillSession));
|
|
516
766
|
}
|
|
517
767
|
};
|
|
518
768
|
try {
|
|
@@ -604,8 +854,8 @@ export async function runWorkflow(ctx) {
|
|
|
604
854
|
fileLog({ level: 'info', event: 'review_complete', repo: `${owner}/${repoName}`, pr: prNumber, reviewer, model, ...stepIdentity, verdict, duration_ms: Date.now() - stepStart, tokens_used: tokensUsed, skills_activated: activatedSkills.map(skill => skill.name), ...(inputTokens !== undefined && { input_tokens: inputTokens }), ...(outputTokens !== undefined && { output_tokens: outputTokens }), ...(ctx.round !== undefined && { round: ctx.round }), ...(ctx.roundMode && { mode: ctx.roundMode }), ...triggerField });
|
|
605
855
|
// Recheck verdict is stored separately to preserve the original review's commentCount on the board
|
|
606
856
|
const phaseUpdate = isRecheck
|
|
607
|
-
? { recheckVerdict: verdict, phase: donePhase, recheckTokens: tokensUsed, recheckReviewer: reviewer, qualityTier:
|
|
608
|
-
: { verdict, commentCount, phase: donePhase, crTokens: tokensUsed, crReviewer: reviewer, qualityTier:
|
|
857
|
+
? { recheckVerdict: verdict, phase: donePhase, recheckTokens: tokensUsed, recheckReviewer: reviewer, qualityTier: quality.tier }
|
|
858
|
+
: { verdict, commentCount, phase: donePhase, crTokens: tokensUsed, crReviewer: reviewer, qualityTier: quality.tier };
|
|
609
859
|
if (ctx.dryRun) {
|
|
610
860
|
onPhaseChange('dry-run — comment not posted', phaseUpdate);
|
|
611
861
|
log(chalk.dim(`\n--- dry-run: comment that would be posted ---\n${commentBody}\n--- end ---`));
|
|
@@ -640,7 +890,13 @@ export async function runWorkflow(ctx) {
|
|
|
640
890
|
annotationSha = execSync('git rev-parse HEAD', { cwd: tmpDir, encoding: 'utf8' }).trim();
|
|
641
891
|
}
|
|
642
892
|
catch { /* fall back to pr.head.sha if git is unavailable */ }
|
|
643
|
-
const commentId = await postReviewComment(octokit, owner, repoName, prNumber, commentBody, reviewer, config.brand, origin, verdict ?? undefined, priorReviewId, isRecheck, model, effectiveType, ctx.round ?? 1, annotationSha, nextStepAnnotation, ctx.trigger === 'kickass' ? 'kickass' : undefined, activatedSkills, effort
|
|
893
|
+
const commentId = await postReviewComment(octokit, owner, repoName, prNumber, commentBody, reviewer, config.brand, origin, verdict ?? undefined, priorReviewId, isRecheck, model, effectiveType, ctx.round ?? 1, annotationSha, nextStepAnnotation, ctx.trigger === 'kickass' ? 'kickass' : undefined, activatedSkills, effort,
|
|
894
|
+
// Withheld when an explicit vendors.*.model overrode the tier map:
|
|
895
|
+
// citing a tier the run did not use would assert a routing decision
|
|
896
|
+
// that never happened.
|
|
897
|
+
strategyDeterminedModel(reviewer === 'codex' ? config.vendors.codex : config.vendors.claude, roundStrategy, model) && roundStrategy?.tier
|
|
898
|
+
? { version: roundStrategy.version, classId: roundStrategy.classId, tier: roundStrategy.tier, reason: roundStrategy.reason }
|
|
899
|
+
: undefined);
|
|
644
900
|
const commentUrl = `github.com/${owner}/${repoName}/pull/${prNumber}`;
|
|
645
901
|
fileLog({ level: 'info', event: 'comment_posted', repo: `${owner}/${repoName}`, pr: prNumber, url: `https://${commentUrl}` });
|
|
646
902
|
// Mirror the verdict onto the PR's Linear issue. `run` and `watch` both
|
|
@@ -734,8 +990,14 @@ export async function runWorkflow(ctx) {
|
|
|
734
990
|
skipFix('no_vendor');
|
|
735
991
|
continue;
|
|
736
992
|
}
|
|
737
|
-
|
|
738
|
-
|
|
993
|
+
// The fix step holds the review's tier — this round's, escalation
|
|
994
|
+
// included: it is generation against an explicit findings list, which
|
|
995
|
+
// models handle well, but a cheap fixer that introduces a regression costs
|
|
996
|
+
// a whole extra round. Recheck does not step down either — it decides
|
|
997
|
+
// whether to spend another round, and a weak judge there is how loops run
|
|
998
|
+
// away.
|
|
999
|
+
const claudeFixModel = resolveClaudeModel(quality, claudeVendor);
|
|
1000
|
+
const codexFixModel = resolveCodexModel(quality, codexVendor);
|
|
739
1001
|
// Guard: don't push more than MAX_CROSSCHECK_COMMITS per PR.
|
|
740
1002
|
// Scope to commits ahead of base so long-lived branches (e.g. staging)
|
|
741
1003
|
// don't count [crosscheck] commits from previously merged PRs.
|
|
@@ -760,13 +1022,17 @@ export async function runWorkflow(ctx) {
|
|
|
760
1022
|
let fixEffort;
|
|
761
1023
|
let fixErr = undefined;
|
|
762
1024
|
let activeVendor = vendor;
|
|
763
|
-
|
|
1025
|
+
// The strategy tier, not the configured one: a risky PR runs the thorough
|
|
1026
|
+
// model here, and the balanced 600s budget would cut it off.
|
|
1027
|
+
const tierMs = tierTimeoutMs(quality.tier);
|
|
764
1028
|
const skillSession = skillSessionFor(step.name, effectiveType);
|
|
765
1029
|
const runFix = async (v) => {
|
|
766
1030
|
if (v === 'codex') {
|
|
767
|
-
return runCodexFixStep(tmpDir, pr.base.ref, pr.title, reviewCommentBody, step.instructions ?? '', codexFixModel, ctx.overrideTimeoutMs ?? vendorTimeoutMs(config.vendors.codex.timeout_sec) ?? tierMs, skillSession,
|
|
1031
|
+
return runCodexFixStep(tmpDir, pr.base.ref, pr.title, reviewCommentBody, step.instructions ?? '', codexFixModel, ctx.overrideTimeoutMs ?? vendorTimeoutMs(config.vendors.codex.timeout_sec) ?? tierMs, skillSession, codexVendor.effort);
|
|
768
1032
|
}
|
|
769
|
-
|
|
1033
|
+
// roundConfig, not config: runFixStep reads vendors.claude.effort and
|
|
1034
|
+
// quality.tier out of it, and both must be this round's values.
|
|
1035
|
+
return runFixStep(tmpDir, pr.base.ref, pr.title, reviewCommentBody, step.instructions ?? '', roundConfig, claudeFixModel, ctx.overrideTimeoutMs ?? vendorTimeoutMs(config.vendors.claude.timeout_sec) ?? tierMs, skillSession);
|
|
770
1036
|
};
|
|
771
1037
|
try {
|
|
772
1038
|
;
|
|
@@ -1069,7 +1335,9 @@ export async function runWorkflow(ctx) {
|
|
|
1069
1335
|
skipConflictResolve('codex_conflict_resolve_unsupported');
|
|
1070
1336
|
continue;
|
|
1071
1337
|
}
|
|
1072
|
-
|
|
1338
|
+
// Conflict-resolve is mechanical text surgery bounded by the markers —
|
|
1339
|
+
// measured at 37s against ~643s for a review — so it always runs fast.
|
|
1340
|
+
const conflictResolveModel = resolveClaudeModel({ ...config.quality, tier: config.quality.mode === 'smart' ? 'fast' : config.quality.tier }, config.vendors.claude);
|
|
1073
1341
|
const isFork = pr.head.repo?.full_name !== pr.base.repo.full_name;
|
|
1074
1342
|
if (isFork) {
|
|
1075
1343
|
try {
|
|
@@ -1324,7 +1592,11 @@ export async function runWorkflow(ctx) {
|
|
|
1324
1592
|
failedStep,
|
|
1325
1593
|
round: ctx.round,
|
|
1326
1594
|
trigger: ctx.trigger,
|
|
1327
|
-
|
|
1595
|
+
// The tier that actually ran, not the configured one and not the base
|
|
1596
|
+
// class tier — under smart mode all three differ, and telemetry naming the
|
|
1597
|
+
// wrong one is the same class of problem as a comment citing a tier that
|
|
1598
|
+
// never reached the vendor.
|
|
1599
|
+
qualityTier: quality.tier,
|
|
1328
1600
|
}));
|
|
1329
1601
|
}
|
|
1330
1602
|
}
|