Skip to content

fix(indexer): emit exact file paths for the root component instead of a glob - #70

Closed
MrSampson wants to merge 1 commit into
davesheffer:mainfrom
MrSampson:fix-root-component-glob
Closed

fix(indexer): emit exact file paths for the root component instead of a glob#70
MrSampson wants to merge 1 commit into
davesheffer:mainfrom
MrSampson:fix-root-component-glob

Conversation

@MrSampson

Copy link
Copy Markdown
Contributor

Summary

deriveComponents() in src/extractors/indexer.ts emits paths: [dir + "/**"] for every component derived from the directory layout. For the root-level component (dir === ".", holding files with no directory — README.md, package.json, etc.), this produces paths: ["./**"].

Two downstream path matchers read that glob inconsistently:

  • src/core/glob.ts's norm() strips a leading ./ before matching, so "./**" normalizes to "**", which matches every file in the repo, not just root-level ones.
  • src/wiki/wiki.ts's globPrefix()/owns() do not strip the leading ./: globPrefix("./**") returns "./", and owns() then checks f.startsWith("./") against a real file path like "README.md" — which is never true. So the wiki's root component page currently owns nothing.

So the same "./**" glob simultaneously over-matches in one consumer and under-matches in another, depending on which one reads it.

Fix

Root-level files are a small, static set — list them exactly instead of globbing:

paths: dir === "." ? [...fileSet].sort() : [dir.endsWith("/") ? dir + "**" : dir + "/**"],

pathMatchesGlob's exact-match fast path and owns()'s exact/prefix check already handle a glob-char-free path correctly, so no changes were needed to glob.ts or wiki.ts — confined to the one producer.

Test plan

  • New test in test/indexer.test.ts: a fixture repo with a root-level file and a src/ file — asserts the root component's paths is an exact file list with no glob characters, and that a non-root component is unaffected (still gets a directory glob).
  • New test in test/wiki.test.ts: constructs the fixed shape directly (paths: ["README.md"]) and confirms assemblePack's existing owns()/globPrefix() machinery already handles it correctly — proving the practical downstream fix without needing any change in wiki.ts itself.
  • Full suite: 1153 tests, 1151 pass, 1 skipped, 1 pre-existing unrelated failure (team-route-contract.test.ts, a doctor schema version-string assertion, independently confirmed to fail identically on unmodified main). npm run typecheck clean.

@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hunch Ready Ready Preview Aug 22, 2026 7:21pm

… a glob

deriveComponents() emitted paths: ["./**"] for the root-level component
(files with no directory, e.g. README.md). src/core/glob.ts's pathMatchesGlob
strips a leading "./" before matching, so "./**" normalizes to "**" and
matches every file in the repo. src/wiki/wiki.ts's owns()/globPrefix() do not
strip it, so "./**" matches nothing there. The same glob was silently
interpreted two different ways by two consumers.

Root-level files are a small, known set once symbols are indexed, so list
them exactly instead of globbing. Both consumers already handle a
glob-char-free path correctly via their exact-match fast paths, so no
changes were needed in glob.ts or wiki.ts.
@MrSampson

Copy link
Copy Markdown
Contributor Author

Closing — main has already absorbed this exact fix (identical logic, same root cause, referencing the same issue #34) via a separate sync from the fork this PR was cut from. Confirmed on current main:

  • src/extractors/indexer.ts's deriveComponents() already has the dir === "." ? [...fileSet].sort() : ... exact-file-list fix.
  • test/indexer.test.ts already has "root-level indexed files get exact-match component paths, not a match-everything glob (issue #34)".
  • test/wiki.test.ts already has "assemblePack: an indexer-derived root component owns only those files, not the whole repo (issue #34)".

Nothing in this PR adds anything main doesn't already have. Sorry for the noise — I diagnosed this independently before checking whether it had already landed.

@MrSampson MrSampson closed this Aug 23, 2026
@MrSampson
MrSampson deleted the fix-root-component-glob branch August 23, 2026 09:42
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.

1 participant