fix: resolve conflicts for PR #352 against current master
This commit is contained in:
@@ -1052,6 +1052,15 @@ def _prs_from_list_response(list_prs_response: list | dict | None) -> list | Non
|
||||
return None
|
||||
|
||||
|
||||
# ── Linked-issue consistency (Issue #314) ────────────────────────────────────
|
||||
#
|
||||
# Stale linked-issue text from a previous PR must not leak into a final
|
||||
# report: the "Linked issue status" field must match the issue(s) the
|
||||
# selected PR actually links, verified live this session, and no other
|
||||
# "Issue #N" mention may appear unless it is a verified linked issue.
|
||||
|
||||
_ISSUE_MENTION_RE = re.compile(r"\bissue\s+#(\d+)", re.IGNORECASE)
|
||||
|
||||
# ── Workspace-vs-worktree mutation consistency (Issue #313) ──────────────────
|
||||
#
|
||||
# A worktree reset/checkout/clean is a workspace mutation even when the
|
||||
@@ -1092,6 +1101,68 @@ def _report_labeled_fields(report_text):
|
||||
return fields
|
||||
|
||||
|
||||
def _issue_numbers_mentioned(text):
|
||||
"""Return the set of ints referenced as 'Issue #N' in *text*."""
|
||||
return {int(n) for n in _ISSUE_MENTION_RE.findall(text or "")}
|
||||
|
||||
|
||||
def assess_linked_issue_consistency(report_text, *, selected_pr=None,
|
||||
linked_issues=None):
|
||||
"""#314: linked-issue status must match the selected PR, live-verified.
|
||||
|
||||
*linked_issues* is the list of issue numbers the selected PR was
|
||||
live-verified to link this session, or None when no live verification
|
||||
happened. Without live proof the report may only say the status was
|
||||
not verified; with proof, the ``Linked issue status`` field must name
|
||||
every linked issue and no stale issue number may appear anywhere in
|
||||
the report.
|
||||
|
||||
Returns {'complete', 'downgraded', 'reasons'}; fails closed.
|
||||
"""
|
||||
fields = _report_labeled_fields(report_text)
|
||||
status_value = fields.get("linked issue status")
|
||||
|
||||
reasons = []
|
||||
|
||||
if status_value is None:
|
||||
reasons.append(
|
||||
"final report missing 'Linked issue status' field for the "
|
||||
"selected PR"
|
||||
)
|
||||
elif linked_issues is None:
|
||||
if not status_value.strip().lower().startswith("not verified"):
|
||||
reasons.append(
|
||||
"linked issue status claimed without live proof; report "
|
||||
"'Linked issue status: not verified in this session' or "
|
||||
"verify the linked issue live"
|
||||
)
|
||||
else:
|
||||
allowed = set(linked_issues)
|
||||
status_mentions = _issue_numbers_mentioned(status_value)
|
||||
for missing in sorted(allowed - status_mentions):
|
||||
reasons.append(
|
||||
f"linked issue #{missing} of selected PR "
|
||||
f"#{selected_pr} not reported in 'Linked issue status'"
|
||||
)
|
||||
for stale in sorted(status_mentions - allowed):
|
||||
reasons.append(
|
||||
f"'Linked issue status' names issue #{stale}, which is "
|
||||
f"not a live-verified linked issue of selected PR "
|
||||
f"#{selected_pr}"
|
||||
)
|
||||
for stale in sorted(_issue_numbers_mentioned(report_text) - allowed):
|
||||
reasons.append(
|
||||
f"stale issue #{stale} mentioned in final report but not "
|
||||
f"live-verified as linked to selected PR #{selected_pr}"
|
||||
)
|
||||
|
||||
return {
|
||||
"complete": not reasons,
|
||||
"downgraded": bool(reasons),
|
||||
"reasons": reasons,
|
||||
}
|
||||
|
||||
|
||||
def _field_claims_none(fields, label):
|
||||
"""True when *label* is present and its value is empty or 'none...'."""
|
||||
value = fields.get(label)
|
||||
@@ -3798,6 +3869,111 @@ def assess_reviewer_baseline_validation_proof(
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Full-suite failure approval gate (#323)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def assess_full_suite_failure_approval_gate(
|
||||
*,
|
||||
review_decision: str,
|
||||
full_suite_passed: bool | None,
|
||||
baseline_validation: dict | None = None,
|
||||
baseline_proof: dict | None = None,
|
||||
report_text: str | None = None,
|
||||
project_root: str | None = None,
|
||||
) -> dict:
|
||||
"""#323: approving a PR whose full suite fails requires baseline proof.
|
||||
|
||||
Default action on a full-suite failure is REQUEST_CHANGES. Approval is
|
||||
allowed only when the #325 baseline proof passes in full (branches/
|
||||
worktree, pinned SHAs, matching failure signatures) and the extra #323
|
||||
fields prove the failures are pre-existing: ``pr_suite_command``,
|
||||
``baseline_suite_command``, ``new_tests_passed``, and a non-empty
|
||||
``unrelated_explanation``.
|
||||
|
||||
*review_decision* is the decision the workflow intends to submit; only
|
||||
``approve`` can be blocked. ``block`` is True when an approval was
|
||||
requested that the proofs do not allow.
|
||||
"""
|
||||
decision = (review_decision or "").strip().lower().replace("-", "_")
|
||||
wants_approval = decision == "approve"
|
||||
reasons: list[str] = []
|
||||
|
||||
if full_suite_passed is True:
|
||||
return {
|
||||
"approve_allowed": True,
|
||||
"block": False,
|
||||
"default_action": "proceed",
|
||||
"reasons": [],
|
||||
}
|
||||
|
||||
default_action = "request_changes"
|
||||
|
||||
if full_suite_passed is None:
|
||||
reasons.append(
|
||||
"full-suite result not proven; approval requires a recorded "
|
||||
"full-suite command and result (#323)"
|
||||
)
|
||||
else:
|
||||
if baseline_validation is None:
|
||||
baseline_validation = assess_reviewer_baseline_validation_proof(
|
||||
baseline_proof=baseline_proof,
|
||||
report_text=report_text,
|
||||
project_root=project_root,
|
||||
)
|
||||
proof = baseline_proof or {}
|
||||
|
||||
if not proof:
|
||||
reasons.append(
|
||||
"full suite failed but no baseline proof was provided; "
|
||||
"default action is REQUEST_CHANGES (#323)"
|
||||
)
|
||||
if not baseline_validation.get("proven"):
|
||||
reasons.append(
|
||||
"baseline validation proof missing or failed (#323/#325)"
|
||||
)
|
||||
reasons.extend(baseline_validation.get("reasons", []))
|
||||
|
||||
if proof:
|
||||
worktree = (proof.get("worktree_path") or "").strip()
|
||||
if not _path_under_branches(worktree, project_root):
|
||||
reasons.append(
|
||||
"baseline comparison must run in a clean baseline "
|
||||
"worktree under branches/, not the main checkout (#323)"
|
||||
)
|
||||
if not (proof.get("pr_suite_command") or "").strip():
|
||||
reasons.append(
|
||||
"PR full-suite command/result missing from baseline "
|
||||
"proof (#323)"
|
||||
)
|
||||
if not (proof.get("baseline_suite_command") or "").strip():
|
||||
reasons.append(
|
||||
"baseline full-suite command/result missing from "
|
||||
"baseline proof (#323)"
|
||||
)
|
||||
if proof.get("new_tests_passed") is not True:
|
||||
reasons.append(
|
||||
"proof that new/changed tests passed is missing (#323)"
|
||||
)
|
||||
if not (proof.get("unrelated_explanation") or "").strip():
|
||||
reasons.append(
|
||||
"explanation why failures are unrelated to the PR is "
|
||||
"missing (#323)"
|
||||
)
|
||||
if proof.get("failure_signatures_match") is not True:
|
||||
reasons.append(
|
||||
"PR and baseline failure signatures do not match; "
|
||||
"request changes (#323)"
|
||||
)
|
||||
|
||||
approve_allowed = not reasons
|
||||
return {
|
||||
"approve_allowed": approve_allowed,
|
||||
"block": wants_approval and not approve_allowed,
|
||||
"default_action": "proceed" if approve_allowed else default_action,
|
||||
"reasons": reasons,
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Identity disclosure (#305)
|
||||
@@ -3880,6 +4056,13 @@ def assess_email_disclosure(
|
||||
}
|
||||
|
||||
|
||||
def assess_reviewer_fallback_report(report_text, **kwargs):
|
||||
"""#324: block local Gitea fallbacks during normal reviewer workflows."""
|
||||
from reviewer_fallback import assess_reviewer_fallback_report as _assess
|
||||
|
||||
return _assess(report_text, **kwargs)
|
||||
|
||||
|
||||
def assess_final_report_validator(report_text, task_kind, **kwargs):
|
||||
"""#327: single entry point for task-specific final-report validation."""
|
||||
from final_report_validator import assess_final_report_validator as _validate
|
||||
@@ -4270,8 +4453,22 @@ def assess_git_ref_mutation_report(report_text, *, command_log=None):
|
||||
}
|
||||
|
||||
|
||||
def assess_prior_blocker_skip_proof(report_text, **kwargs):
|
||||
"""#318: require live blocker proof before skipping earlier open PRs."""
|
||||
from reviewer_blocker_skip import assess_prior_blocker_skip_proof as _assess
|
||||
|
||||
return _assess(report_text, **kwargs)
|
||||
|
||||
|
||||
def assess_non_mergeable_skip_proof(report_text, **kwargs):
|
||||
"""#322: require conflict proof when skipping non-mergeable PRs."""
|
||||
from reviewer_mergeability_skip import assess_non_mergeable_skip_proof as _assess
|
||||
|
||||
return _assess(report_text, **kwargs)
|
||||
|
||||
|
||||
def assess_worktree_ownership_report(report_text, **kwargs):
|
||||
"""#312: prove session-owned or safe-reuse worktree before reset/validation."""
|
||||
from reviewer_worktree_ownership import assess_worktree_ownership_report as _assess
|
||||
|
||||
return _assess(report_text, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user