Repository navigation
fix(skill-projection): compare skill-view ownership by resolved data-home path - #17846
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS One check before merge: the alias hash still uses the unresolved Suggestions
[DESIGN-REVIEWED] 216adab Description read[DESCRIPTION-READ] 3e277a511c4ad63502be3db718aceeeb98096b3695461be5acd64d8ffee27000 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that What this change shipsInventory (6 items) — 6 justifiedIntent: stop skill-view aliases piling up when one data home is reached under two path spellings. This is a FIX.
Sibling count: I grepped [FIRST-PRINCIPLES-REVIEWED] 216adab Description read[DESCRIPTION-READ] 46fb1593570608d2ef89e5bbd84e5b036ff734c1d7551bc86fb45a3e30216e67 That sha256 names the PR description this verdict read. 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: |
a26ebd6 to
c40eccf
Compare
|
|
c40eccf to
4eece9b
Compare
|
4eece9b to
609d67c
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
|
The two failing Windows Backend Tests — |
…home path Skill-view ownership was recorded and compared as data_home().absolute(), which is not symlink-resolved. On cloud desktops /home/<u> is a symlink to /local/home/<u>, so a launch using the other spelling, a pod sharing ~/.kiro, or a moved data home produced views the reclaim/prune/drain paths treated as another home's, so nothing ever cleaned them up. Add _same_crew_home() comparing home identities by os.path.realpath with a literal-string fallback on resolve failure, and route every ownership-home comparison through it. The stored value and the view-name hash are unchanged, so no existing alias is renamed or re-hashed.
609d67c to
216adab
Compare
|
Rebased: main moved. The two inherited reds ( |
|
span=56828ee357a2 — fixed. Tightened the "Why it matters" prose: the moved-data-home example now notes the limit — a relocated home is reunified only while its old spelling still resolves to the new location (e.g. a residual symlink), since the fix matches by resolved path, not by relocation. The leak scenarios the fix actually addresses (alternate spelling, pod sharing |
buluoray
left a comment
There was a problem hiding this comment.
Approving at 216adaba9c. The fix is correct and stays fail-closed.
Coverage. Every read of _MANAGED_CREW_HOME in skill_projection.py now goes through _same_crew_home: the ledger window, the orphan-sidecar sweep, the legacy-sidecar branch in reclaim, the metadata check and its pre-delete revalidation, the census, and _is_current_publication. No literal home comparison is left, and no other module reads the key.
Fail-closed.
- A realpath match only happens when both strings land on the same real directory, i.e. the same home. A pod's data home is a separate directory and stays foreign (
test_prune_never_touches_another_homes_aliasstill passes). - Planting a sidecar whose recorded path symlinks to this home needs write access to
~/.kiro/agents, which already allows deleting the aliases directly, so nothing is gained. - Liveness is unaffected: leased aliases are in the skip set before any ownership check runs.
- Resolution errors fall back to "foreign"; Windows keeps the literal compare and never resolves the untrusted value.
Link-screen baseline. Declaring _is_current_publication is justified: the realpath runs on the home strings, not on the alias_path the function screens with lstat, so it is not a new TOCTOU.
Upgrade impact. No stored value, alias name or hash changes. The default (same-spelling) path takes the unchanged literal fast path; only mixed-spelling POSIX hosts see new behaviour, which is the fix.
Tests. test_native_skill_projection.py plus the link-screen gate: 229 passed. Reverting the helper to == reddens test_same_crew_home_matches_across_symlinked_home_spellings and test_prune_reclaims_an_alias_recorded_under_a_symlinked_home_spelling; removing the Windows guard reddens test_same_crew_home_never_resolves_an_untrusted_path_on_windows. Windows was checked by monkeypatch only, not on a Windows host.
Non-blocking follow-ups
- Changing the orphan-sidecar sweep, census, ledger window, legacy-sidecar branch or
_is_current_publicationback to a literal compare leaves every test green. An end-to-end test for the sweep and census under a symlinked spelling would pin them. - The alias name is still hashed on the literal home spelling, so a mixed-spelling host still mints one alias per spelling; this change makes the other spelling's copies reclaimable, so growth is bounded rather than stopped. Reasonable (canonicalizing would rename every alias on upgrade), but worth saying in the body.
os.path.realpath(current)is constant per process and could be cached; realpath on a recorded value pointing at a stale automount can block while the publication lock is held. Low risk since sidecars are same-user.
Problem / Motivation
Goal: Clean up skill-view aliases even when a data home is reached under more than one path spelling, so they stop piling up in the agents directory.
A skill view's ownership is recorded as the data home's path, and the reclaim, prune, and drain paths decide whether a view is theirs to clean up by comparing that recorded path against the current data home. The comparison was literal string equality on a path that is not symlink-resolved. When one data home reaches disk under two spellings —
/home/<user>is commonly a symlink to/local/home/<user>— a view recorded under one spelling and read under the other looks like it belongs to a different home, so nothing ever reclaims it and the aliases accumulate.Why it matters
Every leaked alias is a file kiro-cli enumerates on every session start, so the backlog is a growing per-session cost, not just clutter. A launch that uses the other spelling, or a pod that shares
~/.kiro, trips this bug, and once a view is stranded no later run can recover it. (A home that moved is only reunified while its old spelling still resolves to the new location — e.g. a residual symlink — since the fix matches by resolved path, not by relocation.)Not a goal
What changed (motivation → approach → change)
Skill views leaked because the ownership-home check compared raw path strings, and one home has two spellings when
/homeis a symlink to/local/home.The fix compares home identities by their resolved path instead of by spelling. A new
_same_crew_home(recorded, current)helper insrc/kiro_crew/acp/skill_projection.pyresolves both sides withos.path.realpathon POSIX and, on a resolution failure (such as a symlink loop), falls back to the old exact-string comparison so the check never widens what counts as this home. The two-spelling problem is a POSIX phenomenon, and the recorded value is untrusted sidecar content, so on Windows the helper does not resolve at all — it keeps the pre-fix literal comparison, which never touches the filesystem for an unequal value and so cannot be steered into opening a UNC/network target.Every ownership-home comparison in the module now goes through that one helper — the ledger prefetch, the orphan-sidecar sweep, the three reclaim gates, the read-only census diagnostic, and the current-publication check. The value stored in each ownership record and the alias name hash are untouched, so a view published before this change is matched by its existing record and no alias is rewritten.
Backwards compatibility
Compatible: the stored ownership value and the alias name hash are unchanged, so existing aliases and sidecars keep their names and keep being matched. The only behavior change is that two spellings of one home now compare equal; a genuinely different home still resolves to a different path and stays foreign.
Removes nothing: no path is hidden, no record or alias is deleted by this change, and no validator is tightened — a view that was reclaimable before stays reclaimable, and some that were wrongly stranded now become reclaimable.
Tests
Added to
test/test_native_skill_projection.py:_same_crew_hometreats/home-style and/local/home-style spellings of one home as the same, in both directions, using a real temporary symlink.The two tests that assert the resolved-path match run only on POSIX (that match is a POSIX phenomenon); the others run on every OS. Because the new helper reaches
os.path.realpath, the link-screen baseline intest/link_screen_sites.pynow also declares_is_current_publicationas a known screen-then-resolve site — it re-validates the alias path itself, and the resolve is of unrelated home-identity strings, so it is a baseline entry, not a hold site.Manual verification
N/A — unit coverage sufficient; the behavior is fully exercised by the symlink-based tests above.
Related Issues
Fixes #13362
Pattern harvest
Not generalizable: this is a single ownership comparison that must be identity-based rather than spelling-based; the module's other path checks already resolve or pin their targets.