Skip to content

Add --redo to nemar admin pr-reviews start - #1922

Merged
neuromechanist merged 9 commits into
devfrom
feature/pr-review-start-redo
Oct 24, 2026
Merged

neuromechanist merged 9 commits into
devfrom
feature/pr-review-start-redo

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1921.

nemar admin pr-reviews start <dataset> <pr> --redo starts a commit whose review already has a result (pass, fail or uncertain) again, and start --all --redo does the same for every open pull request whose current commit has a finished review. Until now a finished review could only run again through an edit of the pull request's title, body or base, a reopen or a ready-for-review, at most five times (ADR 0107, decision 4), so the pull requests the shadow run had already reviewed (for example on006107 #1 and on002578 #2) could not be re-judged with the 0.10.23 scripts and prompt, and the live-review gate could not be run on them.

How it works: the Worker's start route takes ?redo=1 and passes redo to the gate with adminStart. isRestartable now says yes for a reported row when the start is a redo, and the existing restartReview does the rest (nonce replaced so the superseded job's claim and report are refused, verdict and report cleared, check back to running, attempts plus one when the earlier run could have cost a call; the contributor's edit count is left as it is, because a redo is no edit). There is no new SQL, no migration, no workflow and no wrangler change.

Limits that are part of the design: a review that is running is never superseded (new fixed word review_running for a redo; a job that claimed its review less than 50 minutes ago counts as running even after the watchdog closed the row, for a plain start too), a blocked contributor's finished review is left untouched and the answer is contributor_paused, an owner's or administrator's pull request with no review on record is still exempt, and --all --redo leaves out drafts, reviews in progress, exempt pull requests and commits capped for edits. The Worker echoes redo: true in its answers to a start that asked for it; a CLI that sent the flag and does not see the echo reports what the Worker did, says the flag was ignored and exits 1, so an older Worker's duplicate is never read as "nothing to redo" (a bulk run stops after one answer and keeps its results, in the JSON too). An administrator's start is also tried again when the row moves under it, like a change of the text. The audit row of a redo records redo: true.

Cost: a redo is a second run of up to two model calls, stated in the help and in the --all question. A bulk redo of about a hundred reviews starts them back to back like --all does; a --limit to stage it is not built here.

ADR 0093 gets the amendment of 2026-10-24, ADR 0107 decision 4 and the AGENTS.md entry get the matching notes.

Tests, all against the real handler and router (real D1 engine, GitHub as a local stand-in): backend/test/pr-review-start.test.ts (about thirty redo cases: pass, fail and uncertain restarted on the same row, facts-stage report adds no run, running reviews untouched, overdue restarted, blocked contributor declined, capped commit restarted, no row is an ordinary start, the echo including the early returns, the query values 1/true honored and 0/yes/empty/absent not, a member refused, the audit row), backend/test/pr-review-flow.test.ts (a redo supersedes the old job's token and its late report is refused, a redo does not supersede a running review, a delivery with redo set restarts nothing), test/admin-pr-reviews-start-cli.test.ts (the real CLI against the real router, including a Worker stand-in that predates the flag) and test/pr-reviews-render.unit.test.ts. Ten mutations were each turned red by a named test: redo ignored for a reported row, redo restarting a running row, the running word dropped, the echo dropped, any redo value counted, redo as the default for every start, in_progress and exempt joining the redo verdicts, the client-side verdict filter removed, the echo check dropped, and the flag never sent.

Not in this PR: nothing deploys until the next release. Follow-up outside the repository: nemarOrg/docs admin/commands.mdx (private) should list --redo.

start takes ?redo=1: a reported commit is restarted on its row through the restart edits use, a running review is never superseded (review_running), the Worker echoes redo, and the audit row records it. No SQL or migration change. Tested with the real handler and router, and with six mutations of the restart rule.
Named redo, and start --all --redo for every open pull request with a finished review (drafts, running reviews, exempt pull requests and commits capped for edits stay out). A Worker that predates the flag is detected by the missing echo and the command says so. Tested through the real CLI against the real router, and with four mutations.
Amendment of ADR 0093 for the redo and its two limits, the matching notes in ADR 0107 decision 4, and one clause in the AGENTS.md ADR 0093 entry. Docs only.
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1922

Version: 0.10.24-PR1922.a94f6a3
Commit: a94f6a3


🤖 Updated on each push.

Review findings on the redo: an administrator's start no longer supersedes a job still inside its limit (claimed less than 50 minutes ago, even after the watchdog closed the row), a redo of a blocked contributor's finished review answers contributor_paused and writes nothing, a redo leaves the edit count alone, and an administrator's start is tried again when the row moves under it. The job limit is pinned to the workflow. Tests with five mutations.
A Worker that predates the flag: the answer it gave is reported (a start it made is not hidden), then the command says the flag was ignored and exits 1 without the bug-report hint; a bulk run stops after one answer and keeps its results, in the JSON too. The dry-run list marks the finished reviews and their verdicts, and the help states the block, exemption, running-job and edit-count rules.
ADR 0093 amendment: blocks, edit count, the claim window, retries, volume and the name overlap with ADR 0102; ADR 0092 and 0107 pointers; AGENTS.md wording. Docs only.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review round 1 (two reviewers: Sonnet on tests, CLI and docs; Opus on the Worker restart semantics), all resolved in 95abf3b, 6c89788 and 1275337, pushed once.

Fixed: (Opus I1) a start could supersede a job still inside its 50-minute limit when the 60-minute watchdog had closed its row, which a second bulk redo makes likely: isRestartable now refuses a dispatched or unreported row that a job claimed less than PR_REVIEW_JOB_MINUTES ago, pinned to the workflow's timeout-minutes by the workflow test; (Opus I2) a redo of a blocked contributor's finished review erased its verdict and report with no audit row, now the answer is contributor_paused and nothing is written; (Opus S1) a redo that lost a race answered duplicate, an administrator's start is now tried up to three times like a change of the text; (Opus S3) a bulk redo lifted the edit cap for finished reviews at 5 of 5, a redo now leaves the edit count as it is; (Opus S4) stale comments, the contract's list of reason words and the ADR wording; (Sonnet I1) an ignored --redo hid what an older Worker had done and lost the bulk results, it now reports the answer first, keeps the results and the JSON document, and does not print the bug-report hint; (Sonnet I2) tests for the exemption (no row and a row), the gate order (draft, closed, not main, bot), the check going back to in_progress, a real edit-cap case and the blocked case; (Sonnet I3) the AGENTS.md and help wording about the exemption and about "only", and ADR 0092's pointer; (Sonnet suggestions) finished reviews are marked in the dry-run list and the would_start JSON, the command description mentions --redo, the help says a bulk redo is not resumable and what a block does, the review_running hint, and a note in the ADR on the name shared with ADR 0102.

Rejected with a reason: (Opus S2) the first run's tokens leave the volume's sums when the report is cleared, which is how every restart already behaves and what ADR 0107 states about the volume line; the run count keeps both runs, and the ADR amendment now says so; (Sonnet) an assertion on the --all --redo confirmation text, because the prompt is not printed with stdin closed; the question text is pinned by a unit test.

The restart write now also requires the claimed_at it read, so a job that claims the review between the guard and the write is never superseded by an administrator's start; the next try reads the claimed row and the guard refuses it. Tested with an injected claim, redo and plain, and a mutation.
Say how many were not tried only when some were; report the ignored flag before a fault exit and keep the bug-report hint for a real fault; mark the finished reviews of every verdict in the tests; say in the help that a recent claim holds a start back.
ADR 0092 names the 50-minute claim window, ADR 0093 says which starts begin the edit count again and that a blocked redo leaves the result alone. Docs only.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review round 2 (delta only: Opus on the Worker fixes, Sonnet on the CLI and docs fixes): no Critical and no Important findings. Resolved in 04c7b2b, 097f1fb and a94f6a3, pushed once.

Fixed: (Opus) the restart write now also requires the claimed_at it read, so a job that claims the review between the guard and the write is not superseded; the next try reads the claimed row and the guard refuses it (tested with an injected claim for a redo and a plain start, and by a mutation); (Sonnet) the "N pull requests were not tried" sentence only when some were; an ignored flag is reported before a fault exit and the fault keeps its own bug-report hint; the bug-report hint stays hidden only when nothing else failed; the marking test now seeds fail and uncertain reviews; the help and ADR 0092 say that a recent claim holds a start back (and the long ADR line is wrapped); ADR 0093 says which starts begin the edit count again and that a blocked redo leaves the row's result alone.

No third round; merging when CI is green.

@neuromechanist
neuromechanist merged commit c0bea18 into dev Oct 24, 2026
14 checks passed
@neuromechanist
neuromechanist deleted the feature/pr-review-start-redo branch October 24, 2026 08:44

This branch was previously deployed

1 inactive deployment
npm — a94f6a36 Deployed Oct 24, 2026 by neuromechanist via publish #3846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant