Skip to content

fix(catalog): hidden-unicode scans decoded front matter strings (#1334) - #1341

Open
vchamarthi wants to merge 3 commits into
intel:mainfrom
vchamarthi:issue-1334-scan-decoded-front-matter-strings
Open

vchamarthi wants to merge 3 commits into
intel:mainfrom
vchamarthi:issue-1334-scan-decoded-front-matter-strings

Conversation

@vchamarthi

Copy link
Copy Markdown
Contributor

Summary

catalog check reported when_to_use: "Use when x\u202ey" as ok, because hidden-unicode read only the raw file text. This change scans the YAML-decoded front matter strings as well. Fixes #1334. Related: #1285, whose description case is covered because every key is walked.

Changes

  • dokimi/external/content_checks.py: _front_matter_hits composes the front matter with yaml.compose, visits each scalar node once, and reports each hidden character that the scalar's own source text does not hold literally, with its key path and the same cap as a file's hits. It is called for SKILL.md only.
  • tests/test_content_checks.py: tests for each key, nested values, the cap, the literal case, the clean controls and broken front matter.
  • A changelog fragment.
  • docs/external-content.md: the hidden-unicode entry says that decoded front matter escapes are reported.
  • _hidden_indices holds the hidden-character rules (including the filler count per line) for both the raw and the decoded scan; the decoded scan treats the start of a value as not the start of a file.

Risk

Front matter is parsed a second time for each skill. Skills that held a double-quoted escape of a hidden character get a new warn; nothing else changes. Invalid YAML adds no finding here.

Testing

python -m pytest -q -p no:cacheprovider tests/test_content_checks.py tests/test_growth_ratchet.py passes, and python -m ruff check on the two changed .py files passes.

Open questions

None beyond the listed choices.

  • I chose Compare each scalar's decoded value with its own source slice (yaml.compose node marks) and report only the surplus, with the key path in the message over A file-wide count of literal characters, which a literal character in a comment or an aliased value can use up: It is the per-string comparison the issue describes, and needs no second YAML parser. Is that the behaviour you want?
  • I chose Treat front matter that does not compose as having no decoded finding over Reporting the YAML error here: The loader already names that error (the issue and design A say to skip on a parse error). Is that the behaviour you want?

Revert

Revert the commit; nothing is stored.

Checklist

See the boxes.

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

Review points edit lines of recent commits: dokimi/dokimi/external/content_checks.py (bee8c63 fix(catalog): report runs of more than three script fillers as hidden-). Each commit's own tests still pass; none of their assertions changes except those listed above for a scenario of the issue.

Checklist evidence
  • Tests added/updated and pytest passes: 1 test file(s) changed; suite: 33786 passed; 1 failing test(s) fail on the base branch too: tests/test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart; 9 of 10 proof(s) fail before the change; 1 pin behaviour the base code already had
  • ruff, mypy, and schema checks pass: passed: ci.yml:static / ruff check, ci.yml:typecheck / mypy, ci.yml:static / schema-check, ci.yml:static / schema_compat vs the PR base
  • Docs updated (or N/A): updated: dokimi/docs/external-content.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md: nothing left open; mutation of changed lines ran
  • Each new raise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue
  • No ad-hoc run artifacts committed: 1 added file(s), none a run's output
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml): no new source file

Fixes #1334.

…l#1334)

content_findings passed only the raw SKILL.md text to the hidden-unicode
check, so a bidi, tag or zero-width character written as a YAML escape in a
double-quoted front matter value was never reported. The decoded strings of
the front matter, under any key, are now scanned too; a literal character
already reported from the raw text is not reported twice. Also covers the
description case of intel#1285.

Fixes intel#1334

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi
vchamarthi requested a review from a team as a code owner November 27, 2026 17:16
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 17:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Decoded metadata keys can inject terminal-control sequences into warnings, while escaped-character detection can miss hidden characters or duplicate reports and quote scanning scales quadratically.

3 open issues
What changed in this PR

3 new findings.

Extends catalog check to detect hidden Unicode characters produced by YAML decoding in SKILL.md front matter, addressing #1334 and the description case in #1285.

Changes:

  • Adds decoded scalar scanning with key-path diagnostics.
  • Shares hidden-character rules between raw and decoded scans.
  • Adds regression tests, documentation, and a changelog fragment.
File Description
dokimi/​tests/​test_content_checks.py Tests escapes, aliases, literals, reporting limits, and malformed front matter.
dokimi/​dokimi/​external/​content_checks.py Adds decoded front matter scanning and shared detection helpers.
dokimi/​docs/​external-content.md Documents warnings for decoded front matter escapes.
dokimi/​changelog.d/​20261127_120000_hidden-unicode-front-matter-escapes.md Records the expanded hidden-Unicode detection.

Review effort: Balanced

@codecov-commenter

codecov-commenter commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 90.98361% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.18%. Comparing base (1673824) to head (4e2fdbd).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
dokimi/dokimi/external/content_checks.py 90.98% 6 Missing and 5 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1341      +/-   ##
==========================================
- Coverage   96.19%   96.18%   -0.01%     
==========================================
  Files         499      499              
  Lines       66465    66781     +316     
  Branches    11542    11624      +82     
==========================================
+ Hits        63933    64233     +300     
- Misses       1563     1570       +7     
- Partials      969      978       +9     
Files with missing lines Coverage Δ
dokimi/dokimi/external/content_checks.py 94.49% <90.98%> (-2.33%) ⬇️

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@exai-bot

exai-bot commented Nov 27, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 4 selected item(s).

CI at 4e2fdbd: 21 passing, 4 skipped.

Test notes (2)
  • dokimi/dokimi/external/content_checks.py:293: With while i >= 0: changed to while i > 0:, the tests still pass: dokimi/tests/test_content_checks.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
  • dokimi/dokimi/external/content_checks.py:298: With while j > 0 and span[j - 1] == "\\": # the run of backslashes right before this quote changed to while j >= 0 and span[j - 1] == "\\": # the run of backslashes right before this quote, the tests still pass: dokimi/tests/test_content_checks.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
Review details
  • Commit reviewed: 4e2fdbd against merge base 1673824
  • Coverage: 4 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 159k tokens (90k from cache), 1m14s
  • Tool calls: 15 (10 file_read, 2 code_search, 1 ci_status, 1 file_find, 1 local_check_results)
  • Hidden Unicode front-matter escape checks, tests, and documentation: 4 files

…scan (intel#1334)

Track which decoded characters an escape wrote instead of subtracting
codepoint counts, so a literal character no longer hides an escape or
turns folded literal fillers into escape findings. Find the opening quote
in linear time and write control characters of a key as escapes in the
warning.

Keep a blank line after an escaped line break as a newline, so the decoded
value matches YAML's and its escapes are reported.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

This is ready for another look: I've pushed 1 commit on issue-1334-scan-decoded-front-matter-strings (f3be363..4e2fdbd).

Changes:

  • Control characters in a decoded key are written as escapes in the warning.
  • Folded literal fillers are no longer reported as escapes.
  • A blank line after an escaped line break is kept as a newline in the decoder.

Threads:

  • I answered each one in its thread: 4 fixed.

What I checked on the new commit:

  • 2 of 3 new tests fail before the fix and pass after it; the other passes before the fix too, so it guards the change rather than reproduce a bug.
  • One thread I marked fixed has no test of its own; the reply there says what changed.
  • The full test suite passes with main merged in (33,891 tests), apart from 1 failure main has too.
What each test shows
  • key control characters are escaped: fails before, passes after.
  • folded literal fillers are not escapes: fails before, passes after.
  • literal beside escape: passes.
  • many escaped quotes: passes.
  • escape after escaped break and blank line: passes before the fix too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scan decoded front matter strings in hidden-unicode: skills flagged on an escape fixture go from 1 to 6

4 participants