feat(preflight): block workspace edits before identity/capability verification (Closes #210)
This commit is contained in:
+19
-10
@@ -822,6 +822,7 @@ HANDOFF_BASE_FIELDS = (
|
||||
("Files changed", ("files changed", "changed", "files")),
|
||||
("Validation", ("validation",)),
|
||||
("Mutations", ("mutations",)),
|
||||
("Workspace mutations", ("workspace mutations",)),
|
||||
("Current status", ("current status", "status")),
|
||||
("Blockers", ("blockers",)),
|
||||
("Next", ("next",)),
|
||||
@@ -872,7 +873,7 @@ def _handoff_section_lines(report_text):
|
||||
return lines[start:]
|
||||
|
||||
|
||||
def assess_controller_handoff(report_text, role=None):
|
||||
def assess_controller_handoff(report_text, role=None, local_edits=False):
|
||||
"""Issue #182: final reports without a Controller Handoff downgrade.
|
||||
|
||||
Verdicts:
|
||||
@@ -897,10 +898,14 @@ def assess_controller_handoff(report_text, role=None):
|
||||
}
|
||||
|
||||
labels = []
|
||||
fields_dict = {}
|
||||
for line in section:
|
||||
stripped = line.strip().lstrip("-*").strip()
|
||||
if ":" in stripped:
|
||||
labels.append(stripped.split(":", 1)[0].strip().lower())
|
||||
k, v = stripped.split(":", 1)
|
||||
label = k.strip().lower()
|
||||
labels.append(label)
|
||||
fields_dict[label] = v.strip()
|
||||
|
||||
required = list(HANDOFF_BASE_FIELDS)
|
||||
required.extend(HANDOFF_ROLE_FIELDS.get(role or "", ()))
|
||||
@@ -919,15 +924,7 @@ 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:
|
||||
@@ -948,6 +945,18 @@ def assess_controller_handoff(report_text, role=None):
|
||||
],
|
||||
}
|
||||
|
||||
if local_edits:
|
||||
workspace_mutations_val = fields_dict.get("workspace mutations", "").strip().lower()
|
||||
if not workspace_mutations_val or workspace_mutations_val == "none":
|
||||
return {
|
||||
"verdict": "incomplete",
|
||||
"downgraded": True,
|
||||
"missing_fields": ["Workspace mutations"],
|
||||
"reasons": [
|
||||
"Workspace mutations cannot be 'none' or empty when local edits exist"
|
||||
],
|
||||
}
|
||||
|
||||
return {
|
||||
"verdict": "complete",
|
||||
"downgraded": False,
|
||||
|
||||
Reference in New Issue
Block a user