@@ -664,8 +664,6 @@ def build_final_report(checkout_proof, inventory, validation, contamination,
|
||||
report_text, review_decision_lock
|
||||
)
|
||||
|
||||
empty_queue_report = assess_empty_queue_report(report_text)
|
||||
|
||||
contamination_status = contamination.get("status", "unknown")
|
||||
checkout_proven = bool(checkout_proof.get("proven"))
|
||||
validation_claimable = bool(validation.get("claimable"))
|
||||
@@ -789,11 +787,6 @@ def build_final_report(checkout_proof, inventory, validation, contamination,
|
||||
"reviewer worktree safety proof missing or failed (#233)"
|
||||
)
|
||||
downgrade_reasons.extend(worktree.get("reasons", []))
|
||||
if empty_queue_report.get("claimed") and not empty_queue_report.get("proven"):
|
||||
downgrade_reasons.append(
|
||||
"empty-queue report missing or failed trust-gate proof (#198)"
|
||||
)
|
||||
downgrade_reasons.extend(empty_queue_report.get("reasons", []))
|
||||
|
||||
merge_allowed = (
|
||||
identity_eligible
|
||||
@@ -853,12 +846,6 @@ def build_final_report(checkout_proof, inventory, validation, contamination,
|
||||
"unrelated_mutations_avoided": bool(
|
||||
worktree.get("unrelated_mutations_avoided")
|
||||
),
|
||||
"empty_queue_trust_gate_proven": (
|
||||
empty_queue_report.get("proven")
|
||||
if empty_queue_report.get("claimed")
|
||||
else True
|
||||
),
|
||||
"empty_queue_trust_gate_status": empty_queue_report.get("status"),
|
||||
}
|
||||
|
||||
|
||||
@@ -1018,7 +1005,6 @@ HANDOFF_ROLE_FIELDS = {
|
||||
),
|
||||
"author": (
|
||||
("Selected issue", ("selected issue",)),
|
||||
("Issue lock proof", ("issue lock proof", "lock before diff")),
|
||||
("Claim/comment status", ("claim/comment status", "claim status",
|
||||
"claim")),
|
||||
("PR number opened", ("pr number opened", "pr opened", "pr number")),
|
||||
@@ -1029,14 +1015,6 @@ HANDOFF_ROLE_FIELDS = {
|
||||
("Repositories checked", ("repositories checked", "repos checked")),
|
||||
("Open PR counts", ("open pr counts", "open pr count",
|
||||
"open prs per repo")),
|
||||
("PR inventory trust gate", ("pr inventory trust gate",
|
||||
"pr_inventory_trust_gate.status",
|
||||
"trust gate status")),
|
||||
("Trust gate reasons", ("trust gate reasons",
|
||||
"pr_inventory_trust_gate.reason")),
|
||||
("Trust gate corroborated", ("trust gate corroborated",
|
||||
"pr_inventory_trust_gate.corroborated")),
|
||||
("Inventory profile", ("inventory profile", "inventory mcp profile")),
|
||||
("Selected PR or reason", ("selected pr", "none selected",
|
||||
"reason none selected")),
|
||||
("Inventory completeness", ("inventory complete", "inventory scoped",
|
||||
@@ -1420,148 +1398,6 @@ def format_pr_inventory_trust_gate_report(gate: dict) -> list[str]:
|
||||
return lines
|
||||
|
||||
|
||||
_EMPTY_QUEUE_CLAIM = re.compile(
|
||||
r"\b0 open pr|\bno open pr|\bno eligible pr|\bempty (?:review )?queue|"
|
||||
r"nothing to review|queue cleared|inventory empty|"
|
||||
r"open pr count:\s*0|workflow correctly stops with nothing",
|
||||
re.I,
|
||||
)
|
||||
|
||||
_WEAK_EMPTY_QUEUE_CORROBORATION = re.compile(
|
||||
r"latest commit.*(?:merge|pr #)|merge of pr #|"
|
||||
r"master latest commit|recent merge proves",
|
||||
re.I,
|
||||
)
|
||||
|
||||
_TRUST_GATE_STATUS_LINE = re.compile(
|
||||
r"pr_inventory_trust_gate\.status:\s*(\S+)",
|
||||
re.I,
|
||||
)
|
||||
|
||||
|
||||
def parse_trust_gate_status_from_report(report_text: str | None) -> str | None:
|
||||
"""Extract ``pr_inventory_trust_gate.status`` from report text, if present."""
|
||||
match = _TRUST_GATE_STATUS_LINE.search(report_text or "")
|
||||
return match.group(1).strip().lower() if match else None
|
||||
|
||||
|
||||
def assess_empty_queue_report(
|
||||
report_text: str | None,
|
||||
*,
|
||||
trust_gate: dict | None = None,
|
||||
task_role: str | None = None,
|
||||
inventory_profile: str | None = None,
|
||||
) -> dict:
|
||||
"""Issue #198: empty-queue reports must cite the formal trust-gate result.
|
||||
|
||||
Blocks reports that claim an empty queue without
|
||||
``pr_inventory_trust_gate.status == trusted_empty``, required inventory
|
||||
metadata, or that rely on weak corroboration (e.g. a recent merge commit).
|
||||
"""
|
||||
text = report_text or ""
|
||||
lower = text.lower()
|
||||
reasons: list[str] = []
|
||||
missing: list[str] = []
|
||||
|
||||
if not _EMPTY_QUEUE_CLAIM.search(text):
|
||||
return {
|
||||
"claimed": False,
|
||||
"proven": True,
|
||||
"block": False,
|
||||
"status": None,
|
||||
"missing_fields": [],
|
||||
"reasons": [],
|
||||
}
|
||||
|
||||
status = (
|
||||
(trust_gate or {}).get("status")
|
||||
or parse_trust_gate_status_from_report(text)
|
||||
)
|
||||
status_norm = (status or "").strip().lower() or None
|
||||
|
||||
if not status_norm:
|
||||
missing.append("pr_inventory_trust_gate.status")
|
||||
reasons.append(
|
||||
"empty-queue report missing pr_inventory_trust_gate.status; "
|
||||
"fail closed"
|
||||
)
|
||||
elif status_norm != "trusted_empty":
|
||||
reasons.append(
|
||||
f"empty-queue report has trust-gate status '{status_norm}', "
|
||||
"not trusted_empty"
|
||||
)
|
||||
|
||||
has_gate_reasons = (
|
||||
"pr_inventory_trust_gate.reason" in lower
|
||||
or bool((trust_gate or {}).get("reasons"))
|
||||
)
|
||||
if status_norm and status_norm != "trusted_empty" and not has_gate_reasons:
|
||||
missing.append("pr_inventory_trust_gate.reasons")
|
||||
|
||||
if status_norm == "trusted_empty":
|
||||
if "pr_inventory_trust_gate.corroborated" not in lower and (
|
||||
trust_gate or {}
|
||||
).get("corroborated") is not True:
|
||||
missing.append("pr_inventory_trust_gate.corroborated")
|
||||
|
||||
inventory_markers = (
|
||||
"repository:",
|
||||
"remote:",
|
||||
"owner:",
|
||||
"state filter:",
|
||||
"state_filter:",
|
||||
)
|
||||
if not any(marker in lower for marker in inventory_markers):
|
||||
missing.append("inventory remote/owner/repo/state filter")
|
||||
|
||||
profile_markers = (
|
||||
"mcp profile:",
|
||||
"mcp-profile:",
|
||||
"inventory profile:",
|
||||
"active profile:",
|
||||
)
|
||||
has_profile = (
|
||||
any(marker in lower for marker in profile_markers)
|
||||
or bool((inventory_profile or "").strip())
|
||||
)
|
||||
if not has_profile:
|
||||
missing.append("inventory MCP profile")
|
||||
|
||||
if _WEAK_EMPTY_QUEUE_CORROBORATION.search(text):
|
||||
if "pr_inventory_trust_gate.status: trusted_empty" not in lower:
|
||||
reasons.append(
|
||||
"weak corroboration (recent merge commit) cannot substitute "
|
||||
"for pr_inventory_trust_gate.status == trusted_empty"
|
||||
)
|
||||
|
||||
role = (task_role or "").strip().lower()
|
||||
if role == "author" and re.search(
|
||||
r"reviewer queue|nothing to review|review backlog empty",
|
||||
text,
|
||||
re.I,
|
||||
):
|
||||
reasons.append(
|
||||
"author-bound session presented reviewer queue inventory as a "
|
||||
"reviewer decision"
|
||||
)
|
||||
|
||||
if missing:
|
||||
reasons.extend(
|
||||
f"empty-queue report missing required field: {field}"
|
||||
for field in missing
|
||||
)
|
||||
|
||||
proven = not reasons and not missing
|
||||
return {
|
||||
"claimed": True,
|
||||
"proven": proven,
|
||||
"block": not proven,
|
||||
"status": status_norm,
|
||||
"missing_fields": missing,
|
||||
"reasons": reasons,
|
||||
}
|
||||
|
||||
|
||||
def assess_duplicate_search_proof(report_text, matches):
|
||||
"""#207: reject LLM duplicate summaries that omit known title matches."""
|
||||
return issue_duplicate_gate.assess_duplicate_search_proof(
|
||||
|
||||
Reference in New Issue
Block a user