Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion schemas/maintenance-plan.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"mise-php": {"type": "array", "items": {"type": "string"}}
}
},
"requiredChecks": {"type": "array", "items": {"type": "string"}, "const": ["Script checks"]},
"requiredChecks": {"type": "array", "items": {"type": "string", "enum": ["Script checks"]}, "minItems": 1, "maxItems": 1},
"releaseIntent": {
"type": ["object", "null"],
"additionalProperties": false,
Expand Down
9 changes: 8 additions & 1 deletion scripts/validate-structured-output-schemas
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def validate_node(node: Any, location: str) -> None:

if ("const" in node or "enum" in node) and "type" not in node:
fail(f"{location} uses const or enum without an explicit type")
if "const" in node and isinstance(node["const"], (dict, list)):
fail(f"{location} uses a non-scalar const unsupported by OpenAI Structured Outputs")

unsupported = sorted(UNSUPPORTED_KEYWORDS.intersection(node))
if unsupported:
Expand Down Expand Up @@ -82,7 +84,12 @@ def main() -> int:
if schema_pattern != ACTION_KEY_RE.pattern:
fail("maintenance plan actionKey pattern must match deterministic admission")
properties = document.get("properties", {})
if properties.get("requiredChecks", {}).get("const") != REQUIRED_PLAN_CHECKS:
required_checks = properties.get("requiredChecks", {})
if (
required_checks.get("items", {}).get("enum") != REQUIRED_PLAN_CHECKS
or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS)
or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS)
):
Comment on lines +87 to +92

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Require the requiredChecks node to remain an array.

This check validates items.enum and the bounds, but not requiredChecks.type. Since validate_node does not enforce array semantics, a malformed schema typed as a non-array could pass this deterministic-admission check. Also guard items with an explicit mapping check so malformed input produces fail() instead of an AttributeError.

Proposed fix
             required_checks = properties.get("requiredChecks", {})
             if (
-                required_checks.get("items", {}).get("enum") != REQUIRED_PLAN_CHECKS
+                not isinstance(required_checks, dict)
+                or required_checks.get("type") != "array"
+                or not isinstance(required_checks.get("items"), dict)
+                or required_checks["items"].get("enum") != REQUIRED_PLAN_CHECKS
                 or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS)
                 or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS)
             ):
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
required_checks = properties.get("requiredChecks", {})
if (
required_checks.get("items", {}).get("enum") != REQUIRED_PLAN_CHECKS
or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS)
or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS)
):
required_checks = properties.get("requiredChecks", {})
if (
not isinstance(required_checks, dict)
or required_checks.get("type") != "array"
or not isinstance(required_checks.get("items"), dict)
or required_checks["items"].get("enum") != REQUIRED_PLAN_CHECKS
or required_checks.get("minItems") != len(REQUIRED_PLAN_CHECKS)
or required_checks.get("maxItems") != len(REQUIRED_PLAN_CHECKS)
):
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/validate-structured-output-schemas` around lines 87 - 92, Update the
requiredChecks validation in the schema admission logic to require
required_checks.type to be "array" and verify required_checks.items is a mapping
before accessing its enum value. Route both violations through fail() while
preserving the existing enum and minItems/maxItems checks.

fail("maintenance plan requiredChecks must match deterministic admission")
evidence_pattern = (
properties.get("completionAssessment", {})
Expand Down
Loading