Merge pull request 'feat: reject eligible/reviewed wording for already-landed PRs (Closes #298)' (#367) from feat/issue-298-already-landed-wording into master
This commit was merged in pull request #367.
This commit is contained in:
@@ -1242,6 +1242,102 @@ def assess_workspace_mutation_consistency(report_text, observed_commands=None):
|
||||
}
|
||||
|
||||
|
||||
# ── Already-landed report wording (Issue #298) ───────────────────────────────
|
||||
#
|
||||
# An already-landed PR is reconciliation-only: it must never be called
|
||||
# eligible, its head SHA must never be called reviewed, and the legacy
|
||||
# eligible/reviewed/scratch-worktree handoff fields must not appear.
|
||||
# Reviewed-head claims in any report require validation + diff review to
|
||||
# have actually passed.
|
||||
|
||||
ALREADY_LANDED_FORBIDDEN_PHRASES = (
|
||||
"oldest eligible pr",
|
||||
"next eligible pr",
|
||||
"pinned reviewed head",
|
||||
"scratch worktree used",
|
||||
)
|
||||
|
||||
ALREADY_LANDED_ELIGIBILITY_CLASS = "ALREADY_LANDED_RECONCILE_REQUIRED"
|
||||
|
||||
|
||||
def assess_already_landed_report_wording(report_text, *, already_landed,
|
||||
review_validated=False):
|
||||
"""#298: reject eligible/reviewed wording for already-landed PRs.
|
||||
|
||||
*already_landed* states whether the already-landed gate fired for the
|
||||
selected PR. *review_validated* states whether validation and diff
|
||||
review actually passed this session; only then may a reviewed head
|
||||
SHA be populated in a non-already-landed report.
|
||||
|
||||
Returns {'complete', 'downgraded', 'reasons'}; fails closed.
|
||||
"""
|
||||
text_lower = (report_text or "").lower()
|
||||
fields = _report_labeled_fields(report_text)
|
||||
reasons = []
|
||||
|
||||
reviewed_head = fields.get("reviewed head sha")
|
||||
reviewed_head_populated = bool(
|
||||
reviewed_head and not reviewed_head.strip().lower().startswith("none")
|
||||
)
|
||||
pinned_head_present = "pinned reviewed head" in fields
|
||||
|
||||
if already_landed:
|
||||
for phrase in ALREADY_LANDED_FORBIDDEN_PHRASES:
|
||||
if phrase in text_lower:
|
||||
reasons.append(
|
||||
f"already-landed report must not use '{phrase}'; the PR "
|
||||
"is reconciliation-only, not review/merge eligible"
|
||||
)
|
||||
|
||||
eligibility = fields.get("eligibility class", "")
|
||||
if ALREADY_LANDED_ELIGIBILITY_CLASS not in eligibility.upper():
|
||||
reasons.append(
|
||||
"already-landed report missing 'Eligibility class: "
|
||||
f"{ALREADY_LANDED_ELIGIBILITY_CLASS}'"
|
||||
)
|
||||
|
||||
for required in ("oldest open pr requiring action",
|
||||
"candidate head sha"):
|
||||
if required not in fields:
|
||||
reasons.append(
|
||||
f"already-landed report missing '{required}' field"
|
||||
)
|
||||
|
||||
if "reviewed head sha" not in fields:
|
||||
reasons.append(
|
||||
"already-landed report must state 'Reviewed head SHA: none'"
|
||||
)
|
||||
elif reviewed_head_populated:
|
||||
reasons.append(
|
||||
"already-landed report must not claim a reviewed head SHA; "
|
||||
"no validation or diff review passed for this PR"
|
||||
)
|
||||
|
||||
worktree_used = fields.get("review worktree used", "")
|
||||
if worktree_used.strip().lower() not in ("false", "no"):
|
||||
reasons.append(
|
||||
"already-landed report must state 'Review worktree used: "
|
||||
"false'"
|
||||
)
|
||||
elif not review_validated:
|
||||
if pinned_head_present:
|
||||
reasons.append(
|
||||
"'Pinned reviewed head' populated before validation and "
|
||||
"diff review passed"
|
||||
)
|
||||
if reviewed_head_populated:
|
||||
reasons.append(
|
||||
"reviewed head SHA populated before validation and diff "
|
||||
"review passed"
|
||||
)
|
||||
|
||||
return {
|
||||
"complete": not reasons,
|
||||
"downgraded": bool(reasons),
|
||||
"reasons": reasons,
|
||||
}
|
||||
|
||||
|
||||
def assess_role_boundary(proof=None, *, task_role=None, namespaces_used=None,
|
||||
justification=None):
|
||||
"""Assess reviewer/author role separation for blind queue workflows.
|
||||
|
||||
Reference in New Issue
Block a user