Skip to content

fix(members): resolve a crew named as a crew by its member_id without re-keying config.agents - #25805

Merged
dodgeblaster merged 1 commit into
mainfrom
fix/member-handle-lookup-13688
Oct 30, 2026
Merged

dodgeblaster merged 1 commit into
mainfrom
fix/member-handle-lookup-13688

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a crew member can be addressed by its member_id, whichever key shape its config.agents record is stored under, without anyone's config.json being rewritten.

config.agents holds 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 as member_id. A crew created on main today is keyed by a derived id (members_parts/member_space.py key_new_crew). Relabelling already leaves the key alone (check_crew_label). What is still missing is the id lookup: the config resolvers index config.agents by the exact key, so a surface holding a name-keyed member's member_id misses.

Why it matters

A caller that names a name-keyed crew as a crew by its id (crew_agent="crew-program-manager" or a member selection, for the record keyed Crew Program Manager) resolves to no crew, while execution_context.member_config_for_id already 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

  • Re-keying config.agents. No one-way rewrite of config.json, no key rename, no migration: every stored key keeps working exactly as on main, and a downgrade sees the same file.
  • Resolving a crew by its display_name. docs/system-specs/modules/crew-mode.md (the display_name paragraph under select_crew) records the label as presentation only, so a relabel never breaks a binding; this PR keeps that.
  • Changing how new crews are keyed, labelled or relabelled. key_new_crew, NewCrewKey and crew_id_for_display_name stay.
  • Template names. A name a materialized kiro agent declares is never taken as a crew id.

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 treats member_id as 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-88 resolve_crew_identity: an explicit crew_agent is returned verbatim, so resolve_crew_identity(cfg, None, "crew-program-manager") returns a string that is not a config.agents key for the record keyed Crew Program Manager with that member_id; session_capabilities.prepare_runtime then raises capability_member_missing.
  • src/kiro_crew/config/loader_agents.py:113 _resolve_agent_selection: an exact-key test only, so resolve_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-474 canonical_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.

  • The match is execution_context.member_config_for_id (src/kiro_crew/execution_context.py:491), the one unique-member_id rule 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_name is never matched.
  • Only names already in the crew namespace are tried as ids: an explicit crew_agent in resolve_crew_identity, a selection_kind="member" selection in _resolve_agent_selection, and the member-namespace canonical_member_key. A bare agent (which may be a global or project-local template name) and a template selection 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_slug and 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 agent or 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:

  1. One-way config.json rewrite / undeclared breaking change: there is no rewrite here. Old display-name keys stay as stored and are found by key and by member_id, so there is no downgrade behaviour and no Breaking: line is needed.
  2. Removal of key_new_crew / NewCrewKey / crew_id_for_display_name while main and open PRs still call them: nothing is removed; dashboard/agent_admin/crew_records.py is untouched.
  3. Stale branch: this is a fresh branch off current main.

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 and member_id reach the stored key through canonical_member_key, resolve_crew_identity (explicit crew_agent) and _resolve_agent_selection (member selection).
  • test_both_handles_of_a_legacy_record_share_one_slug: member_slug gives 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: a display_name resolves 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_409 stubs execution_context.member_config_for_id to model "the config no longer holds this member". Its stub raised RuntimeError; the real function raises the execution context's own refusal (_unavailable(...), a ValueError subclass). member_slug now 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 (409 member_identity_unavailable) is unchanged and the test is not narrowed.

On main, the member_id case 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_execution already resolves a member_id through member_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 indexing config.agents with a string a surface supplied; never resolve by display_name.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 50cbb4f948868fb17c373151efa0a026190379d4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 50cbb4f948868fb17c373151efa0a026190379d4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The change reuses the existing unique-member_id rule (member_config_for_id) at the three places a caller has already said the name is a crew. Stored keys keep priority, nothing is written, and a missing or ambiguous id resolves to nothing.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 50cbb4f948868fb17c373151efa0a026190379d4 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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, execution_context.member_config_for_id.

Notes

  • Item 3 — one consumer, generalized: the new canonical_member_key branch (try: key, _ = member_config_for_id(config, name) except ValueError: return name) repeats the body of loader_agents._crew_key_for_member_id. Grepping member_config_for_id(config, name) in the diff finds 2 copies of this wrapper. Subtraction: have canonical_member_key's fallback call _crew_key_for_member_id(config, name) or name, and delete the second try/except.

What this change ships

Inventory (5 items) — 4 justified

Intent: address a crew member by its member_id whatever key its record is stored under, without rewriting config. This is a FIX.

  1. An explicit crew_agent given as a name-keyed crew's member id now resolves to that crew's stored key — justified
  2. A member selection given by member id now resolves the crew instead of falling back to the default template — justified
  3. Member-namespace lookups (slug, member dashboard) now accept a member id once key and case-fold lookups miss — one consumer, generalized: the id-lookup wrapper is written twice
  4. New private _crew_key_for_member_id, also added to loader.py's type-checking import list — justified
  5. A test stub now raises the real refusal type instead of RuntimeError; the assertion is unchanged — justified

[FIRST-PRINCIPLES-REVIEWED] 50cbb4f

Description read

[DESCRIPTION-READ] 6a336fdb91d52d044370b6bddd9b69f442f8e3751c78a73236f2aee2bc8c7523

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 50cbb4f948868fb17c373151efa0a026190379d4 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 50cbb4f

Verdict parsed from the review's SHA-scoped output markers for commit 50cbb4f948868fb17c373151efa0a026190379d4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 50cbb4f948868fb17c373151efa0a026190379d4 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 50cbb4f948868fb17c373151efa0a026190379d4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 50cbb4f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 50cbb4f948868fb17c373151efa0a026190379d4 false-positive: <reason, 20 to 500 characters>

@CrysisDeu CrysisDeu changed the title fix(members): resolve a crew by member_id or display_name without re-keying config.agents fix(members): resolve a crew by member_id without re-keying config.agents Oct 29, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/member-handle-lookup-13688 branch from 9f51d77 to 87cf2ee Compare October 29, 2026 16:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 29, 2026
@CrysisDeu CrysisDeu changed the title fix(members): resolve a crew by member_id without re-keying config.agents fix(members): resolve a crew named as a crew by its member_id without re-keying config.agents Oct 29, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/member-handle-lookup-13688 branch from 87cf2ee to 31cbd18 Compare October 29, 2026 17:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 29, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/member-handle-lookup-13688 branch from 31cbd18 to 50cbb4f Compare October 29, 2026 23:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 29, 2026
@dodgeblaster
dodgeblaster merged commit ca250a0 into main Oct 30, 2026
95 of 103 checks passed
@dodgeblaster
dodgeblaster deleted the fix/member-handle-lookup-13688 branch October 30, 2026 04:21
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Key config.agents by member_id and store display_name as a field

2 participants