feat(agent-org): add authoritative team lifecycle - #781
Open
ShiboSheng wants to merge 1 commit into
Open
Conversation
Establish durable Starting materialization receipts and a centralized quiescence boundary so Working teams enter Idle only from committed facts. Keep Run View pure-read, bound the global watchdog, and stop frontend polling for hidden or non-pollable teams behind one fail-closed rollout gate. Verification: - cargo clippy --all-targets -- -D warnings - Packaged Tauri Command+5 foreground, hidden, and restore lifecycle passed - Run View refresh left the isolated database byte-identical Pre-commit hook ran. Total eslint: 0, total circular: 0
ShiboSheng
marked this pull request as ready for review
August 11, 2026 10:35
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 #756.
The existing Agent Org lifecycle does not provide an authoritative, restart-safe boundary for a long-lived Team. Initial member creation can be resumed only through loosely coupled session state, finality is inferred by multiple paths, Run View and background recovery do not have a sufficiently strict read/write boundary, and the frontend retains fallback polling for states that should be quiet.
That model cannot safely support a Team that finishes one batch of work, becomes reusable and idle, and later accepts more work. It also makes identity duplication, stale quiescence decisions, accidental read-side writes, and retained background activity difficult to reject by construction.
Solution
This PR implements the first lifecycle slice from the long-lived Team design:
Startingtogether with canonical member materialization receipts and the initial-input intent. Restart recovery continues the same(member_id, agent_id)identities instead of regenerating a Team.work_revisionstate.Working -> Idleonly through a generation-and-revision conditional transition. Stale observations become no-ops.running-only scan,LIMIT 100, and one 250 ms cooperative deadline shared by the entire tick.starting/runningallowlist. Hidden windows and the last pollable subscriber destroy the shared timer; visibility recovery performs one immediate bounded revalidation.ORGII_AGENT_ORG_REDESIGN, which remains disabled by default.The current compatibility wire value for Working remains
running.Potential risks
ORGII_AGENT_ORG_REDESIGN=1, users can reachIdlebut cannot yet submit a new Root/Group/direct Turn or mutate the Task graph from Idle. The production default must remain disabled until the later stack is complete.Running -> Idleuses a serialized generation/work_revisioncheck. A concurrent work mutation wins by changing the revision, so the idle attempt becomes a no-op; later PRs must not introduce a second lifecycle owner or bypass that revision boundary.Current implementation state
Startingowns first materialization and restart recovery. Successful construction ends inrunningwhen initial formal work exists oridlewhen it does not; unrecoverable construction ends infailedwith structured diagnostics.Idlemeans the current formal work is quiescent and the Team is retained. It is not a terminalCompletedstate.status='running') Teams. Starting recovery is a one-shot launch/startup responsibility.startingorrunningTeam.0, ortruevalues remain disabled; only1enables the internal slice.Scope boundaries and next-PR handoff
PR1 does not implement Pause/Resume redesign, Archive/Delete, the final Task FSM, additional Writers, UserDirectedWork, direct Member work, Group multi-mention, peer side quests, or the final Group read surface.
The enabled PR1-only intermediate state deliberately rejects new work from Idle:
team_idle.idlebefore writing an Inbox row.runningand returnsagent_org_run_not_mutablefor Idle.Idle -> Workingtransition occurs.PR7 is expected to add the atomic first Task graph plus
Idle -> Workingactivation. PR8 opens direct Member UserDirectedWork, PR9 opens Group targeting and peer side quests, and PR10 completes the bounded Group read surface and default rollout. Earlier follow-up PRs must extend the frozen launch roster, generation, revision, and lifecycle transition APIs established here rather than creating another state owner.Verification
Automated checks:
cargo test -p agent_core— passed on the frozen PR1 implementation before packaged acceptance.pnpm typecheck— passed before packaged acceptance.cargo clippy --all-targets -- -D warnings— passed again after fast-forwarding to the latestdevelop.agent_core,org2, andsession_persistence, ESLint 0, circular dependency count 0.git diff --check upstream/develop..HEAD— passed.Packaged Tauri acceptance used a temporary packaged
.applaunched through macOSopen, an isolatedORGII_HOME/SQLite database, isolated ports, a mock provider, and the redesign gate enabled in both frontend and backend:updated_atandwork_revisiondid not change.LIMIT 100; the shared scan used 9-25 ms of its 250 ms budget.Performance verdict: pass.
Visual screenshots are not included because this PR's meaningful acceptance evidence is lifecycle persistence, database immutability, API cadence, hidden-window behavior, and background-resource ownership rather than a visual layout change.