Skip to content

fix(dashboard): alias slots share one project directory - #25899

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/alias-shared-binding-13099
Oct 30, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/alias-shared-binding-13099

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Two chat tabs that share one conversation also share one project directory, so saving one tab never erases the directory the other tab set.

Two live slots that resolve to one transcript (aliases) also run one session and one working directory. Yet each held its own project copy. A blank alias's forced save wrote project: "" over the directory its peer had just stored (#13099).

Why it matters

A user who sets a project in one tab of a shared conversation loses it as soon as the other tab saves. The next restore comes back with no project, so turns run in the wrong directory without warning.

Not a goal

  • Wiring the shared binding into the other transcript-join sites (restore, resume, cron, workflow, channel rebind) and the static guard that keeps new join sites from skipping it. That is the next slice of Single-source transcript-shared slot metadata (alias slots hold divergent per-slot copies) #7497.
  • Moving any other per-session field (memory_store, agent_kind, autocompact_pct, turn_timeout_secs) into the binding.
  • Changing what the metadata codec writes. A real clear still writes "".

What changed (motivation → approach → change)

Root cause: project is per-session state, but it lived in a per-slot cell.

Approach: aliases hold the SAME cell. A new TranscriptBinding object holds project, and _ChatSlot.project is now a property over it. A new slot starts with a private binding. bind_transcript(state, slot) (new, dashboard/transcript_binding.py) runs in get_or_create_slot once the slot's history key is final. It adopts a live alias's binding (the live peer wins), copies the value when a slot leaves a group, and otherwise leaves it alone. It also runs at the end of metadata_codec.apply, after the link row, so tabs restored or resumed from disk rejoin their alias group. A joiner or a disk seed fills a peer that never chose a directory, and arms the deferred reset when that moves a running session.

Because the cell is shared, the existing writers need no change: slot.project = x writes the group's value, and each _CommitToken rollback (slot.project is token) skips a peer's newer write and restores the group otherwise.

Two places had to follow the sharing:

Place Change
Seed from disk (channel_slots.py surface) and restore read (slot_persistence/metadata_codec.py _read_project) skip the stored directory only when a live alias holds a directory the group chose (a set, or a clear of one it held), so a stale value cannot replace it; a slot born linked and never seeded still takes the stored one
_CommitToken rollbacks (chat_api/agent_switch.py, chat_api/session_relaunch.py) rollback_project restores the directory and whether it was chosen, still only while the token is the value
Deferred session reset on a project change (chat_api/session_relaunch.py, crewmate_worktree_scope.py, handlers/members_thread.py, session_directive_apply_slot.py) arm_project_reset arms the reset on every live alias, and bind_transcript hands a still-pending reset to a slot that joins, so no alias's next turn reuses the process in the old directory

Backwards compatibility

Compatible: a slot that never aliases keeps a private binding and behaves exactly as before; every caller still reads and writes slot.project as a string.

Removes nothing: no key, field, route or check is removed; project is still read and written under the same name and persisted the same way.

Tests

test/test_alias_slot_shared_project.py (new) pins: the #13099 repro (a blank alias's save keeps the peer's directory); a clear on one alias stays a clear; a joining slot adopts the live peer; a slot on its own transcript keeps its own value; leaving a group copies the value; both rollback outcomes across aliases, and a rollback restoring the unchosen state while a concurrent clear stays a choice; disk seed and restore read do not overwrite a chosen shared directory or clear, but still seed a lone slot or an unseeded alias; a project change arms the reset on every alias (helper and the set_project directive), and a slot that joins while that reset waits inherits it; the copy.copy edit-resend and rewind paths never write project; two tabs restored through metadata_codec.apply rejoin one binding.

test/test_state_parts_facade.py: the slot inventory now lists _binding and the project property.

test/test_cleared_project_not_resurrected.py passes unchanged (a real clear still writes "").

Determinism: the new file passed 10 of 10 repeats and in a shuffled order.

Proof: PROVEN test/test_alias_slot_shared_project.py::test_blank_alias_save_keeps_peer_project, test/test_alias_slot_shared_project.py::test_a_joining_slot_adopts_the_live_peers_directory, test/test_alias_slot_shared_project.py::test_a_rollback_with_no_peer_write_restores_the_group, test/test_alias_slot_shared_project.py::test_a_restore_read_does_not_overwrite_a_shared_binding, test/test_alias_slot_shared_project.py::test_the_set_project_directive_arms_the_peer (head e8cfc7e)

Manual verification

N/A — unit coverage sufficient: the change is in-memory slot state and its two persistence readers, which the tests drive through the real DashboardState, get_or_create_slot and _save_slot_to_history.

Related Issues

Part of #13099
Refs #7497

Sibling sweep

Swept: git grep -nE ".linked_session_key = |.channel_origin = " -- src/kiro_crew
Sibling: src/kiro_crew/dashboard/state_parts/slot_directory.py -- changed here
Sibling: src/kiro_crew/dashboard/channel_slots.py -- tracked in #7497
Sibling: src/kiro_crew/dashboard/chat_api/resume.py -- changed here -- joins through metadata_codec.apply
Sibling: src/kiro_crew/dashboard/cron_inject.py -- tracked in #7497
Sibling: src/kiro_crew/dashboard/handlers/cron_runs.py -- tracked in #7497
Sibling: src/kiro_crew/dashboard/workflow_inject.py -- tracked in #7497
Sibling: src/kiro_crew/dashboard/slot_persistence/metadata_codec.py -- changed here

Pattern harvest

Rule candidate: review-prompt
Pattern: per-session state stored once per slot, so alias slots on one transcript hold divergent copies

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision e8cfc7ef881b53386648e19b8bab8b4a7aeed5ce 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 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

The root cause is fixed in the right place: aliases now hold one shared project cell, so the existing writers and rollbacks need no per-alias changes.

Notes

  • bind_transcript only protects slots at the two places it's called (get_or_create_slot and metadata_codec.apply). Until the Single-source transcript-shared slot metadata (alias slots hold divergent per-slot copies) #7497 follow-up adds the static guard, any new place that changes a slot's history key and skips the call will bring the bug back without any warning.
  • The copy.copy(slot) previews in chat_rewind.py:296 and chat_regenerate.py:559 now share the live binding. One prospective_slot.project = … write would change the group's directory. Only the "never writes project" test prevents that today.

[DESIGN-REVIEWED] e8cfc7e

Description read

[DESCRIPTION-READ] 44a865fd39251c09d00a86557e2387ff32a1c687c505c074474654b558060967

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 e8cfc7ef881b53386648e19b8bab8b4a7aeed5ce — 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 removes the cause: aliases now share one project cell. The remaining work (other join sites, other per-session fields) is deferred to #7497, which the description says.

Notes

  • Item 1 — second mechanism for the same class: chat_api/slot_settings.py:203-206 keeps autocompact_pct in step across aliases by copying the value onto each live alias (other.autocompact_pct = pct, plus rollback at 225-240). This PR syncs project with a shared cell instead. Grepping slot_history_key\(other\) == found 5 such copy sites in slot_settings.py and session_directive_apply_slot.py, none removed here. The codebase now has two ways to sync alias state. ## Not a goal defers moving the other fields. Subtraction: when Single-source transcript-shared slot metadata (alias slots hold divergent per-slot copies) #7497 moves those fields into TranscriptBinding, delete the copy loops in slot_settings.py:203-240 instead of keeping both.

What this change ships

Inventory (7 items) — 7 justified

Intent: two tabs on one conversation keep one project directory, so saving one tab never erases the directory the other tab set. This is a FIX (#13099).

  1. A blank alias's save no longer erases its peer's project directory — justified
  2. A tab joining a live alias takes on the peer's directory — justified
  3. A tab that leaves an alias group keeps its directory privately — justified
  4. Disk seed and restore no longer overwrite a directory or clear a live alias chose — justified
  5. Changing the project resets the session on every alias, and a tab joining while that reset waits inherits it — justified
  6. Tabs restored from disk rejoin their alias group after the codec runs — justified
  7. Rollback restores both the directory and whether the group had chosen one — justified

[FIRST-PRINCIPLES-REVIEWED] e8cfc7e

Description read

[DESCRIPTION-READ] dd2d7ee4626cea328d53e205bbd38bb037c781b739e1d9511ecd4b0bc5997050

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] e8cfc7e

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable e8cfc7ef881b53386648e19b8bab8b4a7aeed5ce 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 e8cfc7ef881b53386648e19b8bab8b4a7aeed5ce and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e8cfc7e

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

@bolichen97
bolichen97 force-pushed the fix/alias-shared-binding-13099 branch from 6409967 to 355bccb Compare October 29, 2026 19:29
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • In-turn project changes abort an alias’s pending message span=2f3a0f4dbfec

Rebutted: disproportionate remedy, no data at risk. The race needs two live aliases with A's agent emitting set_project inside B's admission await; B then fails loudly with "conversation binding changed during preparation; retry the turn" (turn_admission.py:145), is not counted as a session fault, and a retry re-captures the binding under the lock.
The proposed fix takes the non-reentrant slot_switch_session_lock on the tool-result path, which that turn's own refusal-fallback helpers already take, a new lock-ordering contract with deadlock risk. The server adjudication downgraded it on the same grounds.

@bolichen97
bolichen97 enabled auto-merge (squash) October 29, 2026 19:39
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in files this PR imports or shares a directory with (dashboard/state_parts/, dashboard/chat_turn/, dashboard/chat_api/, dashboard/slot_persistence/ and others) since this head went green (2ad709c -> d328624400); CI re-running.

@bolichen97
bolichen97 force-pushed the fix/alias-shared-binding-13099 branch from 355bccb to a8f841a Compare October 29, 2026 20:18
@bolichen97

Copy link
Copy Markdown
Contributor Author

The three red tests on this head (test_dir_fd_create_race_ratchet::test_no_lock_file_is_created_with_a_nonexclusive_open, test_security_gate_liveness::test_the_package_stays_within_its_line_budget, test_subagent_prompt_hooks::test_hook_time_is_not_charged_to_the_first_prompt_watchdog) also fail on a clean checkout of this PR's base d32862446c, in files this PR does not touch. #25947 fixes them; this PR rebases once it merges.

@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
@bolichen97
bolichen97 force-pushed the fix/alias-shared-binding-13099 branch from a8f841a to cc2df4f Compare October 29, 2026 21:26
@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: disk-seed guard that lets a live alias's directory outrank stale metadata

  • An unseeded workflow alias suppresses the persisted project span=61ea77cbdfb3

fixed in cc2df4f: the disk seed (channel_slots.py surface) and restore read (metadata_codec.py _read_project) now skip the stored directory only when the shared binding holds a directory the group chose, tracked by TranscriptBinding.assigned. A slot born linked and never seeded (the workflow fallback) has not chosen, so it takes the stored directory.
A set, or a clear of a held directory, is a choice; "" over "" (a blank computed default) is not; _CommitToken rollbacks go through rollback_project, which restores whether it was chosen. Tests: test_an_unseeded_live_alias_*, test_a_live_explicit_clear_outranks_stale_disk, test_a_rolled_back_*, test_a_clear_during_a_pending_commit_is_a_choice.

@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
@bolichen97
bolichen97 force-pushed the fix/alias-shared-binding-13099 branch from cc2df4f to cbc0ddc Compare October 29, 2026 21:55
@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 29, 2026
@bolichen97

bolichen97 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: join of restored alias tabs to one shared binding

  • Restored alias tabs never rejoin one binding span=420fdb4ad597

fixed in cbc0ddc: metadata_codec.apply now calls bind_transcript after the whole FIELDS loop, so the link row has run and a restored or resumed tab joins its live alias. An unseeded live peer takes the restored directory (and the deferred reset is armed when that moves a running session); a peer that chose a directory, or cleared one, still wins.
Tests: test_restored_aliases_rejoin_one_binding, test_a_restored_tab_seeds_an_unseeded_live_alias, test_a_restored_tab_keeps_a_live_aliases_clear, test_seeding_a_running_alias_arms_its_reset. This pulls the restore and resume join ahead of the next slice; the frozen Not-a-goal line still lists them and is left for a maintainer to edit.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Each alias repeats an already-completed project reset span=3eb32f58bc96

Rebutted: disproportionate remedy, no correctness or data cost. A second armed alias spends its flag only through state.sessions.reset(..., skip_if_busy=True) on the shared key, so the worst case is one extra cold start of a session already in the right directory; it never runs a turn in the wrong cwd.
Consuming once per binding needs a new cross-alias reset ledger with its own compare-and-clear against newer arms, a larger contract than the one extra spawn it saves. The server adjudication downgraded it on the same grounds.

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

Copy link
Copy Markdown
Contributor Author

Rebased onto main carrying #25947, which fixes the three red tests this PR inherited (test_dir_fd_create_race_ratchet, test_security_gate_liveness, test_subagent_prompt_hooks); all three pass locally on the new head f86625b. CI re-running.

@bolichen97
bolichen97 force-pushed the fix/alias-shared-binding-13099 branch from cbc0ddc to f86625b Compare October 29, 2026 21:59
@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
@bolichen97
bolichen97 force-pushed the fix/alias-shared-binding-13099 branch from f86625b to 104af98 Compare October 29, 2026 22:44
@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 29, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in files that share a directory with this PR's (dashboard/agent_origin.py, dashboard/approval_inheritance.py and others under dashboard/) since this head went green (7e09632 -> e106845); CI re-running.

@bolichen97
bolichen97 force-pushed the fix/alias-shared-binding-13099 branch from 104af98 to e8cfc7e Compare October 29, 2026 23:40
@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 Oct 30, 2026

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

Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head, UX skipped or pass, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit f94edb7 into main Oct 30, 2026
93 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/alias-shared-binding-13099 branch October 30, 2026 02:25
@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.

2 participants