refactor(frontmatter): unified frontmatter contract + handoff spec (ORCH-52c)

src/frontmatter.py grows from a single-key reader into the full machine
contract: reader (read_frontmatter_value, unchanged), one parse primitive
(parse_frontmatter), writer (render/write_frontmatter), schema validator
(validate_schema/REQUIRED_FIELDS, warning-only by default) and a shared
strip_frontmatter helper. The five verdict gates (check_reviewer_verdict,
_parse_tests_verdict, _parse_deploy_status, _parse_staging_status,
parse_security_status) now read through the single parse_frontmatter point
instead of duplicated ad-hoc YAML logic; review_parse._strip_frontmatter and
security_gate.extract_security_findings reuse the shared helper.

Strictly backward compatible + never-raise: STAGE_TRANSITIONS, the QG_CHECKS
composition, verdict semantics (incl. ORCH-047 three-field tester + negative
token priority), reason-strings and worktree->origin/main fallback are 1:1.
The schema validator never influences a gate verdict by default; hard-fail is
reserved behind the frontmatter_validation_strict kill-switch (default False).

New formal handoff spec docs/_standards/HANDOFF_PROTOCOL.md ("stage -> required
output" + required frontmatter schema), aligned 1:1 with PIPELINE_DOCS.md.

Tests: test_frontmatter.py (TC-01..07), test_qg_verdicts.py (TC-08..15),
test_security_gate.py (TC-12), test_stages_invariants.py (TC-16). Full
tests/ green (1212).

Refs: ORCH-076

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 14:03:49 +03:00
committed by orchestrator-deployer
parent 2030d1627a
commit 92961d1d32
14 changed files with 1043 additions and 109 deletions

View File

@@ -44,12 +44,15 @@ def _read(path: str) -> str | None:
def _strip_frontmatter(content: str) -> str:
"""Drop a leading ``--- … ---`` YAML frontmatter block, if present."""
if content.startswith("---"):
parts = content.split("---", 2)
if len(parts) >= 3:
return parts[2]
return content
"""Drop a leading ``--- … ---`` YAML frontmatter block, if present.
ORCH-52c: delegates to the unified ``frontmatter.strip_frontmatter`` helper
(single source of frontmatter logic). Behaviour is identical (only a well-formed
>= 3-segment leading block is stripped) and the never-raise -> input contract is
preserved.
"""
from .frontmatter import strip_frontmatter
return strip_frontmatter(content)
def _truncate(text: str, limit: int) -> str: