Skip to content

fix: let a new bot take over a deleted bot's kept memory - #33148

Merged
bolichen97 merged 1 commit into
mainfrom
fix/22487-adopt-kept-memory
Nov 19, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/22487-adopt-kept-memory

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A deleted bot's kept memory gets a supported way back: a new bot created on the dashboard can take it over, and the delete text says so.

The delete dialog says a bot's memory is kept, and on disk it is. But every route into a member store resolves it through its live owner, so once the bot is gone nothing can open that store again: it is missing from the Copy memories dialog and the memory picker, memory export and memory restore refuse it, memory import cannot carry its facets, and a create always makes a fresh store.

Why it matters

The safe-sounding delete strands the memory. A user who deletes a bot and makes it again (the only repair for #22486) loses every memory row it had, with no supported way to get them back.

Not a goal

  • A CLI route. kirocrew agent create runs outside the gateway, so it cannot close the deleted bot's thread that is still live there; the dashboard create is the one route.
  • Copying or merging a kept store into an existing bot's memory, or forcing a copy before a delete.
  • Exporting a member store's markdown layer (memory export --include-markdown).
  • Removing the other files a delete leaves on disk.

What changed (motivation → approach → change)

Where What a user gets
New bot → Advanced settings A Memory choice, shown only when a deleted bot left a kept store: Start with an empty memory (the default) or Memory of (deleted bot)
POST /api/agents Optional adopt_memory_store: the new bot owns that kept store, nothing copied
GET /api/memory/ownerless-stores The kept stores no bot owns (name, former_owner), owner-gated. The dialog reads that gate's 403 owner_only as nothing kept: no Memory field, no notice
Delete confirmation and danger-zone note Say that a new bot can start from the kept memory

A deleted bot's store could not be reached because a member store is addressed through its owner's member id: the delete removes the owner and keeps the store, and nothing could give the store an owner again.

Picking a kept memory now makes the new bot its owner: the new bot is created on the store's recorded member id, so the database, its rows, its backups and its chat thread are used as they are (member_memory_adopt.py). Only a store nobody owns is offered or accepted: no bot holds its id or uses it, no older bot without a member id has a name that maps to that id, its database carries exactly the recorded identity, and no kept thread is filed under a former name. The create's locked write in memory_stores.py checks the same against the config on disk, so a bot written by another process in the meantime wins. A create that fails leaves the kept store as it was. The dialog reads the offer through api/client/memory.ts, and a pick the server refuses as unusable (409 adopt_memory_unavailable) resets it to an empty memory and reloads the list, while a failure after the store's own checks keeps the pick; its strings are in all twelve catalogs (locales/en.json and its translations), and the generated ui-index.generated.json carries the new delete text. Each delete (the dashboard, kirocrew agent delete, the installed-agent sync in installed_agents.py) writes the name the bot showed onto its kept store as former_owner, a new display-only field of the store record (config/memory_sections.py), so a bot named "审查员" is offered by that name, not by its config key, which for such a name is a hash.

The new bot reuses the deleted bot's member id and store, so its chat thread has the same key. Before saving anything, the create clears every approval grant on that thread's session (Trust, Trust reads, an app's scoped grant and the session's stored approval policy) on every slot whose turns run on it, whether or not the thread is still open: a workflow slot linked to that session outlives a closed thread. When the thread is still open in the gateway, the create then closes it, the way closing a tab does (retire_stale_member_slot in members_thread.py). It is refused (409 member_thread_busy) when the grants cannot be cleared or the close fails. The next open restores the conversation under the new bot's name, with the approval mode set from the new bot's settings, never the deleted bot's grant. Its goals follow it too, but any check-in switch still on is turned off, since the delete removed those check-ins and nothing should start them again unasked. The create's audit row names the adopted store. The memory, config, crew-mode and dashboard specs, the Bots guide (crew-members.md) and the feature map describe the route, and the delete-cleanup docstring in crew_removal.py no longer says the memory store is deleted.

Backwards compatibility

Compatible: adopt_memory_store is optional, and leaving it out keeps the fresh store every create makes today; the delete text changes wording only. former_owner defaults to empty (config-baseline.json lists it), and its one reader is the kept-store offer, which loads the config at request time, so no applier or restart mark is needed. A create that leaves it out runs the same locked-write checks as on main.

Removes nothing: no route, field, record or setting is taken away.

Tests

  • test/test_member_memory_adopt.py: create, delete, then create with the kept store, and the new bot owns the same store and member id, its thread binding follows it, and the store leaves the offer list; the deleted bot's goal follows with its check-ins off; a deleted bot's live thread opens as the new bot; a same-name adopt keeps no approval grant from the deleted bot, on its thread or on a slot sharing that session, and is refused with nothing saved when its thread cannot be closed; an adopt clears Trust, Trust reads, a scoped grant and the stored policy on a linked slot of that session, with the thread open or closed, and leaves a slot on another session alone; the offer names a bot by the name it showed after a dashboard or a CLI delete, and an adopt clears it; a same-name create without asking still gets a fresh store; refusals for a store with an owner, a second adopt, an unknown or default store, a malformed name, a mismatched database identity, a store an older bot would share an identity with, and a thread filed under a former name; the locked write's re-checks; a failed create keeps the store; the list is owner-gated, leaves out a store whose folder is gone, and leaves out one whose folder redirects through a link while still listing the others.
  • NewCrewmateDialog.test.tsx: no Memory field when nothing is kept, a failed list read named in the options notice, an owner-only refusal of the list shown as nothing kept, the empty-memory default sends no adopt, a pick sends adopt_memory_store, and a refused pick resets and reloads.
  • CrewEditorNextDialog.test.tsx: the danger-zone note and the delete confirmation say a new bot can start from the memory.
  • Determinism: test/test_member_memory_adopt.py passed 20/20 at -n0, 10/10 at -n 4 --dist loadgroup --max-worker-restart=2 beside test_crew_memory_store_binding.py and test_members_dm_thread.py, and in a shuffled order (seed 22487).

Proof: not provable -- other: the tests import the new member_memory_adopt module, so prove.py reverting every production hunk stops them at collection (exit 21 INCONCLUSIVE); the grant, label, check-in and redirected-store cases were checked red by hand with their fix hunks reverted

Manual verification

On an isolated gateway started from this branch (its own data home, loopback port, a scripted browser): created a bot, opened its thread, deleted it, opened New bot → Advanced settings, picked its memory, created, and opened the new bot; the server's answer named the kept store and member id, the offer list was then empty, and the thread opened under the new name. The refused pick, the storage failure and the failed list read were forced by answering those requests in the browser; the first-greeting turn was left out so no model ran.

Screenshots / video

Captured from this branch on an isolated loopback gateway (its own data home): a bot was created, its thread opened, the bot deleted, then New bot opened.

New bot → Advanced settings with a deleted bot's memory picked (dark, light):

Memory of Reviewer picked, dark
Memory of Critic picked, light

A bot named in a non-Latin script is offered by the name it showed, not its config key:

Memory of a bot named in Chinese picked, dark

The pick refused by the server (another bot took it first): nothing created, back to an empty memory:

Refused pick, dark

Every other state (default, open list, storage failure, failed list read, delete text, the adopted bot)

Default, with the hint:

Default empty memory, dark
Default empty memory, light

The list open:

Options open, dark
Options open, light

Refused pick, light:

Refused pick, light

A storage failure on the same create is said as one, with its reason, and the pick stays:

Storage failure, dark
Storage failure, light

The kept-memory list could not be read:

List read failed, dark
List read failed, light

The danger-zone note and the delete confirmation:

Danger zone note, dark
Danger zone note, light
Delete confirmation, dark
Delete confirmation, light

The new bot after the adopt, on its Profile tab (its memory is its own private store, the kept one):

Adopted bot profile, dark
Adopted bot profile, light

Related Issues

Closes #22487

Builds on #22947 by @mbriones98.

Sibling sweep

Swept: git grep -n "provision_member_memory(" -- src/kiro_crew (every create path) and git grep -n "del agents\[" -- src/kiro_crew (every delete path)
Sibling: src/kiro_crew/cli_commands_agent.py -- changed here
Sibling: src/kiro_crew/dashboard/agent_admin/installed_agents.py -- changed here
Sibling: src/kiro_crew/crewmate_prune_migration.py -- not affected -- it deletes only fresh sync-shaped rows, which keep no member store
Sibling: src/kiro_crew/agent_materialization/first_crewmate.py -- not affected -- it makes the built-in first bot once, never from a user's pick
Sibling: src/kiro_crew/apps/builtins/auto_improvement/backend/crew.py -- not affected -- an app's own bot made from its manifest, never from a user's pick

Pattern harvest

Not generalizable: a member store is the one record a delete keeps on purpose while every reader needs a live owner, so the fix is a single re-own route, not a rule.

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

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 8, 2026 12:08
@bolichen97
bolichen97 requested a review from Zedmor November 8, 2026 12:08
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 8, 2026 12:14
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 93d3a1160412ceb54f4265ef21daa3e5ec52f7d1 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 93d3a11

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@bolichen97
bolichen97 force-pushed the fix/22487-adopt-kept-memory branch from a5bde1f to 2361509 Compare November 8, 2026 17:27
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]

  • Adoption leaves approval grants on surviving session aliases span=bd25c6879186

fixed in 2361509: retire_stale_member_slot now clears Trust, Trust reads, any scoped grant (ended through the same path the Normal choice uses) and the stored session approval policy on every slot whose turns run on the adopted thread's session, before it checks whether the DM is open, so a linked workflow fallback slot is cleared with or without an open DM.
The create is refused if the clear fails. test_an_adopt_clears_every_grant_on_the_threads_session (DM open and closed) was red on the parent head and is green on the fix; a slot on another session keeps its own choice.

AI-assisted, posted on behalf of bolichen97

@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 Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: giving the kept store a new owner by reusing its recorded member id fixes the stranding where it starts. Nothing is copied, existing creates behave as before, and the new surface comes with rendered evidence.

Notes

  • retire_stale_member_slot clears grants and closes the deleted bot's thread before the config lock and before adopt_member_memory's checks. So a create that is then refused (wrong DB identity, a thread filed under a former name) has already ended that thread. It's harmless because the owner is gone, but the order should be stated in the spec.

[DESIGN-REVIEWED] 93d3a11

Description read

[DESCRIPTION-READ] 6a7b92e7910b4ecef77b1a4659bf80204a2c741027adfd14bbc4c746b54a75b4

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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 93d3a1160412ceb54f4265ef21daa3e5ec52f7d1 — 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 default stays a fresh store and every new surface has exactly one counted consumer. The one premise risk is the framing: this is labelled a fix but it adds a capability.

Notes

  • Item 1 — inherited: titled "fix:", but it adds a new recovery route (POST /api/agents adopt_memory_store, GET /api/memory/ownerless-stores). The defect it closes is the delete promise "memory is kept" with nothing able to reopen that store. Siblings the description lists stay unreachable: Copy memories, the picker, memory export, memory restore.

What this change ships

Inventory (9 items) — 8 justified

Intent: a person who deletes a bot and makes a new one gets the deleted bot's kept memory back. This is an ADDITION framed as a FIX.

  1. New bot → Advanced settings shows a Memory choice when a deleted bot left a kept store — inherited (an addition framed as a fix)
  2. POST /api/agents accepts adopt_memory_store (1 consumer: NewCrewmateDialog.tsx:858) — justified
  3. GET /api/memory/ownerless-stores lists kept stores, owner-gated (1 consumer: api/client/memory.ts:144) — justified
  4. The delete confirmation and danger-zone note say a new bot can start from the memory — justified
  5. Every delete path writes a new memory_stores.*.former_owner field, so a non-Latin name is offered by name, not hash — justified
  6. Adopting first clears the session's grants and closes the deleted bot's live thread, or refuses with 409 — justified
  7. Check-ins the deleted bot left on are turned off on adopt — justified
  8. The create's audit row names the adopted store — justified
  9. The locked write re-checks for a bot added at the same time with the same identity — justified

[FIRST-PRINCIPLES-REVIEWED] 93d3a11

Description read

[DESCRIPTION-READ] e665d33f33aec7b99062d23b9a69f7e9b9aebbaeacdd1b9afac9a8e62ee4bb31

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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing blocks. The blind reader understood the new Memory choice and the updated delete text, and all of them appear in screenshots in both themes. The reader's hesitation over the dropdown was about the choice being one-time, which it is.

Notes

  • create_memory_unavailable shows in the error notice near the top of the form (shots 4 and 9), not next to the Memory field it is about. The reader had "to go looking for that box". Show it as the Memory field's error, or name the field: "The memory you picked can no longer be used…".
  • create_memory_hint says "Only one bot can take over each kept memory." The reader took this as a choice "I can't undo" and held back. If it is one-way, say so plainly ("The new bot keeps this memory; no other bot can take it."). Otherwise drop the line.
  • create_options_failed with the list name "Memory" reads "Couldn't load the Memory choices; the default is shown." The reader could not tell what "the default" is. For this list, say "starting with an empty memory".

[UX-REVIEWED] 93d3a11

Description read

[DESCRIPTION-READ] 470b60bf5cf55eb0370f48d8ce42a1eab5d610142f2b9deab5d70285f6b0c19c

That sha256 names everything this verdict read: the PR description, plus the 22 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 removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 93d3a11

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

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

@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 Nov 8, 2026
@bolichen97
bolichen97 force-pushed the fix/22487-adopt-kept-memory branch from 2361509 to 2ae052c Compare November 8, 2026 18:08
@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 Nov 8, 2026
@bolichen97

bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]

  • Every member_memory_unavailable 409 drops the kept-memory pick span=c65d078810fe

fixed in 2ae052c: the create answers a failed close of the deleted bot's thread with 409 member_thread_busy, and a refusal raised by the adopt's own store checks with 409 adopt_memory_unavailable; a failure after those checks (workspace, database writes, the locked config write) keeps member_memory_unavailable.
The New bot dialog drops the pick and re-reads the list only on adopt_memory_unavailable. A dialog test shows the pick kept for member_memory_unavailable and member_thread_busy (red on the old condition), and the backend tests pin each code.

AI-assisted, posted on behalf of bolichen97

@bolichen97

bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]

  • The hint on the Memory choice scares people off the feature the PR exists to add span=a57a53b54234

fixed in 2ae052c: the Memory hint now reads "Start empty, or pick a deleted bot's memory to keep it and its past chats. Only one bot can take over each kept memory." in English, with each catalog using its own word for past chats from the delete text.
It says what the new bot gets, why the choice is single-use, and fits both choices, so the "won't be offered again" wording is gone.

AI-assisted, posted on behalf of bolichen97

@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 and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@bolichen97
bolichen97 force-pushed the fix/22487-adopt-kept-memory branch from 2ae052c to 2bfaf89 Compare November 8, 2026 19:30
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/docs/ui-index.generated.json since this head was pushed, and the PR stopped merging (27e9359 -> 9657892); CI re-running.
The change itself is the same: the generated index took main's side and was rebuilt from the rebased tree, and every other line of the diff is unchanged. The previous head's reds were CI read failures (the Actions installation API rate limit, on the first run and again on the rerun), not a test, so this head's fresh run decides them.
[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97

bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Failed check-in reset leaves inherited schedules enabled span=d3c691a29ac1

Rebutted: the reset has to run after publish. member_goals._payload stamps member_id only for a member the config on disk holds (member_goals.py:611-619), so a reset before publish writes a name-only record; a create that then fails leaves it, and a later adopt under another name reads an empty record and every write raises slug_collision (member_goals.py:704-707).
Fail-closed would let a goal-file permission fault block reclaiming the memory, which is this PR's goal; the other post-publish create steps (the bot-owned config copy, the Bot tools grant) are best-effort the same way.
Nothing restarts a check-in by itself: the delete removed the jobs (crew_removal.py:172-178), and only the owner's own schedule save re-syncs one (handlers/member_goals.py:466), with the switch already shown on in the panel. Nothing is lost and it can be turned off.
The trigger is a goal record readable but not writable inside the operator's own data home; the lane's adjudicator downgraded it as a disproportionate remedy.
[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/22487-adopt-kept-memory branch from 0cb5484 to 7e9ea2e Compare November 13, 2026 13:49
@bolichen97

bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

resolution: removed -- the ownerless-store listing skips an entry it cannot resolve instead of failing every row; F1 is rebutted and the check-in reset stays after publish

  • One redirected store hides every healthy kept-memory choice span=55b0c12b8539

fixed in 7e9ea2e: ownerless_member_stores treats a store whose directory cannot be resolved (UnknownMemoryStore from the redirect refusal, an OSError, or the RuntimeError a self-looping link raises on Python 3.10-3.12) as not offered and keeps listing the rest; _named_store_dir's refusal is unchanged.
The adopt of one named store at member_memory_adopt.py:101 already answers that refusal with a 409 adopt_memory_unavailable, so the list and the create now agree. A test with one redirected and one healthy kept store pins the list (red before the fix); the spec row for GET /api/memory/ownerless-stores says it.
[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/feature-map/README.md since this head was pushed, and the PR stopped merging (9657892 -> a45e97a); CI re-running.
The feature-map row both sides edited keeps main's per-bot panel text and this PR's Memory choice. The previous head's type-check red was main's own (cli_commands_memory.py, fixed on main by #36457), which the new base carries. This head also leaves a kept store whose folder cannot be resolved out of the New bot list instead of failing the whole list, and the Bots guide says a new bot can take over a deleted bot's memory.
[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Re-sync budget reset
This PR conflicts with main again, in the generated src/kiro_crew/docs/ui-index.generated.json only, and it is inside its 48-hour watch window, so the re-sync count restarts here. One re-sync onto current main follows; the change itself stays the same.
[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: no

  • A losing concurrent adoption closes the winner's new chat span=d3c691a29ac1

Rebutted: between its config snapshot's file read and close_slot, the losing create suspends only for that read's thread hop and, when a slot on the thread carries an app-armed scoped grant, two short thread calls per grant (slot_approval.py:215-218, 231-240); with no scoped grant nothing awaits between the ownership check (members_thread.py:137) and the close.
Harm needs the winner to finish its whole create AND the owner to open the new bot's chat inside that window: the slot under the shared key exists only once that chat is opened. A create that reads the config any later sees the store owned and touches nothing (members_thread.py:137).
The outcome is visible and recoverable: clearing grants tightens what the bot may do, and close_slot archives the chat to history the way a tab close does, so the next open rehydrates it. No row, grant widening or data loss follows.
The suggested fix holds the process-wide config lock across close_slot's bounded drains, stalling every config write behind a slow close; that standing cost exceeds one rare, visible, recoverable close, which is how the lane's adjudicator downgraded it (disproportionate remedy).
[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/22487-adopt-kept-memory branch from 7e9ea2e to 2fe1621 Compare November 13, 2026 20:45
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/docs/ui-index.generated.json since this head was pushed, and the PR stopped merging (a45e97a -> 8579038); CI re-running.
That generated index takes main's side and is rebuilt with the repository's own generator, so the change itself is the same: the diff's other 39 files are byte-identical to the previous head, and the index differs from it only in the generator's input digest. The previous head's one red check, CodeQL's Python analysis, failed while uploading its results on an API rate limit, not on this code.
[operator: bolichen97]

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/feature-map/README.md and src/kiro_crew/docs/ui-index.generated.json since this head was pushed, and the PR stopped merging (8579038 -> 197cde9); CI re-running.
The generated index keeps main's entries plus this PR's strings, and the repository's generator reports it current. The feature map keeps main's new row after Crew Members ("Bot hears the user's answer", #32182) and this PR's words in the Crew Members row. Main now lets a Shared Crew teammate act as the owner inside the crew (#38209), so a teammate gets the same Memory choice in New Bot as the owner; the dialog reads an owner_only refusal of the kept-memory list as nothing kept, instead of a "Couldn't load the Memory choices" notice. Main's other edits to files this PR also changes merged without a conflict, among them the create answer's warnings line for an unconfigured workspace (#38658), which an adopting create returns through unchanged, and the New Bot dialog's workspace-form generation check (#34075). Main's teammate-over-relay work (#38437) adds owner-only writes for teammates (turning Remote Control off, the instances config) and holds the New Bot submit while the name is empty; neither touches the create or the kept-memory list. The full related backend and frontend sets ran on this change on b7e296e, and the feature map, docs, i18n, memory-store seam, generated-index, type, lint and format checks and the tests for the files both sides changed pass again on 197cde9. The only two backend reds in the related set are not this change's and fail the same way on a clean main checkout: the Continue with GitHub golden in test/test_find_ui_auto.py (#32670), and a fixture check in test/test_host_git_repo_exec_neutralization.py whose bare git diff is inert under the test machine's git.
[operator: bolichen97]

Deleting a bot keeps its memory store on disk, but every route into a
member store resolves it through its live owner, so the kept store could
not be opened, exported, restored or picked again, while the delete text
read as if the memory were safe.

A new bot created from the dashboard can now take over a kept store
that no bot owns: the New bot dialog offers it under Advanced settings,
POST /api/agents binds the new bot to the store's recorded member id,
and GET /api/memory/ownerless-stores lists what is on offer. Nothing is
copied. The create clears every approval grant on that thread's session
and closes the deleted bot's thread still live on that key, so its pin
and grants do not carry over, and the delete text says a new bot can
start from the memory.

Builds on #22947 by @mbriones98.
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/feature-map/README.md and website/src/test/ApiClient.refactor.surface.test.ts since this head was pushed, and the PR stopped merging (197cde9 -> 301f9ab); CI re-running.
Main and this PR both edit the one Crew Members row of the feature map, in different clauses: main's side-panel Sessions tab and the removed Show-in-list switch (#37915), and this PR's Memory choice in New Bot's Advanced settings with its handler and route names. The row keeps both, clause by clause. Main replaced the API surface test's hand-kept key-order list with checks built from the client's own endpoint groups (#39011); those cover the new memoryOwnerlessStores call with no list to edit, so this PR no longer changes that file and the Tests section drops its line.
Main's other edits to files this PR also changes merged without a conflict: the config loader reads the new market_registries setting (#38064) near this PR's former_owner line, the memory admin store probe takes its read-only SQLite URI from the shared sqlite_uri helper (#39001), the crew editor test file gains the Abilities tests (#37627), and the config baseline, locale catalogs, specs and generated index gain main's entries next to this PR's. This PR's own lines are unchanged in every file, and the repository's generator reports the index current.
On 910f01f the type check, lint, format and import-order checks, the config baseline and main's config_dir() event-loop guard, docs-lint, the i18n and generated-index checks, the repository's semgrep rules, the flake-pattern ratchet, 1087 related backend tests, the 319 dialog, crew editor and API surface tests, and three repeat runs of the takeover tests all pass.
Nothing in the code needed fixing. The two reds on the previous head were the JavaScript CodeQL analysis, which failed while uploading its results on a GitHub API rate limit, not on a finding, and PR Readiness, which was red on the merge conflict this rebase clears.
[operator: bolichen97]

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

I reviewed head 93d3a11 and found nothing blocking. Both the create route and the new kept-store listing are owner-gated. Only a store no configured bot owns or could share an identity with can be adopted, and its database identity must match its record. The cross-process locked write runs the same checks again, so a store with a live owner can never be claimed. A create that fails leaves the kept store, its database and its offer entry exactly as they were. The deleted bot's approval grants are cleared before anything is published, and if they cannot be cleared the create is refused. I ran the new adoption tests with the related binding and thread suites on this head and all of them pass.

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.

Deleting a crewmate orphans its memory store with no route back

3 participants