Skip to content

fix(lint): derive stub type from target path; slug-match sweep resolution - #753

Open
HUAN2022A wants to merge 1 commit into
nashsu:mainfrom
HUAN2022A:fix/issue-733-derive-stub-type-from-target-pat
Open

fix(lint): derive stub type from target path; slug-match sweep resolution#753
HUAN2022A wants to merge 1 commit into
nashsu:mainfrom
HUAN2022A:fix/issue-733-derive-stub-type-from-target-pat

Conversation

@HUAN2022A

Copy link
Copy Markdown

Fixes #733

Problem (both halves of the issue)

Part 1 — wrong stub type. Lint's "Fix broken link" keeps the broken target's directory but hard-codes type: query, producing pages like wiki/concepts/clash-detection.md with type: query. Those pages are then removed from the graph (HIDDEN_TYPES in wiki-graph.ts) and rejected by validateWikiPageRouting on the next write along that path — the app refuses content it created itself. The reporter accumulated 106 such pages, including their most-referenced page (160 inbound links), invisible in the graph.

Part 2 — "Create Page" and review sweeps never agree. Review-created pages get timestamped filenames (clash-detection-2026-09-06-143052.md) while sweepResolvedReviews resolves missing-page items on exact id/title match only, so the suggestion keeps coming back even though the page exists.

Fix

Part 1 (lint-fixes.ts, ~8 lines): new stubPageType(relativePath) derives the frontmatter type from the destination folder via the existing inferWikiTypeFromPath (which the issue notes was already there, UI-only until now): concepts/foo-bar.mdconcept; single-segment targets still land in queries/ as query (unchanged); unknown knowledge dirs (standards, playbooks, …) fall through to the directory name, matching what schema routing expects. Both "Fix" and "Fix All" call ensureBrokenLinkStub, so they're covered automatically.

Part 2 (sweep-reviews.ts, ~12 lines): buildWikiIndex now also indexes the slug of each page's frontmatter title (byTitleSlug), and pageExists gains a final rule: a candidate matches if its slug equals an indexed title slug — so a candidate named clash-detection resolves against the timestamped page. Titles containing no letters/digits are skipped when indexing (makeQuerySlug degenerates to "query" for those, which would let unrelated candidates collide). Deliberately not changed: the Create Page timestamp itself (intentional same-day overwrite protection, per the wiki-filename.ts docstring) and any migration of the reporter's 106 existing pages (better as a separate lint rule).

Testing

  • lint-fixes.test.ts: multi-segment targets now stub with type: concept / type: entity; single-segment regression (still query in queries/); unknown-dir fallback; stubPageType unit cases.
  • sweep-reviews-build-wiki-index.test.ts: slug indexed from frontmatter title of a timestamped page; pageExists positive (bare candidate ↔ timestamped page) and negative (unrelated name) cases; body-title lines still excluded from the index.
  • Targeted suites: 46 passed · npm run test:mocks: 132 files / 1886 tests passed · npm run typecheck: clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant