crysk 0.0.0 → 0.3.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/LICENSE +176 -0
- package/README.md +609 -3
- package/bin/pr-hero.js +166 -0
- package/config/models/anthropic.json +5 -0
- package/dist/SKILL-7e3725zn.md +496 -0
- package/dist/SKILL-7q35wcaz.md +66 -0
- package/dist/SKILL-9at22381.md +74 -0
- package/dist/SKILL-ex2hxxh3.md +134 -0
- package/dist/adjudicator-dtg2axnh.md +86 -0
- package/dist/admission-config.example-a9vqmmad.json +9 -0
- package/dist/ci-admission-camfbx2b.md +122 -0
- package/dist/cli.js +42292 -0
- package/dist/consolidate-ac0mnfyj.md +24 -0
- package/dist/deep-review-lifecycle-m698ybjp.md +362 -0
- package/dist/deep-review-logic-a6b1gczf.md +156 -0
- package/dist/deep-review-parity-0ec904db.md +120 -0
- package/dist/deep-review-reliability-qyakbjb9.md +125 -0
- package/dist/deep-review-resilience-3tz8y26e.md +118 -0
- package/dist/index.js +20190 -0
- package/dist/opencode-ci-7b0be64p.md +141 -0
- package/dist/review-refuter-j4e9gezy.md +71 -0
- package/dist/scout-yvp153q7.md +140 -0
- package/dist/summarizer-zca44nxa.md +18 -0
- package/dist/workflow-w1g9szna.yml +151 -0
- package/package.json +81 -4
- package/prompts/consolidate.md +24 -0
- package/prompts/default/PROVENANCE.md +18 -0
- package/prompts/default/deep-review-lifecycle.md +362 -0
- package/prompts/default/deep-review-logic.md +156 -0
- package/prompts/default/deep-review-parity.md +120 -0
- package/prompts/default/deep-review-reliability.md +125 -0
- package/prompts/default/deep-review-resilience.md +118 -0
- package/prompts/default/review-refuter.md +71 -0
- package/prompts/scout.md +140 -0
- package/prompts/summarizer.md +18 -0
- package/skills/crysk/SKILL.md +74 -0
- package/skills/crysk-ci-setup/SKILL.md +134 -0
- package/skills/crysk-ci-setup/assets/admission-config.example.json +9 -0
- package/skills/crysk-ci-setup/assets/workflow.yml +151 -0
- package/skills/crysk-ci-setup/references/ci-admission.md +122 -0
- package/skills/crysk-ci-setup/references/opencode-ci.md +141 -0
- package/skills/crysk-loop/SKILL.md +496 -0
- package/skills/crysk-loop/adjudicator.md +86 -0
- package/skills/crysk-pr/SKILL.md +66 -0
- package/src/agent-env.ts +1084 -0
- package/src/asset-manifest.ts +83 -0
- package/src/assets.d.ts +6 -0
- package/src/assets.ts +183 -0
- package/src/brand-paths.ts +155 -0
- package/src/brand.ts +255 -0
- package/src/ci/admission-ledger.ts +350 -0
- package/src/ci/classify-error.ts +73 -0
- package/src/ci/cli-record.ts +271 -0
- package/src/ci/force-comment.ts +39 -0
- package/src/ci/gates.ts +923 -0
- package/src/ci/outcome.ts +2181 -0
- package/src/ci/override.ts +187 -0
- package/src/ci/publish.ts +1639 -0
- package/src/ci/reporter.ts +626 -0
- package/src/ci/review-admission.ts +901 -0
- package/src/ci/review-levels.ts +310 -0
- package/src/ci/review-policy.ts +18 -0
- package/src/ci/review-risk.ts +184 -0
- package/src/ci/setup.ts +844 -0
- package/src/ci/trigger.ts +1353 -0
- package/src/cli.ts +348 -0
- package/src/commands/activity.ts +67 -0
- package/src/commands/ci-setup-questions.ts +397 -0
- package/src/commands/ci-setup.ts +381 -0
- package/src/commands/config.ts +99 -0
- package/src/commands/doctor.ts +108 -0
- package/src/commands/init.ts +139 -0
- package/src/commands/mcp.ts +10 -0
- package/src/commands/menu.ts +129 -0
- package/src/commands/post.ts +302 -0
- package/src/commands/skills.ts +83 -0
- package/src/commands/status.ts +173 -0
- package/src/commands/triage.ts +342 -0
- package/src/commands/uninstall.ts +37 -0
- package/src/commands/upgrade.ts +214 -0
- package/src/commands/usage.ts +98 -0
- package/src/compare/compare.ts +28 -0
- package/src/compare/floor-test.ts +471 -0
- package/src/compare/martian-adapter.ts +80 -0
- package/src/config/config.ts +267 -0
- package/src/corpus/corpus.ts +1094 -0
- package/src/corpus/preflight.ts +1789 -0
- package/src/diversity/accounting.ts +90 -0
- package/src/diversity/adjudication.ts +145 -0
- package/src/diversity/admission.ts +60 -0
- package/src/diversity/benchmark.ts +195 -0
- package/src/diversity/clustering.ts +285 -0
- package/src/diversity/errors.ts +7 -0
- package/src/diversity/identity.ts +285 -0
- package/src/diversity/index.ts +11 -0
- package/src/diversity/pipeline-integration.ts +448 -0
- package/src/diversity/projection.ts +57 -0
- package/src/diversity/self-contained.ts +68 -0
- package/src/diversity/target-validation.ts +179 -0
- package/src/doctor-migration.ts +209 -0
- package/src/doctor.ts +723 -0
- package/src/errors.ts +83 -0
- package/src/execution/admission.ts +75 -0
- package/src/execution/atomic-write.ts +35 -0
- package/src/execution/attempt-evidence.ts +415 -0
- package/src/execution/bucket-id.ts +136 -0
- package/src/execution/concurrency-limiter.ts +175 -0
- package/src/execution/contracts.ts +443 -0
- package/src/execution/failure-classification.ts +42 -0
- package/src/execution/failure-policy.ts +240 -0
- package/src/execution/harness.ts +2548 -0
- package/src/execution/settlement.ts +348 -0
- package/src/execution/spawned-process.ts +66 -0
- package/src/execution/spend-limiter.ts +424 -0
- package/src/execution/step-artifacts.ts +55 -0
- package/src/execution/usage-normalized.ts +469 -0
- package/src/git/git.ts +396 -0
- package/src/git/identity.ts +64 -0
- package/src/git/refs.ts +140 -0
- package/src/home-preflight.ts +443 -0
- package/src/home.ts +243 -0
- package/src/ignore-file.ts +336 -0
- package/src/ignore-read.ts +118 -0
- package/src/index.ts +34 -0
- package/src/legacy-launchd.ts +29 -0
- package/src/mcp/mcp.ts +150 -0
- package/src/mcp/preflight.ts +407 -0
- package/src/menu-context.ts +192 -0
- package/src/model/catalog.ts +251 -0
- package/src/model/exec-snapshots.ts +390 -0
- package/src/model/free-discovery.ts +302 -0
- package/src/model/provider-capabilities.ts +814 -0
- package/src/model/routing.ts +600 -0
- package/src/pr/admission.ts +847 -0
- package/src/pr/ci-admission-gate.ts +665 -0
- package/src/pr/ci-publish.ts +76 -0
- package/src/pr/discovery.ts +432 -0
- package/src/pr/inline.ts +507 -0
- package/src/pr/plan.ts +366 -0
- package/src/pr/posting.ts +115 -0
- package/src/pr/pr-status.ts +787 -0
- package/src/pr/pr.ts +3642 -0
- package/src/pr/preflight.ts +1031 -0
- package/src/pr/publish-outcome.ts +361 -0
- package/src/pr/range.ts +119 -0
- package/src/pr/reverts-preflight.ts +606 -0
- package/src/pr/reverts.ts +377 -0
- package/src/pr/review-pr.ts +927 -0
- package/src/pr/status.ts +154 -0
- package/src/pr/target.ts +388 -0
- package/src/pr/teardown.ts +437 -0
- package/src/pr/worktree-setup.ts +60 -0
- package/src/production-runtime.ts +1877 -0
- package/src/progress.ts +487 -0
- package/src/rereview/adjudicate.ts +89 -0
- package/src/rereview/classify.ts +362 -0
- package/src/rereview/identity.ts +211 -0
- package/src/rereview/plan.ts +308 -0
- package/src/rereview/prepare.ts +1025 -0
- package/src/rereview/state.ts +767 -0
- package/src/rereview/verify.ts +241 -0
- package/src/review/boundary.ts +105 -0
- package/src/review/consolidate.ts +246 -0
- package/src/review/dedupe.ts +368 -0
- package/src/review/drafts.ts +448 -0
- package/src/review/findings-conformance.ts +120 -0
- package/src/review/findings.ts +714 -0
- package/src/review/pipeline.ts +3977 -0
- package/src/review/preflight.ts +3575 -0
- package/src/review/prompt-set.ts +177 -0
- package/src/review/proof-refs.ts +187 -0
- package/src/review/report.ts +1821 -0
- package/src/review/review.ts +490 -0
- package/src/review/root-cause.ts +120 -0
- package/src/review/route-preflight.ts +289 -0
- package/src/review/run.ts +601 -0
- package/src/review/scout.ts +323 -0
- package/src/review/size-gate.ts +595 -0
- package/src/review/spec.ts +235 -0
- package/src/review/step-runner.ts +233 -0
- package/src/runner-authority.ts +596 -0
- package/src/security/binding-policy.ts +115 -0
- package/src/security/credential-broker.ts +773 -0
- package/src/security/evidence-redaction.ts +62 -0
- package/src/security/execution-authority.ts +27 -0
- package/src/security/redact.ts +71 -0
- package/src/security/workspace-read-broker.ts +466 -0
- package/src/server/client.ts +190 -0
- package/src/server/preflight.ts +217 -0
- package/src/server/server.ts +327 -0
- package/src/signal-handler.ts +50 -0
- package/src/store/activity.ts +413 -0
- package/src/store/backfill-preflight.ts +49 -0
- package/src/store/backfill.ts +141 -0
- package/src/store/gc-preflight.ts +206 -0
- package/src/store/gc.ts +424 -0
- package/src/store/metrics-preflight.ts +229 -0
- package/src/store/metrics.ts +236 -0
- package/src/store/preflight.ts +748 -0
- package/src/store/store.ts +693 -0
- package/src/system-tools.ts +355 -0
- package/src/transport-registry.ts +1124 -0
- package/src/transports/claude-code-cli.ts +1348 -0
- package/src/transports/opencode-admission.ts +515 -0
- package/src/transports/opencode-client.ts +3328 -0
- package/src/transports/opencode-evidence.ts +557 -0
- package/src/transports/opencode-mcp.ts +248 -0
- package/src/transports/opencode-sdk.ts +2294 -0
- package/src/transports/opencode-server.ts +535 -0
- package/src/triage/adjudication.ts +113 -0
- package/src/triage/reply.ts +125 -0
- package/src/triage/triage.ts +255 -0
- package/src/ui/activity.ts +173 -0
- package/src/ui/config-edit.ts +816 -0
- package/src/ui/config.ts +462 -0
- package/src/ui/menu.ts +1325 -0
- package/src/ui/plan.ts +1039 -0
- package/src/ui/primitives.ts +300 -0
- package/src/ui/progress.ts +298 -0
- package/src/ui/result.ts +552 -0
- package/src/ui/review-menu.ts +312 -0
- package/src/ui/select.ts +528 -0
- package/src/ui/tree.ts +178 -0
- package/src/uninstaller.ts +479 -0
- package/src/updater.ts +836 -0
- package/src/usage.ts +77 -0
- package/src/watch/preflight.ts +1389 -0
- package/src/watch/watch.ts +1235 -0
- package/src/wizard.ts +877 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// Re-review case machine and the two-delta rule (`docs/item7-rereview-design.md`
|
|
2
|
+
// §3.1). Pure: git facts in, a case and a discovery plan out. The shell
|
|
3
|
+
// owns `merge-base --is-ancestor`, `cat-file -e`, and `diff --name-only`.
|
|
4
|
+
//
|
|
5
|
+
// Five cases over (L, H). Every failure mode falls to a full review, never
|
|
6
|
+
// a silently truncated delta. `--full` widens discovery for whatever case
|
|
7
|
+
// the PR is actually in; it never rewrites the case (R2-C5).
|
|
8
|
+
|
|
9
|
+
import { normalizePath } from "#compare/compare";
|
|
10
|
+
import { listPaths } from "#git/refs";
|
|
11
|
+
import type { RereviewCase } from "./classify";
|
|
12
|
+
|
|
13
|
+
export type LastHeadSource = "summary_marker" | "finding_markers" | "absent";
|
|
14
|
+
|
|
15
|
+
export interface MarkerHead {
|
|
16
|
+
headSha: string;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface LastReviewedHead {
|
|
21
|
+
L: string | null;
|
|
22
|
+
source: LastHeadSource;
|
|
23
|
+
// Rereview-coverage fix: whether the run that posted L actually
|
|
24
|
+
// finished. Only ever false when `source === "summary_marker"` AND that
|
|
25
|
+
// marker carried the coverage=partial token — finding-marker recovery (no
|
|
26
|
+
// summary comment at all) and the absent case both mean "nothing to
|
|
27
|
+
// distrust", so they are always true regardless of `summaryComplete`.
|
|
28
|
+
//
|
|
29
|
+
// WHY this travels WITH L rather than L being nulled out on a partial
|
|
30
|
+
// marker: nulling L would make this function fall through to
|
|
31
|
+
// `latestMarkerHead(findingMarkers)` below — and a partial run's own
|
|
32
|
+
// inline finding markers carry the SAME head, so L would simply be
|
|
33
|
+
// resurrected there and the forced-full re-review this field exists to
|
|
34
|
+
// trigger would be a no-op.
|
|
35
|
+
lastComplete: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface DiscoveryPlan {
|
|
39
|
+
case: RereviewCase;
|
|
40
|
+
// What the hunters read as their attention anchor.
|
|
41
|
+
discovery: "full" | "restricted" | "none";
|
|
42
|
+
discoveryRestricted: boolean;
|
|
43
|
+
skipDiscovery: boolean;
|
|
44
|
+
// Empty diff is a CliError only for a first review (case A). A re-review
|
|
45
|
+
// with an empty restricted delta still classifies and verifies (C6).
|
|
46
|
+
emptyDeltaIsError: boolean;
|
|
47
|
+
verifyAll: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function resolveLastReviewedHead(input: {
|
|
51
|
+
summaryHead: string | null;
|
|
52
|
+
// Ignored when summaryHead is null — required anyway so every call site
|
|
53
|
+
// must make an explicit choice rather than a silent default hiding the
|
|
54
|
+
// exact "leaves the fix a no-op" trap the WHY comment above names.
|
|
55
|
+
summaryComplete: boolean;
|
|
56
|
+
findingMarkers: readonly MarkerHead[];
|
|
57
|
+
}): LastReviewedHead {
|
|
58
|
+
if (input.summaryHead !== null) {
|
|
59
|
+
return {
|
|
60
|
+
L: input.summaryHead,
|
|
61
|
+
source: "summary_marker",
|
|
62
|
+
lastComplete: input.summaryComplete,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const latest = latestMarkerHead(input.findingMarkers);
|
|
66
|
+
if (latest === null) return { L: null, source: "absent", lastComplete: true };
|
|
67
|
+
return { L: latest, source: "finding_markers", lastComplete: true };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function decideRereviewCase(input: {
|
|
71
|
+
L: string | null;
|
|
72
|
+
H: string;
|
|
73
|
+
// `git cat-file -e L`. Null when L is null or the probe did not run.
|
|
74
|
+
objectExists: boolean | null;
|
|
75
|
+
// `git merge-base --is-ancestor L H`. Null when not applicable.
|
|
76
|
+
isAncestor: boolean | null;
|
|
77
|
+
}): RereviewCase {
|
|
78
|
+
if (input.L === null) return "A";
|
|
79
|
+
if (input.L === input.H) return "B";
|
|
80
|
+
if (input.objectExists !== true) return "E";
|
|
81
|
+
if (input.isAncestor === true) return "C";
|
|
82
|
+
return "D";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// What the re-review's Phase B gate may ask git for, given the case the
|
|
86
|
+
// machine landed in. `unreachable` is the force-push case, and it is the whole
|
|
87
|
+
// reason this decision is a function instead of an inline condition.
|
|
88
|
+
//
|
|
89
|
+
// A rebase of a stacked PR orphans the previously-reviewed head L recorded in
|
|
90
|
+
// the `<!-- pr-hero-state head=... -->` marker on the PR. A CI runner's fresh
|
|
91
|
+
// clone never fetched that object, so `git diff --name-status L..H` dies with
|
|
92
|
+
// "Invalid revision range" and takes the entire review down with it. Case E
|
|
93
|
+
// already plans a FULL review for exactly this situation — but the gate that
|
|
94
|
+
// guarded the L..H delta asked only "is this a first review?", a question case
|
|
95
|
+
// E answers "no", so it ran the diff anyway. Found by pr-hero's own Action on
|
|
96
|
+
// PR #68 (2026-08-25): red in 8 seconds, and rebasing is routine.
|
|
97
|
+
//
|
|
98
|
+
// Reachability is read off the case rather than re-probed: inside
|
|
99
|
+
// `prepareDiscovery` (rereview/prepare.ts) — the only production caller of
|
|
100
|
+
// `decideRereviewCase`, and one that always runs `git cat-file -e L^{commit}`
|
|
101
|
+
// when L is non-null — case "E" means exactly "L is non-null and that probe
|
|
102
|
+
// said no".
|
|
103
|
+
export type LastHeadDelta =
|
|
104
|
+
| { kind: "none" }
|
|
105
|
+
| { kind: "diff"; from: string }
|
|
106
|
+
| { kind: "unreachable"; sha: string };
|
|
107
|
+
|
|
108
|
+
export function decideLastHeadDelta(input: {
|
|
109
|
+
case: RereviewCase;
|
|
110
|
+
L: string | null;
|
|
111
|
+
}): LastHeadDelta {
|
|
112
|
+
if (input.case === "A" || input.L === null) return { kind: "none" };
|
|
113
|
+
if (input.case === "E") return { kind: "unreachable", sha: input.L };
|
|
114
|
+
return { kind: "diff", from: input.L };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Degrading silently would be indistinguishable from a review that was always
|
|
118
|
+
// full, which is how a truncated re-review hides. Said once, in CI and out.
|
|
119
|
+
export function unreachableLastHeadMessage(sha: string): string {
|
|
120
|
+
return (
|
|
121
|
+
`The previously-reviewed commit ${sha} is not present in this clone ` +
|
|
122
|
+
"(very likely a force-push or rebase). This run is a full review of the " +
|
|
123
|
+
"PR range rather than a delta, and every prior finding is re-verified."
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// The sibling notice for the OTHER way a re-review's L cannot be trusted
|
|
128
|
+
// as-is: not force-pushed away (that is `unreachableLastHeadMessage`, case
|
|
129
|
+
// E), but never actually finished (rereview-coverage fix). Same
|
|
130
|
+
// "said once, in CI and out" rule, same emission site in cli.ts — right
|
|
131
|
+
// where the L..H delta is about to be asked for.
|
|
132
|
+
export function incompleteLastReviewMessage(sha: string): string {
|
|
133
|
+
return (
|
|
134
|
+
`The previous review of ${sha} did not complete (at least one agent ` +
|
|
135
|
+
"failed). This run reviews the full PR range and re-verifies every " +
|
|
136
|
+
"prior finding."
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// GitHub #166: the THIRD way a re-review's delta can be nothing to trust "as
|
|
141
|
+
// is" — not force-pushed away, not incomplete, just genuinely empty. Case B
|
|
142
|
+
// (L === H) always lands here on the happy path, and it is not rare: a
|
|
143
|
+
// merged PR's head can never advance, so every local re-run of a merged PR
|
|
144
|
+
// is case B. Discovery correctly runs zero DISCOVERY hunters — there is
|
|
145
|
+
// nothing new to read — but the OLD behavior said nothing about that on the
|
|
146
|
+
// CLI/CI log, and the PR comment (`cleanBillLine`, review/report.ts) read the
|
|
147
|
+
// resulting empty findings array as "reviewed and found nothing", a $0/0s run
|
|
148
|
+
// overwriting a real prior summary with a false clean bill. Fired for ANY
|
|
149
|
+
// case whose discovery came up empty (case B, or case C's restricted delta
|
|
150
|
+
// touching none of the PR's own files) — `resolvePrDiscovery` (pr/discovery.ts)
|
|
151
|
+
// sets `discovery_skipped_empty_delta` on that same broader condition, and a
|
|
152
|
+
// reader deserves the same disclosure regardless of which case produced it.
|
|
153
|
+
//
|
|
154
|
+
// pr-hero review #286 findings, both about this function specifically:
|
|
155
|
+
//
|
|
156
|
+
// 1. "No changes... since the last completed review" was flatly wrong for
|
|
157
|
+
// the OTHER way discovery comes up empty: a real, non-empty delta whose
|
|
158
|
+
// every file was excluded by the size gate / `.prheroignore`
|
|
159
|
+
// (`filterDiffByIgnoreRules`'s `droppedPaths`). That case gets its own
|
|
160
|
+
// sentence, naming what was excluded — never "no changes".
|
|
161
|
+
// 2. "No hunter ran... not re-verified now" said "hunter" for a claim only
|
|
162
|
+
// true of DISCOVERY hunters, and asserted verification would NOT happen —
|
|
163
|
+
// false whenever case B's `applied`/`case_b_reply` triggers or case C's
|
|
164
|
+
// `touched()` (rereview/classify.ts) queued a prior for the SAME pass's
|
|
165
|
+
// verifier. The caller (`pr/discovery.ts`) now computes this message only
|
|
166
|
+
// after that queue is built, so `queuedForVerification` is always the
|
|
167
|
+
// real count, never a guess made before the queue existed.
|
|
168
|
+
export function skippedDiscoveryMessage(input: {
|
|
169
|
+
headSha: string;
|
|
170
|
+
reason: "no_delta" | "all_excluded";
|
|
171
|
+
excludedPaths: readonly string[];
|
|
172
|
+
queuedForVerification: number;
|
|
173
|
+
// pr-hero on #286: the Phase B queue is capped downstream at
|
|
174
|
+
// max_verification_steps (capVerificationQueue, rereview/verify.ts); the
|
|
175
|
+
// priors past the cap are marked unconfirmed, never re-verified. The notice
|
|
176
|
+
// states the capped number, never the raw queue length.
|
|
177
|
+
maxVerificationSteps: number;
|
|
178
|
+
}): string {
|
|
179
|
+
const discoverySentence =
|
|
180
|
+
input.reason === "all_excluded"
|
|
181
|
+
? `Every changed file at ${input.headSha} was excluded from review ` +
|
|
182
|
+
`(${listPaths([...input.excludedPaths])}), so the effective diff is empty.`
|
|
183
|
+
: `No changes to discover at ${input.headSha} since the last completed review.`;
|
|
184
|
+
const hunterSentence = "No discovery hunter ran this pass.";
|
|
185
|
+
const verified = Math.min(
|
|
186
|
+
input.queuedForVerification,
|
|
187
|
+
Math.max(0, input.maxVerificationSteps),
|
|
188
|
+
);
|
|
189
|
+
const capped = input.queuedForVerification - verified;
|
|
190
|
+
const verifySentence =
|
|
191
|
+
verified > 0
|
|
192
|
+
? `${verified} prior finding` +
|
|
193
|
+
`${verified === 1 ? " is" : "s are"} re-verified this pass` +
|
|
194
|
+
(capped > 0
|
|
195
|
+
? `; ${capped} more ${capped === 1 ? "stays" : "stay"} unconfirmed (max_verification_steps ${input.maxVerificationSteps}).`
|
|
196
|
+
: ".")
|
|
197
|
+
: capped > 0
|
|
198
|
+
? `No prior finding is re-verified this pass; ${capped} ${capped === 1 ? "stays" : "stay"} unconfirmed (max_verification_steps ${input.maxVerificationSteps}).`
|
|
199
|
+
: "No prior finding is queued for re-verification this pass.";
|
|
200
|
+
return `${discoverySentence} ${hunterSentence} ${verifySentence}`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function planDiscovery(input: {
|
|
204
|
+
case: RereviewCase;
|
|
205
|
+
full: boolean;
|
|
206
|
+
// Rereview-coverage fix: false forces the SAME full-discovery
|
|
207
|
+
// path `full: true` takes, PLUS verifyAll — because an incomplete prior
|
|
208
|
+
// run may be exactly the refuter failing, so prior findings cannot be
|
|
209
|
+
// trusted as merely "carried" the way a clean case B/C would carry them.
|
|
210
|
+
// This never rewrites `case` (R2-C5's rule: widening discovery never
|
|
211
|
+
// rewrites the case) — case stays whatever decideRereviewCase decided.
|
|
212
|
+
lastComplete: boolean;
|
|
213
|
+
}): DiscoveryPlan {
|
|
214
|
+
const caseVerifyAll = input.case === "D" || input.case === "E";
|
|
215
|
+
const forcedByIncompleteness = !input.lastComplete;
|
|
216
|
+
const emptyDeltaIsError = input.case === "A";
|
|
217
|
+
if (input.full || forcedByIncompleteness) {
|
|
218
|
+
return {
|
|
219
|
+
case: input.case,
|
|
220
|
+
discovery: "full",
|
|
221
|
+
discoveryRestricted: false,
|
|
222
|
+
skipDiscovery: false,
|
|
223
|
+
emptyDeltaIsError,
|
|
224
|
+
verifyAll: caseVerifyAll || forcedByIncompleteness,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
switch (input.case) {
|
|
228
|
+
case "A":
|
|
229
|
+
return {
|
|
230
|
+
case: "A",
|
|
231
|
+
discovery: "full",
|
|
232
|
+
discoveryRestricted: false,
|
|
233
|
+
skipDiscovery: false,
|
|
234
|
+
emptyDeltaIsError: true,
|
|
235
|
+
verifyAll: false,
|
|
236
|
+
};
|
|
237
|
+
case "B":
|
|
238
|
+
return {
|
|
239
|
+
case: "B",
|
|
240
|
+
discovery: "none",
|
|
241
|
+
discoveryRestricted: true,
|
|
242
|
+
skipDiscovery: true,
|
|
243
|
+
emptyDeltaIsError: false,
|
|
244
|
+
verifyAll: false,
|
|
245
|
+
};
|
|
246
|
+
case "C":
|
|
247
|
+
return {
|
|
248
|
+
case: "C",
|
|
249
|
+
discovery: "restricted",
|
|
250
|
+
discoveryRestricted: true,
|
|
251
|
+
skipDiscovery: false,
|
|
252
|
+
emptyDeltaIsError: false,
|
|
253
|
+
verifyAll: false,
|
|
254
|
+
};
|
|
255
|
+
case "D":
|
|
256
|
+
case "E":
|
|
257
|
+
return {
|
|
258
|
+
case: input.case,
|
|
259
|
+
discovery: "full",
|
|
260
|
+
discoveryRestricted: false,
|
|
261
|
+
skipDiscovery: false,
|
|
262
|
+
emptyDeltaIsError: false,
|
|
263
|
+
verifyAll: true,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Discovery files: files(B..H) ∩ files(L..H). Upstream-only churn from a
|
|
269
|
+
// merge of main is in L..H but not B..H, so it drops out. A revert-to-base
|
|
270
|
+
// drops out of B..H and therefore out of discovery — touched() still sees
|
|
271
|
+
// it on the unrestricted L..H set (D9).
|
|
272
|
+
export function restrictedDiscoveryFiles(
|
|
273
|
+
prFiles: readonly string[],
|
|
274
|
+
deltaFiles: readonly string[],
|
|
275
|
+
): string[] {
|
|
276
|
+
const pr = new Set(prFiles.map(normalizePath));
|
|
277
|
+
const out: string[] = [];
|
|
278
|
+
const seen = new Set<string>();
|
|
279
|
+
for (const file of deltaFiles) {
|
|
280
|
+
const path = normalizePath(file);
|
|
281
|
+
if (!pr.has(path) || seen.has(path)) continue;
|
|
282
|
+
seen.add(path);
|
|
283
|
+
out.push(path);
|
|
284
|
+
}
|
|
285
|
+
out.sort();
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function latestMarkerHead(markers: readonly MarkerHead[]): string | null {
|
|
290
|
+
if (markers.length === 0) return null;
|
|
291
|
+
let best = markers[0];
|
|
292
|
+
if (best === undefined) return null;
|
|
293
|
+
for (let i = 1; i < markers.length; i++) {
|
|
294
|
+
const candidate = markers[i];
|
|
295
|
+
if (candidate === undefined) continue;
|
|
296
|
+
if (candidate.createdAt > best.createdAt) {
|
|
297
|
+
best = candidate;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (
|
|
301
|
+
candidate.createdAt === best.createdAt &&
|
|
302
|
+
candidate.headSha < best.headSha
|
|
303
|
+
) {
|
|
304
|
+
best = candidate;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return best.headSha;
|
|
308
|
+
}
|