Repository navigation
fix(papyrus): refuse a junctioned project config, not just a symlinked one - #8873
Conversation
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Real POSIX-only refusal gap, closed with the module's own shared predicate at the exact site the docstring says must use it. Watch
[DESIGN-REVIEWED] 0ae6124 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of All claims verified against the base. The fix is derived — the First-Principles-Verdict: CONCERNS The predicate swap is the documented cause-level fix, but the description claims a "guards the guard" test the diff never ships. What this change shipsIntent: make the project-config link refusal fire for Windows junctions, the one link type an unprivileged Windows user can create — a FIX.
Watch
[FIRST-PRINCIPLES-REVIEWED] 0ae6124 |
df90a84 to
3092251
Compare
…d one store.is_reparse_link exists in this module because a Windows directory junction is a reparse point is_symlink() does not report, and its docstring states the rule: every place this module refuses a link at a name KiroCrew owns has to refuse a junction too, or the refusal is POSIX-only. It is used at gitops.py:287-289, latex.py:617 and store.py:215/503 -- five sites, each with a comment. _config_path was the one still asking is_symlink(). Measured on origin/main, with a junction at .papyrus.json pointing at an IN-PROJECT directory, _config_path returns that resolved directory instead of None: the link guard does not fire, and safe_child cannot catch it because an in-project link satisfies containment -- which is why the guard sits ahead of containment in the first place. Scope, stated plainly: a junction is directory-only, so it CANNOT stand in for the .papyrus.json -> paper.tex overwrite the symlink tests cover; the write would land on a directory and fail. What it does is slip past a refusal this module documents as link-type-agnostic, and lose the warning that says why. Zero unfixed siblings: tectonic.py:550 also pairs is_file() with is_symlink(), but it requires is_file(), which a junction fails, so it declines already. The test uses test/conftest.py::make_dir_link, the repo's own seam, which calls _winapi.CreateJunction unconditionally on Windows -- not symlink_or_junction, which tries os.symlink first and hands a privileged runner a symlink instead of the junction arm under test. The file is in .github/black-baseline.txt, so it is deliberately not black-formatted here: the test delta is 24 added lines and no deletions. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
3092251 to
0ae6124
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Tech Lead review: APPROVE.
Verified independently rather than trusting the description:
- The gap is real and the fix is at the right layer.
store.py:340was the last rawis_symlink()guard inpapyrus/backend; swapping it for the module's ownis_reparse_linkis the predicate the helper's docstring atstore.py:166-181explicitly mandates for every link refusal in this module. The guard sits ahead ofsafe_childon purpose, and an in-project junction satisfies containment, so containment could not have caught this. - Enumeration of siblings confirmed by my own grep. After this change no raw
is_symlink()guard remains:tectonic.py:550pairsis_file()withis_symlink()and requiresis_file(), which a directory junction fails, so it already declines; the remaining hits instore.pyandlatex.pyare the helper's own body plus docstring/comment prose. - Semantics match the AGENTS.md cross-platform contract.
is_reparse_linkmirrorsplatform_compat.is_link_or_junctionstructurally (is_symlink()->os.path.isjunctionwhen available -> stat-basedIO_REPARSE_TAG_MOUNT_POINTfallback), so it holds on 3.10 and 3.11 whereos.path.isjunctiondoes not exist. - The test stages the real plant and is valid on both platforms.
make_dir_linkis already imported in this file, the reversed(link, target)argument order matchestest/conftest.py, it calls_winapi.CreateJunctionunconditionally on Windows, and falls back tosymlink_to(target_is_directory=True)on POSIX -- so the assertion holds cross-platform. Asserting on_config_pathrather thanread_project_config, and pointing the link inside the project, are both the load-bearing choices; either one relaxed would produce a test that passes without consulting the guard. - Scope is honest. The description states plainly that a junction is directory-only and cannot stand in for the
.papyrus.json -> paper.texoverwrite the symlink tests cover; the claim is that it slips past a refusal documented as link-type-agnostic and loses the warning. That is exactly what the diff does, and nothing more.
CI: 69 success / 6 skipped / 0 failure on 0ae6124. All four AI lanes clear -- GPT 5.6 and Opus 4.8 no findings, Design Review PASS, First Principles CONCERNS (advisory). The single Watch item both Fable lanes raised -- a described test test_the_staged_plant_is_really_a_junction_on_windows that the diff never ships -- is already corrected in the current description, which now states outright that no guard-the-guard test is added and that the plant is deliberately staged with make_dir_link rather than platform_compat.symlink_or_junction.
One cosmetic nit, deliberately not blocking: the new test declares a tmp_path fixture argument it never uses.
Security-sensitive change reviewed as a strict tightening of an existing guard -- no trust boundary widened, no new capability, refusal path only.
…d one (kirodotdev#8873) store.is_reparse_link exists in this module because a Windows directory junction is a reparse point is_symlink() does not report, and its docstring states the rule: every place this module refuses a link at a name KiroCrew owns has to refuse a junction too, or the refusal is POSIX-only. It is used at gitops.py:287-289, latex.py:617 and store.py:215/503 -- five sites, each with a comment. _config_path was the one still asking is_symlink(). Measured on origin/main, with a junction at .papyrus.json pointing at an IN-PROJECT directory, _config_path returns that resolved directory instead of None: the link guard does not fire, and safe_child cannot catch it because an in-project link satisfies containment -- which is why the guard sits ahead of containment in the first place. Scope, stated plainly: a junction is directory-only, so it CANNOT stand in for the .papyrus.json -> paper.tex overwrite the symlink tests cover; the write would land on a directory and fail. What it does is slip past a refusal this module documents as link-type-agnostic, and lose the warning that says why. Zero unfixed siblings: tectonic.py:550 also pairs is_file() with is_symlink(), but it requires is_file(), which a junction fails, so it declines already. The test uses test/conftest.py::make_dir_link, the repo's own seam, which calls _winapi.CreateJunction unconditionally on Windows -- not symlink_or_junction, which tries os.symlink first and hands a privileged runner a symlink instead of the junction arm under test. The file is in .github/black-baseline.txt, so it is deliberately not black-formatted here: the test delta is 24 added lines and no deletions. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Problem / Motivation
store.is_reparse_linkexists in this module precisely because a Windows directory junction is a reparse pointis_symlink()does not report, and its docstring states the rule it was added to enforce:It is used at
gitops.py:287-289,latex.py:617,store.py:215andstore.py:503— five sites, each carrying a comment explaining why._config_pathwas the one site still askingis_symlink().Measured on
origin/main(9f3c07dc7), with a junction planted at.papyrus.jsonpointing at an in-project directory:_config_pathreturns that resolved directory instead ofNone. The link guard does not fire, andsafe_childcannot catch it either — an in-project link satisfies containment, which is the whole reason this guard sits ahead of containment rather than relying on it.Why it matters
The refusal is currently POSIX-only, for the one link type an unprivileged Windows user can create —
os.symlinkthere needsSeCreateSymbolicLinkPrivilege, a junction needs nothing. So the platform where the plant is cheapest to stage is the platform with no guard.Scope, stated plainly: a junction is directory-only, so it cannot stand in for the
.papyrus.json -> paper.texoverwrite the symlink tests cover — a write would land on a directory and fail. What it does is slip past a refusal this module documents as link-type-agnostic, and lose thelogger.warningthat says why, so the failure surfaces later and opaquely instead of at the guard that was written to name it.This is a completeness fix for the module, finishing what merged #8766 started on
latex.py.What changed (motivation → approach → change)
One predicate:
candidate.is_symlink()→is_reparse_link(candidate), the module's own shared helper, with a comment matching the four sites that already call it. The warning text drops "symlinked" for "linked" now that both link types reach it.Zero unfixed siblings, checked individually rather than asserted:
tectonic.py:550— also pairsis_file()withis_symlink(), but it requiresis_file(), which a junction fails, so it already declines.store.py:183isis_reparse_link's own body; the remainingis_symlink()mentions inlatex.py:555andstore.py:169are prose in docstrings.Tests
test/test_papyrus_store.py, one added test, 24 lines, no deletions. The plant is staged withtest/conftest.py::make_dir_link— the repo's own seam, already imported in this file — which calls_winapi.CreateJunctionunconditionally on Windows. Note the reversed argument order,(link, target).It is deliberately not
platform_compat.symlink_or_junction: that triesos.symlinkFIRST and falls back to a junction only where the privilege is missing, so a runner with Developer Mode gets a SYMLINK and the junction arm is never exercised. The first head of this PR staged it that way and the Windows CI shard caught it.The file's existing config-link tests are
@pytest.mark.skipif(sys.platform == "win32")and therefore left the junction case with no coverage at all.Two choices in the test are load-bearing, and a first draft got both wrong:
_config_path, notread_project_config. Reading a directory fails anyway, so the outcome would look correct while the guard was never consulted — a green test proving nothing.safe_child's containment whether or not the link guard fires, so it cannot tell the two builds apart. In-project is the case the guard exists for.Red on
origin/main:test_a_junctioned_config_is_refused— the resolvedchapters/directory in place ofNone.No guard-the-guard test is added here. The first head had one; review correctly counted it as duplicate evidence, because
TestIsReparseLink::test_a_directory_link_is_a_reparse_linkalready stages withmake_dir_linkand assertsis_reparse_link(link) is True. It proved no additional production contract, so it was removed rather than kept for symmetry.Local (Windows, repo-pinned toolchain):
test_papyrus_store.py115 passed / 16 skipped.flake8,isortandscripts/check_black_formatting.pyall clean in scope.On formatting: this file is in
.github/black-baseline.txt. The first head ranblackover it and carried ~15 unrelated reformatting hunks, which the baselined Black gate correctly failed. That is reverted — the diff is now purely additive.Manual verification
N/A — unit coverage sufficient: the change is a single predicate swap to an existing in-module helper, and the test stages the real plant on the affected platform through the repo's own link seam.
Related Issues
None — found by source review while completing the
is_symlink()-versus-junction seam after #8766.Pattern harvest
Rule candidate:
review-promptPattern: a module that introduces a shared, platform-correct predicate (here
is_reparse_link) and converts most of its call sites leaves the unconverted ones strictly worse off than before — the helper's existence reads as proof the module is covered, so the remaining rawis_symlink()stops looking like a gap. When a helper's docstring says the sites "cannot drift apart", that is a claim to verify by enumeration at review time, not a guarantee. The check is cheap: grep the module for the raw call the helper replaces.Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code