fix(ci): resolve lint and typecheck failures in structural validation module

ISSUES CLOSED: #11147
This commit is contained in:
CleverAgents Bot
2026-05-13 02:19:36 +00:00
committed by CleverThis
parent 3b3a318a4c
commit 65017576b1
+24 -14
View File
@@ -56,7 +56,7 @@ DECISION_CLI_REQUIRED_FIELDS: dict[str, type | tuple[type, ...] | None] = {
"sequence": int, # sequence_number
"question": str, # question text
"chosen": str, # chosen_option text
"confidence": (float, None), # ge=0.0, le=1.0 or None
"confidence": (float, type(None)), # ge=0.0, le=1.0 or None
"parent": str, # parent ULID or "(root)"
"is_correction": bool, # True / False
"superseded": bool, # True / False
@@ -151,8 +151,13 @@ def validate_plan_tree(nodes: list[dict[str, Any]]) -> dict[str, Any]:
# --- type ---
node_type = node.get("type")
if node_type is not None and (not isinstance(node_type, str) or not node_type.strip()):
errors.append(f"node[{idx}] 'type' must be a non-empty string")
if (
node_type is not None
and (not isinstance(node_type, str) or not node_type.strip())
):
errors.append(
f"node[{idx}] 'type' must be a non-empty string"
)
valid = False
# --- sequence ---
@@ -160,7 +165,8 @@ def validate_plan_tree(nodes: list[dict[str, Any]]) -> dict[str, Any]:
if seq is not None:
if not isinstance(seq, int) or isinstance(seq, bool) or seq < 0:
errors.append(
f"node[{idx}] 'sequence' must be a non-negative integer, got {seq!r}"
f"node[{idx}] 'sequence' must be a non-negative "
f"integer, got {seq!r}"
)
valid = False
else:
@@ -178,8 +184,13 @@ def validate_plan_tree(nodes: list[dict[str, Any]]) -> dict[str, Any]:
# --- question ---
question = node.get("question")
if question is not None and (not isinstance(question, str) or not question.strip()):
errors.append(f"node[{idx}] 'question' must be a non-empty string")
if (
question is not None
and (not isinstance(question, str) or not question.strip())
):
errors.append(
f"node[{idx}] 'question' must be a non-empty string"
)
valid = False
# --- children ---
@@ -236,7 +247,7 @@ def validate_decision_dict(d: dict[str, Any]) -> dict[str, Any]:
warnings: list[str] = []
valid = True
for field, expected in DECISION_CLI_REQUIRED_FIELDS.items():
for field in DECISION_CLI_REQUIRED_FIELDS:
if field not in d:
errors.append(f"missing required field: {field}")
valid = False
@@ -294,12 +305,11 @@ def validate_decision_dict(d: dict[str, Any]) -> dict[str, Any]:
valid = False
# --- sequence (int) ---
elif field == "sequence":
if not isinstance(value, int) or isinstance(value, bool):
errors.append(
f"'{field}' must be an integer, got {type(value).__name__}"
)
valid = False
elif not (isinstance(value, int) and not isinstance(value, bool)):
errors.append(
f"'{field}' must be an integer, got {type(value).__name__}"
)
valid = False
return {
"valid": valid,
@@ -476,8 +486,8 @@ def validate_structured_component_output(
__all__ = [
"DECISION_CLI_REQUIRED_FIELDS",
"PLAN_TREE_REQUIRED_KEYS",
"VALID_STATUSES",
"ULID_PATTERN",
"VALID_STATUSES",
"ValidationError",
"ValidationWarning",
"validate_decision_dict",