Repository navigation
Closed
Closed
Copy link
Labels
P3hamsterwheelenhancementNew feature or requestrulespackages/rules — audit rule definitionssize: Mhamsterwheel
Description
Part of #103 (V-05).
links/anchor-text is page-scope and looks only at a page's outgoing links, asking whether the
text is empty or generic. Nothing asks the question that actually matters for topicality: does the
anchor text pointing at a page have anything to do with that page?
Real remainders found across the audited sites, after the false positives were eliminated:
- A consultancy site —
how I work->/engage, x12, and it is the only anchor text that page
ever receives. squirrelscan.com—View all posts->/blog, x18.- An agency site — phrasal anchors like
wire that up->/services/analytics.
Chrome anchors are template text and must be excluded, or every site fails on its own nav.
Must-not-fire — four traps, each of which produced phantom findings
- Extract anchor text with a separator between child nodes. Concatenating them yields
CarpentryStructural & finish carpentrySee details, which matches nothing — 171 phantom
mismatches on one site from this alone. - Plurals must match.
Fridges->/repairs/fridgeis a match. Compare with a stem or prefix
rule, not set intersection. - Two-character brand tokens are real tokens.
LG->/brands/lgmust match; alength > 2
token filter drops the only word in the anchor. - Utility pages are never mismatch targets.
/privacy,/terms,/contactare linked with
boilerplate text by design.
And the counting rule, which is the subject of V-06 (#104): judge per (source page, target) pair,
not per link.
Depends on #109
Depends on #104
Acceptance Criteria
- New site-scope rule
links/anchor-mismatch, registered in the rules catalog - For each (source page, target page) pair joined by at least one contextual link, compares the pair's combined anchor text against the target's title, H1 and slug
- Warns only when no meaningful token is shared, and reports the anchor text, the target URL and the target's title
- Chrome links are excluded from the comparison entirely
- Anchor text extraction inserts a separator between child nodes; fixture: a card whose link wraps a heading and a description resolves to space-separated tokens
- Fixture: anchor
Fridges-> page titledFridge repairsat/repairs/fridge— no warning - Fixture: anchor
LG->/brands/lg— no warning - Fixture:
/privacylinked asPrivacyfrom every page — no warning - Fixture: anchor
click here-> a page titledCommercial freezer repairs— warns - Escalates in the message when the mismatching anchor is the ONLY contextual anchor text a page receives
- Byte-identical output across the legacy and
siteQuerypaths - Rule page added to
docs/andmake validatepasses there -
packages/audit-engine/tests/streaming-rules-canonical-golden.test.tsupdated: bumpv1.findings.lengthandv1.perRuleTally.lengthby exactly one each, and add a comment line naming this rule as the cause, matching the convention already used for the six rules above it
Metadata
Metadata
Assignees
Labels
P3hamsterwheelenhancementNew feature or requestrulespackages/rules — audit rule definitionssize: Mhamsterwheel
Activity
feat(rules): links/anchor-mismatch, inbound anchor text vs the target…
feat(rules): links/anchor-mismatch, inbound anchor text vs the target…
feat(rules): links/anchor-mismatch, inbound anchor text vs the target…
fix(rules): anchor-mismatch judges /?p=N targets, clipped glued parts…
feat(rules): links/anchor-mismatch, inbound anchor text vs the target…
fix(rules): anchor-mismatch judges /?p=N targets, clipped glued parts…
nc9 commentedon Nov 4, 2026
Acceptance check against main 26432b6 (rule landed as 94bc5ed and 447219c, first released in v0.0.165):
links/anchor-mismatch, registeredpackages/rules/src/links/anchor-mismatch.ts(scope: "site"),loadAllRules()returns it (317 rules, links category 14)AnchorGraphBuilder.addPagekeys pairs by (target, source);evaluateAnchorGraphcompares against title+H1 tokens plus slug tokens.anchor-mismatch.test.ts"the pair's combined anchor text is judged, per pair not per link"isContextualGraphLinkdropsisChrome; "chrome links are excluded entirely" (judged stays 1); also in the dual-path fixtureanchor-text-separator.test.ts"a card wrapping a heading and a description is space separated" (both extractors, exact string); rule test "real HTML through parsePage: a card link separates its words"Fridges->Fridge repairsat/repairs/fridge: no warningtokensMatchunit assertsLG->/brands/lg: no warningmeaningfulTokens("LG")is["lg"]/privacylinked from every page: no warningjudgedis 1, so the exclusion is what keeps it quietclick here->Commercial freezer repairswarnssiteQuerypathssite-query-link-rules-golden.test.ts"streaming path is deep-equal to legacy AND flags only the mismatch" (siteQuery run gets emptysite.pages) and four more dual-path cases;streaming-rules-canonical-golden.test.ts"v2 streaming snapshot is byte-identical to the v1 baseline" over the 518-page fixturedocs/,make validatepassesdocs/rules/links/anchor-mismatch.mdxread in full, listed indocs/docs.jsonand the links index;make validateindocs/passed (tangly check strict, links, glossary, 62 tests). Counts match code: Links 14 in README, docs index, rules index, seo indexstreaming-rules-canonical-golden.test.ts: findings 103745 -> 103746 and perRuleTally 316 -> 317, each with a comment naminglinks/anchor-mismatchRan on main, sequentially:
anchor-mismatch.test.ts,anchor-text-separator.test.tsandsite-query-link-rules-golden.test.ts(80 pass, 0 fail);streaming-rules-canonical-golden.test.tsandpage-link-rows-projection.test.ts(5 pass, 0 fail). Local bun was 1.4.3.Memory bounds are not an acceptance item but were read: pair, token, character and per-page caps are tested ("any dropped pair turns the only-anchor escalation off", "the token budget truncates too", "an over-long word is dropped"), and the streaming path keeps one page batch resident. No whole-engine memory measurement was run.
nik