fix(agent-org): delete workers when deleting an Agent Org session - #573
Closed
Harry19081 wants to merge 2 commits into
Closed
fix(agent-org): delete workers when deleting an Agent Org session#573Harry19081 wants to merge 2 commits into
Harry19081 wants to merge 2 commits into
Conversation
Deleting an Agent Org root previously removed only its own row, leaving Rust worker sessions and run-owned data behind. Build a leaf-first Rust hierarchy deletion plan, stop active runs, revalidate the topology in one transaction, clean canonical and run-owned state atomically, evict retained runtime state, and return all deleted IDs so the sidebar stays in sync. Ordinary SDE deletion keeps its existing single-session behavior, and CLI sessions remain out of scope. Verification: - cargo test -p agent_core (3151 passed, 2 ignored) - cargo test -p project_management (521 passed) - pnpm test (770 files, 6823 tests passed) - pnpm run typecheck - pnpm run lint - pnpm run check:circular - isolated rendered E2E (3 passed) - changed Rust and frontend formatting checks - git diff --check Pre-commit hook ran. Total eslint: 2, total circular: 0
Pre-commit hook ran. Total eslint: 0, total circular: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #556
Before this change, deleting an Agent Org session removed only the root/coordinator session. Its Rust worker sessions could remain in the database with a parent that no longer existed.
After this change, deleting the Agent Org root from the sidebar stops the active Rust run when needed, then removes the root, all Rust workers, and the run-owned coordination data together. The sidebar also removes every deleted session immediately.
What changed
agent_sessions.parent_session_idand delete it leaf-first.Scope
code_sessionsqueries or CLI lifecycle/cleanup changes.Known limitation
This PR stops the active Rust runtime and clears queued work before deletion, but it does not add a new global drain/tombstone protocol for every detached background writer. Hardening extremely late asynchronous writes can be handled separately without expanding #556.
Verification
cargo test -p agent_core— 3151 passed, 2 ignoredcargo test -p project_management— 521 passedcargo test -p agent_core session_hierarchy_delete— 11 passedcargo test -p agent_core direct_agent_org_turn_refuses_cancelled_delete_fence— 1 passedpnpm test— 770 files, 6823 tests passedpnpm run typecheckpnpm run lintpnpm run check:circular— no circular dependenciesrustfmt --check; changed frontend/E2E files passed Prettiergit diff --checkRepository baseline notes
cargo clippy --all-targets -- -D warningsis currently blocked by six existing warnings in unchangedorgtrack_coreandproject_managementfiles. Scoped Husky Clippy passed foragent_core,org2, andproject_management, and no warning points to a fix(agent-org): delete workers when deleting an Agent Org session #556 changed file.cargo fmt --all -- --checkis currently blocked by existing formatting differences outside this PR. Every Rust file changed by fix(agent-org): delete workers when deleting an Agent Org session #556 passes the format check.