Skip to content

check-kb: normalize path separators so a knowledge base validates on Windows - #14

Open
brenodias wants to merge 1 commit into
alextnetto:mainfrom
brenodias:fix/check-kb-windows-paths
Open

brenodias wants to merge 1 commit into
alextnetto:mainfrom
brenodias:fix/check-kb-windows-paths

Conversation

@brenodias

Copy link
Copy Markdown

Problem

On Windows, check-kb.mjs flags every nested-defined ID as "referenced but not defined" — every E-### entity, every R-### rule — and warns that evidence/index.csv is misnamed. A knowledge base that is actually valid cannot pass check-kb, so pack-kb then refuses it without --force.

Cause

walk() builds paths with relative(), which returns OS-native separators (backslashes on Windows). The definition logic compares those paths against /-based tables:

  • FILE_ID_DIRS keys such as data-model/entities (via dirname(file) !== dir),
  • the rules/ prefix (file.startsWith('rules/')),
  • EVIDENCE_INDEX = evidence/index.csv (file === EVIDENCE_INDEX).

On Windows none of these match, so no heading/filename definitions register. On POSIX it works, which is why CI never caught it.

Fix

Normalize separators to POSIX once, in walk(), via a small exported toPosix helper — everything downstream already uses /. Added an entry guard (same pattern as build-report.mjs) so the module can be imported, plus a unit test for toPosix.

Testing

node --test tests/kb-scripts.test.mjs → 27/27 pass (new test included). Verified against a real Windows knowledge base: check-kb goes from dozens of spurious "referenced but not defined" errors to OK.

🤖 Generated with Claude Code

walk() produced OS-native paths (backslashes on Windows) that never matched
the '/'-based definition tables (FILE_ID_DIRS, the rules/ prefix,
evidence/index.csv), so on Windows every nested E-/R- definition went
unregistered and valid knowledge bases failed check-kb. Normalize to POSIX in
walk() via an exported toPosix helper; add an entry guard so the module is
importable, and a unit test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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