crysk 0.6.0 → 0.6.1
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 +13 -0
- package/dist/SKILL-nncgwkx7.md +553 -0
- package/dist/cli.js +6379 -5561
- package/dist/index.js +967 -467
- package/dist/workflow-ag62s87j.yml +163 -0
- package/package.json +1 -1
- package/skills/crysk-loop/SKILL.md +2 -2
- package/src/assets.ts +34 -11
- package/src/ci/gates.ts +2 -24
- package/src/ci/platform.ts +50 -0
- package/src/ci/trigger.ts +64 -4
- package/src/commands/status.ts +2 -0
- package/src/index.ts +1 -1
- package/src/pr/answered-findings.ts +3 -0
- package/src/pr/ci-admission-gate.ts +1 -0
- package/src/pr/discovery.ts +1 -0
- package/src/pr/pr-status.ts +18 -3
- package/src/pr/publish-outcome.ts +14 -13
- package/src/pr/review-pr.ts +17 -2
- package/src/rereview/prepare.ts +13 -2
- package/src/review/exit-code.ts +60 -0
- package/src/review/findings.ts +3 -3
- package/src/review/preflight.ts +9 -1
- package/src/review/prompt-set.ts +6 -1
- package/src/review/review.ts +11 -2
- package/src/triage/adjudication.ts +35 -2
- package/src/ui/result.ts +1 -1
- package/src/updater.ts +1 -1
- package/src/watch/preflight.ts +34 -8
- package/src/watch/watch.ts +8 -4
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
import path from "node:path";
|
|
28
28
|
import { classifyCliError } from "#ci/classify-error";
|
|
29
29
|
import { recordReviewDelivered, writeCliRecord } from "#ci/cli-record";
|
|
30
|
-
import { ciExitCode } from "#ci/gates";
|
|
31
30
|
import {
|
|
32
31
|
ingestReviewMetrics,
|
|
33
32
|
notionalCostInput,
|
|
@@ -42,11 +41,12 @@ import {
|
|
|
42
41
|
} from "#pr/admission";
|
|
43
42
|
import { publishCiReviewIfEligible } from "#pr/ci-publish";
|
|
44
43
|
import type { PrDiscoveryResult } from "#pr/discovery";
|
|
45
|
-
import {
|
|
44
|
+
import type { InlinePostOutcome } from "#pr/inline";
|
|
46
45
|
import type { PostMinSeverity } from "#pr/post-floor";
|
|
47
46
|
import { type PostingStageResult, postFindingsIfEnabled } from "#pr/posting";
|
|
48
47
|
import type { CiMode } from "#pr/preflight";
|
|
49
48
|
import { unresolvedBlockingCount } from "#rereview/state";
|
|
49
|
+
import { reviewExitCode } from "#review/exit-code";
|
|
50
50
|
import type { Telemetry } from "#review/findings";
|
|
51
51
|
import type { PipelineResult } from "#review/pipeline";
|
|
52
52
|
import type { CliOptions } from "#review/preflight";
|
|
@@ -359,15 +359,16 @@ export async function publishRunOutcome(
|
|
|
359
359
|
"completed",
|
|
360
360
|
"review complete",
|
|
361
361
|
);
|
|
362
|
-
//
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
362
|
+
// One table for every mode (src/review/exit-code.ts): findings never change
|
|
363
|
+
// the code (spec 2.1), an incomplete review exits 3, a review that did not
|
|
364
|
+
// happen or a dropped posting exits 1.
|
|
365
|
+
return reviewExitCode({
|
|
366
|
+
sessionFailed: result.sessionFailed,
|
|
367
|
+
...(result.noReviewerRan === undefined
|
|
368
|
+
? {}
|
|
369
|
+
: { noReviewerRan: result.noReviewerRan }),
|
|
370
|
+
runStatus: doc.run_status,
|
|
371
|
+
droppedFindingIds: posted?.droppedFindingIds.length ?? 0,
|
|
372
|
+
blockingCount,
|
|
373
|
+
});
|
|
373
374
|
}
|
package/src/pr/review-pr.ts
CHANGED
|
@@ -114,6 +114,7 @@ import {
|
|
|
114
114
|
type AdjudicationOutcome,
|
|
115
115
|
adjudicationMarker,
|
|
116
116
|
CI_ADJUDICATOR_LOGIN,
|
|
117
|
+
trustedAdjudicator,
|
|
117
118
|
} from "#triage/adjudication";
|
|
118
119
|
import { dryRunHunterCount, reviewingLine } from "#ui/plan";
|
|
119
120
|
import { log, styleEnabled, terminalWidth } from "#ui/primitives";
|
|
@@ -264,9 +265,23 @@ export async function postAdjudicationReplies(input: {
|
|
|
264
265
|
commentId,
|
|
265
266
|
spawnFn: input.spawnFn,
|
|
266
267
|
}).catch(() => undefined);
|
|
267
|
-
|
|
268
|
+
// In platform mode the run posts as the platform App's bot, the login the platform's token
|
|
269
|
+
// exchange returned (CRYSK_PLATFORM_ACTOR). Its ruling counts only on a finding that bot
|
|
270
|
+
// posted, so the finding's own author is read too, as the gate's read does.
|
|
271
|
+
const platformActor = process.env.CRYSK_PLATFORM_ACTOR;
|
|
272
|
+
const findingAuthor =
|
|
273
|
+
author === undefined || author === CI_ADJUDICATOR_LOGIN
|
|
274
|
+
? undefined
|
|
275
|
+
: await readCommentAuthor({
|
|
276
|
+
operatorRoot: input.operatorRoot,
|
|
277
|
+
commentId: entry.threadId,
|
|
278
|
+
spawnFn: input.spawnFn,
|
|
279
|
+
}).catch(() => undefined);
|
|
280
|
+
if (
|
|
281
|
+
!trustedAdjudicator(author, findingAuthor, { kind: "ci", platformActor })
|
|
282
|
+
) {
|
|
268
283
|
process.stdout.write(
|
|
269
|
-
`::warning::crysk: the CI adjudication for ${entry.priorId} was not recorded under ${CI_ADJUDICATOR_LOGIN}; the finding still counts toward the gate\n`,
|
|
284
|
+
`::warning::crysk: the CI adjudication for ${entry.priorId} was not recorded under ${CI_ADJUDICATOR_LOGIN} or the platform's bot; the finding still counts toward the gate\n`,
|
|
270
285
|
);
|
|
271
286
|
}
|
|
272
287
|
}
|
package/src/rereview/prepare.ts
CHANGED
|
@@ -9,9 +9,9 @@ import type { Severity } from "#review/findings";
|
|
|
9
9
|
import { parseFindingCommentBadge } from "#review/report";
|
|
10
10
|
import {
|
|
11
11
|
type AdjudicationSubject,
|
|
12
|
-
CI_ADJUDICATOR_LOGIN,
|
|
13
12
|
MAX_ADJUDICATIONS_PER_RUN,
|
|
14
13
|
parseAdjudicationMarker,
|
|
14
|
+
trustedAdjudicator,
|
|
15
15
|
} from "#triage/adjudication";
|
|
16
16
|
import { parseTriageMarker } from "#triage/triage";
|
|
17
17
|
import {
|
|
@@ -981,6 +981,8 @@ export function enrichPriorsFromThreads(input: {
|
|
|
981
981
|
created_at?: string;
|
|
982
982
|
}[];
|
|
983
983
|
summaryUpdatedAt: string | null;
|
|
984
|
+
// In platform mode, the login the platform's token exchange returned (CRYSK_PLATFORM_ACTOR).
|
|
985
|
+
platformActor?: string;
|
|
984
986
|
}): PriorRecord[] {
|
|
985
987
|
const bound = bindPriorsToPosted(input.priors, input.posted);
|
|
986
988
|
return input.priors.map((prior) => {
|
|
@@ -1010,8 +1012,17 @@ export function enrichPriorsFromThreads(input: {
|
|
|
1010
1012
|
// so a verdict on an earlier head is stale and a later head needs a new
|
|
1011
1013
|
// recheck. With no headSha, no bot verdict can be shown current.
|
|
1012
1014
|
if (triage?.replyId !== undefined && input.headSha !== undefined) {
|
|
1015
|
+
// The finding itself sits among the replies (a review comment with no parent).
|
|
1016
|
+
const findingAuthor = input.replies.find((r) => r.id === parent.id)?.user;
|
|
1013
1017
|
for (const reply of thread) {
|
|
1014
|
-
if (
|
|
1018
|
+
if (
|
|
1019
|
+
!trustedAdjudicator(reply.user, findingAuthor, {
|
|
1020
|
+
kind: "ci",
|
|
1021
|
+
platformActor: input.platformActor,
|
|
1022
|
+
})
|
|
1023
|
+
) {
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1015
1026
|
const adjudication = parseAdjudicationMarker(reply.body);
|
|
1016
1027
|
if (
|
|
1017
1028
|
adjudication === null ||
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// The exit code of a review, in every mode: local, `--pr`, and headless CI.
|
|
2
|
+
//
|
|
3
|
+
// The exit code says whether the TOOL did its job, never what it found.
|
|
4
|
+
// Spec 2.1, the assistant posture: "The CLI MUST NOT exit with a non-zero code
|
|
5
|
+
// merely because findings (even `blocking` ones) were discovered". The
|
|
6
|
+
// verdict belongs to the `crysk` commit status and the posted comments.
|
|
7
|
+
//
|
|
8
|
+
// 0 the review is complete, with or without findings
|
|
9
|
+
// 1 no usable review: every hunter failed, no reviewer ran, or findings that
|
|
10
|
+
// should have been posted were dropped
|
|
11
|
+
// 2 usage error (src/cli.ts, before any review starts)
|
|
12
|
+
// 3 the review is incomplete: it ran, but a step failed (a hunter, the
|
|
13
|
+
// refuter, verify, adjudicate, or the pipeline ceiling). Run it again.
|
|
14
|
+
//
|
|
15
|
+
// WHY 3 exists, instead of folding an incomplete review into 0 or 1: until
|
|
16
|
+
// this module, an incomplete review exited 0. In GitHub the job check then
|
|
17
|
+
// stayed green while the gate's own `crysk` status read "review partial", and
|
|
18
|
+
// a pipeline outside GitHub (a script running `crysk review && merge`) had no
|
|
19
|
+
// machine-readable way to learn that a reviewer never looked. Exit 1 would
|
|
20
|
+
// have fixed the signal but merged two different next steps: 1 means
|
|
21
|
+
// something is broken, 3 means retry, the same unlock the partial status
|
|
22
|
+
// names ("/pr-hero review retries it").
|
|
23
|
+
|
|
24
|
+
import type { RunStatus } from "#review/findings";
|
|
25
|
+
|
|
26
|
+
export const EXIT_REVIEW_COMPLETE = 0;
|
|
27
|
+
export const EXIT_REVIEW_FAILED = 1;
|
|
28
|
+
export const EXIT_REVIEW_INCOMPLETE = 3;
|
|
29
|
+
|
|
30
|
+
export type ReviewExitCode =
|
|
31
|
+
| typeof EXIT_REVIEW_COMPLETE
|
|
32
|
+
| typeof EXIT_REVIEW_FAILED
|
|
33
|
+
| typeof EXIT_REVIEW_INCOMPLETE;
|
|
34
|
+
|
|
35
|
+
export function reviewExitCode(input: {
|
|
36
|
+
// Every hunter failed (PipelineResult.sessionFailed).
|
|
37
|
+
readonly sessionFailed: boolean;
|
|
38
|
+
// The pipeline's own statement that no hunter ran on a run meant to review
|
|
39
|
+
// (PipelineResult.noReviewerRan). A re-review that skipped discovery on
|
|
40
|
+
// purpose leaves it false. Absent reads as false.
|
|
41
|
+
readonly noReviewerRan?: boolean;
|
|
42
|
+
// findings.json's `run_status`: "partial" whenever any step failed.
|
|
43
|
+
readonly runStatus: RunStatus;
|
|
44
|
+
// Findings the posting stage could not deliver. 0 when nothing was posted.
|
|
45
|
+
readonly droppedFindingIds: number;
|
|
46
|
+
// Accepted and deliberately NEVER read (spec 2.1): it exists so a test can
|
|
47
|
+
// pass a high blocking count and assert the code does not change, which
|
|
48
|
+
// fails loudly if a future change wires findings into the exit code.
|
|
49
|
+
readonly blockingCount?: number;
|
|
50
|
+
}): ReviewExitCode {
|
|
51
|
+
if (input.sessionFailed || input.noReviewerRan === true) {
|
|
52
|
+
return EXIT_REVIEW_FAILED;
|
|
53
|
+
}
|
|
54
|
+
// WHY a dropped posting outranks an incomplete review: a retry repairs the
|
|
55
|
+
// missing step, but findings that never reached the PR are a delivery
|
|
56
|
+
// failure the author cannot see at all.
|
|
57
|
+
if (input.droppedFindingIds > 0) return EXIT_REVIEW_FAILED;
|
|
58
|
+
if (input.runStatus === "partial") return EXIT_REVIEW_INCOMPLETE;
|
|
59
|
+
return EXIT_REVIEW_COMPLETE;
|
|
60
|
+
}
|
package/src/review/findings.ts
CHANGED
|
@@ -661,9 +661,9 @@ export function deriveTier(
|
|
|
661
661
|
// gets this power — `inconclusive` still blocks, mirroring the rule that
|
|
662
662
|
// `refuted` requires positive disproof. Silence is not a demotion.
|
|
663
663
|
if (finding.refuter_verdict === "downgraded-latent") return "advisory";
|
|
664
|
-
// The blocking tier does not change the job's exit code:
|
|
665
|
-
//
|
|
666
|
-
//
|
|
664
|
+
// The blocking tier does not change the job's exit code: reviewExitCode
|
|
665
|
+
// never reads findings (src/review/exit-code.ts, spec 2.1), and
|
|
666
|
+
// test/review/exit-code.test.ts pins that. What it does change is the pr-hero commit status, and only in
|
|
667
667
|
// gate mode (the CI default, S4): there that status, which is the required
|
|
668
668
|
// check, goes red on blocking findings. In advisory mode the tier buys only
|
|
669
669
|
// the report's loudest register: the red badge, the "Blocking" section, and
|
package/src/review/preflight.ts
CHANGED
|
@@ -613,7 +613,15 @@ questions; use it first.
|
|
|
613
613
|
The size gate is a COST gate, not a quality gate: past its limits a diff bills
|
|
614
614
|
several times more with a much wider spread, so Crysk skips it unattended
|
|
615
615
|
rather than guess at the bill. An interactive run asks first. It says nothing
|
|
616
|
-
about how well a large diff reviews
|
|
616
|
+
about how well a large diff reviews.
|
|
617
|
+
|
|
618
|
+
Exit codes of a review (findings never change them):
|
|
619
|
+
0 the review is complete, with or without findings
|
|
620
|
+
1 no usable review: every hunter failed, no reviewer ran, or findings
|
|
621
|
+
that should have been posted were dropped
|
|
622
|
+
2 usage error
|
|
623
|
+
3 the review is incomplete: a step failed (a hunter, the refuter,
|
|
624
|
+
verify, adjudicate, or the time ceiling). Run it again.`;
|
|
617
625
|
|
|
618
626
|
const VALUE_FLAGS = new Set([
|
|
619
627
|
"--repo",
|
package/src/review/prompt-set.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { EFFORT_LEVELS, type Effort, isEffort } from "#model/catalog";
|
|
9
9
|
import type { ModelProfile } from "#model/profiles";
|
|
10
10
|
import { PROFILE_PROMPT_FILES } from "../asset-manifest";
|
|
11
|
+
import { resolveBundledFilePath } from "../assets";
|
|
11
12
|
import { wrapBlock } from "./boundary";
|
|
12
13
|
|
|
13
14
|
// Fixed order — the lab's promptSetFingerprint hashes the concatenated files
|
|
@@ -69,7 +70,11 @@ export function profilePromptSet(
|
|
|
69
70
|
`model profile "${profile.id}" names prompt set "${profile.promptSet}", which this build does not have`,
|
|
70
71
|
);
|
|
71
72
|
}
|
|
72
|
-
for (const [file,
|
|
73
|
+
for (const [file, bundledPath] of Object.entries(set)) {
|
|
74
|
+
// Set paths come from bundled `with { type: "file" }` imports, which an npm
|
|
75
|
+
// build emits as cwd-relative strings; resolve them against the module like
|
|
76
|
+
// every other bundled asset (src/assets.ts).
|
|
77
|
+
const filePath = resolveBundledFilePath(bundledPath);
|
|
73
78
|
if (defaultAgentFiles.includes(file)) {
|
|
74
79
|
overrides.agents[file] = filePath;
|
|
75
80
|
} else if (isEnginePromptFile(file)) {
|
package/src/review/review.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { engineIdentity } from "#git/identity";
|
|
|
26
26
|
import { countFreeRouteSteps } from "#model/free-discovery";
|
|
27
27
|
import { planRoutes } from "#model/routing";
|
|
28
28
|
import { reviewPr } from "#pr/review-pr";
|
|
29
|
+
import { reviewExitCode } from "#review/exit-code";
|
|
29
30
|
import type { Telemetry } from "#review/findings";
|
|
30
31
|
import { type PipelineResult, runPipeline } from "#review/pipeline";
|
|
31
32
|
import {
|
|
@@ -537,6 +538,14 @@ export async function review(options: CliOptions): Promise<number> {
|
|
|
537
538
|
})) {
|
|
538
539
|
log(line);
|
|
539
540
|
}
|
|
540
|
-
|
|
541
|
-
|
|
541
|
+
// The same table as PR and CI mode (src/review/exit-code.ts). Local mode
|
|
542
|
+
// posts nothing, so nothing can be dropped.
|
|
543
|
+
return reviewExitCode({
|
|
544
|
+
sessionFailed: result.sessionFailed,
|
|
545
|
+
...(result.noReviewerRan === undefined
|
|
546
|
+
? {}
|
|
547
|
+
: { noReviewerRan: result.noReviewerRan }),
|
|
548
|
+
runStatus: doc.run_status,
|
|
549
|
+
droppedFindingIds: 0,
|
|
550
|
+
});
|
|
542
551
|
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// `dismissed` reply to a blocking finding, and posts the ruling as a reply on the
|
|
5
5
|
// finding's thread. That reply is the only CI verdict the gate trusts, and only
|
|
6
6
|
// when all of these hold:
|
|
7
|
-
// - GitHub says the reply's author is CI_ADJUDICATOR_LOGIN
|
|
8
|
-
//
|
|
7
|
+
// - GitHub says the reply's author is CI_ADJUDICATOR_LOGIN, or the GitHub App bot
|
|
8
|
+
// that posted the finding itself (trustedAdjudicator). The marker's own text
|
|
9
|
+
// proves nothing, since anyone can type it;
|
|
9
10
|
// - its `reply=` names the comment id of the thread's LATEST triage reply, so a
|
|
10
11
|
// newer dismissal is pending again;
|
|
11
12
|
// - that triage reply is `dismissed`, and the verdict is `upheld` (D5: only a
|
|
@@ -21,6 +22,38 @@ export const ADJUDICATION_MARKER_PREFIX = `${MARKER_OPEN}adjudication `;
|
|
|
21
22
|
// The login GitHub stamps on comments posted with the workflow's GITHUB_TOKEN.
|
|
22
23
|
export const CI_ADJUDICATOR_LOGIN = "github-actions[bot]";
|
|
23
24
|
|
|
25
|
+
// A GitHub App's bot login. A person's login can never end in `[bot]`.
|
|
26
|
+
const APP_BOT_LOGIN = /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\[bot\]$/;
|
|
27
|
+
|
|
28
|
+
// Who a read trusts to rule (odd/tasks/platform-commands.md in the platform repo, S5).
|
|
29
|
+
// - `ci`: a run's own read, which decides the gate. Standalone only github-actions[bot] rules. A
|
|
30
|
+
// run a Crysk platform dispatched posts as the platform App's bot, the login the platform's
|
|
31
|
+
// token exchange returned (CRYSK_PLATFORM_ACTOR), so that login rules too, on a finding it posted.
|
|
32
|
+
// - `local`: `crysk status` on a developer's machine, which never learns the platform's login. It
|
|
33
|
+
// trusts an App's bot ruling on a finding that same bot posted. That read only advises the next
|
|
34
|
+
// action; the gate's own read is `ci`.
|
|
35
|
+
export type AdjudicatorTrust =
|
|
36
|
+
| { kind: "ci"; platformActor?: string }
|
|
37
|
+
| { kind: "local" };
|
|
38
|
+
|
|
39
|
+
export const CI_ADJUDICATOR_TRUST: AdjudicatorTrust = { kind: "ci" };
|
|
40
|
+
|
|
41
|
+
// WHY the finding's own author: another App installed on the repository can post the marker too,
|
|
42
|
+
// but only the bot that posted the finding rules on it. A person can type the marker under a
|
|
43
|
+
// finding they posted, so the author must be an App's bot.
|
|
44
|
+
export function trustedAdjudicator(
|
|
45
|
+
rulingAuthor: string | undefined,
|
|
46
|
+
findingAuthor: string | undefined,
|
|
47
|
+
trust: AdjudicatorTrust,
|
|
48
|
+
): boolean {
|
|
49
|
+
if (rulingAuthor === undefined) return false;
|
|
50
|
+
if (rulingAuthor === CI_ADJUDICATOR_LOGIN) return true;
|
|
51
|
+
if (rulingAuthor !== findingAuthor || !APP_BOT_LOGIN.test(rulingAuthor)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return trust.kind === "local" || rulingAuthor === trust.platformActor;
|
|
55
|
+
}
|
|
56
|
+
|
|
24
57
|
// The most adjudicator calls one run makes. A pending dismissal past the cap
|
|
25
58
|
// stays pending, still counted, and the next recheck takes it.
|
|
26
59
|
export const MAX_ADJUDICATIONS_PER_RUN = 5;
|
package/src/ui/result.ts
CHANGED
|
@@ -540,7 +540,7 @@ export function renderResult(input: ResultInput): string[] {
|
|
|
540
540
|
);
|
|
541
541
|
}
|
|
542
542
|
// The line that outranks every count above it. The exit code is the SHELL's
|
|
543
|
-
// (
|
|
543
|
+
// (reviewExitCode, src/review/exit-code.ts: 1 here) — this only says so.
|
|
544
544
|
if (input.sessionFailed) {
|
|
545
545
|
lines.push(
|
|
546
546
|
"",
|
package/src/updater.ts
CHANGED
|
@@ -55,7 +55,7 @@ export function detectInstallMethod(
|
|
|
55
55
|
): InstallMethod {
|
|
56
56
|
const home = options.home ?? os.homedir();
|
|
57
57
|
const execPath = options.execPath ?? process.execPath;
|
|
58
|
-
const version = options.version ?? "0.6.
|
|
58
|
+
const version = options.version ?? "0.6.1";
|
|
59
59
|
const exists = options.exists ?? existsSync;
|
|
60
60
|
|
|
61
61
|
const isSource =
|
package/src/watch/preflight.ts
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { isFullCommitId } from "#git/refs";
|
|
13
13
|
import { PR_COMMENT_MARKER_PREFIX } from "#pr/preflight";
|
|
14
|
+
import {
|
|
15
|
+
EXIT_REVIEW_COMPLETE,
|
|
16
|
+
EXIT_REVIEW_INCOMPLETE,
|
|
17
|
+
} from "#review/exit-code";
|
|
14
18
|
import type { NumstatFile } from "#review/preflight";
|
|
15
19
|
import {
|
|
16
20
|
DEFAULT_SIZE_GATE,
|
|
@@ -1096,9 +1100,21 @@ export function launchedLine(
|
|
|
1096
1100
|
return `${ts} launched pr=${pr} repo=${repoBase} head=${headSha.slice(0, 8)}`;
|
|
1097
1101
|
}
|
|
1098
1102
|
|
|
1103
|
+
// What the watcher makes of a review child's exit code, by the review's own
|
|
1104
|
+
// table (src/review/exit-code.ts). "incomplete" is exit 3: the review ran and
|
|
1105
|
+
// may have posted findings, but a step failed, so it is neither a clean "ok"
|
|
1106
|
+
// nor a "failed" whose counts mean nothing.
|
|
1107
|
+
export type ReviewResult = "ok" | "incomplete" | "failed";
|
|
1108
|
+
|
|
1109
|
+
export function reviewOutcomeResult(exitCode: number): ReviewResult {
|
|
1110
|
+
if (exitCode === EXIT_REVIEW_COMPLETE) return "ok";
|
|
1111
|
+
if (exitCode === EXIT_REVIEW_INCOMPLETE) return "incomplete";
|
|
1112
|
+
return "failed";
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1099
1115
|
export interface ReviewOutcome {
|
|
1100
1116
|
pr: number;
|
|
1101
|
-
|
|
1117
|
+
result: ReviewResult;
|
|
1102
1118
|
exitCode: number;
|
|
1103
1119
|
counts: { blocking: number; advisory: number } | null;
|
|
1104
1120
|
}
|
|
@@ -1108,13 +1124,17 @@ export function outcomeLine(
|
|
|
1108
1124
|
repoBase: string,
|
|
1109
1125
|
outcome: ReviewOutcome,
|
|
1110
1126
|
): string {
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
? outcome.counts === null
|
|
1127
|
+
const counts =
|
|
1128
|
+
outcome.counts === null
|
|
1114
1129
|
? ""
|
|
1115
|
-
: ` blocking=${outcome.counts.blocking} advisory=${outcome.counts.advisory}
|
|
1116
|
-
|
|
1117
|
-
|
|
1130
|
+
: ` blocking=${outcome.counts.blocking} advisory=${outcome.counts.advisory}`;
|
|
1131
|
+
const detail =
|
|
1132
|
+
outcome.result === "ok"
|
|
1133
|
+
? counts
|
|
1134
|
+
: outcome.result === "incomplete"
|
|
1135
|
+
? ` exit=${outcome.exitCode}${counts}`
|
|
1136
|
+
: ` exit=${outcome.exitCode}`;
|
|
1137
|
+
return `${ts} outcome pr=${outcome.pr} repo=${repoBase} status=${outcome.result}${detail}`;
|
|
1118
1138
|
}
|
|
1119
1139
|
|
|
1120
1140
|
// Counts today's launches back out of the raw log text. dayPrefix is the
|
|
@@ -1267,9 +1287,15 @@ export function osascriptNotifyArgs(title: string, text: string): string[] {
|
|
|
1267
1287
|
}
|
|
1268
1288
|
|
|
1269
1289
|
export function outcomeNotificationText(outcome: ReviewOutcome): string {
|
|
1270
|
-
if (
|
|
1290
|
+
if (outcome.result === "failed") {
|
|
1271
1291
|
return `PR #${outcome.pr} review failed (exit ${outcome.exitCode})`;
|
|
1272
1292
|
}
|
|
1293
|
+
if (outcome.result === "incomplete") {
|
|
1294
|
+
const prefix = `PR #${outcome.pr} review incomplete, run it again`;
|
|
1295
|
+
return outcome.counts === null
|
|
1296
|
+
? `${prefix} (counts unavailable)`
|
|
1297
|
+
: `${prefix}: ${outcome.counts.blocking} blocking, ${outcome.counts.advisory} advisory`;
|
|
1298
|
+
}
|
|
1273
1299
|
if (outcome.counts === null) {
|
|
1274
1300
|
return `PR #${outcome.pr} reviewed (counts unavailable)`;
|
|
1275
1301
|
}
|
package/src/watch/watch.ts
CHANGED
|
@@ -102,6 +102,7 @@ import {
|
|
|
102
102
|
removeWatchRepo,
|
|
103
103
|
renderWatchPlist,
|
|
104
104
|
renderWatchStatus,
|
|
105
|
+
reviewOutcomeResult,
|
|
105
106
|
skipLine,
|
|
106
107
|
type TickDecision,
|
|
107
108
|
type TickLaunch,
|
|
@@ -860,14 +861,17 @@ async function runTick(
|
|
|
860
861
|
);
|
|
861
862
|
const exitCode = await proc.exited;
|
|
862
863
|
|
|
864
|
+
// An incomplete review (exit 3) still ran and may have posted findings, so
|
|
865
|
+
// its counts are read like a complete one's; only a failed run has none.
|
|
866
|
+
const result = reviewOutcomeResult(exitCode);
|
|
863
867
|
const outcome: ReviewOutcome = {
|
|
864
868
|
pr: launch.pr,
|
|
865
|
-
|
|
869
|
+
result,
|
|
866
870
|
exitCode,
|
|
867
871
|
counts:
|
|
868
|
-
|
|
869
|
-
?
|
|
870
|
-
:
|
|
872
|
+
result === "failed"
|
|
873
|
+
? null
|
|
874
|
+
: await readTierCounts(launched?.runsRoot, launch.pr, launch.head),
|
|
871
875
|
};
|
|
872
876
|
await appendLog(
|
|
873
877
|
paths.logPath,
|