Skip to content

fix(dashboard): publish no binding on an unsettled arm target - #12055

Closed
rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:split/unsettled-arm-publishes-nothing
Closed

rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:split/unsettled-arm-publishes-nothing

Conversation

@rnoack1

@rnoack1 rnoack1 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a workspace or project switch that cannot settle its arm on the key that actually landed answers 409 session_rebound and leaves the slot unchanged, instead of publishing a binding nothing carries.

A slot's workspace and project switches resolve which session key the change should land
on behind an await. A rebind arriving inside that window is parked rather than applied,
so the key the resolve observed never moves and it reports the arm unsettled.

A caller that publishes anyway leaves a workspace or project visible on the slot with no
arm raised to carry it. The next cwd-less claim then binds the directory the slot is
leaving, so every relative write in that turn lands in the wrong project.

Why it matters

The switch answers 200 and the UI shows the new project, so nothing signals that the
binding was never armed. The damage surfaces one turn later and somewhere else — a file
written to the previous project — with no trace connecting it to the switch that caused it.

The cleared case is worse than the unset one. Restoring an empty path without the
cleared marker makes a deliberately-cleared slot read as never-set, and the stored-cwd
resume override then restores the very project the user just cleared.

Not a goal

  • Changing how the rebind itself is parked or applied; this only changes what the switch handlers do when the arm does not settle.
  • Retrying on the server: the 409 hands the retry to the caller, against the current binding.

What changed

Both handlers now branch on whether the arm settled:

  • settled — the arm is transferred to the key that actually landed and the switch
    commits;
  • unsettled — the handler unwinds what it already committed (project, cleared marker,
    pending reset key), marks the slot dirty and answers 409 session_rebound, so the
    caller retries against the current binding.

_settle_arm_target is the single place that resolves an arm target and reports whether it
settled, and it retracts the source arm when it does not.

The slot-allocation core, the arm verbs and the cleared-cwd marker are carried here
identically to their siblings (#11813, #11831, #11910, #11983) so this change compiles and
tests on its own.

Tests

Three added cases in test/test_chat_slot_unsettled_publish.py:

  • a parked rebind during the settle commits nothing;
  • an unsettled transfer unwinds a project that was already committed;
  • a cleared slot comes back cleared, not merely empty.

One existing test is replaced rather than deleted: the rebind-during-save case previously
pinned a rollback, but rolling back is the wrong remedy there — the save awaits after the
arm, so the correct behaviour is to transfer the arm to the live key and commit. It is
renamed to test_rebind_during_the_save_transfers_the_arm_to_the_live_key and now asserts
the transfer. It is also the positive control for the branch the three added cases do not
reach.

Break-armed in both directions:

  • removing the arm_settled guard from the workspace handler fails the workspace case
    while both project cases still pass;
  • removing the project unwind fails both project cases while the workspace case still
    passes;
  • removing the arm transfer fails the replacement case while all three added cases still
    pass.

Several existing fixtures mock resolve_arm_cwd synchronously; it is awaited here, so
they are updated to AsyncMock at the shared state builders rather than per test.

Full suite (110k tests) against a pristine same-base control, both runs launched together
on the same host: zero new failures. The single asymmetry is one item in
test_session.py::TestCleanupLoopResilience, in a file this change does not touch — it
passes 2/2 across four runs on each tree and flips under parallel load only.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 19, 2026
@rnoack1
rnoack1 force-pushed the split/unsettled-arm-publishes-nothing branch from 4c4bf14 to 77293c3 Compare September 19, 2026 18:03
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 19, 2026
@dwu96

dwu96 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 21, 2026
@dwu96

dwu96 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

5 similar comments
@dwu96

dwu96 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

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

Windows-visible runtime issue at head 77293c3178:

The new empty-cwd branch in config.paths.resolved_cwd imports session_default_cwd from config.loader, but that symbol is absent from this head. Clearing a project or resolving the default cwd therefore raises during session reuse/rebinding on Windows and other platforms.

Please include the intended implementation or route through the existing default-cwd owner, and add an unmocked resolved_cwd("") test.

Copy link
Copy Markdown
Contributor

PR triage (automated, head 77293c3178)

P0, following up @bolichen97's review: this breaks every workspace switch, not only clears.

config/paths.py:385 (resolved_cwd) imports session_default_cwd from kiro_crew.config.loader. That function does not exist anywhere at this head (git grep session_default_cwd 77293c3178 matches only that import and its call). It is defined in #11813 and #11831, but this PR does not carry it.

What breaks:

  • api_chat_slot_workspace (chat_handlers.py:9215) calls state.sessions.resolve_arm_cwd(session_key, CWD_CLEARED) on every request, whatever the target. That call reaches resolved_cwd("", key), which raises ImportError. The handler catches it and answers 503 workspace_unavailable, so no workspace switch can succeed.
  • api_chat_slot_project (chat_handlers.py:9531) follows the same path for project="", so clearing a project also returns 503.
  • _record_arm_cwd / transfer_retire_arm (session_allocation.py:569, :646) reach the same import whenever an arm states the cleared cwd.

The tests pass because every fixture replaces resolve_arm_cwd with an AsyncMock (chat_test_helpers.py:133, test_chat_slot_project.py:31, test_chat_slot_switch_atomicity.py:77, test_eager_spawn.py:62, and others). The real resolve never runs. Please carry session_default_cwd, or land after #11813, and add one unmocked resolved_cwd("", "<key>") test.

Rebase: this head conflicts with main (merge base 10a8953f8a, 2284 commits behind).

Merge discussion: this PR carries identical copies of the arm core (CWD_CLEARED, resolved_cwd, resolve_arm_cwd, transfer_retire_arm, _settle_arm_target) alongside the open #11813, #11831, #11910 and #11983. The part unique to this PR is the arm_settled branch in the workspace and project handlers, plus test_chat_slot_unsettled_publish.py. None of this is on main yet. Please agree a landing order so the core lands once, from one PR, and the others rebase onto it. Otherwise each copy can drift, as this one already has.

@dwu96

dwu96 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

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

[P0] Workspace switch and project clear always fail with 503: resolved_cwd imports a nonexistent loader symbol

Mechanism: POST workspace switch -> chat_handlers.py:9215 state.sessions.resolve_arm_cwd(session_key, CWD_CLEARED='') -> session.py:1657 asyncio.to_thread(resolved_cwd, '', key) -> config/paths.py:385 'from kiro_crew.config.loader import session_default_cwd' -> ImportError -> caught at chat_handlers.py:9216 -> 503 workspace_unavailable. Project clear/set reaches the same resolve at chat_handlers.py:9531; session_allocation.py:569/646 also call resolved_cwd(cwd, key) with a cleared cwd.

User impact: Every dashboard user: no workspace switch can succeed (always 503 'configured workspace directory is unavailable'), and the project handler's cleared-arm resolve fails the same way; any other cleared-project arm path (chat_runner.py:866, session_allocation arm) raises too.

Location: src/kiro_crew/config/paths.py:385 @ 77293c31784ad27d909f99112de02af1b70c0e5c

Minimum fix: Import the existing per-session default resolver (main's kiro_crew.config.loader._session_work_dir, or add a public session_default_cwd to loader that wraps it) in resolved_cwd, and add one unmocked test.

How to verify: Unmocked test: resolved_cwd('', 'dashboard:x') returns workspace_root()/ (fails now with ImportError); plus a workspace-switch handler test that uses the real SessionManager.resolve_arm_cwd and asserts 200, not 503.

Independently re-verified on head 77293c3178.

Comment thread src/kiro_crew/config/paths.py Outdated
)
# Deferred: this module is a LEAF by design (see the module docstring) and
# ``config.loader`` imports it at module load, so a top-level import cycles.
from kiro_crew.config.loader import session_default_cwd

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.

[P0] Workspace switch and project clear always fail with 503: resolved_cwd imports a nonexistent loader symbol — see the review summary for mechanism, fix and test.

A rebind parked inside the settle leaves the observed key unmoved, so the
caller published a workspace or project with no arm raised to carry it.
@rnoack1
rnoack1 force-pushed the split/unsettled-arm-publishes-nothing branch from 77293c3 to cbae1e7 Compare October 9, 2026 13:26
@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 9, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Closing this draft as part of stale-PR cleanup: it has had no activity for 14+ days. Nothing is lost. The branch stays, and you can reopen this PR (or open a fresh one rebased on main) whenever you pick it up again. Thanks for the work.

@iamwhatever iamwhatever closed this Nov 2, 2026
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 2, 2026
@rnoack1
rnoack1 deleted the split/unsettled-arm-publishes-nothing branch November 13, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants