Repository navigation
fix: refuse a windows junction wherever a directory symlink is refused - #34331
Conversation
Path.is_symlink() and stat.S_ISLNK are False for a Windows directory junction, so five directory-link guards read one as a real directory: the member-records move's source (trust, trust/<kind>) and destination (member-records/<kind>) checks, the installed-theme validator's pack root and per-entry checks, and the theme list. A junction at the old trust layout was moved through and sealed, deleting the originals in the junction's target, where a symlink holds the move unsealed. Each guard now asks platform_compat.is_link_or_junction, the documented helper, so a junction gets the answer a symlink already gets. POSIX is unchanged. _validate_theme_dir and _list_themes_sync join the link-screen baseline: both refuse every link they find and never traverse one, so neither needs a hold. Closes #33289
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Every guard now calls the existing What this change shipsInventory (5 items) — 5 justifiedIntent: on Windows, an operator's hand-built junction gets the same documented safe refusal a symlink gets, in the member-records move and in installed theme packs. FIX.
[FIRST-PRINCIPLES-REVIEWED] 36c2b70 Description read[DESCRIPTION-READ] eaf94427ccc51161c03d86e36af4b5ba5044e1ece4e1e1c7f4ae60cf46d97cc7 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The PR swaps in the existing Notes
[DESIGN-REVIEWED] 36c2b70 Description read[DESCRIPTION-READ] 45d11abef20bd91cb9ae06ce2e2a6a6d886e2a45aac358c4bf825f856c426146 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 36c2b70. Five directory-link guards (member-records move x2, theme validator root + entry, installed-theme list) now use platform_compat.is_link_or_junction, so a Windows junction gets the symlink answer; on POSIX the predicate equals islink/S_ISLNK, so it only tightens. Decisive lines: src/kiro_crew/member_records.py:194, src/kiro_crew/member_records.py:242, src/kiro_crew/dashboard/theme_validate.py:1277, src/kiro_crew/dashboard/theme_validate.py:1377, src/kiro_crew/dashboard/handlers/themes.py:145
#34331) Path.is_symlink() and stat.S_ISLNK are False for a Windows directory junction, so five directory-link guards read one as a real directory: the member-records move's source (trust, trust/<kind>) and destination (member-records/<kind>) checks, the installed-theme validator's pack root and per-entry checks, and the theme list. A junction at the old trust layout was moved through and sealed, deleting the originals in the junction's target, where a symlink holds the move unsealed. Each guard now asks platform_compat.is_link_or_junction, the documented helper, so a junction gets the answer a symlink already gets. POSIX is unchanged. _validate_theme_dir and _list_themes_sync join the link-screen baseline: both refuse every link they find and never traverse one, so neither needs a hold. Closes #33289 (cherry picked from commit 7c9d44a)
Problem / Motivation
Goal: On Windows, a directory junction in the member-records move or in an installed theme pack is refused exactly the way a directory symlink already is.
Five directory-link guards cannot see a Windows junction (
mklink /J, no elevation needed): four ask onlyPath.is_symlink()orstat.S_ISLNK, one onlyS_ISDIRon anlstat, and a junction passes all three as a real directory:trust\<kind>(ortrust) layout is moved through and sealed: each original is deleted inside the junction's target and the emptied folder is removed (the junction itself, when it sits attrust\<kind>), with one INFO line. A symlink there holds the move unsealed with a WARNING telling the operator to replace the link, which is what the module andsecurity.mdpromise for any link.GET /api/themes/<slug>, while a symlinked one is left out of the list and answers 500invalid_installed_theme.Why it matters
A Windows user who relocated their pre-upgrade member records with a junction has that folder emptied by the one-time move instead of getting the documented safe state. The bytes survive only as the promoted copies, with no warning that anything unusual happened. For themes nothing is gained or lost, but the same layout gets opposite answers on Windows and POSIX.
Not a goal
target.is_symlink()check (theme_validate.py:1795): it runs afterresolve(), so it already answers the same for both link kinds.sandbox_seals.py: the namespace and Seatbelt sandboxes run only on Linux and macOS.is_symlink()(done in junction-guard completion sweep: four remaining is_symlink() residuals (portability import strip, deploy staging walk, connections mint/warm delete guards) #12379 / fix(windows): make four is_symlink guards see a junction (#12379, #10492) #15310).What changed (motivation → approach → change)
A Windows junction now gets the same answer a symlink gets at every directory-link guard in the member-records move and the installed-theme path.
The cause is one predicate:
is_symlink()/S_ISLNKmiss a junction, whichplatform-compat.mdnames as the mistake to avoid. Each guard now asksplatform_compat.is_link_or_junction, the helperthemes.pyalready uses for the install root and copy walk.member_records._legacy_state(trust,trust\<kind>)member_records._plain_dir(member-records,member-records\<kind>)atomic_write, but amember-records\<kind>with nothing to copy let the move seal_validate_theme_dir, pack root_validate_theme_dir, an entry in the packthemes._list_themes_synctest/link_screen_sites.pyis regenerated:_validate_theme_dirand_list_themes_syncnow screen with the helper, and both refuse every link they find, so neither needs a hold.Backwards compatibility
Breaking: on Windows, a junction at
trust,trust\<kind>ormember-records\<kind>now holds the member-records move unsealed until the operator replaces it, a junctioned theme pack is no longer listed or served, and a pack holding a junction is no longer served. POSIX is unchanged. Writer sweep on origin/main @ 9c5e565: no product code creates a junction at any of these names. The move creates its own directories withos.mkdir(_plain_dir(create=True)), the theme install stages with_copy_installed_theme, which already refuses junctions, and the product'ssymlink_or_junctioncallers (apps/bridges_skills.pyfor app skills,frontend.pyfor the built dashboard) link other names. Only a layout an operator built by hand changes.Reader: src/kiro_crew/dashboard/handlers/themes.py:api_themes -- crew page -- leaves a junctioned pack out like a symlinked one; test_junctioned_directory_is_never_listed
Reader: src/kiro_crew/dashboard/handlers/themes.py:api_theme_detail -- crew page -- answers 500 invalid_installed_theme as for a symlinked pack; test_a_junction_is_refused_like_a_symlink
Reader: src/kiro_crew/dashboard/handlers/themes.py:_do_install -- crew page -- validates the staging copy, which holds no link; the existing install tests in test/test_theme_install.py pass
Reader: src/kiro_crew/member_records.py:records_dir -- chat -- raises RecordsNotMoved when ensure_migrated() is False and the kind's old layout still holds a record, which test_a_junction_holds_the_move_like_a_link sets up for a junction; test_records_behind_a_link_are_neither_promoted_nor_read_as_absent pins the reader on that False
Reader: src/kiro_crew/sandbox_staging.py:_member_records_move -- subagent -- refuses a launch whenever ensure_migrated() is False (Linux and macOS spawn prep), as for a symlink; test_records_behind_a_link_are_neither_promoted_nor_read_as_absent pins it on that False
Tests
test_member_records.py::test_a_junction_holds_the_move_like_a_link(junction attrust,trust/member-rules,member-records/member-rules): the move does not seal, the failure names the link, and the member-rules original stays in place with no promoted copy.test_theme_install.py::TestValidateThemeDir::test_a_junction_is_refused_like_a_symlink(pack root, and astylesentry): the validator refuses it.test_dashboard_themes_coverage.py::TestListThemesSync::test_junctioned_directory_is_never_listed: the list leaves it out.Each simulates a junction by patching
platform_compat._ISJUNCTION(theos.path.isjunctionprobe), astest_pod_orphans.pydoes, so the case runs on every OS: the path is a directory, not a symlink, and the probe says junction. The existing symlink and plain-directory tests are unchanged.Determinism: the six new cases passed 20 runs at
-n0and 10 runs at-n 4 --dist loadgroup --max-worker-restart=2withtest_member_records.pyandtest_theme_install_identity.pyas co-tenants; the three changed test files (335 ids) passed in a shuffled order, seed 33289, at-n0(332 passed, 3 skipped).Proof: PROVEN test/test_dashboard_themes_coverage.py::TestListThemesSync::test_junctioned_directory_is_never_listed, test/test_member_records.py::test_a_junction_holds_the_move_like_a_link[trust-reached through a link], test/test_member_records.py::test_a_junction_holds_the_move_like_a_link[trust/member-rules-reached through a link], test/test_member_records.py::test_a_junction_holds_the_move_like_a_link[member-records/member-rules-is not a plain directory], test/test_theme_install.py::TestValidateThemeDir::test_a_junction_is_refused_like_a_symlink[-theme path is not a directory] (head 36c2b70)
Manual verification
N/A — unit coverage sufficient: the guards' only input is the link probe, which the tests drive directly; no Windows host was available for a real
mklink /Jrun.Screenshots / video
N/A — no frontend change.
Related Issues
Closes #33289
Sibling sweep
Swept: git grep -nE "is_symlink()|S_ISLNK|islink(|S_ISDIR(" 69d3a9a -- src/kiro_crew/member_records.py src/kiro_crew/dashboard/theme_validate.py src/kiro_crew/dashboard/handlers/themes.py src/kiro_crew/sandbox_seals.py
Sibling: src/kiro_crew/member_records.py:194 -- changed here
Sibling: src/kiro_crew/dashboard/handlers/themes.py:145 -- changed here
Sibling: src/kiro_crew/dashboard/theme_validate.py:1795 -- not affected -- runs after resolve(), so it answers the same for a symlink and a junction; containment against the resolved root is the guard
Sibling: src/kiro_crew/sandbox_seals.py:241 -- not affected -- the namespace and Seatbelt sandboxes it guards run only on Linux and macOS, which have no junctions
Pattern harvest
Rule candidate: review-prompt
Pattern: a directory-link guard spelled
Path.is_symlink()orstat.S_ISLNKinstead ofplatform_compat.is_link_or_junctionChecklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)