Skip to content

Commit 3b2fb44

Browse files
committed
fix(review): verify provenance against raw Git history
1 parent e1eefe2 commit 3b2fb44

19 files changed

Lines changed: 1240 additions & 627 deletions

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ pnpm run check
3434
Corepack reads the pinned `[email protected]` version from `package.json`; do not
3535
replace it with an unpinned global pnpm command in canonical examples.
3636

37+
Workflow-intake fixtures require Bash 4+ for `mapfile`. macOS `/bin/bash` 3.2 is
38+
insufficient; select an installed newer Bash on `PATH` for validation, for example
39+
`PATH="/opt/homebrew/opt/bash/bin:$PATH" pnpm run check`. This does not change your
40+
default shell.
41+
3742
Use the narrowest meaningful validation for the changed surface first. For a
3843
docs-only change, run `git diff --check` and verify the changed links and
3944
commands. For code, test, workflow, queue, API, UI, package, or integration

‎docs/pr-review-comments.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,33 @@ still read as `Codex review: passed.` in the durable review comment.
170170
Issues use `**Next step**` instead of the PR-specific `**Next step before
171171
merge**` heading. Non-PR comments are never repair triggers.
172172

173+
## History Attribution
174+
175+
The public related-people section separates routing judgment from Git facts.
176+
Reviewers may propose up to five source-line history pointers, identifying the
177+
recorded checkout's path/line, a commit, and either its author or committer.
178+
ClawSweeper verifies the actual line change against every parent recorded in
179+
`git cat-file commit`, using the same reader for structured regression provenance.
180+
Blame boundary markers, graph-truncated parents, or root-style display alone do
181+
not prove introduction. Configured blame revision exclusions are cleared so they
182+
cannot substitute an older line version. Whole-commit rename metadata identifies
183+
exact file moves as carried forward; inexact rename mappings remain unknown.
184+
Other unchanged lines are carried forward; missing objects, quoted blame paths,
185+
oversized reads, or expired verification budgets remain unknown.
186+
Reads reuse the trusted local Git boundary, share a five-second budget per
187+
verification set, and never fetch history or invoke target callbacks. Replacement
188+
refs and legacy grafts are disabled. Parent records must follow the tree record
189+
consecutively; identities, porcelain metadata, and diff hunks split only on LF,
190+
never embedded CR or Unicode line separators.
191+
192+
Public actor names and roles come from raw commit metadata, not reviewer prose.
193+
Author, committer, PR author, and merger remain separate; line history does not
194+
establish feature responsibility. Other candidates retain only a low-confidence
195+
routing suggestion. Host projections carry `raw_parent_line_v1` in the existing
196+
report representation; older unmarked attribution cannot regain verified status
197+
when comments are rendered. Stored reports and live comments are not rewritten by
198+
this reader change. OpenClaw Bay needs no change: no observer API or controls change.
199+
173200
## Primary Body Coverage
174201

175202
Hosted primary issue and PR bodies up to 12,000 UTF-16 units remain intact.

‎prompts/review-item.md‎

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

142+
Blame identifies last modification, not feature introduction. `^SHA`, porcelain
143+
`boundary`, revision limits, or missing parent objects leave introduction unknown.
144+
`--root`/`blame.showRoot` can hide those markers; `git show --root` and graph-based
145+
`%P` can misrepresent a shallow commit as a root. Inspect `git cat-file commit
146+
<sha>` and compare the exact source line against the raw recorded parents. An
147+
unchanged line is carried forward, not introduced. Keep code author, committer,
148+
PR author, reviewer, and merger separate; one role never proves another.
149+
150+
For at most five `likelyOwners`, supply `history` only for a concrete source-line
151+
change: full `commitSha`, `sourcePath` and `sourceLine` at the recorded review
152+
checkout, and `actor: author` or `committer`. A PR-head coordinate locates prior
153+
merged history; branch-only commits do not establish historical routing ownership.
154+
Use `history: null` for independent CODEOWNERS, review-context, or domain candidates. The host verifies Git facts and
155+
projects public actor names/roles itself; unverified history becomes unknown,
156+
and other candidates remain low-confidence routing suggestions without historical
157+
claims. Your free-form role/reason stays in the raw decision artifact, not the
158+
public related-people section. Do not move unsupported introduction claims into
159+
summaries, evidence prose, decision-owner reasons, or other public fields.
160+
142161
For potential regressions, use the non-blaming `regressionAssessment` field.
143162
Set it to `null`, or choose `suspected` with one or more directly observed
144163
supporting evidence kinds, or `probable` with at least two. The only allowed
@@ -156,8 +175,9 @@ repository-relative source path plus positive line. The source path and line
156175
must identify the current target checkout's recorded review revision: current
157176
main, or the exact PR head in a local PR checkout. Never point at an arbitrary
158177
or unrecorded revision. Set it to `null` unless the candidate is direct and
159-
specific. The runtime independently validates the PR metadata and blames the
160-
exact line; only that result publishes a confirmed predecessor link. If the
178+
specific. The runtime independently validates PR metadata and the exact blamed
179+
line's patch against raw recorded parents; only that result publishes a verified
180+
predecessor link, not semantic responsibility for a regression. If the
161181
trail is incomplete or ambiguous, keep the assessment generic and do not name
162182
an automatically attributed predecessor PR.
163183

‎schema/clawsweeper-decision.schema.json‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,24 +142,25 @@
142142
},
143143
"likelyOwners": {
144144
"type": "array",
145-
"description": "People most likely connected to the relevant code or behavior, based on git blame/log/PR history. Include multiple candidates when responsibility is shared or ambiguous.",
145+
"description": "Routing candidates selected by the reviewer. Historical attribution requires a source-line history pointer verified by the host against raw recorded parents; blame alone is not introduction proof. Other people remain unverified routing candidates in public output.",
146146
"minItems": 1,
147+
"maxItems": 5,
147148
"items": {
148149
"type": "object",
149150
"additionalProperties": false,
150-
"required": ["person", "role", "reason", "commits", "files", "confidence"],
151+
"required": ["person", "role", "reason", "commits", "files", "confidence", "history"],
151152
"properties": {
152153
"person": {
153154
"type": "string",
154155
"description": "GitHub login, maintainer handle, or commit author display name. Do not include email addresses."
155156
},
156157
"role": {
157158
"type": "string",
158-
"description": "Neutral role in the history, such as introduced behavior, recent maintainer, reviewer, merger, adjacent owner, or likely follow-up owner."
159+
"description": "Reviewer routing rationale only, not trusted historical attribution. Public roles come from host-verified author or committer facts; these roles never establish PR authorship, merger identity, or semantic responsibility."
159160
},
160161
"reason": {
161162
"type": "string",
162-
"description": "Brief evidence-backed reason this person is relevant."
163+
"description": "Brief model judgment explaining relevance, retained in the raw decision artifact. Public related-people prose is independently projected from Git facts or labeled unverified routing."
163164
},
164165
"commits": {
165166
"type": "array",
@@ -176,6 +177,18 @@
176177
"confidence": {
177178
"type": "string",
178179
"enum": ["high", "medium", "low"]
180+
},
181+
"history": {
182+
"type": ["object", "null"],
183+
"additionalProperties": false,
184+
"required": ["commitSha", "sourcePath", "sourceLine", "actor"],
185+
"description": "Untrusted source-line history pointer. Use null for CODEOWNERS, review-context, or other routing candidates. The host verifies the exact line at the recorded review revision against the blamed commit's raw recorded parents. ^SHA, porcelain boundary, --root, missing parents, and file-touch alone cannot prove introduction. Unknown or carried-forward history cannot name an introducing author.",
186+
"properties": {
187+
"commitSha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}$" },
188+
"sourcePath": { "type": "string", "maxLength": 4096 },
189+
"sourceLine": { "type": "integer", "minimum": 1, "maximum": 1000000 },
190+
"actor": { "type": "string", "enum": ["author", "committer"] }
191+
}
179192
}
180193
}
181194
}
@@ -1061,7 +1074,7 @@
10611074
}
10621075
},
10631076
"regressionProvenance": {
1064-
"description": "An untrusted candidate predecessor link. Use null unless one exact relevant source line and prior merged PR are known. Runtime verification may publish verified provenance when blame matches the canonical merge commit, or cautiously label a related PR as non-causal only when canonical metadata plus an exact, location-and-context-preserving rewritten patch match; all other associations fail closed.",
1077+
"description": "An untrusted candidate predecessor link. Use null unless one exact relevant source line and prior merged PR are known. Runtime verification requires the exact source-line patch against raw recorded parents, not blame or a root-style display alone. It may publish verified provenance when the blamed commit matches the canonical merge commit, or cautiously label a non-causal related PR after an exact location-and-context-preserving rewritten patch match; all other associations fail closed.",
10651078
"type": ["object", "null"],
10661079
"additionalProperties": false,
10671080
"required": [

‎src/clawsweeper-decision-parser.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,27 @@ export function createDecisionParser({
396396
function parseLikelyOwner(value: unknown, path: string): LikelyOwner {
397397
const record = requireRecord(value, path);
398398
rejectUnexpectedKeys(record, LIKELY_OWNER_SCHEMA_KEYS, path);
399+
let history: LikelyOwner["history"];
400+
if (record.history !== undefined && record.history !== null) {
401+
const source = requireRecord(record.history, `${path}.history`);
402+
rejectUnexpectedKeys(
403+
source,
404+
new Set(["commitSha", "sourcePath", "sourceLine", "actor"]),
405+
`${path}.history`,
406+
);
407+
history = {
408+
commitSha: requireSingleLineString(source.commitSha, `${path}.history.commitSha`),
409+
sourcePath: requireSingleLineString(source.sourcePath, `${path}.history.sourcePath`),
410+
sourceLine: requireInteger(source.sourceLine, `${path}.history.sourceLine`),
411+
actor: requireEnum(
412+
source.actor,
413+
new Set(["author", "committer"] as const),
414+
`${path}.history.actor`,
415+
),
416+
};
417+
}
399418
return {
419+
...(record.history === undefined ? {} : { history: history ?? null }),
400420
person: requireReportText(record.person, `${path}.person`),
401421
role: requireReportText(record.role, `${path}.role`),
402422
reason: requireReportText(record.reason, `${path}.reason`),

‎src/clawsweeper-policy.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@ export const LIKELY_OWNER_SCHEMA_KEYS = new Set([
889889
"commits",
890890
"files",
891891
"confidence",
892+
"history",
892893
]);
893894
export const REVIEW_SECTIONS = {
894895
summary: "Summary",

0 commit comments

Comments
 (0)