feat(agent-org): enforce the formal Task FSM and owner permissions - #869
Draft
ShiboSheng wants to merge 3 commits into
Draft
feat(agent-org): enforce the formal Task FSM and owner permissions#869ShiboSheng wants to merge 3 commits into
ShiboSheng wants to merge 3 commits into
Conversation
Make SQLite the final authority for Task creation, mutation, and lifecycle transitions. Add the canonical five-state model, typed actors, durable provenance and results, recovery behavior, and bounded task history reads. Separate coordinator graph administration from Owner lifecycle operations, validate persisted Turn bindings inside each transaction, and expose Current Work and History without eagerly loading full results or annotations. Verification: - cargo test -p agent_core: 3154 passed, 0 failed, 2 ignored - cargo test -p agent_core section_tests -- --nocapture: 12 passed after the final mechanical fix - cargo clippy -p agent_core --all-targets -- -D warnings: passed - pnpm run typecheck: passed - pnpm run lint: 0 errors; 5 pre-existing warnings outside this diff - cargo check -p e2e-test and focused Vitest/WDIO PR4 suites: passed - BuildFast fake-provider batches and one live-provider pending -> in_progress -> completed smoke: passed - pnpm run check:circular: blocked by two baseline ?raw imports unchanged from PR3 Pre-commit hook ran. Total eslint: 5, total circular: 0
Pre-commit hook ran. Total eslint: 5, total circular: 0
Pre-commit hook ran. Total eslint: 5, total circular: 0
Collaborator
Author
|
orgii://cloud/session/ref?v=1&org=bfa7b134-2486-45fa-81ad-a369441fafb4&owner=776dbd69-ac1d-4f72-a0d4-69cb4f2667dd&session=codexapp-rollout-2026-08-20T01-27-48-01a01b10-9b52-7f00-8af2-39711a442d02 |
Collaborator
Author
|
orgii://cloud/session/ref?v=1&org=bfa7b134-2486-45fa-81ad-a369441fafb4&owner=776dbd69-ac1d-4f72-a0d4-69cb4f2667dd&session=codexapp-rollout-2026-08-22T12-17-41-01a027b0-5225-7080-aa68-d96e8cefdc14 |
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 #759
Depends on #841 and is intentionally based on
codex/issue-758-turn-context-fifo.Formal Agent Org Tasks did not have one complete lifecycle and authority contract. Creation, graph mutation, owner execution, recovery, debug helpers, and UI projection could apply overlapping rules, so invalid initial states, coordinator ownership/output, structural mutation by an owner, terminal rewrites, stale owner callbacks, and recovery-budget resets were not all rejected at the same authoritative boundary.
The root cause was that the SQLite Task Store did not own the full field-level state machine with persisted actor and Turn identity. Tool and wake paths could validate only part of the contract, while task history/results were projected without a bounded Current Work/History contract.
Solution
pending,in_progress,completed,failed, andcancelled.pending; require structured output for completion and structured reasons for failure/cancellation.completedsatisfies dependencies; goal/owner/dependency changes after execution starts use atomic cancel-and-replace.This preserves the issue boundary: it does not add new Task states, coordinator-owned formal Tasks, Member-private graphs, Writer-capability resolution, or forced cancellation of an already running old execution.
Potential risks
develop. It must be retargeted/revalidated after the dependency merges.ORGII_HOMEand left the existing~/.orgii/sessions.dbuntouched. Do not mix binaries across incompatible Task schemas.ORGII_HOME; do not downgrade a database after opening it with the new canonical schema.Dependency and scope
codex/issue-758-turn-context-fifo)codex/issue-759-pr4-task-fsmWhy this is much larger than the original design estimate
The planning snapshot copied into Issue #759 estimated 2,200 P50 / 3,800 P90 review lines across 17–27 substantive files. That estimate treated the work primarily as a Task enum/Store FSM change plus a small set of Tool and UI adapters.
The implementation-time impact spike in the design document later revised PR 4 to 10,800 P50 / 13,000 P90 review lines and 58–62 substantive files plus up to 13 locale files. The final diff is 16,985 review lines (
+10,392 / -6,593) across 121 files, but the net growth is only +3,799 lines. The gap is therefore mostly the review cost of replacing an old cross-layer contract, deleting obsolete tests, and proving the replacement—not 16,985 lines of new product surface.Path-based, rename-aware partition against the PR 3 base:
The specific underestimates were:
task_updatepath and its three-state/whole-row-patch assumptions could bypass any new Store gate. Intask_tests.rsalone, 3,099 old lines were deleted and 391 replacement lines added; the dedicated Task Store contract suite adds another 1,169 lines. Those two files account for 4,659 review lines while removing more old code than they add.This remains one PR because canonical DDL, typed Store actors, Tool wire, recovery behavior, and five-state read projection must agree at every runnable point. Splitting them into independently mergeable PRs would require a temporary old/new schema compatibility layer, retain the generic mutation bypass, or expose a half-three-state/half-five-state wire contract. Those intermediate states are explicitly forbidden by the design. The size is a reviewability cost, so the PR keeps focused commits and the review map below; it is not an expansion into Pause/Archive, multi-Writer, or UserDirectedWork scope.
Review map
Verification
cargo test -p agent_core— 3,154 passed, 0 failed, 2 ignored on the completed implementation.cargo test -p agent_core task_store_contract_tests— 14 passed after the final naming cleanup.cargo test -p agent_core core::providers::e2e_fake::tests— 12 passed after the final naming cleanup.cargo test -p agent_core core::tools::impls::orchestration::agent_org::tasks::task_tests— 8 passed after the final naming cleanup../node_modules/.bin/vitest run src/engines/ChatPanel/InputArea/components/AgentOrgTaskPanel.test.ts— 4 passed.cargo check -p agent_core --all-targets— passed.cargo check -p e2e-test— passed.cargo clippy -p agent_core --all-targets -- -D warnings— passed; commit hook also passed scopedagent_coreandorg2Clippy../node_modules/.bin/tsc --noEmit --pretty false— passed.pnpm run lint— 0 errors; 5 pre-existing warnings outside this diff../node_modules/.bin/eslint src/engines/ChatPanel/InputArea/components/AgentOrgTaskPanel.test.ts— passed.cargo fmt --all -- --check, focused Prettier checks,git diff --check, and E2E scriptnode --check— passed.pnpm run tauri:build:fastpackaged-app acceptance — deterministic fake-provider batches and one live-providerpending → in_progress → completedflow passed.ORGII_HOMEpackaged-app smoke — launched the existing app, created/opened an Agent Org Team, completed a Task, relaunched, and read the Team/Task back; the existing database was not deleted or modified.pnpm run check:circular— blocked by two baseline?rawimports unchanged from PR 3; the commit hook reported zero new circular findings in staged files.Visual evidence
No screenshot is attached because this PR changes lifecycle authority, persisted state, and pagination behavior rather than visual styling. Rendered UI assertions and packaged-app interaction were used together with direct Task/database state checks.