diff --git a/docs/mcp.md b/docs/mcp.md
index 67108165..fc77c023 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -93,6 +93,7 @@ Startup validates configuration without opening the credential or contacting the
| `inbox_events` | Required event cursor; optional limit and wait_ms 0–4000; one bounded incoming-event page. |
| `wait_for_messages` | Required event cursor; optional limit 1–100 and wait_seconds 1–50, default 20/25. One new-message event page or quiet timeout over a call-owned persistent stream. |
| `review_execution_read` | No fields; stored execution configuration and revision, without provider work. |
+| `review_lane_diagnostic` | Required channel; provider-free [per-PR lane diagnostics](review-lane-diagnostics.md) with retained source timestamps/completeness, local holds and exact parent blockers. Not fresh admission or a dispatch promise. |
| `review_scheduling_read` | No fields; stored project scheduling settings, revision and paused queued PRs, without provider work. |
| `review_scheduling_configure` | Required idempotency_key/expected_revision/automatic_hosted; optional automatic_cli preserves its existing value when omitted. Project management capability configures [default-off automatic scheduling](review-scheduling.md), including authorization for later provider work within existing review limits. |
| `review_pull_scheduling_read` | Required pull_number; reads the per-PR automatic scheduling pause and revision. |
diff --git a/docs/provider-observations.md b/docs/provider-observations.md
index 7806afb9..2235da79 100644
--- a/docs/provider-observations.md
+++ b/docs/provider-observations.md
@@ -20,6 +20,8 @@ CI reads bind explicit source and selected commit identities, recheck passing ca
CodeRabbit decoding recognizes closed generated envelopes and presentation variants while retaining original bodies and identities. Publication attribution, exact comparison, provider run identity, finished acknowledgment and counted finding inventory remain separate checks. Inline, outside-diff, duplicate and additional findings retain their own source references. Additional-only summaries support at most one bare ` ` as the first visible, nonempty, non-Markdown-quoted line after each `
` inside balanced definition-list wrappers at the same details and HTML blockquote depths, and a standalone heading around exact Review info metadata. Repeated breaks, mid-body breaks and breaks outside the matching definition body remain unsupported; hidden or Markdown-quoted examples cannot supply wrapper boundaries or restart a body. Neither presentation form can hide unknown findings or supply comparison authority by itself. Supported count omission for positive and marked-empty publications follows the [native source contract](review-execution.md#hosted-source-adoption). Malformed or contradictory count metadata remains refused; omission by itself never establishes a clean review. Baseline-qualified historical annotation exclusion retains original comment/review identities, bodies and positions. Positive comparison proof requires an independently bound pre-POST baseline and authenticated current standing metadata; conflicting comparison metadata remains refused. Quoted prompts and examples cannot supply authoritative metadata. An authenticated foreign Bot report whose entire current body contains no case-insensitive `coderabbit` mention is not an inferred request authority merely because it was edited. This current-source policy does not prove its original body or require a pre-trigger copy; bot-looking prose or login names do not replace the source-owned actor kind. Visible competing review commands still close attribution regardless of author. Edited posting-actor, human and other actor-kind comments, and Bot comments with provider mentions even in quoted or hidden text, retain the conservative edit barrier. Baseline-qualified projections and old finding annotation proof preserve their separate source-binding checks without rewriting either capture.
+A markerless submitted review may instead contain exactly one positive, counted Additional comments category followed directly by the existing `h6`-wrapped Review info and generated status footer. The complete provider collections must prove there are no attached inline roots or in-window orphan roots. The original submitted review, unique fresh run, configured provider actor, exact head, explicit full comparison, counted selected-file inventory and unique later finished acknowledgment retain their ordinary checks. Every additional finding must decode completely and name a selected file; category/group counts, source text and its unverified qualification remain intact. Actionable-count declarations, mixed or unknown categories, empty inventories, competing submissions or commands and ambiguous acknowledgments cannot use this path. This parser support preserves positive findings and does not itself finalize adjudication, change round accounting, or grant clean/taper credit. The existing runtime proof pipeline remains responsible for completion.
+
A closed unquoted Follow-up Comments envelope may carry positive outside-diff findings without a count header. Its generated badge, explicit matching title, severity, range, reviewed-head source location and fingerprint must agree. The source location establishes finding coordinates only; it never supplies base or effective-parent proof. Empty, ambiguous or unsupported envelopes remain incomplete.
A generated Review info block can report files whose changes were unavailable. Retain that bounded limitation separately from finding-inventory completeness; a complete captured result does not imply every selected file was reviewed. Original findings and completion accounting remain unchanged.
diff --git a/docs/review-execution.md b/docs/review-execution.md
index 59ffe0bb..960a73e8 100644
--- a/docs/review-execution.md
+++ b/docs/review-execution.md
@@ -122,7 +122,7 @@ The trusted one-pass recovery path reads the original admitted attempt and capab
Hosted preflight must journal its fixed non-review allowance query separately from the eventual review trigger. The preparing attempt binds the original operation, capability, actors and exact source anchor before any query POST. Only the caller that newly creates that intent may make its one post; an existing or uncertain intent requires observation-based recovery and never permits blind reposting. Retain the exact returned or recovered query comment even if preparation later stops. A query grants no review admission or coverage. New query intents recheck current authorization, configuration, policy and source identity; retained query reads and response recording preserve already-issued work. Preparing may perform this journaled non-review metadata query, but may not post a review or spend its allowance before review admission. The query journal, one-pass query observer, immutable availability retention and final hosted guard are implemented components. The concrete hosted driver and configured daemon call them.
-A separate pure allowance-query helper generates the fixed documented `@coderabbitai rate limit` command with an operation/attempt/head marker. Its resolver recognizes the observed availability and cooldown reply grammars in a complete, unambiguous comment window. Availability retains only the original query/response identities and times, without numeric capacity or billing proof. Cooldown retains a conservative retry-not-before time with one reported unit (second or minute) of rounding margin. Neither observation grants review permission or reserves provider quota. Edited competing comments close attribution even when their current bodies removed or hid the command. Unknown replies stay unproven. The pure resolver performs no I/O. A separate one-pass runtime component journals query intent before its one fixed metadata post and recovers an uncertain response without reposting. It saves and reference-checks immutable query source before interpretation. A trusted retention bridge records one proven available observation against the confirmed query and exact source, while preserving the original response time. Final hosted verification combines that record with authorization, policy, reservations, channel-specific target/predecessor evidence and the exact unposted review intent in one SQL snapshot; stale responses cannot become fresh merely because they were fetched again. The concrete driver and daemon compose bounded preflight observation, one-use dispatch and scheduled restart recovery. See CodeRabbit's [review commands](https://docs.coderabbit.ai/reference/review-commands).
+A separate pure allowance-query helper generates the fixed documented `@coderabbitai rate limit` command with an operation/attempt/head marker. Its resolver recognizes the observed availability and cooldown reply grammars in a complete, unambiguous comment window. Availability retains only the original query/response identities and times, without numeric capacity or billing proof. Cooldown retains a conservative retry-not-before time with one reported unit (second or minute) of rounding margin. Neither observation grants review permission or reserves provider quota. Edited competing comments close attribution even when their current bodies removed or hid the command. Unknown replies stay unproven. The pure resolver performs no I/O. A separate one-pass runtime component journals query intent before its one fixed metadata post and recovers an uncertain response without reposting. It saves and reference-checks immutable query source before interpretation. A trusted retention bridge records one proven available observation against the confirmed query and exact source, while preserving the original response time. Final hosted verification combines that record with authorization, policy, reservations, channel-specific target evidence and exact predecessor source identity and the exact unposted review intent in one SQL snapshot; stale responses cannot become fresh merely because they were fetched again. The concrete driver and daemon compose bounded preflight observation, one-use dispatch and scheduled restart recovery. See CodeRabbit's [review commands](https://docs.coderabbit.ai/reference/review-commands).
The operator explicitly selects `commit_status` or `check_run` for hosted progress. Commit statuses require the provider bot's stable numeric identity and the `CodeRabbit` context; check runs require the configured GitHub App ID, exact candidate and `CodeRabbit` check name. The complete selected collection shares a 15-second budget. Validate collection completeness, row identities and duplicates before selection; validate activity timestamps and lifecycle details only for the configured provider signal. Timestamps on another actor’s status or another App’s check cannot establish or block CodeRabbit activity. Selected provider signals retain strict timestamp and lifecycle validation. A trusted pending signal holds dispatch. Complete scoped absence means only that no activity was observed for that candidate; it allows a first review without fabricating a previous status. Unknown states, partial pages and conflicting identities remain unproven. A terminal status, including a successful “review skipped” status, establishes no review coverage. Check-run observation retains any trusted nonterminal run without guessing creation order from IDs or nullable timestamps. These observations do not establish account-wide or other-head idleness. See GitHub's [commit status](https://docs.github.com/en/rest/commits/statuses) and [check-run](https://docs.github.com/en/rest/checks/runs) APIs.
@@ -222,7 +222,7 @@ Trusted initial publication builds a channel-specific native run from the retain
A missing current PR projection leaves successfully retained CLI evidence in the authoritative ledger without changing a completed execution to uncertain or keeping its reservation. It does not recreate browser facts or finalize the source. Other publication failures remain recoverable failures; a failed retention never becomes a completed capture.
-Hosted publication does not confer CLI comparison credit. The shared channel-explicit comparison check keeps current-comparison coverage separate from pending evidence. Each invocation selects `cli` or `hosted`; pending evidence and coverage never cross that channel boundary. Coverage requires a completed native attempt and complete finalized capture for the exact current repository, PR, candidate, base and effective parent, with every finding decided and accepted findings carrying fix proof. Pending completed native evidence is checked across all heads of the selected PR: missing captures, unfinished decisions/finalization and accepted findings without proof block another spend. A ready capture cannot hide another pending capture. The final local action guard repeats this check in its authorization snapshot. Imported history never becomes native execution credit. Repository renames preserve coverage when stable identity and Git objects still match. Hosted captures additionally require their retained command/trigger identity and complete publication metadata; they never fabricate a reviewed-file list. The indexed lookup examines at most 100 completed operations in the selected channel for the selected PR before loading evidence; excess history produces an explicit capacity hold instead of an unbounded scan or another provider spend. This predicate does not establish aggregate policy sufficiency, CI success or merge readiness. The concrete CLI driver supplies fresh source observations, selects only CLI comparison credit for its target and predecessors, and repeats local authorization before its one-use process action. Hosted comparison support alone enables no hosted dispatch.
+Hosted publication does not confer CLI comparison credit. The shared channel-explicit comparison check keeps current-comparison coverage separate from pending evidence. Each invocation selects `cli` or `hosted`; pending evidence and coverage never cross that channel boundary. Coverage requires a completed native attempt and complete finalized capture for the exact current repository, PR, candidate, base and effective parent, with every finding decided and accepted findings carrying fix proof. Pending completed native evidence is checked across all heads of the selected PR: missing captures, unfinished decisions/finalization and accepted findings without proof block another spend. A ready capture cannot hide another pending capture. The final local action guard repeats this check in its authorization snapshot. Imported history never becomes native execution credit. Repository renames preserve coverage when stable identity and Git objects still match. Hosted captures additionally require their retained command/trigger identity and complete publication metadata; they never fabricate a reviewed-file list. The indexed lookup examines at most 100 completed operations in the selected channel for the selected PR before loading evidence; excess history produces an explicit capacity hold instead of an unbounded scan or another provider spend. This predicate does not establish aggregate policy sufficiency, CI success or merge readiness. The concrete CLI driver supplies fresh source observations, checks CLI comparison credit only for its target and verifies predecessor source identities without requiring their review completion, and repeats local authorization before its one-use process action. Hosted comparison support alone enables no hosted dispatch.
New attempts, run evidence, findings, decisions, effective fix proofs and observation freshness are native durable records. Source finalization freezes source counts and identities. Adjudication/fix corrections append guarded evidence; they preserve earlier values and never replace finding text to reuse an old count. Public checkpoint publication is a separate recoverable external action.
diff --git a/docs/review-lane-diagnostics.md b/docs/review-lane-diagnostics.md
new file mode 100644
index 00000000..14c9dd03
--- /dev/null
+++ b/docs/review-lane-diagnostics.md
@@ -0,0 +1,19 @@
+# Review lane diagnostics
+
+The read-only lane diagnostic explains each configured PR's local evidence and dependency state using the latest retained source frame for the selected channel. It never starts or resumes selection, refreshes GitHub, contacts a review provider, changes allowance or adjudicates a result.
+
+Use `fc reviews scheduling diagnostics --channel cli` or `hosted`, MCP `review_lane_diagnostic` with the explicit `channel`, or `GET /api/v1/projects/{project_id}/reviews/lanes/{channel}/diagnostics`. Project read access suffices. The response contains at most the configured 100 PRs in queue order. It returns no provider bodies or credentials.
+
+## Reading the result
+
+The scope is always `retained_source_local_policy`. `evaluated_at` is the time of this local read; `source_checked_at`, each candidate's `source_observed_at`, and `source_configuration_revision` describe retained acquisition, not a fresh provider check. `source_complete` means that acquisition covered the configured queue with no global source error. It does not establish current GitHub heads or dispatch eligibility. Unknown suffixes remain `unknown` with `source_not_observed`; a changed configuration or repository invalidates the frame for all current candidates. Missing or damaged evidence never becomes an empty healthy lane.
+
+Each observed candidate has `local_state` and `local_reason`. `locally_ready` means only that the shared local evaluator found no evidence, source-obligation, route, PR-pause, round or actual-parent hold in that retained comparison. It is not a preview of the next automatic selection. Provider limits, active operations, automatic-intent suppression, authorization, current source and transactional admission still apply. `lane_reason` separately reports a configured project/channel pause, disabled channel or global storage/identity hold.
+
+A `predecessor_unfinished` row identifies `blocking_pull_number` and the concrete source-identity `blocking_reason`, such as a missing, moved, cyclic or unavailable parent. Ancestor findings, review rounds and PR pauses do not hold a child's review. The diagnostic shares the ordinary selector's source-chain checks and target-local obligation checks; it does not grant dispatch or merge permission. A local hold on the candidate itself remains its primary reason.
+
+For a lane audit, combine this diagnostic with current operation/scheduling/round reads and current published source observations. Do not use `locally_ready` to force a review or declare a lane healthy. A stale or incomplete frame means eligibility remains unestablished and calls for an authorized ordinary source/selection workflow, not a new review merely to obtain diagnostics.
+
+## Validation boundary
+
+Focused synthetic tests cover retained pending evidence, independent and stacked review progression, actual-parent source holds with exact blocker identity, incomplete/missing/configuration-changed/repository-changed source, malformed retained frames, revoked read access, strict bound client responses, read-only MCP discovery, CLI parsing and unchanged durable selection state. A 100-row shared completed-ancestor case passes the bounded read deadline normally and under the race detector. Each candidate's local facts stay within the current read transaction; ancestor traversal reads source identity rather than ancestor review sufficiency. Local proof does not establish deployed service support, current live admission or provider throughput.
diff --git a/docs/review-round-controls.md b/docs/review-round-controls.md
index f58246df..8864e18b 100644
--- a/docs/review-round-controls.md
+++ b/docs/review-round-controls.md
@@ -14,7 +14,7 @@ Carried operational adoption is supported through independently guarded preview/
## Operational controls
-Hosted and CLI retain independent per-PR channel state. Each explicit start selects at most one eligible target in queue priority order, preserving actual-parent dependencies. A cooldown or active review in one channel does not hold the other channel. Automatic scheduling remains a separate consumer. Minimum and maximum count additional completed rounds. Equal values express an exact count; the CLI's `--exact` is only shorthand for those equal bounds. A maximum permits early taper once the minimum is satisfied.
+Hosted and CLI retain independent per-PR channel state. Each explicit start selects at most one eligible target in queue priority order, preserving actual-parent source identity without requiring ancestor review completion. A cooldown or active review in one channel does not hold the other channel. Automatic scheduling remains a separate consumer. Minimum and maximum count additional completed rounds. Equal values express an exact count; the CLI's `--exact` is only shorthand for those equal bounds. A maximum permits early taper once the minimum is satisfied.
New execution enrollment atomically initializes missing PR/channel controls using the selected [project defaults](#project-defaults): explicit policy `round_defaults` take precedence over product bounds, and new controls use taper two. A re-added pair with any retained native review operation is excluded from this initialization, so an older unconfigured pair remains unconfigured. Reordering, pausing or changing capability leaves existing enrolled pairs untouched. Existing grants and controls, including explicit controls installed before enrollment, are preserved.
@@ -40,7 +40,7 @@ Work accepted while a PR/channel was unconfigured has no round grant binding. Th
The first explicit conversion of a legacy rule reconstructs only its clean streak from immutable, already-counted current-epoch completions. This handles older rules that froze the displayed streak after taper: all-clean results preserve earned progress, and a recorded accepted result resets it. It adds no completion credit, changes no original capture/counts and leaves the previous history bytes intact. Backup replay validates the same evidenced transition. Older past epochs and imported history remain historical evidence, not new native completions.
-Per-PR changes use their own revision and actor attribution rather than changing the project policy revision or holding unrelated PRs. Requests retain their original grant binding and recheck the current same-epoch limits, closure and obligations before preparation and provider dispatch. Both source preparation and final transactional admission allow another round after earned PR/channel completion only while the bound grant still requires discovery. They preserve pending-capture/finding obligations, source identity, current authority, provider limits and reservations. For ordinary stacked progression, an explicitly finished grant replaces the predecessor single-capture requirement; outstanding evidence/fix obligations still hold dependent work. Closure or exhausted allowance without validated native completion remains a separate readiness limitation and never manufactures earned credit; later Git movement alone does not create that limitation.
+Per-PR changes use their own revision and actor attribution rather than changing the project policy revision or holding unrelated PRs. Requests retain their original grant binding and recheck the current same-epoch limits, closure and obligations before preparation and provider dispatch. Both source preparation and final transactional admission allow another round after earned PR/channel completion only while the bound grant still requires discovery. They preserve pending-capture/finding obligations, source identity, current authority, provider limits and reservations. For ordinary stacked review progression, each PR's grant and outstanding evidence/fix obligations govern that PR, not its descendants. Ancestor completion is not a review-dispatch prerequisite; the [review progression contract](reviews.md#admission-and-execution) preserves exact source identity and separate merge readiness. Closure or exhausted allowance without validated native completion remains a separate readiness limitation and never manufactures earned credit; later Git movement alone does not create that limitation.
If a queued request’s target no longer matches its original comparison, preparation holds that request rather than rebinding it. Follow the [review-execution](review-execution.md) contract with a qualified current comparison and fresh authorized request/key; preserve retained rounds and known cooldowns instead of resetting grants. The recovery does not itself change configured PR queue order.
@@ -100,7 +100,7 @@ See [refusals and recovery](adoption-obligations.md#refusals-and-recovery) for r
## One explicit channel-front run
-`reviews start --channel cli --key KEY` accepts one durable selection before provider reads and authorizes at most one ordinary exact-head child operation. Hosted uses the same independent contract. The service considers configured queue priority while preserving actual published parent dependencies: a Draft, comparison-local refusal or pending earlier PR evidence does not block independent later work, but cannot be bypassed by its real dependent. These are PR-local holds; a queued, preparing, posting, active or uncertain native operation in the same channel holds new selection with `review_inflight`, even for independent later work. Incoming routes and retained source obligations remain guards even after round completion or captured coverage. Verified external Hosted results still awaiting native reconciliation hold that PR's Hosted channel; imported labels alone are not authority, and old-head obligations survive metadata movement. Fresh verified merged entries can be skipped. Closed, tapered or exhausted grants do not erase unfinished evidence or fix obligations.
+`reviews start --channel cli --key KEY` accepts one durable selection before provider reads and authorizes at most one ordinary exact-head child operation. Hosted uses the same independent contract. The service considers configured queue priority while preserving actual published parent source identity. Pending earlier PR evidence and incomplete ancestor rounds do not block a later child's review. Source refusals such as missing, moved or draft parent comparisons remain explicit holds; they do not become review-completion requirements. These are PR-local holds; a queued, preparing, posting, active or uncertain native operation in the same channel holds new selection with `review_inflight`, even for independent later work. Incoming routes and retained source obligations remain guards even after round completion or captured coverage. Verified external Hosted results still awaiting native reconciliation hold that PR's Hosted channel; imported labels alone are not authority, and old-head obligations survive metadata movement. Fresh verified merged entries can be skipped. Closed, tapered or exhausted grants do not erase unfinished evidence or fix obligations.
Acceptance binds the authenticated actor/worker and current configuration, policy and installed capability. `--expect-pr NUMBER` is an assertion, never forced selection. Optional `--expected-configuration-revision REVISION` asserts acceptance against a known configuration. Both assertions reject explicit null HTTP values. Paused execution returns `reviews_paused`; an unconfigured channel returns `review_not_configured` without storing a request or receipt.
diff --git a/docs/review-scheduling.md b/docs/review-scheduling.md
index 73107020..e986ab93 100644
--- a/docs/review-scheduling.md
+++ b/docs/review-scheduling.md
@@ -6,9 +6,9 @@ Projects can independently opt in to automatic new Hosted or CLI requests. Both
A project manager enables scheduling through CLI or MCP. The separate browser scheduling control is not included in this source slice. Enabling binds authorization to that manager's exact credential and an active project worker. The HTTP contract also permits an authorized browser manager to explicitly select the authorizing worker while retaining the human session identity. The controller rechecks that authorization before selection and dispatch. New selections use the current configured authorizer. An already selected automatic operation retains its original principal, worker and credential when a later manager changes settings. Any later scheduling revision requires complete durable history proving that the intent's own channel stayed enabled in every intervening revision, including when the authorizer is unchanged. Missing history or any disable/re-enable blocks continuation. An unchanged authorizer can finish a queued or selecting intent across a continuously enabled history, including unrelated-channel changes. Across an authorizer change, only an already selected operation can continue, and both authorizers must remain valid. This preserves the existing operation and any quota timer rather than creating a replacement. A blocked queued operation reports `automation_authorization_changed` as a current diagnostic for manager investigation. Revoked credentials, lost management access, retired workers and restored-provider holds cannot authorize new work.
-The scheduler uses the existing configured queue and ordinary durable selection/operation path. It checks eligible work at most once per five-second coordinator interval; this is not a promised start time or another GitHub polling loop. Source, dependency, publication, findings, routes, imported obligations, round limits, taper and provider guards still apply. Independent PRs can proceed while another awaits fixes; real dependencies retain predecessor guards. Retained scheduling, channel-front and source-retry selection validation failures, a retained parent cycle, or a planning basis above its row limit prevent planning only for the affected project and channel. Independent projects and the other channel continue. The execution supervisor skips these typed project-local refusals, and a damaged competing priority candidate cannot block a healthy project’s account claim. A deterministic basis refusal during selection settlement rolls back source and child writes and holds the original selection as `automatic_scheduling_unavailable`; it is not transient contention and does not enter the writer retry loop. The accepted basis remains available for duplicate suppression across ticks and restart. Startup validates the shared front-cache table definition without scanning optional cache rows. Damaged rows remain isolated by project/channel readers; backup and restore still validate the complete retained snapshot. Shared storage and transaction failures remain errors rather than being suppressed; arbitrary SQL failures are not classified as project-local corruption. Automatic requests never inherit out-of-order or file-limit overrides. Each project first plans in a bounded read-only snapshot. Only a candidate for a new intent or a due retained source retry enters the writer, which repeats authorization, configuration, policy, pause, busy and basis checks before ordinary atomic acceptance or retry. A changed plan waits for a later pass.
+The scheduler uses the existing configured queue and ordinary durable selection/operation path. It checks eligible work at most once per five-second coordinator interval; this is not a promised start time or another GitHub polling loop. Exact source identity, target-local publication/findings/routes/imported obligations, round limits, taper and provider guards still apply. Both independent PRs and actual descendants can be reviewed while an earlier PR awaits fixes or more review rounds. This is review progression, not merge permission; the [review contract](reviews.md#admission-and-execution) owns that boundary. Retained scheduling, channel-front and source-retry selection validation failures, a retained parent cycle, or a planning basis above its row limit prevent planning only for the affected project and channel. Independent projects and the other channel continue. The execution supervisor skips these typed project-local refusals, and a damaged competing priority candidate cannot block a healthy project’s account claim. A deterministic basis refusal during selection settlement rolls back source and child writes and holds the original selection as `automatic_scheduling_unavailable`; it is not transient contention and does not enter the writer retry loop. The accepted basis remains available for duplicate suppression across ticks and restart. Startup validates the shared front-cache table definition without scanning optional cache rows. Damaged rows remain isolated by project/channel readers; backup and restore still validate the complete retained snapshot. Shared storage and transaction failures remain errors rather than being suppressed; arbitrary SQL failures are not classified as project-local corruption. Automatic requests never inherit out-of-order or file-limit overrides. Each project first plans in a bounded read-only snapshot. Only a candidate for a new intent or a due retained source retry enters the writer, which repeats authorization, configuration, policy, pause, busy and basis checks before ordinary atomic acceptance or retry. A changed plan waits for a later pass.
-Meaningful source, review or control changes can create another automatic intent. A waiting later PR does not prevent reconsideration of an earlier PR that becomes eligible; the earlier request can take priority while the later request retains its identity and cooldown. Existing queued work on a PR prevents a duplicate intent for that PR, and active provider work is not interrupted. Timer-backed requests retain their original operation and retry deadline. Ticks, restarts, observation timestamps and failed/cancelled operation transitions cannot recreate the same request. A clean CLI completion alone cannot restart a cancelled Hosted request. A dependent PR can become eligible when its actual predecessor completes at the same head. Cancellation stops that intent; use a PR pause to hold new reviews persistently. A setting change affecting only the other channel preserves this channel’s intent basis. Changing this channel’s setting or the authorizing principal, worker or credential changes its basis. Explicitly reasserting unchanged settings rearms only the supplied channels; an omitted CLI setting preserves its basis. The current scheduling event retains each channel’s basis revision independently of the shared authorization revision. Older events use their existing shared revision without rewriting any stored digests, so an upgrade alone cannot recreate cancelled work.
+Meaningful source, review or control changes can create another automatic intent. A waiting later PR does not prevent reconsideration of an earlier PR that becomes eligible; the earlier request can take priority while the later request retains its identity and cooldown. Existing queued work on a PR prevents a duplicate intent for that PR, and active provider work is not interrupted. Timer-backed requests retain their original operation and retry deadline. Ticks, restarts, observation timestamps and failed/cancelled operation transitions cannot recreate the same request. A clean CLI completion alone cannot restart a cancelled Hosted request. An ancestor's review completion is not required for a child's eligibility; exact parent source identities still apply. Cancellation stops that intent; use a PR pause to hold new reviews persistently. A setting change affecting only the other channel preserves this channel’s intent basis. Changing this channel’s setting or the authorizing principal, worker or credential changes its basis. Explicitly reasserting unchanged settings rearms only the supplied channels; an omitted CLI setting preserves its basis. The current scheduling event retains each channel’s basis revision independently of the shared authorization revision. Older events use their existing shared revision without rewriting any stored digests, so an upgrade alone cannot recreate cancelled work.
A pre-child automatic Hosted or CLI selection held only by `source_budget_exhausted`, `source_fetch_timeout` or `source_provider_unavailable` can retry its source selection after at least thirty seconds. It reuses the original selection and accepted configuration, policy, capability and authorizer, with the exact scheduling revision still current. At most two such delayed retries are permitted by a conservative durable transition budget; interrupted-selection recovery consumes that budget rather than resetting it. Existing recovery of an interrupted read remains separate from this bound on completed source holds. Restart and backup restore retain the budget and last-transition time. Restore/provider holds still prevent work.
@@ -20,7 +20,7 @@ Results still require normal adjudication, finalization and fix evidence. Automa
A project manager can explicitly enable `automatic_cli` through CLI, MCP or the project scheduling API. A future browser editor must preserve the CLI setting when editing Hosted configuration. Both settings use the retained manager credential and active worker, with the same authorization rechecks before selection and dispatch. Changing either setting uses the shared scheduling revision. Older Hosted-only writes omit `automatic_cli` and preserve its current value; explicit `false` disables new CLI automation.
-Automatic CLI uses the ordinary durable channel-front selection and execution path, without out-of-order or file-limit overrides. Existing grants, maxima, taper, channel closure, exact current-head checks, source-owned predecessor dependencies, publication and adjudication requirements remain in force. No setting increases grants or adjudicates findings. A meaningful completed result or source/control change can authorize another selection; ticks, restart, failed attempts and cancellation alone cannot. CLI and Hosted results have separate intent digests, so a clean completion in the other channel does not recreate a cancelled request.
+Automatic CLI uses the ordinary durable channel-front selection and execution path, without out-of-order or file-limit overrides. Existing grants, maxima, taper, channel closure, exact current-head checks, source-owned predecessor identities, and the selected target's publication and adjudication requirements remain in force. No setting increases grants or adjudicates findings. A meaningful completed result or source/control change can authorize another selection; ticks, restart, failed attempts and cancellation alone cannot. CLI and Hosted results have separate intent digests, so a clean completion in the other channel does not recreate a cancelled request.
The current server policy fixes one repository preference in code; it is not a per-project setting. For competing CLI work on the same installed provider account, the repository `benhook1013/FireMUD` takes priority over other projects. The repository identity is case-insensitive; a project display name does not grant priority. Selection considers that repository first, and the serialized attempt claim also yields to its eligible queued requests. Paused, invalid, draft-waiting or not-yet-due requests do not reserve the account. Other accounts remain independent and active reviews are never preempted. This preference does not relax dependencies or change retained quota deadlines. It has no fairness or maximum-deferral guarantee: other projects on that account may wait indefinitely while the preferred repository continues to have eligible work.
@@ -42,6 +42,8 @@ The existing queue and PR detail views show current round allowance, closure or
## CLI and MCP
+The provider-free [lane diagnostic](review-lane-diagnostics.md) explains each configured PR against retained source and current local evidence/dependency facts, including exact parent blockers and unknown source suffixes. It does not authorize selection or claim fresh admission.
+
Read the current scheduling revision before changing settings. Keep the exact request and key after an uncertain mutation outcome; replaying the same key cannot enable or pause twice.
```sh
diff --git a/docs/reviews.md b/docs/reviews.md
index e44de898..13552046 100644
--- a/docs/reviews.md
+++ b/docs/reviews.md
@@ -34,7 +34,7 @@ Model attempts as prepared, posting/running, active, completed, failed, cancelle
Hosted review and local CLI execution are separate adapters with independent review cycles and quota observations. A cooldown, exhausted allowance, or active attempt in one channel does not by itself prevent admission in the other. They may review the same immutable target concurrently when each adapter satisfies its own admission checks and neither requires an exclusive shared resource. Candidate or effective-parent movement requires fresh admission facts in either channel; separate cycles do not relax original capture identity or publication safety, and movement does not erase retained PR/channel completion.
-For an ordered stack, select the earliest unfinished eligible target independently within each channel. A channel may advance after its configured sufficiency or stopping policy is met without waiting for the other channel to catch up; an upstream movement then requires reassessing current source and pending obligations. A genuine shared provider-account quota or exclusive executor resource constrains only the actions it covers. Record provider responses and next availability rather than infer one channel's limits from the other.
+For an ordered stack, select the earliest eligible target independently within each channel. An ancestor's unfinished review rounds, pending findings, fix work, routes or adoption obligations do not prevent reviewing a child's exact published diff. Each target retains its own pending-evidence, routed-finding, adoption, pause, grant, taper and stopping guards. The actual parent chain must still establish the same repository, published branches and exact head/base identities; source movement requires fresh admission. Reviewing a child does not complete its ancestors, transfer review credit, resolve findings or establish merge readiness. A genuine shared provider-account quota or exclusive executor resource constrains only the actions it covers. Record provider responses and next availability rather than infer one channel's limits from the other.
A local executor receives an explicit project, allowed workspace, immutable target, operation ID, and policy. The server never adopts a client's current working directory as a global setting. The initial executor runs on the server machine; remote executors are deferred until authentication, leasing, and artifact-transfer contracts are proven.
diff --git a/internal/cli/review_lane_diagnostic_test.go b/internal/cli/review_lane_diagnostic_test.go
new file mode 100644
index 00000000..19448421
--- /dev/null
+++ b/internal/cli/review_lane_diagnostic_test.go
@@ -0,0 +1,25 @@
+package cli
+
+import (
+ "bytes"
+ "strings"
+ "testing"
+)
+
+func TestLaneDiagnosticCLIReadSyntax(t *testing.T) {
+ for _, channel := range []string{"cli", "hosted"} {
+ call, ok := parseInvocation([]string{"reviews", "scheduling", "diagnostics", "--channel", channel})
+ if !ok || call.reviewScheduling == nil || call.reviewScheduling.action != "diagnostics" || call.reviewScheduling.channel != channel {
+ t.Fatal(call, ok)
+ }
+ }
+ for _, args := range [][]string{{}, {"--channel", "manual"}, {"--channel", "cli", "--key", "no"}, {"--channel", "cli", "--channel", "hosted"}, {"--channel", "cli", "--pr", "2"}} {
+ if _, ok := parseReviewScheduling(append([]string{"diagnostics"}, args...)); ok {
+ t.Fatal("invalid read accepted", args)
+ }
+ }
+ var out, diag bytes.Buffer
+ if code := RunContext(t.Context(), []string{"--profiles-file", "/missing", "reviews", "scheduling", "diagnostics", "--help"}, nil, &out, &diag); code != 0 || diag.Len() != 0 || !strings.Contains(out.String(), "not fresh admission") {
+ t.Fatal(code, out.String(), diag.String())
+ }
+}
diff --git a/internal/cli/review_scheduling.go b/internal/cli/review_scheduling.go
index 2f9fa0ac..58636b71 100644
--- a/internal/cli/review_scheduling.go
+++ b/internal/cli/review_scheduling.go
@@ -9,11 +9,12 @@ import (
)
type reviewSchedulingInvocation struct {
- action string
- pull int64
- key string
- config client.ConfigureReviewSchedulingRequest
- pause client.ConfigureReviewPullSchedulingRequest
+ action string
+ channel string
+ pull int64
+ key string
+ config client.ConfigureReviewSchedulingRequest
+ pause client.ConfigureReviewPullSchedulingRequest
}
func parseReviewScheduling(args []string) (*reviewSchedulingInvocation, bool) {
@@ -24,6 +25,8 @@ func parseReviewScheduling(args []string) (*reviewSchedulingInvocation, bool) {
allowed := map[string]bool{"--pr": true}
switch in.action {
case "read":
+ case "diagnostics":
+ allowed = map[string]bool{"--channel": true}
case "configure":
allowed = map[string]bool{"--automatic-hosted": true, "--automatic-cli": true, "--expect-revision": true, "--key": true}
case "pause", "resume":
@@ -62,6 +65,10 @@ func parseReviewScheduling(args []string) (*reviewSchedulingInvocation, bool) {
}
in.pull = n
}
+ if in.action == "diagnostics" {
+ in.channel = values["--channel"]
+ return in, in.channel == "cli" || in.channel == "hosted"
+ }
if in.action == "read" {
return in, true
}
@@ -94,6 +101,8 @@ func parseReviewScheduling(args []string) (*reviewSchedulingInvocation, bool) {
func executeReviewScheduling(ctx context.Context, service *client.Client, in *reviewSchedulingInvocation) (any, error) {
switch in.action {
+ case "diagnostics":
+ return service.ReviewLaneDiagnostic(ctx, in.channel)
case "configure":
return service.ConfigureReviewScheduling(ctx, in.key, in.config)
case "pause", "resume":
diff --git a/internal/cli/review_scheduling_help.go b/internal/cli/review_scheduling_help.go
index 15042837..2b37bc88 100644
--- a/internal/cli/review_scheduling_help.go
+++ b/internal/cli/review_scheduling_help.go
@@ -7,9 +7,15 @@ func operationHelp(operation string) (operationHelpResponse, bool) {
case "reviews scheduling":
out.Usage = " reviews scheduling [--pr N] | configure --automatic-hosted true|false [--automatic-cli true|false] --expect-revision N --key KEY | pause|resume --pr N --expect-revision N --key KEY [--reason TEXT]"
out.Optional = []string{"--pr N (read one PR pause; omission reads project settings and queued paused PRs)", "configure --automatic-hosted true|false (project manager; authorizes future automatic Hosted requests)", "pause|resume --pr N (writer; holds new/undispatched reviews without changing rounds)", "--reason TEXT (optional with pause, at most 256 UTF-8 bytes)"}
- out.Optional = append(out.Optional, "reviews scheduling read --help", "reviews scheduling configure --help", "reviews scheduling pause --help", "reviews scheduling resume --help")
+ out.Optional = append(out.Optional, "reviews scheduling diagnostics --help", "reviews scheduling read --help", "reviews scheduling configure --help", "reviews scheduling pause --help", "reviews scheduling resume --help")
out.Semantics = []string{"Automation defaults off. Enabling requires this connection's active bound worker and current project-management authority; CLI automation is separately opt-in via --automatic-cli; omission preserves its current value. Existing grants and taper remain unchanged.", "Pause can precede any intent. Existing provider review collection continues, and separate operation pauses remain in effect. Read the current revision; mutations require an explicit key and preserve original-key recovery.", "No live provider request is needed to read or change a PR pause. Enabling project automation authorizes later Hosted or CLI selection under all existing comparison, obligation, round and provider guards."}
out.Documentation = "docs/review-scheduling.md"
+ case "reviews scheduling diagnostics":
+ out.Usage = " reviews scheduling diagnostics --channel cli|hosted"
+ out.Required = []string{"--channel cli|hosted"}
+ out.Semantics = []string{"Read retained source time/completeness and current local evidence/dependency state for every configured PR. locally_ready is not fresh admission, automatic eligibility or a dispatch promise. No source/provider refresh, review request or mutation."}
+ out.Example = " reviews scheduling diagnostics --channel cli"
+ out.Documentation = "docs/review-lane-diagnostics.md"
case "reviews scheduling read":
out.Usage = " reviews scheduling read [--pr N]"
out.Optional = []string{"--pr N (read one PR pause; omission reads project settings and queued paused PRs)"}
diff --git a/internal/client/review_lane_diagnostic.go b/internal/client/review_lane_diagnostic.go
new file mode 100644
index 00000000..a0093228
--- /dev/null
+++ b/internal/client/review_lane_diagnostic.go
@@ -0,0 +1,66 @@
+package client
+
+import (
+ "context"
+ "net/http"
+)
+
+type ReviewLaneDiagnostic struct {
+ ProjectID string `json:"project_id"`
+ Channel string `json:"channel"`
+ ConfigurationRevision int64 `json:"configuration_revision"`
+ EvaluatedAt string `json:"evaluated_at"`
+ Scope string `json:"scope"`
+ SourceConfigurationRevision int64 `json:"source_configuration_revision"`
+ SourceCheckedAt string `json:"source_checked_at,omitempty"`
+ SourceComplete bool `json:"source_complete"`
+ SourceReason string `json:"source_reason"`
+ LaneReason string `json:"lane_reason"`
+ Candidates []ReviewLaneCandidateDiagnostic `json:"candidates"`
+}
+
+type ReviewLaneCandidateDiagnostic struct {
+ PullNumber int64 `json:"pull_number"`
+ HeadSHA string `json:"head_sha,omitempty"`
+ SourceObservedAt string `json:"source_observed_at,omitempty"`
+ ParentPullNumber int64 `json:"parent_pull_number"`
+ LocalState string `json:"local_state"`
+ LocalReason string `json:"local_reason"`
+ BlockingPullNumber int64 `json:"blocking_pull_number"`
+ BlockingReason string `json:"blocking_reason"`
+}
+
+func (c *Client) ReviewLaneDiagnostic(ctx context.Context, channel string) (ReviewLaneDiagnostic, error) {
+ if !oneReviewOf(channel, "cli", "hosted") {
+ return ReviewLaneDiagnostic{}, validation()
+ }
+ var out ReviewLaneDiagnostic
+ if err := c.requestBounded(ctx, http.MethodGet, c.projectPath("reviews", "lanes", channel, "diagnostics"), nil, true, "", nil, http.StatusOK, false, &out, 128<<10, decodeReviewResponse); err != nil {
+ return ReviewLaneDiagnostic{}, err
+ }
+ if out.ProjectID != c.identity.ProjectID || out.Channel != channel || out.Scope != "retained_source_local_policy" || out.ConfigurationRevision < 1 || !controlTime(out.EvaluatedAt) || out.SourceConfigurationRevision < 0 || out.Candidates == nil || len(out.Candidates) > 100 || out.SourceReason != "" && !safeCode(out.SourceReason) || out.LaneReason != "" && !safeCode(out.LaneReason) {
+ return ReviewLaneDiagnostic{}, invalidResponse()
+ }
+ if out.SourceConfigurationRevision == 0 {
+ if out.SourceCheckedAt != "" || out.SourceComplete || out.SourceReason != "source_unavailable" {
+ return ReviewLaneDiagnostic{}, invalidResponse()
+ }
+ } else if !controlTime(out.SourceCheckedAt) || out.SourceComplete && (out.SourceConfigurationRevision != out.ConfigurationRevision || out.SourceReason != "") {
+ return ReviewLaneDiagnostic{}, invalidResponse()
+ }
+ usableSource := out.SourceConfigurationRevision > 0 && out.SourceConfigurationRevision == out.ConfigurationRevision && out.SourceReason != "repository_changed" && out.SourceReason != "configuration_changed"
+ seen := map[int64]bool{}
+ for _, p := range out.Candidates {
+ if !validPullNumber(p.PullNumber) || seen[p.PullNumber] || !oneReviewOf(p.LocalState, "unknown", "held", "complete", "locally_ready") || p.LocalReason != "" && !safeCode(p.LocalReason) || p.BlockingReason != "" && !safeCode(p.BlockingReason) || p.ParentPullNumber != 0 && (!validPullNumber(p.ParentPullNumber) || p.ParentPullNumber == p.PullNumber) || p.BlockingPullNumber != 0 && !validPullNumber(p.BlockingPullNumber) {
+ return ReviewLaneDiagnostic{}, invalidResponse()
+ }
+ seen[p.PullNumber] = true
+ if !usableSource && p.HeadSHA != "" || out.SourceComplete && p.HeadSHA == "" || p.LocalState == "unknown" && p.LocalReason == "" || p.LocalState == "complete" && p.LocalReason != "" {
+ return ReviewLaneDiagnostic{}, invalidResponse()
+ }
+ if (p.HeadSHA == "") != (p.SourceObservedAt == "") || p.HeadSHA != "" && (!controlHex(p.HeadSHA, 40) || !controlTime(p.SourceObservedAt)) || p.HeadSHA == "" && (p.LocalState != "unknown" || p.ParentPullNumber != 0) || p.LocalState == "held" && p.LocalReason == "" || p.LocalState == "locally_ready" && p.LocalReason != "" || (p.BlockingPullNumber == 0) != (p.BlockingReason == "") || p.BlockingPullNumber != 0 && (p.LocalState != "held" || p.LocalReason != "predecessor_unfinished") {
+ return ReviewLaneDiagnostic{}, invalidResponse()
+ }
+ }
+ return out, nil
+}
diff --git a/internal/client/review_lane_diagnostic_test.go b/internal/client/review_lane_diagnostic_test.go
new file mode 100644
index 00000000..1eb10f4d
--- /dev/null
+++ b/internal/client/review_lane_diagnostic_test.go
@@ -0,0 +1,71 @@
+package client_test
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+
+ "github.com/benhook1013/FireController/internal/client"
+)
+
+func sampleLaneDiagnostic() client.ReviewLaneDiagnostic {
+ return client.ReviewLaneDiagnostic{ProjectID: "project-one", Channel: "cli", ConfigurationRevision: 1, EvaluatedAt: "2026-11-10T21:00:00Z", Scope: "retained_source_local_policy", SourceConfigurationRevision: 1, SourceCheckedAt: "2026-11-10T20:59:00Z", SourceComplete: true, Candidates: []client.ReviewLaneCandidateDiagnostic{{PullNumber: 2, HeadSHA: strings.Repeat("a", 40), SourceObservedAt: "2026-11-10T20:58:00Z", LocalState: "held", LocalReason: "review_evidence_pending"}, {PullNumber: 4, HeadSHA: strings.Repeat("b", 40), SourceObservedAt: "2026-11-10T20:58:00Z", ParentPullNumber: 2, LocalState: "held", LocalReason: "predecessor_unfinished", BlockingPullNumber: 2, BlockingReason: "review_evidence_pending"}}}
+}
+func TestReviewLaneDiagnosticBoundReadAndStrictResponses(t *testing.T) {
+ cases := map[string]func(*client.ReviewLaneDiagnostic){
+ "valid": func(*client.ReviewLaneDiagnostic) {},
+ "project": func(v *client.ReviewLaneDiagnostic) { v.ProjectID = "foreign" },
+ "channel": func(v *client.ReviewLaneDiagnostic) { v.Channel = "hosted" },
+ "duplicate": func(v *client.ReviewLaneDiagnostic) { v.Candidates[1].PullNumber = 2 },
+ "false-freshness": func(v *client.ReviewLaneDiagnostic) { v.SourceConfigurationRevision = 2 },
+ "changed-source-ready": func(v *client.ReviewLaneDiagnostic) {
+ v.SourceConfigurationRevision = 2
+ v.SourceComplete = false
+ v.SourceReason = "configuration_changed"
+ },
+ "no-source-ready": func(v *client.ReviewLaneDiagnostic) {
+ v.Candidates[0].HeadSHA = ""
+ v.Candidates[0].SourceObservedAt = ""
+ v.Candidates[0].LocalState = "locally_ready"
+ v.Candidates[0].LocalReason = ""
+ },
+ "missing-blocker": func(v *client.ReviewLaneDiagnostic) { v.Candidates[1].BlockingPullNumber = 0 },
+ "bad-time": func(v *client.ReviewLaneDiagnostic) { v.SourceCheckedAt = "yesterday" },
+ "null-candidates": func(v *client.ReviewLaneDiagnostic) { v.Candidates = nil },
+ }
+ for name, edit := range cases {
+ t.Run(name, func(t *testing.T) {
+ value := sampleLaneDiagnostic()
+ edit(&value)
+ calls := 0
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if strings.HasSuffix(r.URL.Path, "/instance") {
+ handshake(w)
+ return
+ }
+ calls++
+ if r.Method != "GET" || r.URL.Path != "/api/v1/projects/project-one/reviews/lanes/cli/diagnostics" || r.URL.RawQuery != "" || r.Header.Get("Idempotency-Key") != "" {
+ t.Error("diagnostic changed method or binding")
+ }
+ write(w, 200, value)
+ }))
+ defer srv.Close()
+ c := newClient(t, srv)
+ got, err := c.ReviewLaneDiagnostic(t.Context(), "cli")
+ if calls != 1 {
+ t.Fatal("unexpected fanout", calls)
+ }
+ if name == "valid" {
+ if err != nil || got.Candidates[1].BlockingPullNumber != 2 {
+ t.Fatal(got, err)
+ }
+ } else {
+ checkError(t, err, "invalid_response")
+ }
+ if _, err = c.ReviewLaneDiagnostic(t.Context(), "manual"); err == nil || calls != 1 {
+ t.Fatal("invalid channel contacted service")
+ }
+ })
+ }
+}
diff --git a/internal/mcpadapter/adapter_test.go b/internal/mcpadapter/adapter_test.go
index 3b03299a..c7cb745a 100644
--- a/internal/mcpadapter/adapter_test.go
+++ b/internal/mcpadapter/adapter_test.go
@@ -243,6 +243,7 @@ func TestDiscoveryAndLocalContextAcrossSDKProtocolVersions(t *testing.T) {
expected["review_queue_edit"] = true
expected["review_operation_control"] = true
expected["review_scheduling_read"], expected["review_scheduling_configure"] = true, true
+ expected["review_lane_diagnostic"] = true
expected["review_pull_scheduling_read"], expected["review_pull_scheduling_update"] = true, true
expected["wait_for_ci"] = true
expected["review_rounds_read"], expected["review_rounds_configure"] = true, true
diff --git a/internal/mcpadapter/review_lane_diagnostic_test.go b/internal/mcpadapter/review_lane_diagnostic_test.go
new file mode 100644
index 00000000..2705c563
--- /dev/null
+++ b/internal/mcpadapter/review_lane_diagnostic_test.go
@@ -0,0 +1,47 @@
+package mcpadapter_test
+
+import (
+ "encoding/json"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/benhook1013/FireController/internal/client"
+)
+
+func TestLaneDiagnosticSDKReadOnlyNoProviderWork(t *testing.T) {
+ f, handler, _ := reviewControlsFixture(t)
+ server := httptest.NewServer(handler)
+ defer server.Close()
+ session := reviewControlsStdio(t, reviewControlsProfile(t, f, server.URL), "chosen")
+ listed, err := allDiscoveredTools(t, session)
+ if err != nil {
+ t.Fatal(err)
+ }
+ found := false
+ for _, tool := range listed.Tools {
+ if tool.Name == "review_lane_diagnostic" {
+ found = true
+ a := tool.Annotations
+ if a == nil || !a.ReadOnlyHint || !a.IdempotentHint || a.DestructiveHint == nil || *a.DestructiveHint || a.OpenWorldHint == nil || *a.OpenWorldHint {
+ t.Fatal("incorrect read effects")
+ }
+ }
+ }
+ if !found {
+ t.Fatal("missing diagnostic tool")
+ }
+ before := f.providers.Load()
+ for _, channel := range []string{"cli", "hosted"} {
+ var out client.ReviewLaneDiagnostic
+ decodeResult(t, call(t, session, "review_lane_diagnostic", map[string]any{"channel": channel}), &out)
+ if out.Channel != channel || out.Scope != "retained_source_local_policy" || out.SourceComplete || out.SourceReason != "source_unavailable" {
+ t.Fatal(out)
+ }
+ }
+ for _, raw := range []string{`{}`, `null`, `{"channel":"manual"}`, `{"channel":"cli","refresh":true}`, `{"channel":"cli","channel":"hosted"}`, `{"channel":"cli","project_id":"foreign"}`} {
+ diagnosticResult(t, call(t, session, "review_lane_diagnostic", json.RawMessage(raw)), "invalid_arguments", false)
+ }
+ if f.providers.Load() != before {
+ t.Fatal("diagnostic contacted provider")
+ }
+}
diff --git a/internal/mcpadapter/review_scheduling.go b/internal/mcpadapter/review_scheduling.go
index 91d984b5..5d8c64d2 100644
--- a/internal/mcpadapter/review_scheduling.go
+++ b/internal/mcpadapter/review_scheduling.go
@@ -14,7 +14,7 @@ func reviewSchedulingWrite(name string) bool {
}
func reviewSchedulingTool(name string) bool {
- return reviewSchedulingWrite(name) || name == "review_scheduling_read" || name == "review_pull_scheduling_read"
+ return name == "review_lane_diagnostic" || reviewSchedulingWrite(name) || name == "review_scheduling_read" || name == "review_pull_scheduling_read"
}
func reviewSchedulingArguments(name string, raw json.RawMessage) (arguments, error) {
@@ -26,6 +26,16 @@ func reviewSchedulingArguments(name string, raw json.RawMessage) (arguments, err
if len(raw) > 4096 || len(trimmed) < 2 || trimmed[0] != '{' || trimmed[len(trimmed)-1] != '}' {
return args, invalidArguments()
}
+ if name == "review_lane_diagnostic" {
+ var wire struct {
+ Channel string `json:"channel"`
+ }
+ if strictjson.Decode(raw, &wire) != nil || (wire.Channel != "cli" && wire.Channel != "hosted") {
+ return args, invalidArguments()
+ }
+ args.roundChannel = wire.Channel
+ return args, nil
+ }
if name == "review_scheduling_read" {
var empty struct{}
if strictjson.Decode(raw, &empty) != nil {
@@ -100,6 +110,7 @@ func reviewSchedulingDefinitions() []definition {
pull := map[string]any{"type": "integer", "minimum": 1, "maximum": 2147483647}
key := map[string]any{"type": "string", "minLength": 1, "maxLength": 128, "description": "Explicit original idempotency key; retain with the exact request after unknown outcome."}
return []definition{
+ {"review_lane_diagnostic", "Read every configured PR in one channel against retained source facts and current local evidence/dependency policy. Includes source time/completeness and exact blocking parent. Provider-free and read-only; locally_ready is NOT fresh admission, automatic eligibility or a promise of dispatch. No new selection, retry, provider call, cap or control change.", object(map[string]any{"channel": map[string]any{"type": "string", "enum": []string{"cli", "hosted"}}}, "channel")},
{"review_scheduling_read", "Read this project's automatic Hosted and CLI settings and current queued PR pauses in one provider-free call. No settings, review or allowance changes. See docs/review-scheduling.md.", object(map[string]any{})},
{"review_scheduling_configure", "Project manager: explicitly enable or disable automatic future Hosted or CLI requests under existing source, obligation, round and provider guards. Both default off. Optional automatic_cli preserves the current CLI setting when omitted. Existing grants and taper apply; no automatic adjudication or grant increase. Enabling retains this connection's current credential and active bound worker; withdrawn authority stops new automatic actions. This setting can authorize asynchronous provider work. Current revision and explicit key required; no automatic mutation retry. See docs/review-scheduling.md.", object(map[string]any{"expected_revision": revision, "automatic_hosted": map[string]any{"type": "boolean"}, "automatic_cli": map[string]any{"type": "boolean", "description": "Optional CLI opt-in; omission preserves the current setting."}, "idempotency_key": key}, "expected_revision", "automatic_hosted", "idempotency_key")},
{"review_pull_scheduling_read", "Read one PR's temporary scheduling pause before or after an intent exists. Does not change Draft, grant, taper, closure or active provider work.", object(map[string]any{"pull_number": pull}, "pull_number")},
diff --git a/internal/mcpadapter/tools.go b/internal/mcpadapter/tools.go
index 5d50dc1d..6ab6483f 100644
--- a/internal/mcpadapter/tools.go
+++ b/internal/mcpadapter/tools.go
@@ -207,6 +207,8 @@ func boundServer(binding profile.Binding) *mcp.Server {
value, err = service.ReviewExecution(ctx)
case "review_operations_list":
value, err = service.ReviewOperations(ctx, args.reviewOperations)
+ case "review_lane_diagnostic":
+ value, err = service.ReviewLaneDiagnostic(ctx, args.roundChannel)
case "review_scheduling_read":
value, err = service.ReviewScheduling(ctx)
case "review_scheduling_configure":
diff --git a/internal/reviewexec/adoption_holds_integration_test.go b/internal/reviewexec/adoption_holds_integration_test.go
index 8fb78962..b2ad1d56 100644
--- a/internal/reviewexec/adoption_holds_integration_test.go
+++ b/internal/reviewexec/adoption_holds_integration_test.go
@@ -235,7 +235,7 @@ func integrationSelectionWorker(t *testing.T, f *attemptFixture) {
}
}
-func TestAdoptionHoldsIntegrationFinalPredecessorRecheck(t *testing.T) {
+func TestAdoptionHoldsIntegrationAncestorObligationsStayLocal(t *testing.T) {
for _, mode := range []string{"covered", "closed", "tapered", "merged"} {
t.Run(mode, func(t *testing.T) {
f, prior, id, predecessor := coverageFixture(t, 0, false)
@@ -289,7 +289,11 @@ func TestAdoptionHoldsIntegrationFinalPredecessorRecheck(t *testing.T) {
_, err := f.e.Enqueue(t.Context(), f.scope(t, attemptProject, f.writer, false), "merged-source-still-held", Request{ExpectedConfigurationRevision: 2, PullNumber: 2, Channel: "cli", HeadSHA: strings.Repeat("a", 40)})
integrationSourceHeld(t, err)
} else {
- integrationSourceHeld(t, f.e.VerifyAction(t.Context(), attemptProject, child.ID, child.Revision, predecessors...))
+ if err := f.e.VerifyAction(t.Context(), attemptProject, child.ID, child.Revision, predecessors...); err != nil {
+ t.Fatal("ancestor adoption work blocked child review", err)
+ }
+ _, err := f.e.Enqueue(t.Context(), f.scope(t, attemptProject, f.writer, false), "ancestor-target-still-held", Request{ExpectedConfigurationRevision: 2, PullNumber: 2, Channel: "cli", HeadSHA: strings.Repeat("a", 40)})
+ integrationSourceHeld(t, err)
}
if after := integrationHoldDetail(t, f, hold.ID); !reflect.DeepEqual(beforeHold, after) || after.Status != "open" {
t.Fatal("final guard changed the retained source hold", beforeHold, after)
@@ -600,9 +604,11 @@ func TestAdoptionHoldsIntegrationSelectionRechecksActualParent(t *testing.T) {
t.Fatal(worked, err)
}
got := selectionRead(t, f, r.ID)
- if !imported || got.State != "held" || got.Reason != "source_obligations_pending" || got.OperationID != "" || attemptCount(t, f.store, `SELECT count(*) FROM review_operations`) != 0 {
- t.Fatal("late actual-parent hold escaped transactional child admission", got)
+ if !imported || got.State != "selected" || got.OperationID == "" || roundOperation(t, f, got.OperationID).PullNumber != 4 || attemptCount(t, f.store, `SELECT count(*) FROM review_operations`) != 1 {
+ t.Fatal("ancestor adoption work blocked exact child selection", got)
}
+ _, err := f.e.Enqueue(t.Context(), f.scope(t, attemptProject, f.writer, false), "late-ancestor-target-still-held", Request{ExpectedConfigurationRevision: 2, PullNumber: 2, Channel: "cli", HeadSHA: strings.Repeat("a", 40)})
+ integrationSourceHeld(t, err)
}
func TestAdoptionHoldsIntegrationSupervisorSettlesRepositoryChangeDuringPrepare(t *testing.T) {
diff --git a/internal/reviewexec/front_evaluator.go b/internal/reviewexec/front_evaluator.go
index 9a04970a..4ae28fd9 100644
--- a/internal/reviewexec/front_evaluator.go
+++ b/internal/reviewexec/front_evaluator.go
@@ -10,8 +10,10 @@ import (
// evaluatedFront is shared with admission. A diagnostic hold retains the actual
// blocking predecessor, whereas the legacy adapter intentionally returns zero.
type evaluatedFront struct {
- state, reason string
- plan *SourcePlan
+ state, reason string
+ plan *SourcePlan
+ blockingPull int64
+ blockingReason string
}
func (e *Engine) evaluateFrontPlan(ctx context.Context, q *sql.Tx, r Run, repo int64, plan *SourcePlan) (evaluatedFront, error) {
@@ -93,6 +95,47 @@ func (e *Engine) evaluateFrontPlan(ctx context.Context, q *sql.Tx, r Run, repo i
return evaluatedFront{state: "ready", plan: plan}, nil
}
+// evaluateCandidatePlan shares source-identity checks with lane diagnostics.
+// Ancestor review sufficiency is not permission to review a child's pinned diff.
+func (e *Engine) evaluateCandidatePlan(ctx context.Context, q *sql.Tx, r Run, repo int64, plan *SourcePlan, byNumber map[int64]*SourcePlan) (evaluatedFront, error) {
+ return evaluateCandidateLocalState(plan, byNumber, func(p *SourcePlan) (evaluatedFront, error) { return e.evaluateFrontPlan(ctx, q, r, repo, p) })
+}
+
+func evaluateCandidateLocalState(plan *SourcePlan, byNumber map[int64]*SourcePlan, evaluate func(*SourcePlan) (evaluatedFront, error)) (evaluatedFront, error) {
+ result, err := evaluate(plan)
+ if err != nil || result.state != "ready" {
+ return result, err
+ }
+ seen := map[int64]bool{plan.Pull.Number: true}
+ parentNumber, parentSHA := plan.ParentPullNumber, plan.ParentSHA
+ for parentNumber != 0 {
+ parent := byNumber[parentNumber]
+ reason := ""
+ switch {
+ case seen[parentNumber]:
+ reason = "parent_cycle"
+ case parent == nil:
+ reason = "parent_source_unavailable"
+ case parent.Pull.HeadSHA != parentSHA:
+ reason = "parent_moved"
+ case parent.Repository.ID != plan.Repository.ID || !sameTarget(parent.Pull, plan.Repository.ID, parentNumber):
+ reason = "parent_identity_changed"
+ case parent.SourceReason != "":
+ reason = parent.SourceReason
+ case parent.Pull.State != "open" || parent.Pull.Merged:
+ reason = "parent_unavailable"
+ }
+ if reason != "" {
+ return evaluatedFront{state: "held", reason: "predecessor_unfinished", plan: plan, blockingPull: parentNumber, blockingReason: reason}, nil
+ }
+ seen[parentNumber] = true
+ // The parent supplies source identity, not review completion or allowance.
+ // Its findings, rounds and PR pause remain obligations on that parent.
+ parentNumber, parentSHA = parent.ParentPullNumber, parent.ParentSHA
+ }
+ return result, nil
+}
+
func (e *Engine) evaluateFront(ctx context.Context, q *sql.Tx, r Run, repo int64, prefix []SourcePlan, complete bool) (evaluatedFront, error) {
byNumber := map[int64]*SourcePlan{}
for i := range prefix {
@@ -101,7 +144,7 @@ func (e *Engine) evaluateFront(ctx context.Context, q *sql.Tx, r Run, repo int64
var firstHeld *evaluatedFront
for i := range prefix {
plan := &prefix[i]
- result, err := e.evaluateFrontPlan(ctx, q, r, repo, plan)
+ result, err := e.evaluateCandidatePlan(ctx, q, r, repo, plan, byNumber)
if err != nil {
return evaluatedFront{}, err
}
@@ -111,27 +154,6 @@ func (e *Engine) evaluateFront(ctx context.Context, q *sql.Tx, r Run, repo int64
if result.state == "complete" {
continue
}
- if result.state == "ready" {
- seen := map[int64]bool{plan.Pull.Number: true}
- parentNumber, parentSHA := plan.ParentPullNumber, plan.ParentSHA
- for parentNumber != 0 {
- parent := byNumber[parentNumber]
- if seen[parentNumber] || parent == nil || parent.Pull.HeadSHA != parentSHA {
- result = evaluatedFront{state: "held", reason: "predecessor_unfinished", plan: plan}
- break
- }
- seen[parentNumber] = true
- parentState, err := e.evaluateFrontPlan(ctx, q, r, repo, parent)
- if err != nil {
- return evaluatedFront{}, err
- }
- if parentState.state != "complete" {
- result = evaluatedFront{state: "held", reason: "predecessor_unfinished", plan: plan}
- break
- }
- parentNumber, parentSHA = parent.ParentPullNumber, parent.ParentSHA
- }
- }
if result.state == "ready" {
return result, nil
}
diff --git a/internal/reviewexec/hosted_admission_test.go b/internal/reviewexec/hosted_admission_test.go
index dafb3aa9..17cef490 100644
--- a/internal/reviewexec/hosted_admission_test.go
+++ b/internal/reviewexec/hosted_admission_test.go
@@ -150,13 +150,13 @@ func hostedAdmissionStack(t *testing.T, f *attemptFixture, open SourcePlan) (Att
return child, []SourcePlan{open}
}
-func TestHostedAdmissionStackRequiresHostedPredecessor(t *testing.T) {
+func TestHostedAdmissionStackDoesNotRequireAncestorReviewCoverage(t *testing.T) {
hostedAdmissionNoHTTP(t)
f, prior, id, open := coverageFixture(t, 0, false)
coverageFinalize(t, f, prior, id, 0)
child, plans := hostedAdmissionStack(t, f, open)
- // A complete native CLI predecessor cannot advance the hosted cycle.
- hostedAdmissionVerify(t, f, child, "review_held", "predecessor_unfinished", plans...)
+ // The ancestor needs no Hosted completion to review the child's exact diff.
+ hostedAdmissionVerify(t, f, child, "", "", plans...)
}
func TestHostedAdmissionStackChecksAllFreshPlansAndLateFixCorrection(t *testing.T) {
@@ -191,7 +191,7 @@ func TestHostedAdmissionStackChecksAllFreshPlansAndLateFixCorrection(t *testing.
moved[0].Pull.HeadSHA = strings.Repeat("9", 40)
hostedAdmissionVerify(t, f, child, "validation_failed", "", moved...)
adjudicationDecide(t, f, id, "hosted-stack-correct", 4, 0, "accepted")
- hostedAdmissionVerify(t, f, child, "review_held", "predecessor_unfinished", plans...)
+ hostedAdmissionVerify(t, f, child, "", "", plans...)
coverageFix(t, f, id, "hosted-stack-fix", 5, 0, "")
hostedAdmissionVerify(t, f, child, "", "", plans...)
admissionPolicy(t, f, 1, "hosted")
diff --git a/internal/reviewexec/lane_diagnostic.go b/internal/reviewexec/lane_diagnostic.go
new file mode 100644
index 00000000..3d723a75
--- /dev/null
+++ b/internal/reviewexec/lane_diagnostic.go
@@ -0,0 +1,133 @@
+package reviewexec
+
+import (
+ "context"
+ "database/sql"
+ "slices"
+
+ "github.com/benhook1013/FireController/internal/core"
+)
+
+// LaneDiagnostic reports local policy against explicitly retained source facts.
+// It is not an admission preview: source freshness, automatic-intent ownership,
+// provider capacity and dispatch authorization still require normal selection.
+type LaneDiagnostic struct {
+ ProjectID string `json:"project_id"`
+ Channel string `json:"channel"`
+ ConfigurationRevision int64 `json:"configuration_revision"`
+ EvaluatedAt string `json:"evaluated_at"`
+ Scope string `json:"scope"`
+ SourceConfigurationRevision int64 `json:"source_configuration_revision"`
+ SourceCheckedAt string `json:"source_checked_at,omitempty"`
+ SourceComplete bool `json:"source_complete"`
+ SourceReason string `json:"source_reason"`
+ LaneReason string `json:"lane_reason"`
+ Candidates []LaneCandidateDiagnostic `json:"candidates"`
+}
+
+type LaneCandidateDiagnostic struct {
+ PullNumber int64 `json:"pull_number"`
+ HeadSHA string `json:"head_sha,omitempty"`
+ SourceObservedAt string `json:"source_observed_at,omitempty"`
+ ParentPullNumber int64 `json:"parent_pull_number"`
+ LocalState string `json:"local_state"`
+ LocalReason string `json:"local_reason"`
+ BlockingPullNumber int64 `json:"blocking_pull_number"`
+ BlockingReason string `json:"blocking_reason"`
+}
+
+func (e *Engine) ReadLaneDiagnostic(ctx context.Context, scope core.Scope, channel string) (LaneDiagnostic, error) {
+ if !validChannel(channel) {
+ return LaneDiagnostic{}, invalid()
+ }
+ out := LaneDiagnostic{ProjectID: scope.ProjectID, Channel: channel, Scope: "retained_source_local_policy", Candidates: []LaneCandidateDiagnostic{}}
+ err := e.store.Read(ctx, scope, func(ctx context.Context, tx *sql.Tx) error {
+ c, revision, err := readConfiguration(ctx, tx, scope.ProjectID)
+ if err != nil {
+ return err
+ }
+ out.ConfigurationRevision, out.EvaluatedAt = revision, stamp()
+ if c.Paused {
+ out.LaneReason = "reviews_paused"
+ } else if !slices.Contains(c.Channels, channel) {
+ out.LaneReason = "review_not_configured"
+ }
+ policy, err := readPolicy(ctx, tx, scope.ProjectID)
+ if err != nil {
+ return err
+ }
+ if slices.Contains(policy.Policy.PausedChannels, channel) {
+ out.LaneReason = "reviews_paused"
+ }
+ frame, found, err := readFrontFrame(ctx, tx, scope.ProjectID, channel)
+ if err != nil {
+ return err
+ }
+ var repository int64
+ if err = tx.QueryRowContext(ctx, `SELECT github_repository_id FROM projects WHERE id=?`, scope.ProjectID).Scan(&repository); err != nil {
+ return err
+ }
+ out.SourceReason = "source_unavailable"
+ if found {
+ out.SourceConfigurationRevision, out.SourceCheckedAt = frame.configuration, frame.checkedAt
+ out.SourceReason = frame.sourceReason
+ switch {
+ case frame.configuration != revision:
+ out.SourceReason = "configuration_changed"
+ case frame.repository != repository:
+ out.SourceReason = "repository_changed"
+ }
+ }
+ usable := found && frame.configuration == revision && frame.repository == repository
+ out.SourceComplete = usable && frame.complete
+ plans := frame.plans()
+ byNumber := map[int64]*SourcePlan{}
+ if usable {
+ for i := range plans {
+ byNumber[plans[i].Pull.Number] = &plans[i]
+ }
+ }
+ // An empty selection identity deliberately does not impersonate an automatic
+ // intent. This diagnostic describes local evidence/dependency facts only.
+ r := Run{ProjectID: scope.ProjectID, Channel: channel}
+ // Every local fact belongs to this same read transaction. Reuse ancestor
+ // evaluations so a full queue of siblings does not repeat thousands of SQL
+ // reads under the bounded Store.Read deadline. This cache never survives the
+ // request and is not used by selection or admission.
+ local := map[int64]evaluatedFront{}
+ evaluate := func(plan *SourcePlan) (evaluatedFront, error) {
+ if state, ok := local[plan.Pull.Number]; ok {
+ return state, nil
+ }
+ state, err := e.evaluateFrontPlan(ctx, tx, r, repository, plan)
+ if err == nil {
+ local[plan.Pull.Number] = state
+ }
+ return state, err
+ }
+ for _, number := range c.Queue {
+ item := LaneCandidateDiagnostic{PullNumber: number, LocalState: "unknown", LocalReason: "source_not_observed"}
+ if plan := byNumber[number]; plan != nil {
+ item.HeadSHA, item.SourceObservedAt, item.ParentPullNumber = plan.Pull.HeadSHA, plan.ObservedAt, plan.ParentPullNumber
+ state, err := evaluateCandidateLocalState(plan, byNumber, evaluate)
+ if err != nil {
+ return err
+ }
+ item.LocalState, item.LocalReason = state.state, state.reason
+ if globalFrontHold(state.reason) && out.LaneReason == "" {
+ out.LaneReason = state.reason
+ }
+ if item.LocalState == "ready" {
+ item.LocalState = "locally_ready"
+ }
+ item.BlockingPullNumber, item.BlockingReason = state.blockingPull, state.blockingReason
+ }
+ out.Candidates = append(out.Candidates, item)
+ }
+ return nil
+ })
+ if err != nil {
+ return LaneDiagnostic{}, err
+ }
+ return out, nil
+}
diff --git a/internal/reviewexec/lane_diagnostic_http.go b/internal/reviewexec/lane_diagnostic_http.go
new file mode 100644
index 00000000..acef3a47
--- /dev/null
+++ b/internal/reviewexec/lane_diagnostic_http.go
@@ -0,0 +1,24 @@
+package reviewexec
+
+import (
+ "github.com/benhook1013/FireController/internal/core"
+ "net/http"
+)
+
+func (e *Engine) readLaneDiagnosticHTTP(w http.ResponseWriter, r *http.Request) {
+ scope, err := e.store.Scope(r, "read")
+ if err != nil {
+ core.WriteError(w, err)
+ return
+ }
+ if _, err = core.QueryKeys(r, "validation_failed"); err != nil {
+ core.WriteError(w, err)
+ return
+ }
+ out, err := e.ReadLaneDiagnostic(r.Context(), scope, r.PathValue("channel"))
+ if err != nil {
+ core.WriteError(w, err)
+ return
+ }
+ core.WriteJSON(w, http.StatusOK, out)
+}
diff --git a/internal/reviewexec/lane_diagnostic_test.go b/internal/reviewexec/lane_diagnostic_test.go
new file mode 100644
index 00000000..3d606159
--- /dev/null
+++ b/internal/reviewexec/lane_diagnostic_test.go
@@ -0,0 +1,229 @@
+package reviewexec
+
+import (
+ "context"
+ "database/sql"
+ "encoding/json"
+ "net/http"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/benhook1013/FireController/internal/reviewprovider"
+)
+
+func laneDiagnosticFrame(t *testing.T, f *attemptFixture, channel string, plans []SourcePlan) {
+ t.Helper()
+ err := f.store.BackgroundWrite(t.Context(), func(ctx context.Context, tx *sql.Tx) error {
+ c, rev, err := readConfiguration(ctx, tx, attemptProject)
+ if err != nil {
+ return err
+ }
+ return writeFrontFrame(ctx, tx, Run{ProjectID: attemptProject, Channel: channel, ConfigurationRevision: rev}, 801, c, runChoice{prefix: plans})
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+func laneDiagnosticPlan(n int64) SourcePlan {
+ p := schedulingPull(n)
+ return SourcePlan{Repository: reviewprovider.Repository{ID: 801, FullName: "acme/repo", DefaultBranch: "main"}, Pull: p, ParentSHA: p.BaseSHA, ObservedAt: stamp()}
+}
+func TestLaneDiagnosticIndependentAndStackedReviewProgress(t *testing.T) {
+ for _, dependent := range []bool{false, true} {
+ t.Run(map[bool]string{false: "independent", true: "dependent"}[dependent], func(t *testing.T) {
+ f := schedulingFixture(t)
+ // A genuine completed native CLI capture still awaiting adjudication holds
+ // its own PR, even after a later head or a closed allowance.
+ roundCapture(t, f, 1, false)
+ one := int64(1)
+ if _, err := f.e.Configure(t.Context(), f.scope(t, attemptProject, f.admin, true), "diagnostic-stack", Configuration{ExpectedRevision: &one, CapabilityID: "test-capability", Mode: "stacked", Queue: []int64{2, 4}, Channels: []string{"cli", "hosted"}}); err != nil {
+ t.Fatal(err)
+ }
+ p2, p4 := laneDiagnosticPlan(2), laneDiagnosticPlan(4)
+ if dependent {
+ p4.ParentPullNumber = 2
+ p4.ParentSHA = p2.Pull.HeadSHA
+ p4.Pull.BaseSHA = p2.Pull.HeadSHA
+ p4.Pull.BaseRef = "branch-two"
+ }
+ laneDiagnosticFrame(t, f, "cli", []SourcePlan{p2, p4})
+ before := selectionCounts(t, f)
+ out, err := f.e.ReadLaneDiagnostic(t.Context(), selectionScope(t, f, attemptProject, f.reader, "read"), "cli")
+ if err != nil || !out.SourceComplete || len(out.Candidates) != 2 {
+ t.Fatal(out, err)
+ }
+ if out.Candidates[0].LocalReason != "review_evidence_pending" {
+ t.Fatal(out)
+ }
+ later := out.Candidates[1]
+ if later.LocalState != "locally_ready" || later.BlockingPullNumber != 0 {
+ t.Fatal(later)
+ }
+ // The exact shared selector agrees, rather than a duplicated approximation.
+ err = f.e.readAdmission(t.Context(), func(ctx context.Context, tx *sql.Tx) error {
+ got, reason, err := f.e.runFront(ctx, tx, Run{ProjectID: attemptProject, Channel: "cli"}, 801, []SourcePlan{p2, p4})
+ if err != nil {
+ return err
+ }
+ if got != 4 || reason != "" {
+ t.Fatal(got, reason)
+ }
+ return nil
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if selectionCounts(t, f) != before {
+ t.Fatal("read mutated selection, provider, event or receipt state")
+ }
+ })
+ }
+}
+func TestLaneDiagnosticSourceBoundariesAndHTTP(t *testing.T) {
+ f := schedulingFixture(t)
+ scope := selectionScope(t, f, attemptProject, f.reader, "read")
+ before := selectionCounts(t, f)
+ out, err := f.e.ReadLaneDiagnostic(t.Context(), scope, "cli")
+ if err != nil || out.SourceComplete || out.SourceReason != "source_unavailable" || out.Candidates[1].LocalState != "unknown" {
+ t.Fatal(out, err)
+ }
+ laneDiagnosticFrame(t, f, "cli", []SourcePlan{laneDiagnosticPlan(2)})
+ out, err = f.e.ReadLaneDiagnostic(t.Context(), scope, "cli")
+ if err != nil || out.SourceComplete || out.Candidates[1].LocalReason != "source_not_observed" {
+ t.Fatal(out, err)
+ }
+ mux := http.NewServeMux()
+ f.e.Register(mux)
+ w := runHTTPCall(t, f, mux, "GET", "/api/v1/projects/"+attemptProject+"/reviews/lanes/cli/diagnostics", "", "", "")
+ if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &out) != nil || len(out.Candidates) != 2 {
+ t.Fatal(w.Code, w.Body.String())
+ }
+ for _, suffix := range []string{"manual/diagnostics", "cli/diagnostics?refresh=true"} {
+ if w = runHTTPCall(t, f, mux, "GET", "/api/v1/projects/"+attemptProject+"/reviews/lanes/"+suffix, "", "", ""); w.Code != 400 {
+ t.Fatal(w.Code, w.Body.String())
+ }
+ }
+ if selectionCounts(t, f) != before {
+ t.Fatal("diagnostic changed state")
+ }
+ one := int64(1)
+ if _, err = f.e.Configure(t.Context(), f.scope(t, attemptProject, f.admin, true), "changed-queue", Configuration{ExpectedRevision: &one, CapabilityID: "test-capability", Mode: "independent", Queue: []int64{4, 2}, Channels: []string{"cli", "hosted"}}); err != nil {
+ t.Fatal(err)
+ }
+ out, err = f.e.ReadLaneDiagnostic(t.Context(), scope, "cli")
+ if err != nil || out.SourceReason != "configuration_changed" || out.SourceComplete || out.Candidates[0].HeadSHA != "" {
+ t.Fatal(out, err)
+ }
+ // Source decode damage remains an error, never a healthy empty lane.
+ admissionSQL(t, f, `UPDATE review_front_frames SET prefix_json=?`, strings.Repeat("x", 128*1024+1))
+ if _, err = f.e.ReadLaneDiagnostic(t.Context(), scope, "cli"); err == nil {
+ t.Fatal("damaged frame accepted")
+ }
+}
+
+// Many ready siblings share one long completed ancestry. This exercises the
+// advertised 100-row bound inside the real two-second Store.Read deadline.
+func TestLaneDiagnosticMaximumSharedCompletedAncestry(t *testing.T) {
+ queue := make([]int64, 100)
+ for i := range queue {
+ queue[i] = int64(i + 1)
+ }
+ f := schedulingFixtureWithQueue(t, queue)
+ one := int64(1)
+ if _, err := f.e.Configure(t.Context(), f.scope(t, attemptProject, f.admin, true), "maximum-stack", Configuration{ExpectedRevision: &one, CapabilityID: "test-capability", Mode: "stacked", Queue: queue, Channels: []string{"cli", "hosted"}}); err != nil {
+ t.Fatal(err)
+ }
+ plans := make([]SourcePlan, len(queue))
+ zero := int64(0)
+ for i, n := range queue {
+ plans[i] = laneDiagnosticPlan(n)
+ if i > 0 {
+ parent := int64(i)
+ if i >= 50 {
+ parent = 50
+ }
+ plans[i].ParentPullNumber = parent
+ plans[i].ParentSHA = strings.Repeat("a", 40)
+ plans[i].Pull.BaseSHA = plans[i].ParentSHA
+ plans[i].Pull.BaseRef = "ancestor"
+ }
+ if i < 50 {
+ if _, err := f.e.ConfigureRoundControl(t.Context(), f.scope(t, attemptProject, f.admin, true), "complete-"+strconv.FormatInt(n, 10), n, "cli", RoundControlRequest{ExpectedRevision: &zero, Action: "close"}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ laneDiagnosticFrame(t, f, "cli", plans)
+ started := time.Now()
+ out, err := f.e.ReadLaneDiagnostic(t.Context(), selectionScope(t, f, attemptProject, f.reader, "read"), "cli")
+ t.Logf("100-row shared ancestry read: %s", time.Since(started))
+ if err != nil || !out.SourceComplete || len(out.Candidates) != 100 {
+ t.Fatal(out, err)
+ }
+ for i, c := range out.Candidates {
+ want := "complete"
+ if i >= 50 {
+ want = "locally_ready"
+ }
+ if c.LocalState != want {
+ t.Fatal(i, c)
+ }
+ }
+}
+
+func TestLaneDiagnosticRepositoryChangeAndRevokedRead(t *testing.T) {
+ f := schedulingFixture(t)
+ scope := selectionScope(t, f, attemptProject, f.reader, "read")
+ laneDiagnosticFrame(t, f, "cli", []SourcePlan{laneDiagnosticPlan(2), laneDiagnosticPlan(4)})
+ admissionSQL(t, f, `UPDATE projects SET github_repository_id=999 WHERE id=?`, attemptProject)
+ out, err := f.e.ReadLaneDiagnostic(t.Context(), scope, "cli")
+ if err != nil || out.SourceReason != "repository_changed" || out.SourceComplete {
+ t.Fatal(out, err)
+ }
+ for _, c := range out.Candidates {
+ if c.LocalState != "unknown" || c.HeadSHA != "" {
+ t.Fatal(c)
+ }
+ }
+ admissionSQL(t, f, `UPDATE credentials SET revoked=1 WHERE id='exec-reader-cred'`)
+ if _, err = f.e.ReadLaneDiagnostic(t.Context(), scope, "cli"); err == nil {
+ t.Fatal("retained read scope bypassed credential revocation")
+ }
+}
+
+func TestStackReviewSourceIdentityRemainsRequired(t *testing.T) {
+ for _, cause := range []string{"parent_source_unavailable", "parent_moved", "parent_identity_changed", "pull_draft", "parent_unavailable", "parent_cycle"} {
+ t.Run(cause, func(t *testing.T) {
+ parent, child := laneDiagnosticPlan(2), laneDiagnosticPlan(4)
+ child.ParentPullNumber, child.ParentSHA, child.Pull.BaseSHA = 2, parent.Pull.HeadSHA, parent.Pull.HeadSHA
+ byNumber := map[int64]*SourcePlan{2: &parent, 4: &child}
+ switch cause {
+ case "parent_source_unavailable":
+ delete(byNumber, 2)
+ case "parent_moved":
+ parent.Pull.HeadSHA = strings.Repeat("f", 40)
+ case "parent_identity_changed":
+ parent.Repository.ID++
+ case "pull_draft":
+ parent.SourceReason = cause
+ case "parent_unavailable":
+ parent.Pull.State = "closed"
+ case "parent_cycle":
+ parent.ParentPullNumber, parent.ParentSHA = 4, child.Pull.HeadSHA
+ }
+ calls := 0
+ out, err := evaluateCandidateLocalState(&child, byNumber, func(p *SourcePlan) (evaluatedFront, error) {
+ calls++
+ if p.Pull.Number != 4 {
+ t.Fatal("ancestor review state was evaluated")
+ }
+ return evaluatedFront{state: "ready", plan: p}, nil
+ })
+ if err != nil || out.state != "held" || out.blockingReason != cause || calls != 1 {
+ t.Fatal("source identity was bypassed", out, calls, err)
+ }
+ })
+ }
+}
diff --git a/internal/reviewexec/policy_admission.go b/internal/reviewexec/policy_admission.go
index fbd5d0cb..beb62548 100644
--- a/internal/reviewexec/policy_admission.go
+++ b/internal/reviewexec/policy_admission.go
@@ -237,16 +237,9 @@ func verifyPredecessors(ctx context.Context, tx *sql.Tx, project string, current
if err != nil || observed.IsZero() || plan.Repository.ID != current.RepositoryID || !repository.MatchString(plan.Repository.FullName) || plan.Repository.DefaultBranch == "" || !safeText(plan.Repository.DefaultBranch, 256) || !sameTarget(plan.Pull, current.RepositoryID, number) || !validCoverageSource(plan) || plan.Pull.Merged {
return invalid()
}
- if err := requireSourceObligationsClear(ctx, tx, project, number); err != nil {
- return err
- }
- state, err := channelProgress(ctx, tx, project, current.RepositoryID, number, current.Operation.Channel)
- if err != nil {
- return err
- }
- if state.Pending || state.RoundsConfigured && !state.RoundsComplete || !state.RoundsConfigured && !state.Covered {
- return sourceHold("predecessor_unfinished")
- }
+ // Ancestor findings, imported obligations and unfinished rounds do not
+ // invalidate this child's exact source comparison. Target-local obligations
+ // are rechecked separately in this same admission snapshot.
number, head, branch = plan.ParentPullNumber, plan.ParentSHA, plan.Pull.BaseRef
}
if number != 0 {
diff --git a/internal/reviewexec/policy_admission_test.go b/internal/reviewexec/policy_admission_test.go
index 704c1fad..427d37c3 100644
--- a/internal/reviewexec/policy_admission_test.go
+++ b/internal/reviewexec/policy_admission_test.go
@@ -466,11 +466,13 @@ func TestVerifyActionStackedRequiresExactActualParentWitness(t *testing.T) {
if adjudicationState(t, f, child) != before {
t.Fatal("moved actual parent refusal changed retained state")
}
- // The proof was ready at preparation, but a real current correction now needs
- // a fix. The final guard must check predecessors and target in the same read.
+ // A late accepted ancestor finding does not change the child's pinned diff.
+ // The final guard preserves that obligation without making it a review gate.
adjudicationDecide(t, f, id, "late-predecessor-acceptance", 2, 0, "accepted")
afterCorrection := adjudicationState(t, f, child)
- attemptCode(t, f.e.VerifyAction(t.Context(), attemptProject, child.ID, child.Revision, dependencies...), "review_held")
+ if err := f.e.VerifyAction(t.Context(), attemptProject, child.ID, child.Revision, dependencies...); err != nil {
+ t.Fatal("ancestor fix work blocked child review", err)
+ }
if adjudicationState(t, f, child) != afterCorrection {
t.Fatal("late predecessor refusal mutated state")
}
diff --git a/internal/reviewexec/round_controls_admission.go b/internal/reviewexec/round_controls_admission.go
index a5f6b3c4..fa03052b 100644
--- a/internal/reviewexec/round_controls_admission.go
+++ b/internal/reviewexec/round_controls_admission.go
@@ -26,8 +26,9 @@ func (e *Engine) RoundAdmission(ctx context.Context, project, operationID string
return configured, err
}
-// DiscoveryComplete controls PR/channel progression. Later commits do not
-// reopen completed rounds; unresolved native evidence still holds progression.
+// DiscoveryComplete reports this PR/channel's retained discovery sufficiency.
+// Later commits do not reopen completed rounds. This is not an ancestor-review
+// prerequisite or authority to dispatch another review or merge a PR.
func (e *Engine) DiscoveryComplete(ctx context.Context, project string, current SourcePlan, channel string) (bool, error) {
state, err := e.Comparison(ctx, project, current, channel)
if err != nil {
diff --git a/internal/reviewexec/run_selection_actual_parent_test.go b/internal/reviewexec/run_selection_actual_parent_test.go
index 0d272c15..80949173 100644
--- a/internal/reviewexec/run_selection_actual_parent_test.go
+++ b/internal/reviewexec/run_selection_actual_parent_test.go
@@ -86,20 +86,16 @@ func TestRunSelectionActualParentKeepsUnfinishedFindingLocal(t *testing.T) {
wantCalls := map[string]int{"repository:801": 1, "pull:2": 1, "pull:4": 2}
if dependent {
wantCalls["parent:agent-a"] = 1
- if got.State != "held" || got.OperationID != "" {
- t.Fatal("unfinished actual parent allowed dependent dispatch", got)
- }
- if count := attemptCount(t, f.store, `SELECT count(*) FROM review_operations`); count != 1 {
- t.Fatal("held dependency created another operation", count)
- }
- } else {
- if got.State != "selected" || got.OperationID == "" {
- t.Fatal("unrelated finding blocked independent work", got)
- }
- op, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), got.OperationID)
- if err != nil || op.PullNumber != 4 || op.HeadSHA != reader.pulls[4].HeadSHA {
- t.Fatal("selected wrong independent source", op, err)
- }
+ }
+ if got.State != "selected" || got.OperationID == "" {
+ t.Fatal("ancestor finding blocked distinct review work", got)
+ }
+ op, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), got.OperationID)
+ if err != nil || op.PullNumber != 4 || op.HeadSHA != reader.pulls[4].HeadSHA {
+ t.Fatal("selected wrong source comparison", op, err)
+ }
+ if count := attemptCount(t, f.store, `SELECT count(*) FROM review_operations`); count != 2 {
+ t.Fatal("selection did not create exactly one child", count)
}
gotCalls := map[string]int{}
for _, call := range reader.calls {
diff --git a/internal/reviewexec/scheduling_cli_test.go b/internal/reviewexec/scheduling_cli_test.go
index 0d93b64b..78ae9030 100644
--- a/internal/reviewexec/scheduling_cli_test.go
+++ b/internal/reviewexec/scheduling_cli_test.go
@@ -300,7 +300,7 @@ func TestSchedulingCLIPublicationAndAdjudicationRemainRequired(t *testing.T) {
}
}
-func TestSchedulingCLIActualParentStillBlocks(t *testing.T) {
+func TestSchedulingCLIActualParentPauseDoesNotBlockChild(t *testing.T) {
f := schedulingFixture(t)
one := int64(1)
_, err := f.e.Configure(t.Context(), f.scope(t, attemptProject, f.admin, true), "stacked-cli", Configuration{ExpectedRevision: &one, CapabilityID: "test-capability", Mode: "stacked", Queue: []int64{2, 4}, Channels: []string{"cli", "hosted"}})
@@ -323,8 +323,12 @@ func TestSchedulingCLIActualParentStillBlocks(t *testing.T) {
reader.parents = map[string]reviewprovider.Pull{"branch-two": func() reviewprovider.Pull { p := schedulingPull(2); p.HeadRef = "branch-two"; return p }()}
selectionNext(t, f, reader)
r := schedulingLatest(t, f)
- if r.OperationID != "" || r.State != "held" {
- t.Fatal("actual predecessor bypassed", r)
+ if r.OperationID == "" || r.State != "selected" {
+ t.Fatal("ancestor pause blocked the child review", r)
+ }
+ op, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), r.OperationID)
+ if err != nil || op.PullNumber != 4 {
+ t.Fatal(op, err)
}
}
diff --git a/internal/reviewexec/scheduling_http.go b/internal/reviewexec/scheduling_http.go
index b88e13e6..06306860 100644
--- a/internal/reviewexec/scheduling_http.go
+++ b/internal/reviewexec/scheduling_http.go
@@ -8,6 +8,7 @@ import (
)
func (e *Engine) registerSchedulingHTTP(mux *http.ServeMux) {
+ mux.HandleFunc("GET /api/v1/projects/{project_id}/reviews/lanes/{channel}/diagnostics", e.readLaneDiagnosticHTTP)
mux.HandleFunc("GET /api/v1/projects/{project_id}/reviews/scheduling", e.schedulingHTTP)
mux.HandleFunc("POST /api/v1/projects/{project_id}/reviews/scheduling", e.schedulingHTTP)
mux.HandleFunc("GET /api/v1/projects/{project_id}/reviews/pulls/{pull_number}/scheduling", e.pullSchedulingHTTP)
diff --git a/internal/reviewexec/scheduling_test.go b/internal/reviewexec/scheduling_test.go
index a355a5fc..99e44b00 100644
--- a/internal/reviewexec/scheduling_test.go
+++ b/internal/reviewexec/scheduling_test.go
@@ -235,7 +235,7 @@ func TestSchedulingAutomaticAuthorizerWithdrawalAndRestoreHold(t *testing.T) {
t.Fatal("withdrawn manager claimed attempt", a, err)
}
}
-func TestSchedulingPausedFrontSkipsIndependentButNotDependency(t *testing.T) {
+func TestSchedulingPausedFrontSkipsIndependentAndStackedReviews(t *testing.T) {
f := schedulingFixture(t)
schedulingPause(t, f, 2, 0, true)
r, _ := selectionEnqueue(t, f, "independent-paused", "hosted", nil)
@@ -248,7 +248,7 @@ func TestSchedulingPausedFrontSkipsIndependentButNotDependency(t *testing.T) {
if err != nil || op.PullNumber != 4 {
t.Fatal(op, err)
}
- // The same evaluator cannot turn a paused parent into earned completion.
+ // The parent pause stays local; selecting the child grants no parent completion.
err = f.store.BackgroundWrite(t.Context(), func(ctx context.Context, tx *sql.Tx) error {
base := strings.Repeat("b", 40)
head := strings.Repeat("a", 40)
@@ -261,8 +261,8 @@ func TestSchedulingPausedFrontSkipsIndependentButNotDependency(t *testing.T) {
if err != nil {
return err
}
- if front != 0 || reason != "pull_scheduling_paused" {
- t.Fatalf("dependent PR passed paused parent: %d %s", front, reason)
+ if front != 4 || reason != "" {
+ t.Fatalf("ancestor pause blocked child review: %d %s", front, reason)
}
return nil
})
@@ -452,18 +452,12 @@ func TestSchedulingAutomaticIndependentProgressAcrossRetainedEvidence(t *testing
}
selectionNext(t, f, reader)
r := schedulingLatest(t, f)
- if dependent {
- if r.State != "held" || r.OperationID != "" {
- t.Fatal("dependency bypassed", r)
- }
- } else {
- if r.State != "selected" {
- t.Fatal(r)
- }
- op, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), r.OperationID)
- if err != nil || op.PullNumber != 4 {
- t.Fatal(op, err)
- }
+ if r.State != "selected" {
+ t.Fatal("ancestor evidence blocked a distinct review target", r)
+ }
+ op, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), r.OperationID)
+ if err != nil || op.PullNumber != 4 {
+ t.Fatal(op, err)
}
schedulingGenerate(t, f, false)
})
@@ -676,7 +670,7 @@ func schedulingStackReader() *refreshTestReader {
r.parents = map[string]reviewprovider.Pull{"branch-two": func() reviewprovider.Pull { p := schedulingPull(2); p.HeadRef = "branch-two"; return p }()}
return r
}
-func TestSchedulingDependentHeldChildReleasesAfterParentTapersAtSameHead(t *testing.T) {
+func TestSchedulingAncestorRoundChangesKeepOriginalChild(t *testing.T) {
f := schedulingFixture(t)
schedulingCleanHosted(t, f, 1, 81)
one := int64(1)
@@ -717,38 +711,23 @@ func TestSchedulingDependentHeldChildReleasesAfterParentTapersAtSameHead(t *test
}
return verifyPredecessors(ctx, tx, attemptProject, current, anchor, []SourcePlan{parent})
})
- attemptCode(t, err, "review_held")
- var failure *core.Error
- if !errors.As(err, &failure) {
- t.Fatal(err)
- }
- details, ok := failure.Details.(map[string]string)
- if !ok || details["reason"] != "predecessor_unfinished" {
- t.Fatal("not the genuine dependency hold", failure)
- }
- if _, err = f.e.Advance(t.Context(), attemptProject, a.ID, a.Revision, "held", "predecessor_unfinished", ""); err != nil {
- t.Fatal(err)
+ if err != nil {
+ t.Fatal("ancestor round work stopped final child source verification", err)
}
- schedulingCleanHosted(t, f, 2, 82)
+ // Change parent progress after the child has an admitted operation/attempt.
control := roundRead(t, f, 2, "hosted")
- if !control.Tapered || control.Used != 1 {
- t.Fatal("parent did not actually taper", control)
- }
- schedulingGenerate(t, f, true)
- selectionNext(t, f, reader)
- next := schedulingLatest(t, f)
- if next.State != "selected" || next.OperationID == child.ID {
- t.Fatal("dependent child remained suppressed after genuine parent completion", next)
+ if _, err := f.e.ConfigureRoundControl(t.Context(), f.scope(t, attemptProject, f.admin, true), "close-parent-during-child", 2, "hosted", RoundControlRequest{ExpectedRevision: &control.Revision, Action: "close"}); err != nil {
+ t.Fatal(err)
}
- op, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), next.OperationID)
- if err != nil || op.PullNumber != 4 || op.HeadSHA != child.HeadSHA || op.ConfigurationRevision != child.ConfigurationRevision {
- t.Fatal(op, err)
+ schedulingGenerate(t, f, false)
+ var children int
+ if err := f.store.DB().QueryRow(`SELECT count(*) FROM review_operations WHERE project_id=? AND pull_number=4 AND channel='hosted'`, attemptProject).Scan(&children); err != nil || children != 1 {
+ t.Fatal("ancestor progress created another child request", children, err)
}
- old, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), child.ID)
- if err != nil || old.State != "held" || old.Reason != "predecessor_unfinished" {
- t.Fatal("old dependency hold was rewritten", old, err)
+ current, err := f.e.ReadOperation(t.Context(), selectionScope(t, f, attemptProject, f.writer, "read"), child.ID)
+ if err != nil || current.ID != child.ID || current.AttemptID != a.ID {
+ t.Fatal("ancestor progress replaced the child operation", current, err)
}
-
}
func TestSchedulingPrepareControlRaceFinalVerificationKeepsSupervisorHealthy(t *testing.T) {
diff --git a/internal/reviewprovider/hosted_standing_zero.go b/internal/reviewprovider/hosted_standing_zero.go
index 196ee3f1..afbbc4e5 100644
--- a/internal/reviewprovider/hosted_standing_zero.go
+++ b/internal/reviewprovider/hosted_standing_zero.go
@@ -138,10 +138,153 @@ func (p *standingRiskParser) line(line string, stack []string) (handled, ok bool
return false, true
}
+// Only this explicitly historical report is recognized as narrative. Counts
+// are bounded and must reconcile; the report supplies no current inventory or
+// comparison proof. Unknown wording, nonzero routes and current claims retain
+// the global finding guard.
+var standingHistoricalCheckpoint = regexp.MustCompile(`^The latest reported Hosted review checkpoint lists (0|[1-9][0-9]{0,2}) accepted findings: (0|[1-9][0-9]{0,2}) minor and (0|[1-9][0-9]{0,2}) trivial, with (0|[1-9][0-9]{0,2}) major and 0 routed\. Finding details and current review findings are not available\.$`)
+
+func standingHistoricalCheckpointLine(line string) bool {
+ counts := standingHistoricalCheckpoint.FindStringSubmatch(line)
+ if counts == nil {
+ return false
+ }
+ var values [4]int
+ for i := range values {
+ values[i], _ = strconv.Atoi(counts[i+1]) // The bounded decimal grammar cannot overflow.
+ }
+ return values[0] <= 100 && values[0] == values[1]+values[2]+values[3]
+}
+
+// This parser observes the existing visibility/HTML scanner; it never removes
+// or hides text. It recognizes one closed, root walkthrough Summary envelope
+// with one generated release-notes region. Only a complete envelope can exempt
+// its one standalone historical checkpoint line from the numeric-claim guard.
+// All other lines, including other claims in that same region, remain guarded.
+type standingHistoricalParser struct {
+ phase, claimLine int
+ seen, invalid, bodyBreak bool
+}
+
+func (p *standingHistoricalParser) line(line string, stack []string, index int, inRecent bool) {
+ if line == "" {
+ return
+ }
+ ancestry := strings.Join(stack, "/")
+ const releaseStart = ""
+ const releaseEnd = ""
+ switch line {
+ case "":
+ if p.seen || inRecent || ancestry != "" {
+ p.invalid = true
+ }
+ p.seen, p.phase = true, 1
+ return
+ case "":
+ if p.phase != 10 || inRecent || ancestry != "" {
+ p.invalid = true
+ }
+ p.phase = 11
+ return
+ case releaseStart:
+ if p.phase != 5 || inRecent || ancestry != "details/dl/dd" {
+ p.invalid = true
+ }
+ p.phase = 6
+ return
+ case releaseEnd:
+ if p.phase != 6 || inRecent || ancestry != "details/dl/dd" {
+ p.invalid = true
+ }
+ p.phase = 7
+ return
+ }
+ if strings.Contains(line, "\n## Validation\n\n"+standingHistoricalCheckpointTest+"\n\nIndependent synthetic change description.\n
\n" +
+ " \n" +
+ "\n" +
+ "`24-24`: ** Trivial** · **Maintainability & Code Quality** · **Low value**\n" +
+ "\n" +
+ " **Unverified finding**\n" +
+ "Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.\n" +
+ "\n" +
+ "**Consider the optional example wording.**\n" +
+ "\n" +
+ "The synthetic example text may be clearer with an optional wording change. This observation remains unverified.\n" +
+ "\n" +
+ "_Source: Linters/SAST tools_\n" +
+ "\n" +
+ "
\n" +
+ " \n" +
+ "\n" +
+ "Reviewing files that changed from the base of the PR and between bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb and aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.\n" +
+ "\n" +
+ "
\n" +
+ "\n" +
+ "\n" +
+ "**Included review availability:** This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.\n" +
+ "\n" +
+ "