Repository navigation
fix(scripts): normalize walked paths in ai-context orphan check - #330
Merged
Merged
Conversation
The check compares router keys and `unrouted` entries, which are stored in forward-slash form, against paths built by `os.walk` and `os.path.relpath`. On Windows those carry backslashes, so no comparison ever matches: every wiki page is reported as an orphan, the history branch is unreachable (its files are reported with the wiki message), and deliberately unrouted docs are flagged too. The check is therefore permanently red on Windows, which means it cannot flag real router drift there either. Normalize `rel` once and keep the prefix tests in the same forward-slash vocabulary the rest of the function uses. Verified on the same tree: Windows 13 problems -> ok, Linux unchanged, and an unindexed history file is now reported as `history file not indexed` instead of passing unnoticed. Refs: runkids#329
runkids
self-requested a review
October 2, 2026 08:45
runkids
added a commit
to runkids/agents-context-router
that referenced
this pull request
Oct 2, 2026
orphans() built paths with os.walk and os.path.relpath, which use backslashes on Windows, and compared them with the forward-slash paths from ai-context.json and the router index. On Windows every check failed with false orphans, and history files fell through to the wiki branch, so a history page missing from the index was reported with the wrong reason among the noise. Convert walked paths to forward slashes before comparing them. Ported from runkids/skillshare#330.
runkids
approved these changes
Oct 2, 2026
5 tasks done
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.
What
Normalizes the paths the orphan check builds with
os.walk/os.path.relpathintothe forward-slash vocabulary the rest of the function already uses. Four lines in
scripts/ai-context.py; no behavior change on POSIX.Details and measured evidence are in #329.
Why it matters
The router check runs in CI (
unit-test), but that job isubuntu-latest, so theseparator mismatch is invisible there. On Windows the check was permanently red,
and a permanently red gate is not a gate: it could not flag real router drift
either. This restores it as a gate for Windows contributors.
Verification
Same tree, same command, before and after:
80ac109fpython scripts/ai-context.py check)13 problem(s), exit 1ok, exit 0python3 scripts/ai-context.py check)ok, exit 0ok, exit 0The 13 failures reproduce identically on a pristine worktree of
4e3b2b26and onthis branch's base, so they are not caused by anything my earlier PRs added.
Blindness proof (the part that makes this more than cosmetic): removing the index
line for
history/git-hooks-management.mdfromwiki/README.mdon stock mainproduces output byte-identical to the clean run — the real drift is invisible.
After this change the same edit is caught, with the correct message:
The
historybranch was previously unreachable on Windows (history + os.sepproduces
wiki/history\, which a backslash-separated path never prefix-matches),so those files fell through to the wiki branch and reported the wrong reason. Both
prefix tests and the inner
relpathresult now use/.section()'s containment guard (path.startswith(ROOT + os.sep)) is deliberatelyleft alone: that comparison is native-path against native-path, so it is already
consistent.
Closes #329