Add hard queue-target resolution wall before PR inventory or empty-queue claims #200

Closed
opened 2026-07-05 15:13:27 -05:00 by jcwalker3 · 4 comments
Owner

Problem

Reviewer agents can check the wrong repository queue and then report "no open PRs," even when the intended review backlog has open PRs. This creates a false stop condition and hides actionable PRs from the operator.

Observed failure

The agent repeatedly reported that Scaled-Tech-Consulting/mcp-control-plane had zero open PRs and concluded that there was nothing to review. However, the active review backlog is Scaled-Tech-Consulting/Gitea-Tools, which currently has six open PRs:

  • #195 — Add fail-closed PR inventory wall when list_prs returns an unexpected empty queue
  • #193 — Raise reviewer A-bar: capability, sweep, live-state, and role-boundary proofs
  • #192 — Add role-boundary proofs for reviewer queue workflows
  • #190 — Fix MCP registration and naming for Jenkins/GlitchTip servers and add discoverability coverage
  • #187 — Harden author-run reporting and mutation capability proof
  • #181 — Add fail-closed branch-identity proofs for author commit/push workflow

Required wall

Before any PR inventory, review selection, or empty-queue report, the workflow must resolve and lock the intended queue target.

The queue target must be derived from explicit operator context, including:

  • repo name mentioned by the user;
  • PR numbers/titles supplied by the user;
  • current working project context;
  • previous handoff target;
  • remote/owner/repo configured for the active task.

If these sources conflict, the agent must fail closed with a target-resolution blocker. It must not silently inventory a different repo.

Required behavior

  • If the operator provides PR numbers or PR titles, the agent must verify those PRs exist in the resolved repo before claiming the queue is empty.
  • If the agent inventories mcp-control-plane but the supplied PRs are in Gitea-Tools, the result must be target_repo_mismatch, not trusted_empty.
  • Empty-queue claims are forbidden unless the queue target has first been resolved and locked.
  • The final report must include the locked queue target: remote, owner, repo, source of target resolution, and whether user-provided PRs were reconciled.

Acceptance criteria

  • Add a test where the user supplies open Gitea-Tools PRs but the agent inventories mcp-control-plane; expected result: target_repo_mismatch.
  • Add a test where list_prs returns empty for the wrong repo; expected result: blocked, not "no open PRs."
  • Add a test where the user says "currently we have 6 open PRs" and provides PR numbers; expected result: the workflow must reconcile those PR numbers before stopping.
  • Add a test where repo context is ambiguous between mcp-control-plane and Gitea-Tools; expected result: fail closed and require target clarification or explicit operator target.
  • Empty-queue reports must include queue_target_lock.status == resolved.
  • pr_inventory_trust_gate must consume the queue target lock result; it cannot return trusted_empty if the repo target is unresolved or contradicted by operator context.

Suggested implementation

Add a queue_target_lock or resolve_pr_queue_target helper that runs before pr_inventory_trust_gate. The trust gate should refuse to evaluate empty inventory unless the target lock is resolved and consistent with operator-provided PR context.

Related

  • #194 (false-empty investigation), PR #195 (pr_inventory_trust_gate helper), #196 (gate wired into live path), #198 (gate status required in reports). This issue adds the upstream target-resolution lock the gate must consume.
  • Context note for implementers: in the origin runs the operator prompt explicitly stated Repository: Scaled-Tech-Consulting/mcp-control-plane while the actionable backlog lived in Gitea-Tools — exactly the conflicting-sources case this wall must fail closed on (explicit directive vs. supplied PR context), rather than silently privileging either source.
### Problem Reviewer agents can check the wrong repository queue and then report "no open PRs," even when the intended review backlog has open PRs. This creates a false stop condition and hides actionable PRs from the operator. ### Observed failure The agent repeatedly reported that `Scaled-Tech-Consulting/mcp-control-plane` had zero open PRs and concluded that there was nothing to review. However, the active review backlog is `Scaled-Tech-Consulting/Gitea-Tools`, which currently has six open PRs: * #195 — Add fail-closed PR inventory wall when list_prs returns an unexpected empty queue * #193 — Raise reviewer A-bar: capability, sweep, live-state, and role-boundary proofs * #192 — Add role-boundary proofs for reviewer queue workflows * #190 — Fix MCP registration and naming for Jenkins/GlitchTip servers and add discoverability coverage * #187 — Harden author-run reporting and mutation capability proof * #181 — Add fail-closed branch-identity proofs for author commit/push workflow ### Required wall Before any PR inventory, review selection, or empty-queue report, the workflow must resolve and lock the intended queue target. The queue target must be derived from explicit operator context, including: * repo name mentioned by the user; * PR numbers/titles supplied by the user; * current working project context; * previous handoff target; * remote/owner/repo configured for the active task. If these sources conflict, the agent must fail closed with a target-resolution blocker. It must not silently inventory a different repo. ### Required behavior * If the operator provides PR numbers or PR titles, the agent must verify those PRs exist in the resolved repo before claiming the queue is empty. * If the agent inventories `mcp-control-plane` but the supplied PRs are in `Gitea-Tools`, the result must be `target_repo_mismatch`, not `trusted_empty`. * Empty-queue claims are forbidden unless the queue target has first been resolved and locked. * The final report must include the locked queue target: remote, owner, repo, source of target resolution, and whether user-provided PRs were reconciled. ### Acceptance criteria * Add a test where the user supplies open Gitea-Tools PRs but the agent inventories mcp-control-plane; expected result: `target_repo_mismatch`. * Add a test where `list_prs` returns empty for the wrong repo; expected result: blocked, not "no open PRs." * Add a test where the user says "currently we have 6 open PRs" and provides PR numbers; expected result: the workflow must reconcile those PR numbers before stopping. * Add a test where repo context is ambiguous between `mcp-control-plane` and `Gitea-Tools`; expected result: fail closed and require target clarification or explicit operator target. * Empty-queue reports must include `queue_target_lock.status == resolved`. * `pr_inventory_trust_gate` must consume the queue target lock result; it cannot return `trusted_empty` if the repo target is unresolved or contradicted by operator context. ### Suggested implementation Add a `queue_target_lock` or `resolve_pr_queue_target` helper that runs before `pr_inventory_trust_gate`. The trust gate should refuse to evaluate empty inventory unless the target lock is resolved and consistent with operator-provided PR context. ### Related * #194 (false-empty investigation), PR #195 (`pr_inventory_trust_gate` helper), #196 (gate wired into live path), #198 (gate status required in reports). This issue adds the upstream target-resolution lock the gate must consume. * Context note for implementers: in the origin runs the operator prompt explicitly stated `Repository: Scaled-Tech-Consulting/mcp-control-plane` while the actionable backlog lived in `Gitea-Tools` — exactly the conflicting-sources case this wall must fail closed on (explicit directive vs. supplied PR context), rather than silently privileging either source.
Author
Owner

Consolidation note: this issue is the canonical copy of an exact-title triple — #201 and #202 carry the identical title and body intent, filed by parallel author sessions within minutes (TOCTOU duplicate-search failure, now walled by #207). #202 has been closed as a duplicate by its authoring session; #201 still needs operator/triage consolidation into this issue.

Preserved deltas from the #202 copy for whoever implements this:

  • The queue_target_lock / resolve_pr_queue_target helper should build on review_proofs.resolve_repos_from_user_reference (added for #184 via PR #185), which already maps user repo references to canonical repos — the lock adds operator-PR reconciliation, conflict fail-close, and the lock-status output.
  • A target_repo_mismatch blocker report must also follow the #197 terminal-report purity rules.
Consolidation note: this issue is the canonical copy of an exact-title triple — #201 and #202 carry the identical title and body intent, filed by parallel author sessions within minutes (TOCTOU duplicate-search failure, now walled by #207). #202 has been closed as a duplicate by its authoring session; #201 still needs operator/triage consolidation into this issue. Preserved deltas from the #202 copy for whoever implements this: * The `queue_target_lock` / `resolve_pr_queue_target` helper should build on `review_proofs.resolve_repos_from_user_reference` (added for #184 via PR #185), which already maps user repo references to canonical repos — the lock adds operator-PR reconciliation, conflict fail-close, and the lock-status output. * A `target_repo_mismatch` blocker report must also follow the #197 terminal-report purity rules.
Author
Owner

Additional observed failure (reviewer-side, new evidence):

A reviewer run authenticated correctly as sysadmin / prgs-reviewer and proved pagination for Scaled-Tech-Consulting/mcp-control-plane, returning 0 open PRs. However, the operator context stated that there were 4 open PRs in the active review backlog.

The agent treated the empty mcp-control-plane result as a clean stop instead of reconciling the contradiction. This is a target-resolution failure — and it shows the failure mode survives even with correct identity, correct capability, and a proven-complete single-repo inventory.

Correct behavior should be:

  • detect that operator context says open PRs exist;
  • verify which repo owns those PRs;
  • compare that repo to the resolved target repo;
  • return target_repo_mismatch if they differ;
  • refuse to report "no open PRs" or "nothing to review."

Important distinction:

The REST pagination proof and X-Total-Count: 0 only prove that the queried repo has zero open PRs. They do not prove that the intended queue is empty. Inventory-completeness proof (per-repo) and queue-target correctness are independent axes; pr_inventory_trust_gate covers the first, this wall covers the second, and trusted_empty requires both.

Required acceptance test (add to this issue's list):

Given operator context: "there are 4 open PRs"
And the agent inventories Scaled-Tech-Consulting/mcp-control-plane
And that repo returns 0 open PRs
But the active backlog is Scaled-Tech-Consulting/Gitea-Tools
Then the workflow must stop with target_repo_mismatch, not trusted_empty.

Additional observed failure (reviewer-side, new evidence): A reviewer run authenticated correctly as `sysadmin / prgs-reviewer` and proved pagination for `Scaled-Tech-Consulting/mcp-control-plane`, returning `0` open PRs. However, the operator context stated that there were 4 open PRs in the active review backlog. The agent treated the empty `mcp-control-plane` result as a clean stop instead of reconciling the contradiction. This is a target-resolution failure — and it shows the failure mode survives even with correct identity, correct capability, and a proven-complete single-repo inventory. Correct behavior should be: * detect that operator context says open PRs exist; * verify which repo owns those PRs; * compare that repo to the resolved target repo; * return `target_repo_mismatch` if they differ; * refuse to report "no open PRs" or "nothing to review." Important distinction: The REST pagination proof and `X-Total-Count: 0` only prove that the queried repo has zero open PRs. They do not prove that the intended queue is empty. Inventory-completeness proof (per-repo) and queue-target correctness are independent axes; `pr_inventory_trust_gate` covers the first, this wall covers the second, and `trusted_empty` requires both. Required acceptance test (add to this issue's list): Given operator context: "there are 4 open PRs" And the agent inventories `Scaled-Tech-Consulting/mcp-control-plane` And that repo returns `0` open PRs But the active backlog is `Scaled-Tech-Consulting/Gitea-Tools` Then the workflow must stop with `target_repo_mismatch`, not `trusted_empty`.
Owner

Additional observed failure:

A reviewer run again resolved and inventoried Scaled-Tech-Consulting/mcp-control-plane, proved that repo had zero open PRs, and stopped with trusted_empty.

This did not reconcile against the active operator context, where the review backlog is in Scaled-Tech-Consulting/Gitea-Tools.

The run proves only that mcp-control-plane has no open PRs. It does not prove the intended queue is empty.

Required behavior:

  • Before inventory, resolve the queue target from operator context.
  • If the target repo conflicts with the active backlog context, stop with target_repo_mismatch.
  • pr_inventory_trust_gate must not return trusted_empty if queue target resolution is unresolved or contradicted.
Additional observed failure: A reviewer run again resolved and inventoried `Scaled-Tech-Consulting/mcp-control-plane`, proved that repo had zero open PRs, and stopped with `trusted_empty`. This did not reconcile against the active operator context, where the review backlog is in `Scaled-Tech-Consulting/Gitea-Tools`. The run proves only that `mcp-control-plane` has no open PRs. It does not prove the intended queue is empty. Required behavior: * Before inventory, resolve the queue target from operator context. * If the target repo conflicts with the active backlog context, stop with `target_repo_mismatch`. * `pr_inventory_trust_gate` must not return `trusted_empty` if queue target resolution is unresolved or contradicted.
jcwalker3 added the status:in-progress label 2026-07-06 10:28:39 -05:00
Author
Owner

Claimed and implemented on feat/issue-200-queue-target-lock.

Approach: reconcile_queue_target locks the intended queue repo from operator context / supplied PR backlog before list_prs. pr_inventory_trust_gate returns target_repo_mismatch (not trusted_empty) when the inventoried repo does not own the operator-supplied PRs. Wired into assess_reviewer_queue_inventory.

Tests: 7 new unit tests covering mismatch, ambiguity, conflicting sources, PR-number reconciliation, final-report fields, and canonical inventory integration. All 11 queue-target + inventory tests pass.

PR opened for review.

Claimed and implemented on `feat/issue-200-queue-target-lock`. **Approach:** `reconcile_queue_target` locks the intended queue repo from operator context / supplied PR backlog before `list_prs`. `pr_inventory_trust_gate` returns `target_repo_mismatch` (not `trusted_empty`) when the inventoried repo does not own the operator-supplied PRs. Wired into `assess_reviewer_queue_inventory`. **Tests:** 7 new unit tests covering mismatch, ambiguity, conflicting sources, PR-number reconciliation, final-report fields, and canonical inventory integration. All 11 queue-target + inventory tests pass. PR opened for review.
sysadmin removed the status:in-progress label 2026-07-06 11:30:28 -05:00
Sign in to join this conversation.
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#200