#!/usr/bin/env python3 """Validate Headroom PR template compliance for GitHub Actions.""" from __future__ import annotations import argparse import json import os import re import sys from dataclasses import asdict, dataclass, field from pathlib import Path from typing import Any COMMENT_MARKER = "" READY_LABEL = "status: ready for review" AUTHOR_ACTION_LABEL = "status: needs author action" REQUIRED_SECTIONS = ( "Description", "Type of Change", "Changes Made", "Testing", "Real Behavior Proof", "Runtime Rollout Safety", "Review Readiness", ) PROOF_FIELDS = ( "Environment", "Exact command / steps", "Observed result", "Not tested", ) ROLLOUT_FIELDS = ( "Rollout-managed feature(s)", "Minimum rollout channel", "Stable/default behavior changed", "Kill switch / disable path", "Unsafe override required", "Qualification impact", "Rollback path", ) # Conventional-commit types accepted by .commitlintrc.json. Keep the two in # sync: commitlint gates the *commits* on a PR, but the repo squash-merges, so # it is the PR *title* that becomes the subject line on main. COMMIT_TYPES = ( "build", "chore", "ci", "deps", "docs", "feat", "fix", "parity", "perf", "refactor", "revert", "style", "test", ) # type(optional-scope)!: subject TITLE_RE = re.compile(rf"^(?:{'|'.join(COMMIT_TYPES)})(?:\([^)]+\))?!?: .+") SECTION_RE = re.compile(r"^##\s+(.+?)\s*$", re.MULTILINE) CHECKBOX_RE = re.compile(r"^- \[(?P[ xX])\] (?P