Per-repo 'allow self-approval' setting (default on) replacing the hard author-cannot-approve block #586
Labels
No labels
actions
bug
cli
duplicate
enhancement
fork
forum
git storage
help wanted
insights
invalid
issues
moderation
oidc
ownership transfer
packages
pr/merge protection rules
projects
pull requests
question
releases
sponsorships
tags
webhooks
wiki
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crueber/walhub#586
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What's requested
A per-repo "allow self-approval" setting (default: permissive / allowed) that replaces today's hard server-side block on PR authors approving their own pull requests.
Today an author who tries to Approve (or Request Changes on) their own PR gets a 422:
internal/review/service.go:344-347—SubmitReviewrejects whennormPrincipal(h.Author) == who && in.State != StateCommentedwith "author cannot approve their own pull request".docs/features/04_code_review.md(route table line ~203: "author self-approve/request-changes → 422"; constraints bullet line ~269: "no author self-approval, enforced server-side"). This ticket amends that stated design rule — flagged for the user's call, not silently changed.Proposed design
internal/api/settings.go, WAL-published TOML, GET AuthRead / PUT AuthAdmin, ≤16 KiB), e.g.allow_self_approval(or grouped under a review section per the doc's existing shape). Default permissive — on — so repos behave like GitHub out of the box.SubmitReviewconsults the setting instead of the unconditional author check: when allowed, an author may submit APPROVED / CHANGES_REQUESTED on their own PR; when disabled, the current 422 behavior stands. COMMENTED is always allowed either way.Decision points (planner/user's call — pick one and note it)
Service.EvaluateGate/CheckRequiredReviewsininternal/review/service.go~line 698+, wired into merges via pulls'ReviewGateseam ininternal/pulls/review.go) counts EVERY latestStateApprovedreview towardmin_approvals, with no author exclusion — the current code never needs one because the author can't produce an approval. Once self-approval is allowed, an author's own approval WILL count towardmin_approvalsby default. Options:min_approvals, regardless of the setting (self-approval then only affects the review summary/decision display, not the gate) — safest for protection semantics.required-reviewspolicy effect (internal/pulls/policy.go), e.g.count_self: falsedefault. Most flexible, most surface.The ticket should land the setting first with a choice made and stated in code/tests; do not leave the gate counting ambiguous.
Architecture notes
SubmitReview);review.go'sPRKeycomment andmodel.go:27doc comments reference the self-approve rule and should be updated alongside.scanReviews→latestOf(authoritative scan); no caching/ETag concern here (the setting itself is on the settings doc — if it's projected into any SWR-cached summary, it must be ETag-covered per the mutability law).docs/features/04_code_review.mdlines ~203 (route table) and ~269 (constraints bullet) must be amended to describe the conditional behavior; this is a deliberate design-rule change, presented for user ratification.Acceptance criteria
allow_self_approvalsetting on the settings doc, default on, editable via PUT AuthAdmin, rendered in the settings UI with an existing toggle component.docs/features/04_code_review.mdamended (route table + constraints bullet) to describe the conditional rule.internal/review/model.go,internal/review/review.go,internal/review/service.goheader) updated — no stale "never self-approve" claims.Fixed by #589 (merged): per-repo [review] allow_self_approval (default ON, zero migration) on the settings doc with a General-tab toggle; SubmitReview consults it (OFF keeps the 422); merge gate never counts author self-approvals toward min_approvals (Decision b), author's CHANGES_REQUESTED still blocks; dismiss_stale needs no special handling. Spec amended in 04_code_review.md + 11_config_cli.md as a deliberate rule change. Verified: review/config coverage ≥95%, go -race green, 1456 web unit green (smoke excluded, pre-existing), vite/esbuild green, independent review APPROVE.