#!/usr/bin/env python3
"""The override-file acceptance matrix: which shapes parse, which warn, which
silently skip. Run from the OpenAnt checkout root."""
import os, sys, json, tempfile, io, contextlib
sys.path.insert(0, "libs/openant-core")
from pathlib import Path
from context import application_context as ac
fence = chr(96) * 3
body = {"application_type": "library", "purpose": "probe"}
cases = [
("json fence", "OPENANT.md", "# ctx\n" + fence + "json\n" + json.dumps(body) + "\n" + fence + "\n"),
("YAML frontmatter", "OPENANT.md", "---\napplication_type: library\npurpose: probe\n---\n"),
(".openant.md lowercase", ".openant.md", fence + "json\n" + json.dumps(body) + "\n" + fence + "\n"),
("CRLF file", "OPENANT.md", ("---\napplication_type: library\npurpose: probe\n---\n").replace("\n", "\r\n")),
("BOM + json fence", "OPENANT.md", "\ufeff" + fence + "json\n" + json.dumps(body) + "\n" + fence + "\n"),
("prose only", "OPENANT.md", "# My app\nThis is a library.\n"),
("uppercase JSON fence tag", "OPENANT.md", fence + "JSON\n" + json.dumps(body) + "\n" + fence + "\n"),
("untagged fence", "OPENANT.md", fence + "\n" + json.dumps(body) + "\n" + fence + "\n"),
("unclosed fence", "OPENANT.md", fence + "json\n" + json.dumps(body) + "\n"),
("BOM + YAML frontmatter", "OPENANT.md", "\ufeff---\napplication_type: library\npurpose: probe\n---\n"),
("leading blank line", "OPENANT.md", "\n---\napplication_type: library\npurpose: probe\n---\n"),
("empty file", "OPENANT.md", ""),
("fence missing purpose", "OPENANT.md", fence + "json\n" + json.dumps({"application_type": "library"}) + "\n" + fence + "\n"),
]
for label, fn, content in cases:
d = Path(tempfile.mkdtemp(prefix="mx.", dir=os.environ.get("TMPDIR")))
(d / fn).write_text(content)
err = io.StringIO()
with contextlib.redirect_stderr(err):
ctx = ac.check_manual_override(d)
outcome = ("parsed type=" + str(getattr(ctx, "application_type", None))) if ctx else "None"
warn = "WARNED" if err.getvalue().strip() else "silent"
print(f"{label:28s} -> {outcome:18s} [{warn}]")
Summary (likely cosmetic)
The UNSUPPORTED remedy says "create a manual OPENANT.md override file" but
not what the file must contain — and the override loader skips seven
near-miss shapes silently (no warning): prose-only, an uppercase
JSONfence tag, an untagged fence, an unclosed fence, a BOM before YAMLfrontmatter, a leading blank line before frontmatter, and an empty file.
Only one failure mode warns (a missing key inside an otherwise-parsed fence).
Mechanism (at
ad2bb7e)context/application_context.py:106— the remedy line: "To analyze thisrepository, create a manual OPENANT.md override file." No shape stated.
check_manual_override,:661-714):.mdvia a json fence(the
re.searchat:695) or YAML frontmatter (there.matchat:701),.jsondirectly (:687-689); theexceptat:710warns onparse errors — but a file whose fence/frontmatter did not
match falls through both
ifs to thereturn Noneat:713with nowarning (the only
continue, at:685, is the file-absent branch).Executed at
ad2bb7eoverride_matrix.py — full script
The ask (two halves)
frontmatter declaring
application_typeandpurpose(a one-line fix at:106).in the matrix falls through the same two missed
ifs to the onereturn None, so a single warning on that path covers all seven — theway the missing-key parse error already warns. (A maintainer who instead
widens the matcher — the BOM-before-frontmatter and leading-blank-line
cases are matcher quirks — makes those shapes parse, which equally
removes their silence.)
Falsifier
The remedy naming the shape, and the fall-through path at the loader
warning (or the matcher widened so the quirk shapes parse). Authored at
filing time; no falsifier existed in the source record.
Prior art
None on the message or the loader's silence. An earlier one-line version of
this note landed in #720's thread (the UNSUPPORTED raise is that issue's
trigger); this issue supersedes it — the silent-skip set measured here is
broader than that note's "prose-only", and the remedy belongs to this file,
not that mechanism.
Fix-direction: neither — diagnostics and wording; no finding changes.