Skip to content

Fix linkgraph purity-contract mismatch for wikilink resolution#739

Draft
jeduden wants to merge 2 commits into
mainfrom
claude/youthful-knuth-qdxlc9
Draft

Fix linkgraph purity-contract mismatch for wikilink resolution#739
jeduden wants to merge 2 commits into
mainfrom
claude/youthful-knuth-qdxlc9

Conversation

@jeduden

@jeduden jeduden commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Resolves plan 2607121915: go.md documented internal/linkgraph as "pure (no file reads, no workspace walks)" but NewWikilinkIndex and ResolveWikiLink both called fs.WalkDir, and they maintained two independent copies of the walk/match algorithm.

  • Deduplication: ResolveWikiLink now delegates to NewWikilinkIndex(root).Resolve(target) — the walk/match algorithm lives in one place.
  • Doc accuracy: go.md's internal/linkgraph entry now correctly scopes the purity guarantee to per-file extraction functions and documents NewWikilinkIndex, ResolveWikiLink, and WikilinkIndexFor as workspace-walking (with WikilinkIndexFor memoizing per run via lint.RunCache).
  • Stale comments fixed: NewWikilinkIndex's comment no longer claims a ResolveWikiLink fallback (circular after the refactor); wikilinkSearchKey's comment now references WikilinkIndex.Resolve and documents its pre-normalized-input contract.
  • Dead code removed: _ = from in ResolveWikiLink (Go function parameters don't need silencing); redundant strings.ReplaceAll backslash normalization in wikilinkSearchKey (already done by Resolve before calling it).
  • Test updated: TestWikilinkSearchKey drops the raw-backslash case (now belongs at the Resolve level, which already has it in TestWikilinkIndex_ResolveSemantics).

Test plan

  • go build ./... passes
  • go test ./internal/linkgraph/... ./cmd/mdsmith/... ./internal/rules/crossfilereferenceintegrity/... passes
  • go test ./... passes
  • mdsmith check . — 0 failures

Generated by Claude Code

claude added 2 commits July 13, 2026 00:13
ResolveWikiLink reimplemented the same fs.WalkDir stem/name search
as NewWikilinkIndex, duplicating ~70 lines of walk, filter, and
sort logic. Simplify it to delegate to NewWikilinkIndex(root).Resolve
so the walk/match algorithm lives in exactly one place.

Also narrows go.md's purity claim for internal/linkgraph: per-file
extraction functions are pure and goroutine-safe, while
NewWikilinkIndex and ResolveWikiLink walk the workspace.

Resolves plan/2607121915 acceptance criteria 1 and 2.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018boGj6rmVRTQPFqEYKK1rb
- Remove false fallback claim from NewWikilinkIndex comment (ResolveWikiLink
  now delegates to it, so there is no independent fallback path)
- Update wikilinkSearchKey comment to say it expects pre-normalized input
  and references WikilinkIndex.Resolve instead of ResolveWikiLink
- Remove redundant backslash normalization from wikilinkSearchKey (Resolve
  already normalizes before calling it); update TestWikilinkSearchKey to
  drop the now-invalid raw-backslash case (coverage stays in Resolve test)
- Remove _ = from dead code from ResolveWikiLink (Go params need no silencing)
- Clarify go.md: WikilinkIndexFor also walks on first use; memoizes via RunCache
- Mark plan 2607121915 as done with all acceptance criteria checked

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018boGj6rmVRTQPFqEYKK1rb
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (3d1cf7a) to head (950cf53).

Additional details and impacted files
Components Coverage Δ
Go 98.64% <100.00%> (+<0.01%) ⬆️
TypeScript 99.54% <ø> (ø)

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants