feat(author-workflow): enforce exact issue lock before branch/commit/push/PR (Closes #204)
This commit is contained in:
@@ -527,6 +527,35 @@ def assess_controller_handoff(report_text, role=None):
|
||||
"reasons": [f"handoff missing required field: {m}"
|
||||
for m in missing],
|
||||
}
|
||||
|
||||
# Validate issue/PR references for exact number and no forbidden terms (Issue #194 / #196)
|
||||
fields_dict = {}
|
||||
for line in section:
|
||||
stripped = line.strip().lstrip("-*").strip()
|
||||
if ":" in stripped:
|
||||
k, v = stripped.split(":", 1)
|
||||
fields_dict[k.strip().lower()] = v.strip()
|
||||
|
||||
for alias in ("selected issue", "pr number opened", "pr opened", "pr number", "selected pr"):
|
||||
val = fields_dict.get(alias)
|
||||
if val:
|
||||
numbers = re.findall(r"\d+", val)
|
||||
has_forbidden = any(term in val.lower() for term in ("equivalent", "related", "same", "/"))
|
||||
if len(numbers) != 1 or has_forbidden:
|
||||
field_name = "Selected issue/PR"
|
||||
for name, aliases in list(HANDOFF_BASE_FIELDS) + list(HANDOFF_ROLE_FIELDS.get(role or "", ())):
|
||||
if alias in aliases:
|
||||
field_name = name
|
||||
break
|
||||
return {
|
||||
"verdict": "incomplete",
|
||||
"downgraded": True,
|
||||
"missing_fields": [field_name],
|
||||
"reasons": [
|
||||
f"{field_name} must specify exactly one number and no ambiguous references (got: '{val}')"
|
||||
],
|
||||
}
|
||||
|
||||
return {
|
||||
"verdict": "complete",
|
||||
"downgraded": False,
|
||||
|
||||
Reference in New Issue
Block a user