test: pin unescapeMdx's entity regex against the ESCAPES table - #847
Merged
mrbobbytables merged 1 commit intoSep 29, 2026
Merged
Conversation
unescapeMdx() matches a fixed alternation of character references and decodes each one through the module-level ESCAPES Map. The alternation and the Map keys are written out separately and nothing keeps them in step: an alternative added without a Map entry makes the lookup fall through and re-emit the raw reference, which shows through literally wherever unescaped text is rendered as a plain text node. Neither list is reachable from outside the module, and the existing unescapeMdx assertions only exercise references escapeMdx already produces - the subset that is in sync by construction - so no behavioural test can see the drift. Parse the source and assert both directions, plus that every table entry actually decodes. Closes #845 Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Improvement
Adds three contract tests to
tests/mdx-escape.test.mjscoveringunescapeMdx()inscripts/lib/mdx-escape.mjs. No production code changes.unescapeMdx()decodes by matching a fixed alternation of character references and looking each match up in the module-levelESCAPESMap. The alternation and the Map keys are written out separately, and nothing keeps them in step:Neither list is reachable from outside the module, and the file's existing
unescapeMdxassertions (unescapeMdx(escapeMdx(source)) === sourceandunescapeMdx('plain & simple')) only exercise referencesescapeMdx()already produces — precisely the subset that is in sync by construction. So the drift is invisible to a behavioural test. These tests read the source instead, the same idiom already used bytests/adr-contract.test.mjs,tests/docs-contract.test.mjsandtests/manifest-contract.test.mjs.Added:
every character reference unescapeMdx matches has an ESCAPES entryevery ESCAPES entry is reachable from the unescapeMdx regexunescapeMdx decodes every entry in the ESCAPES tableVerification
npm run test:unit— 1473 pass, 0 fail (2 pre-existing todo).npm run test:unit:coverage:check— exit 0.npx prettier --check tests/mdx-escape.test.mjs— clean.Each test was mutation-checked against the source to confirm it is not vacuous:
scripts/lib/mdx-escape.mjs|&to theunescapeMdxregexevery character reference unescapeMdx matches has an ESCAPES entryfails['e', 'e']ESCAPESrowevery character reference unescapeMdx matches has an ESCAPES entryfails['a', 'a']ESCAPESrowevery ESCAPES entry is reachable from the unescapeMdx regexandunescapeMdx decodes every entry in the ESCAPES tablefailThe source was restored after each mutation; this PR's diff touches
tests/mdx-escape.test.mjsonly.Scope
Claims
tests/mdx-escape.test.mjsand thescripts/lib/mdx-escape.mjsunescapeMdx/ESCAPEScluster. Checked for overlap against every open hold-gated PR: #810 (tests/import-architecture-issue.test.mjs,tests/helpers-import-issue-sandbox.mjs), #818 (tests/svg-active-content.test.mjs), #825 (tests/collect-case-studies.test.mjs,tests/import-architectures.test.mjs,tests/validate-architecture-assets.test.mjs), and the page-contract PRs #829, #832, #834, #838, #840, #844. None touchestests/mdx-escape.test.mjsorscripts/lib/mdx-escape.mjs.Related Issues
Closes #845
Refs #846 (needs-human: #846 deletes the unreachable
?? entityfallback inunescapeMdx(), which is production code and therefore outside this lane's PR scope — it needs a human or an ISSUES_PRS_MERGE agent to land. This PR makes the regex/table agreement that justifies that deletion machine-checked, so it should land first, but it deliberately leaves #846 open.)Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88