Repository navigation
fix(members): resolve a crew named as a crew by its member_id without re-keying config.agents - #25805
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The change reuses the existing unique- [DESIGN-REVIEWED] 50cbb4f Description read[DESCRIPTION-READ] 94dcbc7b4541311111d28c9add5484ffa98dc03a1582d5ef6ac2639056bd8355 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 Nothing blocks. The defect has provenance: issue #13688, and a new test that fails on base. All three resolution paths reuse the one existing id rule, Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: address a crew member by its
[FIRST-PRINCIPLES-REVIEWED] 50cbb4f Description read[DESCRIPTION-READ] 6a336fdb91d52d044370b6bddd9b69f442f8e3751c78a73236f2aee2bc8c7523 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: |
9f51d77 to
87cf2ee
Compare
87cf2ee to
31cbd18
Compare
… re-keying config.agents
31cbd18 to
50cbb4f
Compare
Problem / Motivation
Goal: a crew member can be addressed by its
member_id, whichever key shape itsconfig.agentsrecord is stored under, without anyone'sconfig.jsonbeing rewritten.config.agentsholds two key shapes side by side on main. A record from before crews were keyed by id is keyed by its display name and carries its id asmember_id. A crew created on main today is keyed by a derived id (members_parts/member_space.pykey_new_crew). Relabelling already leaves the key alone (check_crew_label). What is still missing is the id lookup: the config resolvers indexconfig.agentsby the exact key, so a surface holding a name-keyed member'smember_idmisses.Why it matters
A caller that names a name-keyed crew as a crew by its id (
crew_agent="crew-program-manager"or amemberselection, for the record keyedCrew Program Manager) resolves to no crew, whileexecution_context.member_config_for_idalready accepts that id for the same member's memory. The session's crew identity and its memory then disagree about who it is. The member's id is the handle that never changes, so it is the one a binding should be able to use.Not a goal
config.agents. No one-way rewrite ofconfig.json, no key rename, no migration: every stored key keeps working exactly as on main, and a downgrade sees the same file.display_name.docs/system-specs/modules/crew-mode.md(thedisplay_nameparagraph underselect_crew) records the label as presentation only, so a relabel never breaks a binding; this PR keeps that.key_new_crew,NewCrewKeyandcrew_id_for_display_namestay.Intended? / Repro
Intended? No.
canonical_member_key's docstring (src/kiro_crew/members_parts/member_space.py:444) states its job is to stop "a write and a read of one crewmate land[ing] in two directories".execution_context.member_config_for_id(src/kiro_crew/execution_context.py:491) already treatsmember_idas the member's identity ("names and slug candidates are never identity"). Issue #13688 asks for id lookups. Nothing on main says a member's id must not resolve its record.Repro (read on current main
8437295709):src/kiro_crew/config/loader_agents.py:87-88resolve_crew_identity: an explicitcrew_agentis returned verbatim, soresolve_crew_identity(cfg, None, "crew-program-manager")returns a string that is not aconfig.agentskey for the record keyedCrew Program Managerwith thatmember_id;session_capabilities.prepare_runtimethen raisescapability_member_missing.src/kiro_crew/config/loader_agents.py:113_resolve_agent_selection: an exact-key test only, soresolve_agent_bindings(cfg, "crew-program-manager", selection_kind="member")resolves no crew and falls through to the default template with the default memory store.src/kiro_crew/members_parts/member_space.py:466-474canonical_member_key: exact key, then case-fold key, else the name unchanged.What changed (motivation → approach → change)
Symptom: a member id that is not the stored key resolves to nothing. Cause: the config resolvers are exact-key only. Change: where the caller has already stated the name is a crew, a member id resolves to the stored key through the existing id lookup.
execution_context.member_config_for_id(src/kiro_crew/execution_context.py:491), the one unique-member_idrule memory resolution already uses. No second copy: a missing or ambiguous id raises there and is answered as "no match" here, so a lookup never guesses whose thread or memory it addresses.display_nameis never matched.crew_agentinresolve_crew_identity, aselection_kind="member"selection in_resolve_agent_selection, and the member-namespacecanonical_member_key. A bareagent(which may be a global or project-local template name) and atemplateselection resolve exactly as on main, so no template can be taken for a crew and no project directory has to be threaded through.canonical_member_key: exact key and case-fold key keep their priority; only when neither matches is the id tried.member_slugand the member dashboard route use it already.loader_agents._crew_key_for_member_id: the wrapper the two config resolvers share; a stored key answers""so their exact-key paths stay first.Backwards compatibility
Compatible: no stored value changes shape and nothing is written. A name that was an exact key, a case-fold key, a bare
agentor a template resolves exactly as on main. A label resolves exactly as on main. Only a member id, named where a crew is expected, that resolved to nothing on main now resolves.Removes nothing: no key, field, helper or error path is removed.
How the review on #14423 is addressed
bolichen97's CHANGES_REQUESTED on #14423:
config.jsonrewrite / undeclared breaking change: there is no rewrite here. Old display-name keys stay as stored and are found by key and bymember_id, so there is no downgrade behaviour and noBreaking:line is needed.key_new_crew/NewCrewKey/crew_id_for_display_namewhile main and open PRs still call them: nothing is removed;dashboard/agent_admin/crew_records.pyis untouched.Tests
test/test_member_handle_lookup.py(new), against a config with one name-keyed record and one id-keyed record:test_a_crew_named_as_a_crew_resolves_by_key_or_member_id: key andmember_idreach the stored key throughcanonical_member_key,resolve_crew_identity(explicitcrew_agent) and_resolve_agent_selection(memberselection).test_both_handles_of_a_legacy_record_share_one_slug:member_sluggives one slug per member.test_a_bare_agent_is_never_taken_as_a_member_id,test_template_selection_never_resolves_a_member_id,test_a_template_name_stays_a_template_when_a_crew_carries_it_as_its_id: bare agents and templates resolve as on main.test_a_label_never_resolves_a_crew: adisplay_nameresolves nothing, as on main.test_stored_keys_are_not_rewritten,test_a_member_id_two_records_carry_resolves_to_nothing,test_no_crew_stays_no_crew,test_unknown_name_is_unchanged,test_an_empty_roster_leaves_a_handle_unchanged.Existing test changed:
test/test_agent_panel_routes_record.py::test_a_member_the_config_no_longer_holds_is_a_409stubsexecution_context.member_config_for_idto model "the config no longer holds this member". Its stub raisedRuntimeError; the real function raises the execution context's own refusal (_unavailable(...), aValueErrorsubclass).member_slugnow consults that function, so the test's own client setup hit the stub's wrong type. The stub now raises the real refusal type; the assertion (409member_identity_unavailable) is unchanged and the test is not narrowed.On main, the
member_idcase of the first test fails.Proof: not provable -- other: this host runs no local tests; CI runs the new tests
Manual verification
N/A: resolver-only change. Static gates run locally: black, isort, flake8,
scripts/check_file_line_cap.py. Tests run in CI.Related Issues
Fixes #13688
Supersedes #14423
Sibling sweep
Swept: git grep -n "in config.agents|config.agents.get(|config.agents[" -- src/
Sibling: src/kiro_crew/execution_context.py -- not affected (
resolve_member_executionalready resolves amember_idthroughmember_config_for_id)Sibling: src/kiro_crew/dashboard/handlers/member_dashboard.py -- changed through
canonical_member_key(no edit in the file)Sibling: src/kiro_crew/members_parts/member_space.py
is_configured_dispatchable_member-- not affected (the chat guard admits a stored key; the dashboard sends the key)Sibling: src/kiro_crew/memory_stores.py -- not affected (callers pass the alias the resolvers return, which is now always the stored key)
Pattern harvest
Rule candidate: resolve a crew handle through
canonical_member_key/ the loader resolvers, never by indexingconfig.agentswith a string a surface supplied; never resolve bydisplay_name.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.