Repository navigation
fix(agents): keep a default its workspace checkout still declares (release/0.8.0) - #16568
Conversation
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the backport claim — that this branch's patch-id equals #16562 as merged on main — since the review environment cannot run What this change shipsInventory (4 items) — 4 justifiedIntent: FIX — stop the default-agent healer from silently resetting a default that still dispatches via the alias's workspace checkout (#16555, test fails on base).
Lens-4 check: [FIRST-PRINCIPLES-REVIEWED] 69aed43 |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Confirm [DESIGN-REVIEWED] 69aed43 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsThe in-lock workspace re-derivation reads a different document than the pre-lock one, so the heal can be silently disabled — advisory, nothing blocks. FINDING — src/kiro_crew/config/loader.py:6472 — FINDING — src/kiro_crew/config/loader.py:6449 — [OPUS-REVIEWED] 69aed43 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
The default-agent healer takes its removal evidence from the user-level agents directory only. kiro-cli resolves --agent against the session's project directory first, so a global spec uninstalled while the alias's workspace checkout still declared a same-named spec left the default dispatching there, yet the healer read it as removed and durably reset default_agent to "default". Before resetting, the healer now scans the alias's workspace, placed by workspace_dir_from_entry (the named entry, else default_workspace, as dispatch does). The scan covers <workspace>/.kiro/agents, the only project location the backend activates, and uses the same scan as the snapshot, so it knows whether it was complete. The healer declines when that checkout still declares the template, when the scan was partial, when the listing fails, and when the workspace path is sensitive (never read). The locked config write re-derives the row's workspace from the document it holds and declines if it changed. Fixes #16555 (cherry picked from commit b0c503b)
6b98c04 to
69aed43
Compare
Problem / Motivation
Goal: the default-agent healer never resets a default that the alias's workspace checkout still declares.
Repro (#16555), now
test_a_default_its_workspace_still_declares_is_not_reset:pkgrunsreviewerin workspaceprojand is the default. Both~/.kiro/agents/reviewer.jsonandproj/.kiro/agents/reviewer.jsondeclarereviewer.default_agenttodefaultinconfig.json. On origin/main the test fails with'default' == 'pkg'.Cause:
reset_dangling_default_agent(config/loader.py) takes its removal evidence (_MATERIALIZED_SEENminus the current snapshot) from the user-level agents directory only. kiro-cli resolves--agentagainst the session's project directory first (config.paths.project_agents_dir), so the default still dispatches in that workspace. The healer cannot see that.Why it matters
A durable, silent change to the owner's setting, for a default that still works. Nothing puts it back.
Not a goal
What changed (motivation → approach → change)
Backport of #16562 to release/0.8.0, which carries the healer through #16385. It is a clean
cherry-pick -x, and its patch-id equals the source's._alias_workspace_dirplaces the alias's workspace the way dispatch does: the named entry, elsedefault_workspace, throughworkspace_dir_from_entry. That is the one placement rule, so a relativedirlands under the data home and not the gateway's cwd._workspace_declares(template, workspace_dir)scans<workspace>/.kiro/agentswith the same scan as the snapshot (_scan_materialized_index). That directory, in both spec forms, is the only project location the backend activates; the legacy.agent-spec.jsonfiles are not counted. Using the same scan also tells it whether the scan was complete..kiro/agentsdeclares nothing._locked_workspace_dirre-derives the row's workspace from the document it holds. The write is declined if that differs from the workspace that was checked.Backwards compatibility
Compatible. A default whose template is gone from both the user-level directory and its workspace is still reset; the test also covers that step.
Tests
New in
test/test_config_loader.py::TestDanglingDefaultAgentReset, each paired with the targeted mutation that fails it:test_a_default_its_workspace_still_declares_is_not_reset(also resets once the checkout drops it)test_a_relative_workspace_is_placed_under_the_data_homePath(dir).expanduser()test_a_workspace_spec_that_cannot_be_read_is_not_evidence_eithertest_a_row_repointed_at_another_workspace_inside_the_locked_write_is_keptRegression proof on this branch: with
loader.pyreverted to the release/0.8.0 tip, the 4 new tests fail.Gates:
test_config_loader.py,test_agent_execution_catalog.pyandtest_config_api.py: 723 passed.test/integration: 17792 passed. The failures are the parallel-run spawn tests intest_acp_runtime.pyandtest_subagent_shared_scratch.py, which fail the same way on the untouched release tip.session_agent_selection.pyoffender.Manual verification
N/A. The tests drive real refreshes over a real agents directory, a real project checkout and a real
config.json.Related Issues
Part of #16555. Backport of #16562; the healer reached release/0.8.0 with #16385.
Pattern harvest
Rule candidate: review-prompt
Pattern: "X is gone" evidence must come from every place the consumer resolves X. A self-healing write keyed on one directory is wrong when the resolver also searches another.
Checklist