Repository navigation
fix(acp): remove legacy projection metadata from the agents directory - #36125
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (4 items) — 3 justifiedIntent: stop a leftover pre-
[FIRST-PRINCIPLES-REVIEWED] f9bb8a3 Description read[DESCRIPTION-READ] 0c2656377d7c85506cf7e0b43b430febe971f73e265be091adc4cafa0b92320e 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 cleanup deletes only files Crew can prove it wrote, at a location no current reader uses. The one build that would still read them was already declared unsupported for this directory. [DESIGN-REVIEWED] f9bb8a3 Description read[DESCRIPTION-READ] 01a36302cf426c5b965811bf1b6f4391812c44853bf4a4e9667410ec5f48d608 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: |
5a7df8d to
9e6a272
Compare
|
GPT 6.1 review of
The branch was also rebased onto main |
9e6a272 to
e84be79
Compare
Builds before v0.10.0 wrote the skill-projection view ledger and ownership sidecars to ~/.kiro/agents/.kirocrew-skill-projection-metadata/. Nothing reads them there, and kiro-cli 3.1.0 loads every .json under the agents directory as an agent, so a leftover ledger becomes a fake subagent in every session. The boot drain now removes the regular files there whose name and content prove Crew wrote them, and the directory once it is empty. Any other file stays, and a linked directory is never walked. Fixes #35501
…ards Stage the linked-directory test with make_dir_link, which makes an unprivileged junction on Windows, instead of skipping it there. Declare _remove_legacy_metadata_dir in the link-screen baseline (regenerated with test/gen_link_screen_sites.py): it refuses every link, like the orphan sweeps beside it. Name the three new alias_reclaim definitions in the skill_projection facade's TYPE_CHECKING manifest.
e84be79 to
f9bb8a3
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approve at f9bb8a3. I read the whole product diff: alias_reclaim.py, the facade re-exports in skill_projection.py, and the spec paragraph.
kiro-cli 3.1.0 loads every .json under the agents directory as an agent, dot-prefixed subdirectories included. So the ledger and sidecars a pre-v0.10.0 build left in .kirocrew-skill-projection-metadata/ showed up as subagents. The boot drain now removes them through _remove_legacy_metadata_dir, and it only deletes what Crew provably wrote:
- it walks only a real directory, never a link or junction, bounded by
_PROJECTION_PRUNE_WORK_LIMIT; - it unlinks only regular files whose name and content pass
_is_legacy_metadata_file: a ledger that maps view names to strings and nothing else, or a view-named sidecar carrying the managed marker; - each unlink goes through the existing identity-checked
_unlink_projection_lease_if_unchanged; - it removes the directory only once it is empty, so any other file keeps it;
- an
OSErroris logged at debug and the drain goes on.
No regex is added. The name check reuses main's existing _LEGACY_ALIAS_NAME_RE unchanged. There is no refusal, and nothing is live red (the cancelled runs are superseded by newer passes).
Problem / Motivation
Goal: A projection metadata file left in
~/.kiro/agents/by a pre-v0.10.0build no longer shows up as a fake subagent in every kiro-cli session.Builds before
v0.10.0wrote the skill-projection view ledger and ownership sidecars to~/.kiro/agents/.kirocrew-skill-projection-metadata/. Nothing on main reads, moves or removes them there. kiro-cli 3.1.0 loads every.jsonunder the agents directory as an agent profile, dot-prefixed subdirectories included, so a leftoverview-sources.jsonregisters a subagent.kirocrew-skill-projection-metadata/view-sourcesin every session and logs an invalid-tool-name warning.Why it matters
Every session on an upgraded install lists a subagent tool built from a metadata file. The model can try to call it, and it costs tool-spec tokens on every turn. The file never goes away on its own.
Not a goal
.kirocrew-skill-projection.lockor.kirocrew-skill-projection-leases/(not.jsonat the agents-directory level, so not loaded as agents).What changed (motivation → approach → change)
Symptom: a fake subagent per session. Root cause: the legacy readers and migration were removed (#20213 / #32139), so a file at the old location stays forever, and kiro-cli 3.1.0 now loads it.
Fix, in
src/kiro_crew/acp/skill_projection_parts/alias_reclaim.py: the boot drain (drain_stale_aliases) first calls_remove_legacy_metadata_dir. It walks.kirocrew-skill-projection-metadata/only when it is a real directory (never a link or junction), bounded by the prune's work limit, and unlinks only regular files whose name and content prove Crew wrote them:view-sources.jsonholding onlykirocrew-skill-view-<24 hex>→ string entries, or akirocrew-skill-view-<24 hex>.jsonsidecar carrying the managed marker. Each unlink is identity-checked through the existing_unlink_projection_lease_if_unchanged. The directory is removed withos.rmdironce empty; any other file keeps it. Errors are caught so the drain still never raises. Cost: onelstatper boot once the directory is gone.docs/system-specs/modules/acp-client.mdis updated to describe the cleanup.src/kiro_crew/acp/skill_projection.pynames the three new definitions in the facade'sTYPE_CHECKINGmanifest.test/link_screen_sites.pydeclares_remove_legacy_metadata_dir, regenerated withtest/gen_link_screen_sites.py. The function refuses every link, like the orphan sweeps declared beside it, so it is not a held site.Backwards compatibility
Compatible: only files no code path reads are removed; the current layout under
<data_home>/skill-projection/is untouched.Reader: src/kiro_crew/acp/skill_projection_parts/view_sources.py:_read_view_ledger -- entry: chat -- reads
_projection_metadata_dir()under the data home only, never the legacy directory (test_resume_retired_agent_names.py passes)Reader: src/kiro_crew/acp/skill_projection_parts/view_ownership.py:_managed_metadata_for_alias -- entry: chat -- reads
_projection_metadata_dir()only (test_native_skill_projection_rewrites.py passes)Tests
test/test_skill_projection_legacy_metadata.py, against the realdrain_stale_aliases:make_dir_link, so it runs on Windows as a junction too).Proof: PROVEN test/test_skill_projection_legacy_metadata.py::test_drain_removes_the_legacy_ledger_sidecars_and_directory, test/test_skill_projection_legacy_metadata.py::test_drain_keeps_a_file_crew_did_not_write[ledger-with-foreign-key], test/test_skill_projection_legacy_metadata.py::test_drain_keeps_a_file_crew_did_not_write[ledger-not-an-object], test/test_skill_projection_legacy_metadata.py::test_drain_keeps_a_file_crew_did_not_write[name-crew-never-wrote] (head f9bb8a3)
Ran locally: the new file plus
test_resume_retired_agent_names.py,test_skill_view_relaunch_harness.py,test_native_skill_projection_lease_scan.py,test_skill_view_mode_recovery.py,test_native_skill_projection_rewrites.py(136 passed), andlocal-gate.pybackend related (95 passed).Manual verification
Reproduced on main: a Linux host upgraded from 0.9 has
~/.kiro/agents/.kirocrew-skill-projection-metadata/view-sources.json(35 entries, every keykirocrew-skill-view-<24 hex>, every value a string), which matches the ownership test above. The new test reproduces the drain leaving it on main (4 failures) and passes with the fix.Related Issues
Fixes #35501
Sibling sweep
Swept: git grep -n "kirocrew-skill-projection" -- src/
Sibling: src/kiro_crew/acp/skill_projection_parts/alias_reclaim.py -- changed here
Pattern harvest
Not generalizable: a one-off file layout move whose migration was removed before every install had run it.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.