fix(validator): read frontmatter as YAML does #253
No reviewers
Labels
No labels
bug
cannot reproduce
duplicate
enhancement
help wanted
invalid
need info
need triage
need verification
not a bug
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
claudiomaradonna/agent-foundry!253
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "validator-frontmatter-delimiters"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The validator is the gate that keeps the agent adapters read-only, but
it selected the frontmatter region with awk programs that count a line
as a delimiter only when it is exactly
---, while OpenCode followsYAML document boundaries. On a file opening with a byte order mark —
or with trailing spaces, tabs, or CR breaks on the delimiters — the
two disagree: the pinned permissions block can sit in the body while
the frontmatter the client actually parses holds permissive rules, and
the check still printed
agent configuration statically valid. Issue#245 records the reproduction; at
6930f9cthe crafted{"action": "*","resource": "*","effect": "allow"}rule reached thechange reviewer's effective permissions with the validator green. The
same strictness refused honest files: an adapter saved with a BOM or
CRLF was rejected with a misleading "permissions block missing or
altered".
Closes #245
What changed
One
frontmatter_regionhelper inscripts/verify-agent-config.shnow selects the region the way OpenCode's YAML parser reads the
document boundary: it strips one leading BOM, drops a CR at each
line's end, accepts
/^---[ \t]*$/as the delimiter, and requires thefirst line (after the BOM) to be a delimiter with a closing one. When
no such region exists it yields nothing, so the pinned block
comparison and the skill
name:anddescription:greps refuse thefile instead of silently comparing body text.
check_skillandcheck_permissionsshare it. The check stays purely textual: no YAML-parser dependency.
The adapter and skill areas gained eleven cases: BOM, trailing-space,
and trailing-tab crafted adapters and a CR-crafted one, an adapter
with no closing delimiter, legitimate adapters opened with a BOM, a
trailing space, or CRLF endings, a skill with no closing delimiter, a
BOM'd skill hiding its name in the body, and a legitimate BOM'd
skill. The bypass-fixture helper derives its body copy from the
fixture's own permissions block and fails loudly when none exists, so
the crafted cases cannot pass vacuously if the pin ever changes.
How to verify
From a fresh checkout, base
6930f9cand branchvalidator-frontmatter-delimiters(7a5baef):bash tests/agent-config/reviewer-adapters.shwith this branch'stest files fails the bypass cases as
unexpectedly validand thelegitimate-shape cases with exit 1; at the tip the area passes
19/19 (all run).
repro.shfrom the issue's text printsPASS #245: validator rejected the crafted adapterwith the tip's script, whereat the base it prints
FAIL #245: validator accepted a crafted adapter(run on both).bash tests/agent-config/skills.sh11/11 at the tip;at the base with these test files the unclosed and BOM'd legitimate
skills fail (run).
bash tests/verify-agent-config.sh358/358,
.agents/hooks/shellcheck.sh repo51 files clean,prettier --check '**/*.md',scripts/verify-agent-config.shstatically valid,
git diff --check mainclean. The shipped adaptersand skills are unchanged and keep validating.
Considerations
BOM'd skill hiding its name (the old check refused it too, by a
different path) and the CR-crafted adapter.
parse-error shapes, duplicate keys) found no validator-accepted
shape that yields permissive effective rules.
touches only the validator and its tests.