Prevent ephemeral workspace leaks and add safe bulk cleanup - #814
Conversation
w-winter
left a comment
There was a problem hiding this comment.
Looks to us like the right fix for future ephemeral workspace leaks. There are just a few gaps to address:
- The missed
Persistent Agent Mode MCP Readrecords described in this other comment - The explicit save methods return a path without writing a file for ephemeral workspaces. This reports false success and already breaks
TabContextRoutingTests. Explicit persistence should fail clearly while autosave is skipped at its caller. - Retrying the same rejected ephemeral create reaches
repairRecoveredCreatebefore the ephemeral guard and can return a persistence failure instead of deduping the original rejection - Bulk deletion treats local ephemeral workspaces as already absent because they aren't in the authority snapshot, but then leaves them in memory
Sol believes the red CI isn't unrelated (TabContextRoutingTests and WorkspaceSavePreparationTests both fail on behavior changed here).
|
Follow-up to #814 (review) — addressed in
Validation at exact head
A Fable 5 High follow-up review of this exact clean checkpoint reported no must-fix findings and confirmed all four requested behaviors are resolved. The remaining notes were low-risk/pre-existing, so I am keeping them out of this already-expanded PR. |
|
Final follow-up to #814 (review): the exact-head shard regressions are fixed in The affected tests had been relying on an intentionally ephemeral shared fixture passing through persistence-oriented setup. The corrections preserve the production invariant rather than weakening it:
Validation at exact head
The two inline review threads are replied to and resolved. @w-winter, this should now be ready for re-review. |
Audit disposition — conditional merge candidate; supersedes #485 (2026-08-14)The future-persistence prevention, narrow leaked-fixture evidence, apply-time revalidation, catalog tombstone authority, revision fencing, and explicit artifact-cleanup warnings are substantially more complete than #485. Exact-head CI was green in the reviewed state. One policy must be settled before merge: |
Deep-review assessment — 2026-08-14Disposition: strong successor to #485; resolve the cross-process deletion invariant before merge. Preventing ephemeral documents from entering domain persistence, preserving local ephemeral projections, using the domain catalog/tombstone as cleanup authority, narrowly classifying leaked fixtures, revalidating at apply time, and surfacing artifact-cleanup warnings are all solid. The reviewed exact-head CI was green. The remaining question is explicit in the PR: activation/deletion leases coordinate only one app process, while the catalog and artifacts are durable/shared. If two GUI/headless processes can use the same profile, one process can delete a workspace active in another. Either enforce and document a single-writer process identity at the persistence boundary or add a durable cross-process activity/deletion lease. Once that invariant is established, merge this and close #485 after transferring unique tests. |
Summary
manage_workspacesinventoryRoot cause and authority
The leaked
Agent Mode Chat Switch XXXXXXXXrecords are runtime/domain-catalog workspaces withephemeralFlag: trueand temporaryAgentModeChatSwitchActivationTests-*roots. Settings renders the domain projection, whilemanage_workspaces list/deletereads the smaller legacy disk index, so those records can appear in Settings without being addressable through the MCP inventory.This change makes the domain catalog the cleanup inventory and mutation authority. Ordinary runtime projections exclude persisted ephemeral records, but the explicit cleanup preview can still enumerate narrowly verified fixture candidates. Cleanup requires all of:
Agent Mode Chat Switchplus eight uppercase hexadecimal charactersAgentModeChatSwitchActivationTests-<UUID>path componentSystem, active, pinned, and agent-referenced workspaces are protected. Cleanup candidates are revalidated at apply time. Catalog tombstones remain authoritative; best-effort artifact cleanup warnings are returned and persisted separately.
Manage Workspaces UX
Normal row actions remain unchanged until the user enters selection mode. Selection mode adds:
Single-row deletion and bulk deletion use the same domain-authority protections rather than the incomplete legacy inventory.
Validation
Exact merged head:
06b8006bb276aacf02457d42cd5ba9111b85c105Passed:
eb030db1-7c7c-4f4d-899e-a861940219c8WorkspaceEphemeralPersistenceTests: 7/7 — ticket1dd39e6b-fa0c-40ee-a657-0e17e7d0f2c2WorkspaceManagementSelectionStateTests: 7/7 — ticket9039cae6-06ee-4d16-939a-7d046310cf64DomainWorkspaceContextAuthorityTests: 33/33 — ticketdcdfb306-2c28-43c8-a7d7-29921295963eswift build --product RepoPrompt— ticketc892ff87-0f22-47b1-9ec7-972d0adce68bFull PR-ready root test lane compiled successfully but timed out at the one-hour conductor limit. Before timeout it reported unrelated failures in
BackgroundComposeTabAdmissionTests,CodeMapV6CacheDeletionTests, andCodemapBindingEngineWarmManifestTests, plus an MCP bootstrap lock warning. The affected focused suites above all pass on the exact merged head. Full-suite ticket:c056d08c-8c5a-4da8-95c5-ad8b6d479e3a; timing receipt:.build/validation-artifacts/pr-ready/20260813T114431Z-0a367d8c61c44f68952ccdc38cfb1d38.json.Limitations