fix(lint): give broken-link stubs the type of the folder they land in (#733) - #746
Open
dajiaohuang wants to merge 1 commit into
Open
fix(lint): give broken-link stubs the type of the folder they land in (#733)#746dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
Wiki Lint's "Fix broken link" keeps the directory of the link it replaces but hard-coded `type: query` on the stub. Only `wiki/queries/` made that true. Everywhere else it did two kinds of damage at once: - `wiki-graph.ts` drops every node whose type is `query`, so the new page and all links pointing at it disappeared from the graph — which is also what made the Insights panel report the pages as isolated. - The project's own schema routing rejected the file on the next ingest, since a page under `wiki/concepts/` must carry `type: concept`. The app was refusing content it had written itself. `inferStubType()` now derives the type from the stub's destination directory. The project's `schema.md` is consulted first, because that table is exactly what `validateWikiPageRouting` validates against — and because the built-in directory map does not know custom folders, so it would answer `playbooks` where the schema declares `playbook` and the plural would still fail routing's exact match. With no schema to consult, `inferWikiTypeFromPath` (previously used only for UI labels) supplies the type; `query` stays the last resort. The schema is read after the exists-check, so the common "stub already there" path does no extra I/O. Not addressed: the second half of the report — `makeQueryFileName` always appending a `-YYYY-MM-DD-HHMMSS` suffix, so pages created from a review suggestion are never recognised by `sweepResolvedReviews`'s exact-name match and the suggestion returns on the next sweep. That changes the filename policy for every "Save to Wiki" write, well beyond this stub path, and belongs in its own change. Verified by 18 tests in `src/lib/lint-fixes.test.ts` (10 new), 8 of which fail against the unfixed source, including one asserting the generated frontmatter passes `validateWikiPageRouting`. Full mock suite (1909 tests) and `tsc --build` pass. Refs nashsu#733
dajiaohuang
force-pushed
the
fix/lint-stub-frontmatter-type
branch
from
September 11, 2026 10:53
1faa0cc to
bd328cd
Compare
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.
Refs #733 — addresses the first half of the report (the
type: querystubs).Wiki Lint's "Fix broken link" keeps the directory of the link it replaces but
hard-coded
type: queryon the stub. Onlywiki/queries/made that true.Everywhere else it did two kinds of damage at once:
src/lib/wiki-graph.ts:242drops every node whose type isquery(
HIDDEN_TYPES), so the new page and every link pointing at it vanishedfrom the graph. That is also what drove the inflated isolated-page count in
Insights.
under
wiki/concepts/must carrytype: concept. The app was refusingcontent it had written itself.
inferStubType()now derives the type from the stub's destination directory.The project's
schema.mdis consulted first, and that ordering is the partworth reviewing. The report suggested
inferWikiTypeFromPath, but that map isbuilt-in only: for the custom folders in the report's own measurements
(
playbooks/,standards/) it returns the plural directory name, which wouldstill fail
validateWikiPageRouting's exact match and leave the page droppedon the next ingest. The schema table is what routing actually validates
against, so it wins. With no schema to consult,
inferWikiTypeFromPath(previously used only for UI labels) supplies the type;
querystays the lastresort.
The schema is read after the exists-check, so the common "stub already there"
path does no extra I/O.
Not addressed
The second half of the report:
makeQueryFileNamealways appending-YYYY-MM-DD-HHMMSS, so a page created from a review suggestion is neverrecognised by
sweepResolvedReviews's exact-name match and the suggestionreturns on the next sweep. Fixing it changes the filename policy for every
"Save to Wiki" write, well beyond this stub path. I left it out deliberately
rather than smuggling a broad filename change into a lint fix — happy to do it
as a separate PR, or to fold it in here if you would rather review them
together.
Verification
10 new tests in
src/lib/lint-fixes.test.ts(8 of the 18 fail against theunfixed source), including one that feeds the generated frontmatter through
validateWikiPageRoutingand asserts it is accepted — the exact check thatused to reject it.
npx vitest run src/lib/lint-fixes.test.ts→ 18 passednpm run test:mocks→ 133 files / 1909 tests passed (no regressions)npx tsc --build→ cleannpx vite build→ succeedsStubs are identified downstream by
tags: [stub, lint], not by their type, andensureBrokenLinkStubhas only one production caller (lint-view.tsx), sonothing keys off the old
queryvalue. I have not run this against a real2,900-file wiki; the report's reproduction is the basis for the test fixtures.
🤖 Generated with Claude Code