Skip to content

fix(acp): map stored skill-view mode names to their source agent - #15202

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/skill-view-mode-recover
Sep 30, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/skill-view-mode-recover

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A chat or crewmate that stored a kirocrew-skill-view-<hash> name starts on the agent that view was built from, and a skill-view miss names that agent and a repair that keeps the operator's config.

After upgrading to 0.8, turns fail with Agent spec 'kirocrew-skill-view-<hash>' is not installed ... repair with kirocrew setup --agent-only --clean, then restart the gateway. Some of these names are stored ones: crewmate rows an older sync generated for alias files (#15103), or a mode a frame reported from an earlier projection. Kiro Crew sends such a name straight to session/set_mode, but the boot drain (#13502) or a content change has already removed that file, so kiro-cli can only answer Mode not found. The message then points at --clean, which skips merging the existing config and drops the operator's own MCP servers and tools.

Why it matters

A user on a stored view name gets a failed turn every time, and the one fix the error suggests costs them their MCP config. The message also names a hash instead of the agent, so nobody can tell which agent broke.

Not a goal

What changed (motivation → approach → change)

Symptom: set_mode names a view file that is gone. Cause: nothing maps a stored view name back to an agent before it is sent, and a projection only translates names it minted itself. Change:

  • skill_projection.py remembers every view name this process publishes, mapped to its agent (bounded, and admitting only a registered agent name, the same check the sidecar and ledger reads apply). source_agent_name() maps a view name back through that memory, then the view's ownership sidecar, then a bounded view ledger (view-sources.json in the sidecar directory, newest 2048 entries, the same bound as the in-memory map, rewritten under the publication lock). The ledger is what still answers after a restart, when the boot drain has removed both the alias and its sidecar. A name neither records raises RetiredSkillView with a sentence telling the user to pick the agent again. It never guesses an agent, because the guess could be a broader one. NativeSkillProjection.agent() and frame() apply the in-memory map, so a stale view name is sent as the agent's CURRENT view and is reported back as the agent.
  • Every path that feeds a mode name to kiro-cli maps it first: AcpRuntime spawn (self._agent), create_session, load_session, AcpSessionHandle.set_mode, and AcpClient spawn (inside its existing executor hop).
  • runtime._format_runtime_rpc_error: the skill-view sentence fix(acp): stop sending skill-view mode errors to setup --clean #15140 added now names the source agent when this process minted the view. The missing real spec hint drops --clean.

Backwards compatibility

Compatible: agent names pass through untouched with no file read. Only a name with the kirocrew-skill-view- prefix changes behaviour, and today every such name that is not the current view fails at set_mode anyway.

Tests

  • test/test_skill_view_mode_recovery.py: the view memory keeps no oversized, newline-bearing or view-named agent; a view resolves after the drain removed its alias and sidecar; the ledger keeps its newest admissible entries and drops malformed ones; a view from an earlier process maps back through its sidecar with the alias file deleted; an unrecorded view is refused, not guessed; an agent name makes no read; set_mode with a stale view (the agent was edited, so a new alias exists) sends the current view and a frame reports the agent; the runtime entry helper, AcpSessionHandle.set_mode and the direct client all map the name; a view miss names the source agent, or 'this agent' when nothing remembers it; a missing real spec suggests setup without --clean.
  • test_agent_spec_preflight.py and test_acp_runtime.py repair-hint assertions updated.
  • Mutations, each caught by one test: dropping the mapping in NativeSkillProjection.agent, in AcpSessionHandle.set_mode, and the ledger lookup.

Manual verification

N/A. The mapping and message are pure functions of the name, the sidecar and the in-memory map, and unit tests drive every entry path with those inputs.

Related Issues

Refs #13362, #13750. Related #13502, #15103, #1548, #15125, #15140.

Pattern harvest

Not generalizable: the defect is the one place a generated transport name was persisted and later replayed as an agent name.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

@iamwhatever
iamwhatever requested a review from a team as a code owner September 30, 2026 00:23
@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@iamwhatever
iamwhatever force-pushed the fix/skill-view-mode-recover branch from 2ddc62c to 6f99a77 Compare September 30, 2026 00:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of a2fbf255908aefc8255e57782a3a9c5f20998e50 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

is_skill_view_name re-spells is_native_skill_alias_name (agent_spec_format.py:153) — every caller already holds a str, so the existing predicate serves them all.

Not justified as shipped

  • Item 7 — duplicate of src/kiro_crew/agent_spec_format.py: the new is_skill_view_name is the same startswith(NATIVE_SKILL_ALIAS_PREFIX) test as is_native_skill_alias_name (grep: 2 named predicates plus 3 pre-existing inline uses at runtime.py:1058, skill_projection.py:1266/1554). Its only delta, the isinstance guard, is dead at every call site: frame() checks isinstance(value, str) first, and _admissible_source_agent short-circuits on is_registered_agent_name, which already rejects non-str.
    Subtraction: delete is_skill_view_name from skill_projection.py and import is_native_skill_alias_name, which the module's import line already reaches.
    Clears when: the deletion is made, or a caller is shown that can pass a non-str the existing predicate would crash on.

What this change ships

Inventory (8 items) — 7 justified

Intent: a chat or crewmate that stored a generated skill-view name starts on the agent it was built from, and the failure messages stop costing the operator their config — a FIX.

  1. A stored view name now starts its source agent instead of failing every turn — justified
  2. A view name nothing records is refused with "pick the agent again", never guessed — justified
  3. New persisted file view-sources.json (newest 2048 view→agent entries) beside the sidecars — justified
  4. Frames report a stale view name as its agent, so sessions stop storing view names — justified
  5. The skill-view "Mode not found" error names the source agent when known — justified
  6. The missing-spec repair hint drops --clean, keeping the operator's MCP config (other --clean hints declared deferred) — justified
  7. New module surface source_agent_name/resolve_source_agent/RetiredSkillView/is_skill_view_name — duplicate of src/kiro_crew/agent_spec_format.py (the predicate only; the rest is new)
  8. Spawn, create_session, load_session and set_mode each map the name before it is sent — justified

[FIRST-PRINCIPLES-REVIEWED] a2fbf25

Description read

[DESCRIPTION-READ] 90a06a7555f029fae26106588193e86a992cafdc950a0fe14f60e03cfc3bb501

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 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of a2fbf255908aefc8255e57782a3a9c5f20998e50 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The new persisted artifact view-sources.json lands in the spec-governed projection metadata directory undocumented — acp-client.md still describes that directory as sidecars-plus-leases only.

Watch

  • acp-client.md exhaustively specifies the metadata/lease directory contract (ownership sidecars, census, reclaim scan, prune deferral), and prune/reclaim changes are written against that spec. A ledger file the spec never names risks a later reclaim/census change treating it as unowned garbage or an unreadable record, silently re-opening the post-restart resolution gap this PR exists to close. AGENTS.md also requires the owning spec updated in the same commit.
    Clears when: acp-client.md documents the view ledger (location, bound, lock, failure semantics) in this PR.
  • Ledger eviction is insertion-ordered and only publication refreshes entries, so the stored stale names this PR recovers — which are never republished — are evicted first; after _VIEW_SOURCES_MAX view publications (alias churn is a known issue, skill-view aliases not reclaimed on 0.7.0-insider.9 (post #13225): live-source orphans retained, breaks bare kiro-cli /context and Kiro IDE ProfileLoader #13362) a stored crewmate row degrades back to RetiredSkillView. The failure is at least actionable now, but the recovery window is silently finite.
    Clears when: a successful ledger resolve refreshes the entry, or #15103 prunes the stored rows before churn can evict them.

[DESIGN-REVIEWED] a2fbf25

Description read

[DESCRIPTION-READ] ff827e4ed3dd1dc1ba5be3fa9b4c544d6f0e4106b1650eff68827e5b7f74d5eb

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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of a2fbf255908aefc8255e57782a3a9c5f20998e50 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a2fbf25

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a2fbf255908aefc8255e57782a3a9c5f20998e50: <one-sentence reason>

@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 Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] a2fbf25

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable a2fbf255908aefc8255e57782a3a9c5f20998e50: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the fix/skill-view-mode-recover branch from 6f99a77 to 479f1c3 Compare September 30, 2026 01:26
@iamwhatever

Copy link
Copy Markdown
Contributor Author

BLOCKING -- src/kiro_crew/acp/skill_projection.py:267 -- boot cleanup destroys cross-process recovery

Fixed in 479f1c3: verified in code that the boot drain (keep=set()) unlinks the sidecar with the alias, so a stored view name had nothing left to resolve from after a restart. _recorded_view_source now falls back to a bounded view ledger (view-sources.json in the sidecar directory, which the prune never walks; newest 2048 admissible entries, rewritten under the publication lock). test_a_view_resolves_after_the_boot_drain_removed_alias_and_sidecar pins it and fails with the ledger lookup removed.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@iamwhatever
iamwhatever force-pushed the fix/skill-view-mode-recover branch from 479f1c3 to a2fbf25 Compare September 30, 2026 01:48
@iamwhatever

Copy link
Copy Markdown
Contributor Author

BLOCKING -- src/kiro_crew/acp/skill_projection.py:200 -- Stored source names permit log injection

Fixed in a2fbf25: verified in code that a sidecar or ledger value reached logger.info at runtime._source_agent with only a length/NUL check. _admissible_source_agent now requires validation.is_registered_agent_name (which admits no control character and bounds the length) for the in-memory map, the sidecar read and the ledger alike. The test feeds a newline-bearing name and asserts it is not retained.

BLOCKING -- src/kiro_crew/acp/skill_projection.py:169 -- View stores use conflicting retention bounds

Adjudicated as a downgrade, fixed anyway because it is one line: both stores now use _VIEW_SOURCES_MAX (2048).

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 30, 2026

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bulk approve: readiness passed, board green, no outstanding changes requested.

@chenmingwei23
chenmingwei23 merged commit 49df1b6 into main Sep 30, 2026
97 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/skill-view-mode-recover branch September 30, 2026 03:44
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 30, 2026
bolichen97 added a commit that referenced this pull request Sep 30, 2026
Backport of #15132 (name skill-view aliases without MCP env values,
keep the source path in the name) and #15125 (set_mode never sends an
alias kiro-cli has not loaded: the fresh alias, a forced rescan and a
3 s retry, then the authored agent only while its grants are unchanged
since spawn) to release/0.8.0, squashed to keep the backport within
two commits. #15202's view-source map is not on this branch, so only
#15125's own lines were kept where its commit touches that code.

(cherry picked from commit 96888ff)
(cherry picked from commit 689291f)

Co-authored-by: buluoray <38930179+buluoray@users.noreply.github.com>
bolichen97 added a commit that referenced this pull request Sep 30, 2026
Backport of #15132 (name skill-view aliases without MCP env values,
keep the source path in the name) and #15125 (set_mode never sends an
alias kiro-cli has not loaded: the fresh alias, a forced rescan and a
3 s retry, then the authored agent only while its grants are unchanged
since spawn) to release/0.8.0, squashed to keep the backport within
two commits. #15202's view-source map is not on this branch, so only
#15125's own lines were kept where its commit touches that code.

(cherry picked from commit 96888ff)
(cherry picked from commit 30840bb)

Co-authored-by: buluoray <38930179+buluoray@users.noreply.github.com>
bolichen97 added a commit that referenced this pull request Sep 30, 2026
Backport of #15132 (name skill-view aliases without MCP env values,
keep the source path in the name) and #15125 (set_mode never sends an
alias kiro-cli has not loaded: the fresh alias, a forced rescan and a
3 s retry, then the authored agent only while its grants are unchanged
since spawn, with every non-volatile MCP env value in the alias name) to release/0.8.0, squashed to keep the backport within
two commits. #15202's view-source map and #15278's AcpFrameTooLarge are
not on this branch, so only #15125's own lines were kept where its commit
touches that code, and its agent-name admission uses this branch's
registered-name grammar directly.

(cherry picked from commit 96888ff)
(cherry picked from commit 5434873)

Co-authored-by: buluoray <38930179+buluoray@users.noreply.github.com>
bolichen97 added a commit that referenced this pull request Sep 30, 2026
Backport of #15132 (name skill-view aliases without MCP env values,
keep the source path in the name) and #15125 (set_mode never sends an
alias kiro-cli has not loaded: the fresh alias, a forced rescan and a
3 s retry, then a clear start failure rather than any older copy, with
every non-volatile MCP env value in the alias name) to release/0.8.0,
squashed to keep the backport within two commits. #15202's view-source
map and #15278's AcpFrameTooLarge are not on this branch, so only
#15125's own lines were kept where its commit touches that code, and
its agent-name admission uses this branch's registered-name grammar.

(cherry picked from commit 96888ff)
(cherry picked from commit 0f54509)

Co-authored-by: buluoray <38930179+buluoray@users.noreply.github.com>
bolichen97 added a commit that referenced this pull request Sep 30, 2026
…15574)

* fix(acp): backport skill-view mode errors and alias naming (#15140, #15132)

fix(acp): stop sending skill-view mode errors to setup --clean (#15140)

(cherry picked from commit ac0c8bb)

fix(acp): name skill-view aliases without mcp env values (#15132)

* fix(acp): name skill-view aliases without mcp env values

A sandboxed kiro-cli launcher that rewrites a fresh per-write value into
every agent file's MCP server env changed each projected view on every
spawn, so each spawn named a new kirocrew-skill-view alias per agent and
the agents directory grew without bound.

The alias digest now hashes the view with each server's env reduced to
its sorted key list. A changed env value reuses the alias and
publication rewrites the file with the full view; an added or removed
env key still names a new alias.

Refs #15119

* fix(acp): keep the source path in the skill-view alias name

Dropping env values from the alias digest let two agent files that
differ only in env values share one alias, so a project agent copied
into two workspaces with its own token each could publish one
workspace's credential into the alias the other launches. The source
spec path is now part of the digest, so each agent file keeps its own
alias while env value rewrites still reuse it.

(cherry picked from commit 96888ff)

* fix(acp): backport skill-view mode-name mapping and settings retry (#15202, #15177)

fix(acp): map stored skill-view mode names to their source agent (#15202)

Co-authored-by: Joe Guo <zejiangg@amazon.com>
(cherry picked from commit 49df1b6)

fix(acp): retry the Kiro settings read in the native skill projection (#15177)

A transiently refused gated read of a healthy cli.json (a rename-over between open and the descriptor check, or a saturated path resolver) made _settings raise, so a new dashboard chat failed to start. _settings now retries: an immediate re-check, then one resolver-budget pause and a final attempt, off the event loop only. A path that stays refused still raises.

Co-authored-by: Joe Guo <zejiangg@amazon.com>
(cherry picked from commit 2b91a6b)

---------

Co-authored-by: Ray Xu <38930179+buluoray@users.noreply.github.com>
Co-authored-by: Joe Guo <zejiang.guo@gmail.com>
Co-authored-by: Joe Guo <zejiangg@amazon.com>
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.

2 participants