ui-server: the wikilink map stats every file it walks although the directory entry already has the type
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 79/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- bun, typescript
- Ambito
- backend, performance
Direzione di ricerca
Inizia da packages/ui-server/src/files/walker.ts, in corrispondenza di buildWikilinkMap (righe 449–515), e leggi la gestione delle voci intorno alle righe 461–493. Aggiungi o individua il test per i file normali e i symlink in packages/ui-server/tests/files-walker.test.ts, poi esegui questo test e packages/ui-server/tests/wikilink-reliability.test.ts. Il lavoro è completato quando vengono sottoposti a stat solo i symlink, le note symlink interne al brain restano mappate, le destinazioni esterne restano escluse e i risultati esistenti della map rimangono invariati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Context
buildWikilinkMap (packages/ui-server/src/files/walker.ts:449-515) walks the whole brain to map note slugs
to paths. It lists each directory with readdir(abs, { withFileTypes: true }) (:461), and then awaits
stat() on every entry (:477-482). The only thing it reads from the result is whether the entry is a
directory (:493); size and modification time are never used. For everything except a symbolic link the
directory entry from readdir already answers that question.
GET /api/files/wikilinks rebuilds the map at most every 30 seconds, or on ?refresh=1
(WIKILINK_TTL_MS, packages/ui-server/src/routes/files.ts:24; the route at :284-292). The client asks for
it when a markdown surface first needs a wikilink (packages/ui-react/src/stores/file-state.ts:159).
Measured cost (auditor micro-benchmark, synthetic tree of 10,000 files in 200 directories, warm file cache,
one server-class machine; not a device or production figure): the serial walk with a stat per entry took
103 to 121 ms; the same walk trusting the directory entry took 10 to 12 ms. The walk grows with the brain,
and every non-markdown attachment is stat-ed too.
Related: #1799 (file browsing and .gitignore when anchored snapshots are unavailable) and #1800 (symlinked
brain roots) change the same file.
Scope
- In
buildWikilinkMap, decide "is a directory" from the directory entry, and callstatonly when the
entry is a symbolic link. The symlink branch keeps itsrealpathcontainment check
(packages/ui-server/src/files/walker.ts:483-491). - The resulting map, including which path wins when two files share a slug, is unchanged.
Out of scope
listDirectory(packages/ui-server/src/files/walker.ts:217-262). It returns size and modification time,
so it needs itsstat.- Extracting the entry-filter block that
listDirectoryandbuildWikilinkMapboth carry into one helper.
It is a real duplicate, but merging it widens this diff into the listing path that #1799 and #1800 are
changing. - Caching the parsed
.gitignorematcher (loadIgnore,packages/ui-server/src/files/walker.ts:180-191).
That read goes through the anchored snapshot path #1799 owns, and it was not measured. - The per-directory
safeResolveandrealpathcalls (:455,:458); they guard against cycles and
escapes. - The 30-second cache and the route.
Acceptance criteria
- A test builds a brain with regular files, a nested directory, a symlink to a directory inside the
brain and a symlink to a directory outside it, replacesfs/promisesstatwith a counting double
for the walk (restoring the complete original in teardown), and assertsstatis called only for the
two symlinks. It fails on the tree before the change, where every entry is stat-ed. Mutation: call
statfor every entry again and the count assertion fails. - The same test asserts notes under the in-brain symlinked directory are in the map and notes under the
outside one are not. Mutation: drop the symlink branch and the in-brain symlinked notes disappear. - For the fixtures of
packages/ui-server/tests/files-walker.test.tsand
packages/ui-server/tests/wikilink-reliability.test.ts, the map is unchanged: both files pass with no
expected value changed, including the first-wins precedence for a shared slug.
Verification
bun run test packages/ui-server/tests/files-walker.test.ts
bun run test packages/ui-server/tests/wikilink-reliability.test.ts
NODE_OPTIONS=--max-old-space-size=6144 bun run typecheck
bun run lint
bun run check:pr --base origin/main
Contract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
The wikilink map returned by GET /api/files/wikilinks is identical; only the number of filesystem calls
changes.
It edits files under a published package's src, so scripts/check-changeset.ts requires a (patch) changeset
even though outputs are unchanged.
Found by a repository audit on 2026-11-26 (main 87b96b10c); independently reviewed before filing.
- Lingua principale
- TypeScript
- Stelle
- 5
- Fork
- 0
- Merge medio
- 8h 3m
- PR unite (30g)
- 606
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di schlessera/brain-kit
-
agent-ready area: ui-server priority: p3 type: refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
schlessera/brain-kit#4833 ·
I maintainer di solito rispondono entro 1 giorno
-
ui-sdk: the turnId doc comment tells client authors echoing is optional, which a rev 3 host refusesApertaagent-ready area: ui-sdk priority: p3 type: docs
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
schlessera/brain-kit#4824 ·
I maintainer di solito rispondono entro 1 giorno
-
ui-react: the recordings tray and the associate dialog import each other for two label helpersApertaagent-ready area: ui-react blocked priority: p3 type: refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
schlessera/brain-kit#4819 ·
I maintainer di solito rispondono entro 1 giorno
-
jobs: every command writes on open, so a read fails with "database is locked" during a long writeApertaagent-ready area: modules priority: p2 type: fix
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
schlessera/brain-kit#4809 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-ready area: ui-server priority: p3 type: fix
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
schlessera/brain-kit#4807 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di schlessera/brain-kit
Issue simili
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster no-stale P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
openclaw/openclaw#206303 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eliasstravik/herdr-projects#1604 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
golang-malawi/qatarina#502 ·
I maintainer di solito rispondono entro 2 giorni