| id | 171 | |
|---|---|---|
| title | MDS027 link-integrity hardening | |
| status | ✅ | |
| model | opus | |
| depends-on |
|
|
| summary | Extend MDS027 to validate image targets, resolve absolute paths against a configured site root, and cover reference-style links, gated by a shared `links:` config block. Add a subpath-baseURL regression test for the Hugo render-link hook. |
MDS027 passes three link forms silently. Close those blind spots. They are gaps G1–G3 in the link handling audit. Also lock in the G4 baseURL fix with a regression test.
The audit lives at
docs/research/links/README.md.
It found that
linkgraph.ExtractLinks
walks only *ast.Link with Reference == nil. So
MDS027
never resolves image targets (G1). It also
short-circuits absolute paths (G2).
It ignores reference-style links even though
ExtractRefLinks
already exists (G3). The audit decided to extend
MDS027 rather than split it. The new behavior is gated
by a shared links: block.
- Add a
links:config block parser:site-root,validate-images,validate-reference-style. Deep-merge per kind like every other rule config. - G1: walk
*ast.Imagein the MDS027 resolver behindvalidate-images(default on). Red test: a missingreports a broken target. - G3: feed
linkgraph.ExtractRefLinksthrough the same resolver behindvalidate-reference-style. Red test: a[a]with a broken[a]:def is flagged. - G2: when
site-rootis set, resolve absolute targets to a workspace path instead of short-circuiting. Red test:/docs/rules/MDS027/resolves; a missing one is flagged; unset preserves today's short-circuit. - G4 regression: assert the website render-link hook
prefixes site-absolute links with
site.Home.RelPermalinkunder a non-root baseURL. - Update MDS027's README and the audit doc's status if any decision changed during implementation.
- A broken
is flagged by MDS027 withvalidate-imageson and silent when off. - A broken reference-style target is flagged with
validate-reference-styleon. - An absolute target resolves against
site-rootwhen set and short-circuits when unset. - A subpath-baseURL regression test asserts the render-link prefix.
- All tests pass:
go test ./.... -
go tool golangci-lint runreports no issues.