Fix linkgraph purity-contract mismatch for wikilink resolution#739
Draft
jeduden wants to merge 2 commits into
Draft
Fix linkgraph purity-contract mismatch for wikilink resolution#739jeduden wants to merge 2 commits into
jeduden wants to merge 2 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Resolves plan
2607121915:go.mddocumentedinternal/linkgraphas "pure (no file reads, no workspace walks)" butNewWikilinkIndexandResolveWikiLinkboth calledfs.WalkDir, and they maintained two independent copies of the walk/match algorithm.ResolveWikiLinknow delegates toNewWikilinkIndex(root).Resolve(target)— the walk/match algorithm lives in one place.go.md'sinternal/linkgraphentry now correctly scopes the purity guarantee to per-file extraction functions and documentsNewWikilinkIndex,ResolveWikiLink, andWikilinkIndexForas workspace-walking (withWikilinkIndexFormemoizing per run vialint.RunCache).NewWikilinkIndex's comment no longer claims aResolveWikiLinkfallback (circular after the refactor);wikilinkSearchKey's comment now referencesWikilinkIndex.Resolveand documents its pre-normalized-input contract._ = frominResolveWikiLink(Go function parameters don't need silencing); redundantstrings.ReplaceAllbackslash normalization inwikilinkSearchKey(already done byResolvebefore calling it).TestWikilinkSearchKeydrops the raw-backslash case (now belongs at theResolvelevel, which already has it inTestWikilinkIndex_ResolveSemantics).Test plan
go build ./...passesgo test ./internal/linkgraph/... ./cmd/mdsmith/... ./internal/rules/crossfilereferenceintegrity/...passesgo test ./...passesmdsmith check .— 0 failuresGenerated by Claude Code