Skip to content

Commit 37283cc

Browse files
authored
feat(review): add regression provenance signals (#1023)
1 parent 29e64d1 commit 37283cc

21 files changed

Lines changed: 1067 additions & 2 deletions

‎prompts/review-item.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ signals. Do not include email addresses in `likelyOwners`, `person`, reasons,
7575
summaries, or public comments. Prefer GitHub handles from PR/commit metadata;
7676
otherwise use a display name without the `<email>` part.
7777

78+
For potential regressions, use the non-blaming `regressionAssessment` field.
79+
Set it to `null`, or choose `suspected` with one or more directly observed
80+
supporting evidence kinds, or `probable` with at least two. The only allowed
81+
supporting evidence kinds are `reproduction`, `reviewed_change`,
82+
`failure_trace`, and `known_regression_link`. Timing, nearby history, title
83+
similarity, an adjacent change, and correlation are not evidence kinds. Never
84+
use `confirmed`: confirmation is assigned only by the runtime.
85+
86+
Do not name a predecessor PR in `regressionAssessment`. When one specific
87+
earlier merged PR appears to have introduced the exact source line responsible
88+
for the reviewed behavior, you may also fill `regressionProvenance` as a
89+
candidate hint. It must name the same target repo, one earlier PR number and
90+
canonical GitHub pull URL, that PR's full 40-character merge SHA, and one exact
91+
repository-relative source path plus positive line. The source path and line
92+
must identify the current target checkout's recorded review revision: current
93+
main, or the exact PR head in a local PR checkout. Never point at an arbitrary
94+
or unrecorded revision. Set it to `null` unless the candidate is direct and
95+
specific. The runtime independently validates the PR metadata and blames the
96+
exact line; only that result publishes a confirmed predecessor link. If the
97+
trail is incomplete or ambiguous, keep the assessment generic and do not name
98+
an automatically attributed predecessor PR.
99+
78100
For PRs, set `changeSummary` to a neutral one-sentence summary of what the PR
79101
branch changes, based on the title, body, diff, files, and commits. Describe the
80102
actual code/docs/tests/workflow/package surface touched; do not use

‎schema/clawsweeper-decision.schema.json‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
"fixedRelease",
5050
"fixedSha",
5151
"fixedAt",
52+
"regressionAssessment",
53+
"regressionProvenance",
5254
"closeComment",
5355
"workCandidate",
5456
"workConfidence",
@@ -854,6 +856,96 @@
854856
"type": ["string", "null"],
855857
"description": "ISO-8601 commit or merge timestamp for the fix/proof SHA when known. Required for implemented_on_main and mostly_implemented_on_main when fixedRelease is null so maintainers know when it became fixed on main."
856858
},
859+
"regressionAssessment": {
860+
"description": "A non-blaming preliminary regression assessment. Do not name a predecessor here; a PR link is published only through independently verified regressionProvenance.",
861+
"oneOf": [
862+
{
863+
"type": "null"
864+
},
865+
{
866+
"type": "object",
867+
"additionalProperties": false,
868+
"required": ["confidence", "supportingEvidence"],
869+
"properties": {
870+
"confidence": {
871+
"type": "string",
872+
"enum": ["suspected", "probable"]
873+
},
874+
"supportingEvidence": {
875+
"type": "array",
876+
"minItems": 1,
877+
"maxItems": 3,
878+
"uniqueItems": true,
879+
"items": {
880+
"type": "string",
881+
"enum": [
882+
"reproduction",
883+
"reviewed_change",
884+
"failure_trace",
885+
"known_regression_link"
886+
]
887+
}
888+
}
889+
},
890+
"allOf": [
891+
{
892+
"if": {
893+
"properties": { "confidence": { "const": "probable" } }
894+
},
895+
"then": {
896+
"properties": { "supportingEvidence": { "minItems": 2 } }
897+
}
898+
}
899+
]
900+
}
901+
]
902+
},
903+
"regressionProvenance": {
904+
"description": "An untrusted candidate predecessor link. The runtime publishes it only after exact GitHub PR metadata and local blame agree on the merge commit; use null unless one exact relevant source line and prior merged PR are known.",
905+
"oneOf": [
906+
{
907+
"type": "null"
908+
},
909+
{
910+
"type": "object",
911+
"additionalProperties": false,
912+
"required": [
913+
"repo",
914+
"pullRequestNumber",
915+
"pullRequestUrl",
916+
"mergeCommitSha",
917+
"sourcePath",
918+
"sourceLine"
919+
],
920+
"properties": {
921+
"repo": {
922+
"type": "string",
923+
"description": "Target owner/repository only."
924+
},
925+
"pullRequestNumber": {
926+
"type": "integer",
927+
"minimum": 1
928+
},
929+
"pullRequestUrl": {
930+
"type": "string",
931+
"description": "Canonical https://github.com/<owner>/<repo>/pull/<number> URL."
932+
},
933+
"mergeCommitSha": {
934+
"type": "string",
935+
"pattern": "^[0-9a-fA-F]{40}$"
936+
},
937+
"sourcePath": {
938+
"type": "string",
939+
"description": "One exact repository-relative tracked source path; no absolute or traversal path."
940+
},
941+
"sourceLine": {
942+
"type": "integer",
943+
"minimum": 1
944+
}
945+
}
946+
}
947+
]
948+
},
857949
"closeComment": {
858950
"type": "string"
859951
},

‎src/clawsweeper-decision-parser.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ import {
2727
REAL_BEHAVIOR_PROOF_EVIDENCE_KINDS,
2828
REAL_BEHAVIOR_PROOF_SCHEMA_KEYS,
2929
REAL_BEHAVIOR_PROOF_STATUSES,
30+
REGRESSION_ASSESSMENT_CONFIDENCES,
31+
REGRESSION_ASSESSMENT_SCHEMA_KEYS,
32+
REGRESSION_PROVENANCE_SCHEMA_KEYS,
33+
REGRESSION_SUPPORTING_EVIDENCE,
3034
REPRODUCTION_STATUSES,
3135
REVIEW_FINDING_SCHEMA_KEYS,
3236
REVIEW_LABEL_VALUES,
@@ -63,6 +67,8 @@ import type {
6367
ReviewFinding,
6468
ReviewLabelName,
6569
ReviewMetric,
70+
RegressionAssessment,
71+
RegressionProvenanceCandidate,
6672
RootCauseClusterAssessment,
6773
RootCauseClusterMember,
6874
RootCauseNormalizationItem,
@@ -744,6 +750,48 @@ export function createDecisionParser({
744750
};
745751
}
746752

753+
function parseRegressionProvenanceCandidate(
754+
value: unknown,
755+
path: string,
756+
): RegressionProvenanceCandidate | null {
757+
if (value === null) return null;
758+
const record = requireRecord(value, path);
759+
rejectUnexpectedKeys(record, REGRESSION_PROVENANCE_SCHEMA_KEYS, path);
760+
return {
761+
repo: requireString(record.repo, `${path}.repo`),
762+
pullRequestNumber: requireInteger(record.pullRequestNumber, `${path}.pullRequestNumber`),
763+
pullRequestUrl: requireString(record.pullRequestUrl, `${path}.pullRequestUrl`),
764+
mergeCommitSha: requireString(record.mergeCommitSha, `${path}.mergeCommitSha`),
765+
sourcePath: requireString(record.sourcePath, `${path}.sourcePath`),
766+
sourceLine: requireInteger(record.sourceLine, `${path}.sourceLine`),
767+
};
768+
}
769+
770+
function parseRegressionAssessment(value: unknown, path: string): RegressionAssessment | null {
771+
if (value === null) return null;
772+
const record = requireRecord(value, path);
773+
rejectUnexpectedKeys(record, REGRESSION_ASSESSMENT_SCHEMA_KEYS, path);
774+
const confidence = requireEnum(
775+
record.confidence,
776+
REGRESSION_ASSESSMENT_CONFIDENCES,
777+
`${path}.confidence`,
778+
) as RegressionAssessment["confidence"];
779+
const supportingEvidence = requireEnumArray(
780+
record.supportingEvidence,
781+
REGRESSION_SUPPORTING_EVIDENCE,
782+
`${path}.supportingEvidence`,
783+
) as RegressionAssessment["supportingEvidence"];
784+
if (
785+
supportingEvidence.length === 0 ||
786+
supportingEvidence.length > 3 ||
787+
new Set(supportingEvidence).size !== supportingEvidence.length ||
788+
(confidence === "probable" && supportingEvidence.length < 2)
789+
) {
790+
throw new Error(`${path} has insufficient or duplicate supporting evidence`);
791+
}
792+
return { confidence, supportingEvidence };
793+
}
794+
747795
function requireEnum<T extends string>(value: unknown, allowed: Set<T>, path: string): T {
748796
if (typeof value === "string" && allowed.has(value as T)) return value as T;
749797
throw new Error(`${path} has invalid value`);
@@ -880,6 +928,14 @@ export function createDecisionParser({
880928
fixedRelease: requireNullableString(record.fixedRelease, "decision.fixedRelease"),
881929
fixedSha: requireNullableString(record.fixedSha, "decision.fixedSha"),
882930
fixedAt: requireNullableString(record.fixedAt, "decision.fixedAt"),
931+
regressionAssessment: parseRegressionAssessment(
932+
record.regressionAssessment,
933+
"decision.regressionAssessment",
934+
),
935+
regressionProvenance: parseRegressionProvenanceCandidate(
936+
record.regressionProvenance,
937+
"decision.regressionProvenance",
938+
),
883939
closeComment: requireString(record.closeComment, "decision.closeComment"),
884940
workCandidate: requireEnum(record.workCandidate, WORK_CANDIDATES, "decision.workCandidate"),
885941
workConfidence: requireEnum(record.workConfidence, CONFIDENCES, "decision.workConfidence"),

‎src/clawsweeper-policy.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ export const DECISION_SCHEMA_KEYS = new Set([
743743
"fixedRelease",
744744
"fixedSha",
745745
"fixedAt",
746+
"regressionAssessment",
747+
"regressionProvenance",
746748
"closeComment",
747749
"workCandidate",
748750
"workConfidence",
@@ -753,6 +755,22 @@ export const DECISION_SCHEMA_KEYS = new Set([
753755
"workValidation",
754756
"workLikelyFiles",
755757
]);
758+
export const REGRESSION_PROVENANCE_SCHEMA_KEYS = new Set([
759+
"repo",
760+
"pullRequestNumber",
761+
"pullRequestUrl",
762+
"mergeCommitSha",
763+
"sourcePath",
764+
"sourceLine",
765+
]);
766+
export const REGRESSION_ASSESSMENT_SCHEMA_KEYS = new Set(["confidence", "supportingEvidence"]);
767+
export const REGRESSION_ASSESSMENT_CONFIDENCES = new Set(["suspected", "probable"]);
768+
export const REGRESSION_SUPPORTING_EVIDENCE = new Set([
769+
"reproduction",
770+
"reviewed_change",
771+
"failure_trace",
772+
"known_regression_link",
773+
]);
756774
export const EVIDENCE_SCHEMA_KEYS = new Set(["label", "detail", "file", "line", "command", "sha"]);
757775
export const SECURITY_REVIEW_SCHEMA_KEYS = new Set(["status", "summary", "concerns"]);
758776
export const REAL_BEHAVIOR_PROOF_SCHEMA_KEYS = new Set([

0 commit comments

Comments
 (0)