feat(agent-org): add irreversible archive and guarded team delete - #888
Draft
ShiboSheng wants to merge 7 commits into
Draft
feat(agent-org): add irreversible archive and guarded team delete#888ShiboSheng wants to merge 7 commits into
ShiboSheng wants to merge 7 commits into
Conversation
ShiboSheng
force-pushed
the
codex/issue-761-archive-team-delete
branch
from
August 24, 2026 10:39
e43c5c7 to
8ac2812
Compare
Commit the irreversible Archived state, generation bump, cancellation facts, and bounded teardown receipts atomically. Capture canonical Root and Member ownership so retries are idempotent and later deletion can prove the same Team boundary.\n\nVerification:\n- cargo test -q -p agent_core -- --test-threads=1 — 3,193 passed on the complete PR6 working tree\n- cargo clippy -p agent_core --all-targets -- -D warnings — passed on the complete PR6 working tree\n- cargo fmt --all -- --check — passed Pre-commit hook ran. Total eslint: 5, total circular: 0
Reject post-Archive writes at Task, Inbox, Turn, Provider, Wake, recovery, and Resume boundaries. Release captured Root and Member runtimes with exact-lease checks, three bounded rounds, and one-shot startup reconciliation without a persistent watchdog. Verification: - cargo test -q -p agent_core -- --test-threads=1 — 3,193 passed on the complete PR6 working tree - cargo clippy -p agent_core --all-targets -- -D warnings — passed on the complete PR6 working tree - packaged BuildFast Archive races, retained-runtime deadline, restart, and ten-runtime parallel teardown — passed Pre-commit hook ran. Total eslint: 5, total circular: 0
Route every Agent Org Root or Member away from generic Session Delete. Allow the dedicated Team Delete only after Archived persistence, a quiesced Archive receipt, unchanged ownership, and zero current runtime leases are all proven. Verification: - cargo test -q -p agent_core -- --test-threads=1 — 3,193 passed on the complete PR6 working tree - generic Root and Member Delete fail-closed tests — passed - isolated packaged-app Team Delete preserved unrelated Team data — passed in four repeated rendered runs Pre-commit hook ran. Total eslint: 5, total circular: 0
Wire Archive and guarded Team Delete through Tauri, make every Archived composer read-only, keep history visible, surface bounded teardown diagnostics, and require a second danger-zone confirmation before physical deletion. Verification: - pnpm test — 1,116 files and 8,771 tests passed on the frozen PR6 tree - pnpm run lint — passed with five pre-existing ProjectManager warnings and zero errors - rendered Archive/Delete E2E — passed three consecutive full runs plus one final smoke - BuildFast packaged-app Computer Use and SQLite evidence — passed for PR5 baseline, fake Provider, and configured real Provider Pre-commit hook ran. Total eslint: 5, total circular: 0
Packaged-app testing exposed two terminal-boundary gaps: late session callbacks could still reach persistence after Archive, and Team Delete removed sidebar ownership without closing cached Team tabs or unregistering session marker files. Route late callbacks through the Archived fence, keep the destructive confirmation modal stable, close every deleted Root/Member tab atomically, select one safe fallback view, and unregister each committed deletion from the file registry. Verification: - pnpm test — 1,116 files and 8,776 tests passed - RUST_TEST_THREADS=1 pnpm run cargo:test — 1,113 passed and 1 ignored - cargo test -p agent_core — 3,197 passed and 2 ignored - cargo clippy -p agent_core --all-targets -- -D warnings — passed - rendered Archive/Delete E2E — 3 frozen-code runs and 9 UI paths passed - BuildFast packaged-app Computer Use — real Provider Archive/Delete and restart passed Pre-commit hook ran. Total eslint: 5, total circular: 0
TaskExecution assistant persistence reused the execution-admission gate, so a Turn that completed its own Task lost its final reply because terminal Tasks are not runnable. Split the phase-specific validation while preserving the shared live Turn authority and Archive transaction fence. Allow completed or failed Tasks only when the latest terminal event belongs to the exact owner and Turn; keep cancellation, reassignment, stale generations, and new execution admission closed. Verification: - cargo test -p agent_core — 3,215 passed, 2 ignored - cargo clippy -p agent_core --all-targets -- -D warnings — passed - pnpm test — 1,116 files and 8,777 tests passed Pre-commit hook ran. Total eslint: 5, total circular: 0
Archive receipts could become quiesced after a job was marked killed even though its process tree, replay pipeline, or subagent task was still executing. Team Delete also left retained background-job registry state after the durable hierarchy was removed. Add exact Session indexes and execution-finality barriers, make Archive wait for runtime, memory, and background owners, and make Delete fail closed before commit and purge only after a successful transaction. Add deterministic race coverage, rendered lifecycle coverage, and read-only WebDriver evidence. Verification: - cargo test -p agent_core: 3230 passed, 2 ignored - cargo clippy -p agent_core --all-targets -- -D warnings: passed - cargo fmt --all -- --check: passed - pnpm test: 8777 passed - pnpm run lint: passed with 0 errors and 5 pre-existing warnings - pnpm run check:circular: blocked by the existing Madge raw-import resolver failure - WEBDRIVER=1 pnpm run tauri:build:fast: passed - BuildFast real-provider Archive x3, Pause/Resume, Task smoke, restart, and UI Delete: passed Pre-commit hook ran. Total eslint: 5, total circular: 0
ShiboSheng
force-pushed
the
codex/issue-761-archive-team-delete
branch
from
August 25, 2026 01:53
8ac2812 to
4781b83
Compare
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.
Problem
Fixes #761.
PR5 provides durable Pause/Resume and exact ownership for background shell commands and subagents, but a Team still needs a separate irreversible close boundary. Without PR6,
Archivedhas no durable receipt, late Provider/Task/Inbox writes can cross the boundary, and generic Session deletion cannot safely dismantle a Team hierarchy.After PR5 was updated, integration testing exposed an additional lifecycle gap in PR6: Archive waited for runtime release and memory work, but not for the real execution owner of a background job. A shell could be marked
Killedwhile its process tree or replay pipeline was still draining, and a subagent could be markedKilledwhile its Tokio task was still running. Archive could therefore publish aquiescedreceipt too early, and Team Delete did not have exact Session-scoped evidence or cleanup for retained job results and tombstones.A separate final-reply regression was also found in the PR6 stack: after a Member Turn completed its Task, assistant persistence reused execution admission and rejected the exact completing Turn because a terminal Task is no longer runnable. The Task completed durably while the final assistant message could be lost.
This Draft is stacked directly on the latest PR5 branch
codex/issue-760-pr5-pause-resumeatecaa1c721cbb0f4ec60c0136b85c53531421f1ec. PR6 HEAD is4781b832935e95620f5310aef9a38b5568819d35; the comparison contains seven PR6 commits and 87 files with 7,121 additions and 692 deletions.Solution
Add an irreversible Archive protocol and an Archived-only Team Delete protocol, then integrate PR5's real background-execution finality into both boundaries:
team_archivedor becomes a stale no-op.The final integration commit is
4781b8329 fix(agent-core): drain archived background jobs before delete. It adds no new schema, dependency, public product wire, product UI state, polling loop, Archived watchdog, or migration beyond the already-reviewed PR6 contracts.Potential risks
retained_runtimeevidence and blocks Delete; it never reopens the Team. Physical Delete is permanent and remains separately confirmed.team_deleted_but_background_job_purge_failed; the database deletion cannot be rolled back at that point. Runtime fencing and preflight tests are intended to make this state unreachable.pnpm run check:circularexits before graph analysis because Madge cannot resolve the pre-existing React artifact?rawimports. The failing module is outside this diff; commit hooks report zero circular dependencies in staged TypeScript files.Verification
Automated checks on the rebased implementation:
cargo check -p agent_core— passed.cargo check -p org2— passed.cargo test -p agent_core— 3,230 passed, 0 failed, 2 ignored; doc tests completed with 11 ignored.cargo clippy -p agent_core --all-targets -- -D warnings— passed.agent_coreand desktoporg2— passed; no hook was bypassed.cargo fmt --all -- --check— passed.pnpm test— 1,116 files and 8,777 tests passed.pnpm run lint— passed with 0 errors and 5 pre-existing warnings outside this diff.pnpm run check:circular— blocked before graph analysis by the existing Madge raw-import resolver failure described above.git diff --checkand staged secret/personal-path/build-artifact scan — passed.Rendered, packaged-app, and real-machine verification:
quiesced→ Overview refresh → danger-zone Delete rendered spec passed for idle/completed, working, and paused Teams in one packaged-app run.WEBDRIVER=1 pnpm run tauri:build:fastpassed. The packaged binary SHA-256 is706a3d30459a38801ccef113acd05a39acc005b63509d0f108e15070d7cec74e. Product source was frozen before this build; the only later adjustment was E2E test code, not application code.Architecture and rollback
The architecture audit covered all ten relevant layers: schema, authoritative ownership, domain semantics, control flow, concurrency/lock ordering, persistence transaction boundaries, wire/test surface, initialization/restart, compatibility/isolation, and naming/dead-code/test coverage. The performance lifecycle matrix covered active Archive, idle/hidden, restart, repeated open/close, multi-Team isolation, and ordinary SDE isolation. Verdict: pass for the PR6 background-job integration; no long-lived lifecycle owner was added.
To roll back, revert the seven PR6 commits together and use a fresh/reset Agent Org database or the database paired with PR5. If Archive retains execution, keep the Team Archived, inspect the receipt evidence, and do not run Team Delete until the execution owner is proven absent. There is no migration to reverse for the final background-job integration commit.