Turn reviewer hints on¶
Reviewer hints let a person steer a proposal from its pull request with a /shadewright reanalyze: comment (give a reviewer hint). They are off by default. Turn them on per install with the executor flag --reviewer-hints, and only after the GitOps repository requires the check shadewright/review from the Shadewright App. Background: ADR-0028, section 5 for the merge gate.
Why the repository rule comes first¶
With hints on, the executor creates a check run shadewright/review on every head of the pull requests it opened. It passes only when the latest head has an approving review from someone who wrote no hint in the chain, so the person who steered a change cannot be its only approver. While the pull request waits, the executor keeps reading the reviews and its own check run on the head, and makes the check show what the reviews call for: back to in progress when no such approval of the head stands any more (a dismissed approval, a later review that requests changes), passed again when one does. A review that only comments does not take an approval back. When the plan goes stale, the executor fails the check with a summary saying so, also when the Git host refuses to close the pull request; that failure is final, and the pull request must not be merged. That check is the merge gate, and it blocks only what the repository requires:
- With the rule (the target branch requires
shadewright/review, with the Shadewright App as the expected source), a pull request cannot merge until the check passes. - Without the rule, or without the source, the check only informs. A hint author can approve and merge their own steered change, and with no source anyone with push access could post a commit status of that name. Do not turn hints on for that repository.
Shadewright cannot verify the rule: the App has no administration permission. Checking it is your part.
1. Require the check on the target branch¶
In the GitOps repository, edit the ruleset that targets the branch Shadewright opens pull requests against (Settings > Rules > Rulesets):
- Under Require status checks to pass, add the check
shadewright/review. - Set its source to the Shadewright GitHub App, not "any source".
- Save the ruleset.
Through the API, the rule in the ruleset reads as follows, with the App's numeric ID as integration_id:
{
"type": "required_status_checks",
"parameters": {
"strict_required_status_checks_policy": false,
"required_status_checks": [
{ "context": "shadewright/review", "integration_id": <app id> }
]
}
}
Pull requests people open to that branch¶
The rule applies to every pull request to the target branch, but only Shadewright's pull requests get the check shadewright/review: the executor creates it only on the pull requests it opened. A pull request a person opens to that branch waits for a check that never comes, and cannot merge. Choose one of these before you save the rule:
- Maintainers on the ruleset's bypass list. Add the role or team that merges people's changes as a bypass actor of the ruleset. They can merge their own pull requests past the missing check; GitHub records each bypass. Everyone else's pull requests to that branch stay blocked until a bypass actor merges them. The bypass is not limited to people's pull requests: every bypass actor can also merge Shadewright's pull requests past
shadewright/review, including a change they steered with their own hint, so for them the gate does not hold. Keep the list to the repository admin role, or use a separate target branch (below). Never add the Shadewright App to the bypass list. - A separate target branch for Shadewright. The repository entry's
targetBranchmust be the branch Flux tracks (configuration), so make that a branch only Shadewright opens pull requests against, and require the check only there. People open their pull requests to another branch, which never waits for the check, and a maintainer carries that branch over to the tracked one with a push under the ruleset's bypass, as the scenario clusters do withcluster/<cluster>(ADR-0022). It costs one more step before a person's change is applied.
The lab fleet uses a maintainer bypass: its ruleset for cluster/* lists the repository admin role, the maintainer's, as its bypass actor, so the maintainer's own pull requests and resets of cluster/lab still go through.
The App also needs the checks: write permission. Every token request of the executor names it since #539, so an App without it already fails (ADR-0006). Nothing else changes: no new App permission and no Kubernetes RBAC.
2. Turn the flag on¶
With the Helm chart, set the value and upgrade (keep your values in a file, as in upgrade with Helm):
helm upgrade shadewright oci://ghcr.io/pkalin/charts/shadewright --version <version> \
--namespace shadewright-system -f my-values.yaml --wait --timeout 10m
The timeout is twice the five minutes a new Pod may take to turn Ready (health probes), so a slow start is not reported as a failed upgrade.
The chart renders --reviewer-hints on the executor only, and refuses the flag in executor.extraArgs. With the kustomize manifests, add --reviewer-hints to the args of the executor's container.
3. Check it¶
The executor logs the setting once at start:
The line shows enabled true and, as a reminder, the required check shadewright/review. Within about one --pull-request-poll-interval (a minute by default), every waiting Shadewright pull request shows the check shadewright/review, in progress until a reviewer who wrote no hint approves its latest head. In the pull request's merge box the check is listed as required; if it is not, the rule of step 1 is missing.
Turn it off¶
- Set
executor.reviewerHints.enabledback tofalseand upgrade. -
Close the pull request of every request that stopped in
NeedsInterventionwith reasonHintsTurnedOff. Each one took its pull request over for a hint before the switch, so the pull request may carry a change a hint steered, and the checkshadewright/reviewis no longer kept on it. Also close, or review by hand, the pull request of a request that stopped with reasonHeadMovedand an aborted handoff (Abortedin the third column): a handoff pushed its commit there just before the switch. List them, with their pull requests:kubectl -n shadewright-system get remediationrequests -o jsonpath='{range .items[?(@.status.phase=="NeedsIntervention")]}{.metadata.name}{"\t"}{.status.conditions[?(@.type=="Approved")].reason}{"\t"}{.status.handoff.to.phase}{"\t"}{.status.pullRequest.url}{"\n"}{end}' \ | grep -wE 'HintsTurnedOff|HeadMoved'kubectl shadewright explain <name>shows the stop of one request. Close each such pull request without merging. -
Remove the rule of step 1.
Hints off fails closed, which makes this order safe. On its first look at each waiting pull request, the executor declines every stored hint that was not applied yet (Pending or Reserved, reason HintsTurnedOff), so the analyzer starts no analysis for it. A replacement the analyzer proposed for a hint is denied at admission (HintsTurnedOff), and one already admitted ends Cancelled with that reason without touching the pull request, which keeps its plan. If a handoff had pushed its commit just before the restart, the commit is not adopted: the original request stops in NeedsIntervention, as for any foreign push, and its pull request stays open for a person to review or close. A replacement that had already taken the pull request over stops in NeedsIntervention with reason HintsTurnedOff, whatever step it stood at: it no longer ends the original request, rewrites the pull request or waits for review as Shadewright's. So no change a hint steered waits for review as Shadewright's after the switch without the check.
Until you remove the rule, the executor no longer creates or completes the check, so Shadewright's pull requests wait and cannot merge; nothing is lost. That is why step 2 comes before step 3: once the rule is gone, any approval lets a pull request merge, including one a hint changed.
Not yet run
These steps were not run against a live cluster for this documentation. The flag, the chart value and the log line are covered by unit and chart tests; the lab run is #541.