fix(wiki): reserve manual/jobs only at the wiki root, not at any depth - #57
fix(wiki): reserve manual/jobs only at the wiki root, not at any depth#57dev-noaman wants to merge 1 commit into
Conversation
is_reserved_page_path tested every directory component:
any(part in RESERVED_WIKI_SOURCE_DIRS for part in relative.parts[:-1])
but the reserved directories are only ever created at the wiki root
(WikiService: `almanac_path / "manual"`, BuildWorkflow: `almanac_path /
"manual"`). Any user page under a directory named `manual` or `jobs`, at any
depth, was therefore excluded from indexing, health and frontmatter rewriting.
Silently, which is the costly part: health and validate walk with the same
iterator, so the tool cannot report pages it refuses to see. The visible
symptom is a broken link to a file that plainly exists on disk, plus a page
count that disagrees with the filesystem. It also makes `sync` fail
permanently, since the post-run validation gate trips on those broken links.
In one real wiki this hid four committed pages (~29KB) under
architecture/jobs/, and nearly caused a duplicate to be written: the coverage
map listed the target as unwritten and health called the link broken, both
consistent with "missing", when it existed and was hidden.
Restricting the check to the first directory component keeps the intended
exclusion (the bundled manual, including its subdirectories) while leaving user
pages alone. page_id_for_path in the same module already reasons positionally,
so top-level-only matches the established convention here.
The added test fails without this change and passes with it. Root-level manual/
exclusion stays covered by the existing test.
Refs AlmanacCode#56
|
Withdrawing the follow-up I floated at the end of the description — a
Verified against this branch: With this PR merged the reservation cases are: Adding one would also have been actively harmful: No change to the diff; this PR remains the one-line fix plus its regression test. |
|
Opened #58 with the severity tier this thread ran into — It is cut from |
Fixes the over-broad reserved-directory check reported in #56.
The bug
is_reserved_page_pathtests every directory component:But the reserved directories are only ever created at the wiki root:
services/wiki/service.py—self.manual.install_missing(almanac_path / "manual")workflows/build/service.py—manual_root=repository.almanac_path / "manual"So the predicate is broader than its purpose, and any user page under a directory named
manualorjobs— at any depth — is dropped from indexing,health, and frontmatter rewriting.The failure is silent, and that is what makes it expensive:
healthandvalidatewalk with the same iterator, so the tool cannot report pages it refuses to see. The only visible symptoms are a broken link pointing at a file that plainly exists on disk, and a page count that quietly disagrees with the filesystem (reindexreported46 pages (46 files seen)against 50.mdfiles).It also makes
syncfail permanently — the post-run validation gate trips on the resulting broken links, so the run exitsfailedand no ingest can complete while such a directory exists.In the wiki where this surfaced it hid four committed pages (~29 KB) under
architecture/jobs/, and nearly caused a duplicate to be written: the coverage map listed the target as unwritten andhealthcalled the link broken — both consistent with "missing" — when the page existed and was hidden.The change
Restrict the check to the first directory component:
page_id_for_path, immediately below in the same module, already reasons positionally (if len(relative.parts) == 1), so top-level-only matches the established convention here.Behaviour:
manual/intro.mdmanual/nested/deep.mdjobs/run.mdarchitecture/jobs/queue.mdguides/manual/setup.mdarchitecture/risk/overview.mdjobs.md(a file, not a directory)Nested content inside the bundled manual stays excluded, because only the first component is consulted.
Tests
Adds
test_page_iteration_keeps_nested_dirs_named_after_reserved_roots, which asserts a nestedjobs/manualdirectory is indexed while a root-levelmanual/is not. It fails onmainand passes with this change, so it pins the regression rather than merely describing it. The existingtest_page_iteration_excludes_repository_manualscontinues to cover the intended root-level exclusion and is unmodified.Checks
Per
CONTRIBUTING.md:uv run pytest— the failing-test set is identical before and after this change (14 both ways on this machine; all pre-existing and unrelated — 5 are macOSlaunchdtests running on Windows).tests/test_wiki_parsing.pygoes 9 passed → 10 passed.uv run ruff check .— All checks passeduv build— sdist and wheel builtNote on a related rough edge
Even with this fix, a page skipped by reservation is dropped without a trace. A
healthnotice along the lines of "N page(s) skipped: reserved directory" would make this class of problem self-diagnosing — as it stands, the only clue is a broken link to a file that exists. Happy to add that in a follow-up if you'd want it.