Skip to content

fix(cloud): name a refused session manager plugin instead of offering a reinstall - #24863

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/issue-triage/fix-24781-plugin-refused-tunnel
Oct 27, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/issue-triage/fix-24781-plugin-refused-tunnel

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: When Remote Crew or kirocrew cloud cannot use an installed Session Manager plugin because its file ownership fails the safety check, it says so and names the fix, instead of saying "not installed" and offering a reinstall.

On macOS, a plugin file owned by a leftover account (uid 1501 in the report) is refused by the gateway's provenance check. Starting a Remote Crew SSM tunnel then fails with "session-manager-plugin is not installed locally. Install the AWS Session Manager plugin...". The CLI connect/launch flow offers to install it again. Reinstalling and restarting do not help, because the AWS package does not reset the ownership.

Why it matters

Anyone whose plugin tree carries stale ownership (an older, imaged, migrated or MDM-pushed install) cannot connect to Remote Crew, and the product points them at a reinstall loop that can never fix it. The user has to find the ownership cause alone.

Not a goal

  • Accepting a plugin the provenance check refuses. The check stays exactly as it is; a binary owned by a third account is still not run with AWS credentials.
  • Changing the dashboard pre-flight or kirocrew cloud doctor; both already name a refusal on main.
  • New UI copy or translations in the dashboard.

What changed (motivation → approach → change)

Symptom: a found-but-refused plugin is reported as missing when a tunnel starts.

Root cause: the pre-flight and doctor rows were taught to tell "refused" from "missing" (session_manager_plugin_refusal()), but the paths that run at connect time still only asked session_manager_plugin_installed() and printed the install hint.

Decision: keep the refusal, and make every connect-time path explain it. This is the most conservative fix; it changes what the user reads, never what the gateway trusts.

Path Before After
Remote Crew tunnel start (ssh_tunnel_manager_lifecycle.py) "not installed" refused path, reason, next step
require_session_manager_plugin() (cloud connect) "not installed" same message
install_session_manager_plugin(), refused in AWS's tree downloads and reruns the installer returns the refusal, installs nothing
_ensure_session_manager_plugin() in cli_cloud.py and wizard.py, refused in AWS's tree prompts "Install now?" prints the refusal, no prompt
Installer finished but the plugin is still refused "not found on PATH" the refusal

A new helper, session_manager_plugin_unavailable_message() in cloud/ssm.py, builds that message. When the refused file sits in AWS's own install tree it adds the known sudo chown -R root:<group> /usr/local/sessionmanagerplugin command, after the same "reinstall it from AWS first if you are not sure" warning the doctor shows. With no fix command, it adds the next step for that refusal code from REFUSAL_NEXT_STEP. That per-code table moved from cli_cloud.py into cloud/ssm.py, so the doctor and this message read the same one. With no refusal it returns the old install hint. The tunnel manager builds it in a worker thread, like the probe before it.

The reinstall offer is skipped only when reinstall_cannot_clear_refusal() is true: the refused file is in AWS's own tree with a known ownership fix, so the installer would rewrite that same file. A refused copy elsewhere (for example a second account's Homebrew) still gets the install offer, because a fresh AWS install in /usr/local/bin can be accepted after it.

Backwards compatibility

Compatible: a plugin that is absent still gets the same install hint, and an accepted plugin takes the same path as before; only the refused case reads differently.

Removes nothing: the change adds a message helper and an early return; no key, function, or accepted input is removed.

Tests

  • test_cloud_ssm.py: a really refused plugin (real resolver walk, refusing validator) makes require_session_manager_plugin() name the path and reason. A plugin refused in AWS's tree is not reinstalled; a refusal with no known fix still runs the installer. The helper adds a known remedy and falls back to the install hint. test_unavailable_message_without_a_remedy_takes_the_per_code_next_step: a file another account owns, with no fix command, gets the table's other_owner step; it fails with the old hard-coded sentence put back.
  • test_cloud_cli.py / test_cloud_wizard.py: with a refusal in AWS's tree, _ensure_session_manager_plugin() names it and never prompts or installs.
  • test_instances_ssm.py: a Remote Crew SSM connect with a refused plugin errors with the refusal, not "not installed", and spawns no tunnel.
  • Existing missing-plugin tests now pin session_manager_plugin_refusal to None, so they no longer depend on what the host has installed.

Proof: PROVEN test/test_cloud_cli.py::TestEnsurePlugin::test_a_refused_plugin_is_named_not_offered_an_install, test/test_cloud_ssm.py::TestSessionManagerPluginProbe::test_a_refused_plugin_is_not_reported_as_not_installed_at_tunnel_start, test/test_cloud_wizard.py::TestSessionManagerPluginPrereq::test_ensure_session_manager_plugin_names_a_refusal_instead_of_offering_install, test/test_instances_ssm.py::TestSsmTransportSelection::test_ssm_connect_names_a_refused_plugin_not_missing (head 651d26c96140)

test_a_plugin_refused_in_aws_install_tree_is_not_reinstalled calls a function that is new in this PR, so prove.py's full revert fails it on a missing name and does not count it. Proved by hand instead: with reinstall_cannot_clear_refusal() kept but returning False, it fails on assert False is True; on the fix it passes (head 76b84fdae88e). Both proofs ran before the last rebase onto main; the diff is unchanged since.

Self-review (local Opus/GPT reviewers could not start: host memory stayed under 1 GB): the provenance check and resolve_aws_tool_bin are untouched, so nothing new is accepted or run. The reinstall offer is dropped only for a refusal inside AWS's own tree, where the installer cannot change ownership; a refused copy elsewhere keeps the offer. The chown remedy is only printed, never run, behind the same "reinstall from AWS first" warning the doctor uses. The tunnel manager builds the message off the event loop. CI's GPT and Opus lanes are the review of record.

Determinism: the new tests passed 20/20 repeats, and in reversed file order. They use tmp_path, monkeypatched module state and no clocks, sockets or sleeps.

Scoped suites run: test_cloud_ssm.py, test_cloud_ssm_cov80.py, test_cloud_cli.py, test_cloud_wizard.py, test_cloud_connect.py, test_cloud_handlers.py, test_instances_ssm.py (468 passed). isort, flake8, black, mypy and the repo's semgrep rules are clean on the diff.

Manual verification

N/A: the refusal is driven by file ownership that unit tests reproduce through the real resolver; no UI was changed.

Related Issues

Closes #24781

Sibling sweep

Swept: git grep -nE "session_manager_plugin_install_hint|session_manager_plugin_installed(" -- src/
Sibling: src/kiro_crew/instances/ssh_tunnel_manager_lifecycle.py -- changed here
Sibling: src/kiro_crew/cloud/ssm.py:566 -- changed here
Sibling: src/kiro_crew/cloud/ssm.py:522 -- changed here
Sibling: src/kiro_crew/cli_cloud.py:635 -- changed here
Sibling: src/kiro_crew/cloud/wizard.py:798 -- changed here
Sibling: src/kiro_crew/cloud/connect.py -- not affected -- calls require_session_manager_plugin, fixed above
Sibling: src/kiro_crew/cli_cloud.py:576 -- not affected -- already names the refusal before the install hint
Sibling: src/kiro_crew/dashboard/handlers_cloud.py:395 -- not affected -- already returns the refusal fields

Pattern harvest

Rule candidate: review-prompt
Pattern: "a probe that has a refused-vs-missing variant, called somewhere that still reports only missing"

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

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 7ef349bdb38c538e08cf39615c141e72e498576e 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 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

No design-level concerns. The change only alters messages and adds one early return before reinstalling; the provenance check is unchanged.

Notes

  • reinstall_cannot_clear_refusal() treats "has a remedy_command" as meaning "the file is in AWS's own tree". If a remedy is later added for a path outside that tree, the reinstall offer silently goes away for it too. Checking the location directly would keep the reinstall gate correct if that happens.

[DESIGN-REVIEWED] 7ef349b

Description read

[DESCRIPTION-READ] d9cfd437abfd21adafca382b2d45738d809c37f2274c0d69e555676493b2c080

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 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7ef349bdb38c538e08cf39615c141e72e498576e — 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

The fix is aimed at the cause: the connect-time paths were missing the refused-versus-missing split. One copy duplication rides along.

Notes

  • Item 2 — oversized: session_manager_plugin_unavailable_message() writes out the "If you did not install it from AWS yourself, or are not sure, reinstall it from AWS first. Then make its install directory root-owned and rerun:" text again. _cloud_doctor in src/kiro_crew/cli_cloud.py:578-590 already prints the same text from its own string literals, so the two copies can drift apart. Subtraction: have _cloud_doctor's refused branch print ssm.session_manager_plugin_unavailable_message() and delete its three inline ui.detail literals. (I grepped for "reinstall it from AWS first" and got 2 sites.)

What this change ships

Inventory (6 items) — 6 justified

Intent: a user whose Session Manager plugin is refused by the ownership check is told why and how to fix it, not sent into a reinstall loop. FIX (#24781).

  1. A Remote Crew SSM tunnel start with a refused plugin names the path, the reason and the next step, not "not installed" — justified
  2. cloud connect (require_session_manager_plugin) shows the same refusal message — justified
  3. install_session_manager_plugin no longer downloads when the refused file is in AWS's own tree — justified
  4. The CLI and wizard "Install now?" prompt is skipped for that refusal — justified
  5. When the installer ran and the plugin is still refused, it reports the refusal instead of "not found on PATH" — justified
  6. The next-step table moved from cli_cloud.py into ssm.REFUSAL_NEXT_STEP and is now shared — justified

[FIRST-PRINCIPLES-REVIEWED] 7ef349b

Description read

[DESCRIPTION-READ] 901d575aa35e18e23060b95aaca0e01aa48dee3ff264891fa6a676067d4ea8af

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 Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 7ef349b

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

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

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

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7ef349bdb38c538e08cf39615c141e72e498576e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7ef349b

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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Backend Tests (Windows) (2) is red on test/test_crew_log_fullscan_guard.py::test_a_warm_session_read_that_earns_a_savepoint_reads_only_the_gap ([XPASS(strict)]). This is main's known red, tracked in #24765 with the fix in #24774; this PR does not touch that code. No rerun or new issue; I will rebase once the fix lands.

🤖 AI-assisted comment 🤖

@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 27, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/fix-24781-plugin-refused-tunnel branch from 876e699 to 6588026 Compare October 27, 2026 12:52
@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 Oct 27, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/fix-24781-plugin-refused-tunnel branch from 6588026 to 7ef349b Compare October 27, 2026 13:29
@iamwhatever

iamwhatever commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: per-code next-step table for a refused plugin with no fix command

  • span=f53058676f03 Second spelling of the per-code next step

fixed in 7ef349b: the next-step table moved to cloud/ssm.py as REFUSAL_NEXT_STEP; the doctor and session_manager_plugin_unavailable_message() both read it, and the hard-coded fallback sentence is gone.
Test: test/test_cloud_ssm.py::TestSessionManagerPluginProbe::test_unavailable_message_without_a_remedy_takes_the_per_code_next_step (an other-account file with no fix command gets the table's other_owner step); it fails with the old sentence restored.
Made in-session, not by a review helper: helpers could not start because host memory was near zero.

🤖 AI-assisted comment 🤖

@iamwhatever

iamwhatever commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: per-code next-step table for a refused plugin with no fix command

  • span=ddd464a68881 Hard-coded no-remedy next step in src/kiro_crew/cloud/ssm.py

fixed in 7ef349b: src/kiro_crew/cloud/ssm.py no longer hard-codes the no-remedy step; it reads REFUSAL_NEXT_STEP[refusal.code], the same table the doctor uses.
Test: test/test_cloud_ssm.py::TestSessionManagerPluginProbe::test_unavailable_message_without_a_remedy_takes_the_per_code_next_step; it fails with the old sentence restored.
Made in-session, not by a review helper: helpers could not start because host memory was near zero.

🤖 AI-assisted comment 🤖

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 27, 2026

@buluoray buluoray 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.

Approving 7ef349b.

A missing plugin cannot be misread as refused: _tool_refusal still returns None both when the resolver accepted a plugin and when it found no candidate at all, and session_manager_plugin_unavailable_message() falls back to the exact old install hint in that case. The new reinstall gate is narrow: it fires only when the refusal carries a remedy command, which _plugin_ownership_remedy produces only for a third-account-owned file inside AWS's own /usr/local/sessionmanagerplugin tree, so a refused copy elsewhere still gets the install offer. The CLI and wizard check installed() first, and the tunnel manager does the filesystem walk off the event loop. The messages are plain sentences naming the file, the reason and the fix, with no traceback, which is what the error-handling spec asks for at a CLI boundary.

Verified locally: the touched cloud and instances tests pass (282), plus 285 in sibling cloud/deploy suites. Making the gate always true, ignoring the remedy, dropping the refusal-None fallback, or reverting require_session_manager_plugin to the install hint each turns a test red. CI is green on this head (91 pass, 16 skipped).

Non-blocking:

  • The post-install "still refused" branch in install_session_manager_plugin isn't covered; removing it keeps the suite green.
  • The Remote Crew tunnel error is still English prose. The cloud handler already exposes refusal codes, so carrying the code on the tunnel status would let the dashboard render it localized later.

@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 27, 2026 16:08

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (8 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: names a found-but-refused session manager plugin and its reason instead of offering a reinstall that rewrites the same file; acceptance unchanged; with tests.

@KiroCrewCaptain
KiroCrewCaptain merged commit fa7d1ba into main Oct 27, 2026
166 of 175 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/issue-triage/fix-24781-plugin-refused-tunnel branch October 27, 2026 16:14
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 27, 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.

Session Manager plugin reported "not installed" when the plugin is installed and working

3 participants