Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion design/developer-workflows/pr-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Use this guide for pull-request status, review handling, CI, Renovate, merging,
- If that exact legacy transition is followed by a fresh review and a later coherent fix head, reauthorize only the same immutable fingerprints with `dev-tools/pr-review decide transition --reauthorize --pr <number> --head <exact live SHA> --reason "<reason>"`. The controller requires a prior transition, verifies every carried record again, and requires every other observation to be normal completed attributable anchored evidence; newer evidence remains counting and subject to ordinary reconciliation and judgment. A changed head without this explicit reauthorization remains blocked, and the command never creates a checkpoint or consumes review quota.
- A single previously audited Hosted fingerprint that is absent from the complete current history may be retired only with `--reauthorize --retire-missing-hosted-fingerprint <exact fingerprint>`. This requires the exact prior fingerprint, coherent current topology, complete available Hosted trigger records and paginated GitHub review/comment history, terminal and uniquely attributable responses, no active or unresolved reservation, and no unresolved actionable findings; any missing or ambiguous proof remains held. The fingerprint stays in the transition audit and remains non-counting if it later reappears. This decision never reconstructs evidence or creates a checkpoint and does not grant review, taper, finding-count, or merge-readiness credit.
- Record an explicit channel judgment with `dev-tools/pr-review decide judgment retain|reopen --pr <number> --channel hosted|cli --head <exact live SHA> --checkpoint <id> --reason "<reason>"`. Retain confirms the verified equivalent patch for request and queue safety; reopen explicitly requires fresh review without deleting historical completed taper and resets the taper streak at the bound checkpoint. For CLI, a reopen may bind the latest complete modern checkpoint to a proven descendant live head, but carries no new review credit until later completed results arrive. A narrow channel policy override uses `dev-tools/pr-review decide policy --pr <number> --head <exact live SHA> --checkpoint <id> --hosted-zero-useful <count> --reason "<reason>"` or `--cli-zero-useful <count>` (exactly one channel); it sets that channel's zero-useful completion count for the exact checkpoint.
- Extend the existing allocation with `dev-tools/pr-review decide allocation grant --pr <number> --channel hosted|cli --head <exact live SHA> [--checkpoint <completed checkpoint>] [--min-additional-completed <N>] [--max-additional-completed <N>] [--fresh-taper] --reason "<human judgment>"`. Both bounds count completed, attributable results for that PR and channel beginning at the decision; the optional checkpoint records the observed identity but does not move that count's start. With neither bound, the existing one-result promise remains (`min=1`, `max=1`). A minimum-only allocation has no maximum; a maximum-only allocation has no extra minimum (`min=0`). Without `--fresh-taper`, an allocation after completed taper affects queue eligibility and its additional-result count while preserving the existing historical taper display. Its zero-useful results continue the normal streak. An accepted allocated result resets the active streak at that result, while all earlier checkpoints remain visible with their original counts; after fixes, later zero-useful results can satisfy taper. `--fresh-taper` starts the active streak at the allocation decision immediately; earlier dry results remain visible historical evidence but cannot satisfy it. When both bounds are set, reject `min > max`; the minimum requires that many additional results even after fresh taper, while taper may stop earlier than the maximum once the minimum is met. Rate limits, connection failures, duplicates, partial or ambiguous responses, provisional captures, and other non-counting observations do not consume the count. Hosted and CLI allocations remain independent; request-time identity checks apply only when posting a new review.
- Extend the existing allocation with `dev-tools/pr-review decide allocation grant --pr <number> --channel hosted|cli --head <exact live SHA> [--checkpoint <completed checkpoint>] [--min-additional-completed <N>] [--max-additional-completed <N>] [--exact-additional-completed <N>] [--fresh-taper] --reason "<human judgment>"`. Both bounds count completed, attributable results for that PR and channel beginning at the decision; the optional checkpoint records the observed identity but does not move that count's start. With neither bound, the existing one-result promise remains (`min=1`, `max=1`). A minimum-only allocation has no maximum; a maximum-only allocation has no extra minimum (`min=0`). `--exact-additional-completed N` is mutually exclusive with the separate bounds and `--fresh-taper`, and records `min=max=N`, so ordinary taper cannot stop discovery before all `N` results and the cap stops discovery immediately afterward. It preserves the existing taper rather than starting a fresh streak. Use `allocation renew --exact-additional-completed N` to replace an existing allocation or audited human stop explicitly. A verifiable request already admitted at the exact-allocation decision remains in flight and counts only when it completes attributably; ambiguous or unsupported active evidence is refused. Without `--fresh-taper`, an allocation after completed taper affects queue eligibility and its additional-result count while preserving the existing historical taper display. Its zero-useful results continue the normal streak. An accepted allocated result resets the active streak at that result, while all earlier checkpoints remain visible with their original counts; after fixes, later zero-useful results can satisfy taper. `--fresh-taper` starts the active streak at the allocation decision immediately; earlier dry results remain visible historical evidence but cannot satisfy it. When both bounds are set, reject `min > max`; the minimum requires that many additional results even after fresh taper, while taper may stop earlier than the maximum once the minimum is met. Rate limits, connection failures, duplicates, partial or ambiguous responses, provisional captures, and other non-counting observations do not consume the count. Hosted and CLI allocations remain independent; request-time identity checks apply only when posting a new review.
- Normal taper can finish before a maximum once the minimum is met. After any additional result with accepted findings, no next request is allowed until those findings, current/outdated threads, actionable summary findings, and fix publication/validation obligations are clear, even if capacity remains. Once the maximum is used, no further request is allowed for that PR/channel; a maximum stop is not taper and does not waive accepted findings or fixes. `status` and `evidence` expose the minimum, maximum, completed count, baseline identity, in-flight results, taper state, and controlling reason. When the maximum is exhausted, the controller derives an audited human-cap stop and advances that channel through its normal selector without a separate `decide stop`, subject to the active-review safety described below. Pending obligations remain source-owned and visible as `cap exhausted; findings pending`; this stop is not taper, current-head review, CI/Smoke proof, or merge readiness. A bounded allocation can be replaced explicitly with `allocation renew` and new bounds; `allocation cancel` removes it. Ordinary fixes never reset its completed count.
- When the Overseer deliberately allocates one further completed review before deciding whether to continue, record it before the review with `dev-tools/pr-review decide allocation grant --pr <number> --channel hosted|cli --head <exact live SHA> --reason "<reason>"`. Completed-result counts belong to the PR and channel and survive later identity changes; rate limits, partial, duplicate, and unattributable results do not consume the allocation. Record a human decision to make no further requests with `dev-tools/pr-review decide stop --pr <number> --channel hosted|cli --reason "<human judgment>"`. This audited PR/channel override bypasses the taper gate only for queue advancement; it is not taper completion or proof of review coverage, and it persists across head and parent changes. It requires no completed checkpoint, clean findings, idle provider, or coherent review topology. An already admitted CLI or Hosted run continues with its reservation, capture, attribution, and eventual findings intact; finishing that run does not clear the override. Stop recording and new-request admission share only the short state mutation boundary, while each provider keeps its execution exclusion. Optional `--head` and `--checkpoint` pins must match the observed identities; unavailable optional Git proof is recorded as absent, never fabricated. Existing ambiguity-retention and over-ceiling acknowledgment options record their specific evidence without granting review credit. Discovery can advance only when the same channel has no active provider run. Accepted fixes, pending captures and adjudication, attributable evidence, current and outdated threads, actionable summaries, required CI, runtime proof, ancestry, and merge safety remain independent obligations. A stop overrides taper only and does not manufacture a reviewed head or merge readiness.
- For a channel that still needs review, targeting stops at the first held, unstable, unreconciled, over-ceiling, or judgment-blocked PR; it skips PRs whose channel has completed taper or an audited human stop. The narrow exception is a verified terminal, non-counting Hosted response: keep that PR incomplete and visible, but use the next coherent PR's Hosted window if one exists. Do not post another request on the ambiguous PR or grant it taper or merge credit; revisit its evidence or obtain an audited human stop before its merge handoff. Request-time identity and active-review checks still apply before any new request for an incomplete channel. A file-ceiling rejection requires a coherent topology decision; there is no normal incremental-review fallback.
Expand Down
2 changes: 2 additions & 0 deletions dev-tools/pr_review/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The output identifies the SQLite schema and writer build. The live shared cutove

For a posted Hosted request, `dev-tools/pr-review wait hosted --pr <number> --trigger-id <comment ID>` watches only that saved trigger. `--poll-seconds` defaults to 30 and `--max-wait-minutes` to 90. It returns JSON and exit status 0 for an attributable completion, 3 for another terminal result, or 4 when the wait expires; it never posts a request, grants review credit, or retires the trigger. The caller must read the result and use `records sync-hosted --pr <number>` before adjudicating a completed review. A wait expiration leaves the underlying trigger unchanged.

To require exactly a chosen number of further completed attributable results on one channel, use `dev-tools/pr-review decide allocation grant --pr <number> --channel hosted|cli --head <exact live SHA> --exact-additional-completed <N> --reason "<human judgment>"`. Use `allocation renew` instead of `grant` to replace an existing allocation or human stop explicitly. The command records the existing minimum and maximum as the same positive number; it does not start a fresh taper streak. Earlier completed evidence remains historical, while a verifiable request already admitted at the decision remains in flight and consumes one result only if it later completes attributably. Failures, rate limits, and other non-counting results consume none. Discovery continues until all `N` results complete even if ordinary taper was already satisfied or becomes satisfied early, then closes at the exact cap while accepted findings and fixes remain mandatory obligations.

### Manual Hosted adoption

A human-posted Hosted CodeRabbit request can be incorporated without requesting another review: after the review completes, run `dev-tools/pr-review decide trigger-adopt-manual --pr <number> --trigger-id <GitHub comment ID> --head <current reviewed SHA>`. This verifies the immutable public command, completed response, and current anchor before writing a private attribution record. A queued PR uses its reconciled stack parent; an off-queue PR uses its actual live base branch after matching the live base and head tips to their remote refs. Off-queue adoption leaves the configured review queue unchanged. The command does not post a GitHub comment, create a result checkpoint, or grant taper by itself; adjudicate findings and post the normal public Hosted checkpoint next. A moved head or ambiguous response is refused.
Expand Down
7 changes: 7 additions & 0 deletions dev-tools/pr_review/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ def records_database(command: argparse.ArgumentParser) -> None:
metavar="N",
help="maximum additional completed attributable results after the decision",
)
allocation.add_argument(
"--exact-additional-completed",
type=_positive_int,
metavar="N",
help="require exactly N additional completed attributable results after the decision",
)
allocation.add_argument(
"--fresh-taper",
action="store_true",
Expand Down Expand Up @@ -1662,6 +1668,7 @@ def record(current):
checkpoint=args.checkpoint,
min_additional_completed=args.min_additional_completed,
max_additional_completed=args.max_additional_completed,
exact_additional_completed=args.exact_additional_completed,
fresh_taper=args.fresh_taper,
), 0
if args.decide_command == "stop":
Expand Down
47 changes: 41 additions & 6 deletions dev-tools/pr_review/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5607,6 +5607,7 @@ def decide_allocation(
checkpoint: str | None = None,
min_additional_completed: int | None = None,
max_additional_completed: int | None = None,
exact_additional_completed: int | None = None,
fresh_taper: bool = False,
) -> dict[str, Any]:
"""Grant, replace, or cancel a one-result or bounded review allocation."""
Expand All @@ -5623,6 +5624,22 @@ def decide_allocation(
raise ControllerError("fresh taper selection must be boolean")
if checkpoint is not None and (not isinstance(checkpoint, str) or not checkpoint.strip()):
raise ControllerError("allocation baseline checkpoint must be a non-empty immutable identity")
if exact_additional_completed is not None and (
isinstance(exact_additional_completed, bool)
or not isinstance(exact_additional_completed, int)
or exact_additional_completed <= 0
):
raise ControllerError("exact additional completed reviews must be a positive integer")
if exact_additional_completed is not None and (
min_additional_completed is not None or max_additional_completed is not None
):
raise ControllerError("exact additional completed reviews cannot be combined with minimum or maximum")
if exact_additional_completed is not None and fresh_taper:
raise ControllerError("exact additional completed reviews preserve the existing taper")
exact_replacement = exact_additional_completed is not None
if exact_replacement:
min_additional_completed = exact_additional_completed
max_additional_completed = exact_additional_completed
if min_additional_completed is not None and (
isinstance(min_additional_completed, bool)
or not isinstance(min_additional_completed, int)
Expand Down Expand Up @@ -5706,10 +5723,26 @@ def provable_posted_hosted_request(value: Any) -> bool:
and self._hosted_anchor_matches(value, pr, current)
)

def exact_in_flight_request(value: Any) -> bool:
if not exact_replacement or _field(value, "channel") not in (None, selected.value):
return False
if selected == policy.Channel.HOSTED:
return self._hosted_active_response_overlaps_cli(
value,
pr,
item.head,
current,
require_response_identity=True,
)
return self._active_cli_review_overlaps_hosted(value, pr, current)

def permitted_in_flight_request(value: Any) -> bool:
return exact_in_flight_request(value) if exact_replacement else provable_posted_hosted_request(value)

stop_evidence_checked = False
if (
bounded_replacement
and not any(provable_posted_hosted_request(value) for value in history)
and not any(permitted_in_flight_request(value) for value in history)
and (
prior_taper_complete
or any(
Expand Down Expand Up @@ -5749,7 +5782,7 @@ def provable_posted_hosted_request(value: Any) -> bool:
and target.pr == pr
and target.status == policy.ReviewStatus.JUDGMENT_REQUIRED
):
if not fresh_taper:
if not fresh_taper and not exact_replacement:
raise ControllerError(
"bounded Hosted allocation after a judgment-required taper must explicitly reopen fresh taper"
)
Expand All @@ -5769,12 +5802,12 @@ def provable_posted_hosted_request(value: Any) -> bool:
bounded_replacement
and target.pr == pr
and target.status == policy.ReviewStatus.HELD
and any(provable_posted_hosted_request(value) for value in history)
and any(permitted_in_flight_request(value) for value in history)
):
raise
elif bounded_replacement:
assert previous is not None
if previous.stop_basis is not None:
if previous.stop_basis is not None and not exact_replacement:
raise ControllerError("a stopped allocation cannot be renewed")
if self._head_repository_problem(item):
raise ControllerError(f"PR #{pr} has an unsupported head repository")
Expand All @@ -5798,10 +5831,12 @@ def provable_posted_hosted_request(value: Any) -> bool:
_field(value, flag) is True
for flag in ("held", "unstable", "rate_limited", "unreconciled", "parent_moved", "over_ceiling")
) and _field(value, "head", "reviewed_head") in (None, "", item.head)
if blocked and not provable_posted_hosted_request(value):
if blocked and not permitted_in_flight_request(value):
raise ControllerError("current review evidence is blocked; allocation cannot be promised")
baseline = tuple(
_field(value, "checkpoint", "checkpoint_id") for value in history if _field(value, "correction") is not True
_field(value, "checkpoint", "checkpoint_id")
for value in history
if _field(value, "correction") is not True and not exact_in_flight_request(value)
)
if any(not isinstance(value, str) or not value for value in baseline):
raise ControllerError("existing review evidence lacks a checkpoint identity")
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/pr_review/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,9 @@ def _current_hosted_history(
observation["anchor"] = dict(anchor) if isinstance(anchor, Mapping) else None
observation["trigger_id"] = state.trigger_comment_id
observation["response_id"] = state.response_id
observation["state"] = state.state
observation["attributable"] = state.attributed
observation["terminal"] = state.terminal
if state.state == "ambiguous" and not operational_only:
terminal_observation = self._terminal_ambiguous_hosted_observation(pr, record, state, payload)
if terminal_observation is not None:
Expand Down
2 changes: 2 additions & 0 deletions dev-tools/pr_review/sqlite_provider_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ def _import_reply_only_hosted_checkpoint(
checkpoint,
state.response_id,
state.duration_seconds,
repo,
pr_number,
captured_head,
record,
hosted_payload,
Expand Down
Loading
Loading