Skip to content

fix(scripts): normalize walked paths in ai-context orphan check - #330

Merged
runkids merged 2 commits into
runkids:mainfrom
star-nebula:fix/ai-context-windows-paths
Oct 2, 2026
Merged

runkids merged 2 commits into
runkids:mainfrom
star-nebula:fix/ai-context-windows-paths

Conversation

@star-nebula

Copy link
Copy Markdown
Contributor

What

Normalizes the paths the orphan check builds with os.walk/os.path.relpath into
the 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 is ubuntu-latest, so the
separator 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:

stock 80ac109f this branch
Windows (python scripts/ai-context.py check) 13 problem(s), exit 1 ok, exit 0
Linux (python3 scripts/ai-context.py check) ok, exit 0 ok, exit 0

The 13 failures reproduce identically on a pristine worktree of 4e3b2b26 and on
this 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.md from wiki/README.md on stock main
produces output byte-identical to the clean run — the real drift is invisible.
After this change the same edit is caught, with the correct message:

FAIL wiki/history/git-hooks-management.md: history file not indexed in wiki/README.md
1 problem(s)

The history branch was previously unreachable on Windows (history + os.sep
produces 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 relpath result now use /.

section()'s containment guard (path.startswith(ROOT + os.sep)) is deliberately
left alone: that comparison is native-path against native-path, so it is already
consistent.

Closes #329

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
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
runkids merged commit b789042 into runkids:main Oct 2, 2026
7 checks passed
@star-nebula
star-nebula deleted the fix/ai-context-windows-paths branch October 3, 2026 01:23
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.

scripts/ai-context.py check fails on every Windows contributor: orphan detection compares /-form keys against \-form paths

2 participants