Skip to content

Commit 9740359

Browse files
committed
fix(review): scope authority proof gating
1 parent e34fce5 commit 9740359

19 files changed

Lines changed: 116 additions & 488 deletions

‎.github/workflows/sweep.yml‎

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,17 +1010,6 @@ jobs:
10101010
- uses: ./.github/actions/setup-openclaw
10111011
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outputs.proceed == 'true' }}
10121012

1013-
- uses: ./.github/actions/setup-state
1014-
id: review-records-state
1015-
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outputs.proceed == 'true' }}
1016-
with:
1017-
coordinator-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
1018-
records-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
1019-
records-secret: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
1020-
records-repo-slugs: ${{ steps.target.outputs.target_slug }}
1021-
hydrate-git-state: "false"
1022-
hydrate-state-blobs: "false"
1023-
10241013
- name: Reserve exact review lease
10251014
id: reserve-exact-review-lease
10261015
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outputs.proceed == 'true' }}
@@ -1131,7 +1120,7 @@ jobs:
11311120
11321121
- name: Review exact event item
11331122
id: review-exact-event-item
1134-
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outputs.proceed == 'true' && steps.reserve-exact-review-lease.outputs.status == 'posted' && steps.review-records-state.outcome == 'success' }}
1123+
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outputs.proceed == 'true' && steps.reserve-exact-review-lease.outputs.status == 'posted' }}
11351124
continue-on-error: true
11361125
env:
11371126
# Review hydration is the largest read stream (~30 calls/review); it
@@ -4376,17 +4365,6 @@ jobs:
43764365
run: |
43774366
tar -xzf .artifacts/review-runtime.tar.gz
43784367
4379-
- uses: ./clawsweeper/.github/actions/setup-state
4380-
id: review-shard-records-state
4381-
with:
4382-
coordinator-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
4383-
records-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
4384-
records-secret: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
4385-
records-repo-slugs: ${{ needs.plan.outputs.target_slug }}
4386-
hydrate-git-state: "false"
4387-
hydrate-state-blobs: "false"
4388-
worktree-path: clawsweeper
4389-
43904368
- name: Install review compiler service
43914369
continue-on-error: true
43924370
working-directory: clawsweeper

‎prompts/review-item.md‎

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,17 @@ For PRs, include a dedicated security review pass in addition to the functional
412412

413413
For PRs, also run an authority-chain and invariant-inversion pass inside the
414414
existing functional, security, proof, risk, and rating outputs; do not create a
415-
separate review section. Trigger this pass when the PR creates or persists an
416-
identifier, route, binding, capability, default, or authorization decision;
417-
broadens discovery, enumeration, fallback, dispatch, retry, replay, or recovery;
418-
or treats data as trusted, internal, host-derived, or server-derived so it can
419-
bypass normal validation. Follow each triggered value from every producer to
420-
the final network, provider, filesystem, process, queue, or other side effect.
415+
separate review section. Trigger this pass only when the diff materially changes
416+
authority: it creates, persists, transfers, or consumes an authority-bearing
417+
value and at least one of these is true: that authority crosses a principal,
418+
account, tenant, session, or comparable trust boundary; it can outlive or bypass
419+
the authorization decision that established it; or it changes which principals
420+
can reach a final side effect.
421+
An identifier, route, binding, default, retry, replay, fallback, recovery, or
422+
refactor does not trigger this pass merely because it exists; it counts only
423+
when the diff materially changes authority. Follow each triggered value from
424+
every producer to the final network, provider, filesystem, process, queue, or
425+
other side effect.
421426
Stored provenance and an internal origin are context, not proof of current
422427
authorization at the point of use.
423428

@@ -445,12 +450,24 @@ changed surface.
445450

446451
For PRs, include a dedicated `realBehaviorProof` assessment before any pass, automerge, or repair verdict. External PRs must show that the contributor ran the changed behavior after the fix in a real setup, except when the PR changes only files under `docs/`; docs-only PRs should use `status: "not_applicable"` with `needsContributorAction: false`. Unit tests, mocks, snapshots, lint, typechecks, and CI are supplemental only; they are not real behavior proof by themselves. Treat screenshots, recordings, terminal screenshots, console output, copied live output, linked artifacts, and redacted runtime logs as valid proof, including for non-visual CLI, console, text, or error-message changes. Prefer asking for screenshots or videos when they can show the behavior, including terminal screenshots for text or console changes, while keeping logs and live output acceptable. Remind contributors to redact private information like IP addresses, API keys, phone numbers, non-public endpoints, and other private details before posting evidence. A plain app screenshot is sufficient only for behavior it directly shows. Do not mark screenshot-only proof sufficient for browser runtime, CSP, CORS, `connect-src`, auth callback, network, or security changes when the proof only says no console error, warning, or violation is visible; require console output, a network trace, terminal/live output, logs, a recording with diagnostics, or a linked artifact that actually shows the runtime path. Use your tools and best judgement: inspect the PR body, comments, links, screenshots, videos, logs, terminal output, and changed behavior context; you may download/open GitHub attachment links, generate stills or contact sheets from videos, inspect terminal screenshots and logs, and compare the proof against the PR diff. Use the provided scratch directory for downloaded artifacts and keep the target checkout read-only. Use `status: "sufficient"` only when the evidence convincingly shows after-fix real behavior and an observed improved result. Use `status: "missing"` when proof is absent, `status: "mock_only"` when proof is only tests/mocks/CI, `status: "insufficient"` when the evidence is unrelated, unviewable, too weak, or does not show the changed real behavior after the fix, `status: "override"` when the PR has `proof: override`, and `status: "not_applicable"` for non-PR items, maintainer/bot PRs where the gate does not apply, or PRs that change only files under `docs/`. When proof is missing, mock-only, or insufficient, set `needsContributorAction: true`, make the PR a human-only merge blocker, and do not request ClawSweeper repair markers because automation cannot prove the contributor's setup for them.
447452

448-
The maintainer/bot exception applies only when the authority-chain pass does not
449-
trigger. For a triggered PR, require the same allowed and nearest-forbidden
450-
final-effect proof based on the changed surface, regardless of author role. For
451-
every triggered PR, begin `realBehaviorProof.summary` with the exact marker
452-
`Authority-chain proof required:` so existing proof parsing and merge gates can
453-
preserve the surface-based requirement.
453+
When the narrowed authority-chain pass leaves a material, plausible authority
454+
violation unresolved by the diff and available evidence, require allowed and
455+
nearest-forbidden final-effect proof based on the changed authority surface,
456+
regardless of author role. Do not require this proof or emit its marker merely
457+
because the pass ran. When it is required, begin `realBehaviorProof.summary`
458+
with the exact marker `Authority-chain proof required:` so existing proof
459+
parsing and merge gates preserve this surface-based requirement.
460+
461+
For OWNER, MEMBER, COLLABORATOR, and bot-authored PRs carrying that marker,
462+
assess `realBehaviorProof` only against the required authority final-effect
463+
evidence; their exemption from proof unrelated to authority remains intact.
464+
Sufficient authority evidence can therefore satisfy this scoped gate without
465+
unrelated runtime proof. External contributors must satisfy both the ordinary
466+
contributor proof requirement and any applicable authority-chain proof
467+
requirement; use `status: "sufficient"` only when the evidence satisfies both.
468+
The marker activates only the authority-chain proof exception to trusted-author
469+
exemptions; it must not turn every proof category into a requirement. Continue
470+
to honor `proof: override` for either case.
454471

455472
A reviewer-side environment limitation is not missing contributor proof. If a
456473
required dependency checkout, network path, credential, or inspection tool is
@@ -573,16 +590,6 @@ title or line location. If the earlier SHA is unavailable or the comparison is
573590
inconclusive, leave `lateFinding` false or omitted. Repeatedly surfacing one
574591
new previously-visible concern per cycle is a review defect, not author churn.
575592

576-
When an explicitly linked related item includes
577-
`latestClawSweeperAssessment`, first decide whether that item is an
578-
implementation predecessor, such as the design/feature issue this PR implements
579-
or a canonical predecessor named by the PR. If it is, carry its latest stated
580-
invariants, risks, findings, and proof expectations into the current review and
581-
re-evaluate them against this diff and current behavior. Do not blindly inherit
582-
its verdict, and do not carry assessments from title similarity, search,
583-
gitcrawl, duplicates, or merely adjacent items. A predecessor assessment is
584-
review input, not proof that the new implementation preserves the invariant.
585-
586593
Use target `AGENTS.md` policy as review input, not as a standalone source of
587594
findings. For PRs, if the diff concretely violates an applicable `AGENTS.md`
588595
policy in a way the author can fix, report it through `reviewFindings` using
@@ -1043,9 +1050,10 @@ Include `nextSteps` as 0-3 concrete
10431050
rank-up moves only when they are merge-relevant and likely to improve reviewer
10441051
confidence. Use an empty array for `S`, `A`, and `NA`, and usually for `B`
10451052
unless one specific action materially reduces risk. Do not invent optional
1046-
polish work or create churn for already-good PRs. For an authority-sensitive
1047-
PR, tailor a rank-up move to the nearest forbidden principal and the final side
1048-
effect; generic requests for more tests or more security review are not enough.
1053+
polish work or create churn for already-good PRs. For a PR that meets the
1054+
narrowed authority-chain trigger, tailor any authority-related rank-up move to
1055+
the nearest forbidden principal and the final side effect; generic requests for
1056+
more tests or more security review are not enough.
10491057

10501058
Always fill `telegramVisibleProof` using the changed-behavior classification
10511059
above. It only controls the `mantis: telegram-visible-proof` label.

‎src/clawsweeper-context-hydration.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ interface CreateContextHydrationDependencies {
6868
numberForMarkdownFile: (file: string) => number;
6969
replaceFrontMatterValue: (markdown: string, key: string, value: string) => string;
7070
repoRelativePath: (path: string) => string;
71-
reportPrRating: (markdown: string) => import("./clawsweeper-types.js").PrRating;
72-
reportRealBehaviorProof: (markdown: string) => import("./clawsweeper-types.js").RealBehaviorProof;
73-
reportReviewFindings: (markdown: string) => import("./clawsweeper-types.js").ReviewFinding[];
7471
reportUrl: (path?: string) => string;
7572
reviewCommentBodyDigest: (body: string) => string;
7673
reviewSectionValue: (
@@ -132,9 +129,6 @@ export function createContextHydration(dependencies: CreateContextHydrationDepen
132129
numberForMarkdownFile,
133130
replaceFrontMatterValue,
134131
repoRelativePath,
135-
reportPrRating,
136-
reportRealBehaviorProof,
137-
reportReviewFindings,
138132
reportUrl,
139133
reviewCommentBodyDigest,
140134
reviewSectionValue,
@@ -585,9 +579,6 @@ export function createContextHydration(dependencies: CreateContextHydrationDepen
585579
frontMatterValue,
586580
reviewSectionValue,
587581
effectiveReviewStatus,
588-
reportPrRating,
589-
reportRealBehaviorProof,
590-
reportReviewFindings,
591582
displayTitle: (title) => displayTitle(title),
592583
markdownFiles,
593584
numberForMarkdownFile,

‎src/clawsweeper-markdown.ts‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,21 @@ function firstDecisionNeededQuestion(body: string): string {
158158
return firstNonEmptyLine(section);
159159
}
160160

161-
export function beforeMergeActions(body: string): string[] {
161+
export function firstBeforeMergeAction(body: string): string {
162162
const section = markdownTopLevelSection(body, "Before merge");
163163
// "None." is the no-action sentinel; a checked task is finished work, not a
164164
// remaining action.
165165
if (!section || /^none[.!]?$/i.test(section.trim())) {
166-
const decision = firstDecisionNeededQuestion(body);
167-
return decision ? [decision] : [];
166+
return firstDecisionNeededQuestion(body);
168167
}
169-
const actions: string[] = [];
170168
let sawTask = false;
171169
for (const line of section.split(/\r?\n/)) {
172170
if (/^- \[[xX]\]/.test(line)) {
173171
sawTask = true;
174172
continue;
175173
}
176174
const task = line.match(/^- \[ \][ \t]+(?:\*\*(?:\\.|[^*\\\n])+\*\*[ \t]+-[ \t]+)?(\S.*)$/);
177-
if (task?.[1]) {
178-
actions.push(task[1].trim());
179-
continue;
180-
}
175+
if (task?.[1]) return task[1].trim();
181176
if (line.startsWith("- [")) sawTask = true;
182177
const cells = markdownTableCells(line);
183178
if (cells.length < 2) continue;
@@ -189,17 +184,11 @@ export function beforeMergeActions(body: string): string[] {
189184
.toLowerCase(),
190185
);
191186
if (labels[0] === "needed" && labels[1] === "why") continue;
192-
if (cells[1]) actions.push(cells[1]);
187+
if (cells[1]) return cells[1];
193188
}
194-
if (actions.length) return [...new Set(actions)];
195189
// A checklist whose tasks are all checked has no remaining checklist action, but
196190
// an outstanding maintainer decision still is one.
197-
const fallback = sawTask ? firstDecisionNeededQuestion(body) : firstNonEmptyLine(section);
198-
return fallback ? [fallback] : [];
199-
}
200-
201-
export function firstBeforeMergeAction(body: string): string {
202-
return beforeMergeActions(body)[0] ?? "";
191+
return sawTask ? firstDecisionNeededQuestion(body) : firstNonEmptyLine(section);
203192
}
204193

205194
export function previousReviewStatus(body: string): string {

0 commit comments

Comments
 (0)