Repository navigation
fix(quality): derive instruction tokens from parsed frontmatter - #356
Conversation
Signed-off-by: YMuskrat <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Reviewed head a16c0591 against main 55d8b8d4.
The fix works for the cases it targets. A --- inside a quoted value, a nested value or a YAML comment no longer inflates the estimate, and 7 of the 8 new cases fail on main. I ran the validator on every tracked SKILL.md on both trees. Only text-analyzer (359 to 358) and tests/fixtures/skills/simple (81 to 80) change; scores, totals, frontmatter tokens and issues are identical. Nothing in scoring, deductions or the gate reads instructions_tokens.
I've left one P3 inline: an unclosed or empty frontmatter block followed by a body --- still produces an estimate, which the new CHANGELOG sentence says no longer happens.
chrisknvidia
left a comment
There was a problem hiding this comment.
Reviewed. Using the parser's body group is the right direction, and the quoted/nested/comment --- cases are covered well.
+1 to the open P3 thread on quality_score.py:882, which I reproduced on the current head (a16c059):
SKILL.md |
frontmatter_tokens |
instructions_tokens |
|---|---|---|
unclosed frontmatter, then a body --- thematic break |
22 | 4 |
empty ---\n---\n block, then a body --- |
14 | 4 |
Both estimates still come from body text even though no valid frontmatter was parsed, which contradicts the new CHANGELOG sentence. Gating both assignments on a successful parse (if fm_match and _frontmatter:) and adding the "unclosed frontmatter + later body ---" case to test_instruction_tokens_do_not_infer_frontmatter_from_body_separators would close it.
CI has not run on this fork PR yet, so it needs a maintainer to approve the workflow run.
Require successful frontmatter parsing before estimating frontmatter and instruction tokens. Cover unclosed and empty blocks followed by a body separator, plus invalid YAML. Merge upstream main d136a59 and preserve its changelog while placing this fix under Unreleased. Signed-off-by: Codex <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
LGTM at a2c7b76. My earlier point is addressed: both token estimates are now set only when _parse_frontmatter returned a mapping (if fm_match and _frontmatter:), which matches how has_frontmatter is decided, and the unclosed / empty / invalid-YAML cases with a later body --- are covered and assert zero for both estimates.
Checked locally:
tests/validatorspasses apart from 12test_plugin_dependencies.pyfailures that fail identically on the base commitd136a59in my environment, so they are unrelated to this change.ruff checkandruff format --checkare clean on the changed files.
No further concerns from me.
Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
All review comments are addressed. Both token estimates require successfully parsed frontmatter, with regressions for unclosed/empty frontmatter plus a later body separator and invalid YAML. Resolved the CHANGELOG-only conflict with current main while preserving both sets of entries. Fresh verification on the merged tree: 406 quality/schema/frontmatter tests passed; src/tests lint, changed-file formatting and PR whitespace checks passed.
Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Reconfirmed approval after moving the same changelog entry within Fixed to avoid a second conflict with PR #357. Source and test trees are identical to the tested 2b9ab75 revision (406 quality/schema/frontmatter tests passed). Verified the two PRs now merge cleanly in a local squash-merge simulation; whitespace checks pass.
rng1995
left a comment
There was a problem hiding this comment.
Reconfirmed approval on the new main-merge commit. The PR diff against current main remains the intended three files, and the quality validator and regression tests are byte-for-byte unchanged from the previously approved revision. Fresh validation on this head: 406 quality/schema/frontmatter tests passed; changed-file lint, formatting and PR whitespace checks passed. All review threads remain addressed.
Summary
The Tier 1 instruction-token estimate finds the first literal
---after the opening delimiter. Valid YAML values or comments containing that text therefore make it count metadata as instructions. A horizontal rule in a document without frontmatter can also produce a spurious estimate.Use the Markdown-body group from the existing frontmatter parser for the estimate. Tests exercise quoted descriptions, nested metadata, YAML comments, LF/CRLF, body-only separators and unclosed frontmatter. Seven of the eight new cases failed before the change.
Total/frontmatter token estimates, quality deductions and the minimum-score gate retain their existing behavior. The packaged text-analyzer still scores 84.5/B; its instruction estimate changes from 359 to 358 because the closing-delimiter newline is excluded.
Verification
make lintand changed-file formatting checks passed.make buildproduced the wheel and source distribution.make testwith two workers and a first-failure limit: 824 passed, 2 skipped, 2 failed before stopping. Both failures also occur on unchanged upstream55d8b8d: the GitLab template test cannot create its hard-coded/tmpdirectory in this sandbox, and the standalone provenance test returns norun_dir(cause not diagnosed). Full-suite success is not claimed.Validated on Python 3.12 with the repository's locked all/dev dependencies; no live model requests.
Release Impact
CHANGELOG.md.