fix(agent-org): address PR review correctness and performance findings - #419
Merged
Merged
Conversation
Make Agent Org reads side-effect free and bounded so polling no longer takes broad writer locks or repeatedly expands large Task, Inbox, and Plan payloads. Preserve complete Group Chat history through keyset pagination while loading full Task and Plan results only when requested. Unify task graph, finality, wake-budget, Inbox materialization, and Plan approval transitions around transactional persisted state. Prevent duplicate delivery, stale dependency notifications, premature Run abandonment, approval loss across pause or restart, and one broken Run from blocking recovery for other Runs. Align Rust and TypeScript outcomes for Task Graph, TaskOutput, Kanban, Plan approval, pause and resume, and direct user intervention. Add production-parity fixtures, focused regressions, rendered E2E coverage, and architecture and frontend audit reports for both review rounds. Verification: - Agent Core application suite: 3,028 / 3,028 passed - session_persistence suite: 29 / 29 passed - Vitest suite: 5,318 / 5,318 passed - TypeScript typecheck, ESLint, and circular-dependency checks passed - rustfmt --check passed for all 80 changed Rust files - Isolated Debug App Agent Org HTTP E2E: 46 / 46 passed - Rendered Group Chat WebDriver: 5 / 6 passed; the remaining failure reproduces on clean develop - Rendered Pause/Resume WebDriver: 8 / 8 passed - Rendered Recovery WebDriver: 2 / 2 passed - Husky staged-file TypeScript and Rust checks passed Pre-commit hook ran. Total eslint: 0, total circular: 0
Bring the latest develop changes into PR #419 while preserving the recovery invariants introduced by the branch. Keep run-view reads side-effect free and retain Group Chat history pagination through the extracted history surface. Verification: - pnpm run typecheck - pnpm run lint - pnpm run check:circular - cargo check -p e2e-test - pnpm exec vitest run src/engines/ChatPanel/hooks/useAgentOrgGroupChatHistory.test.ts - Focused Agent Org lifecycle tests passed Pre-commit hook ran. Total eslint: 0, total circular: 0
Neonforge98
pushed a commit
that referenced
this pull request
Jul 30, 2026
Bring the latest develop changes into PR #419 while preserving the recovery invariants introduced by the branch. Keep run-view reads side-effect free and retain Group Chat history pagination through the extracted history surface. Verification: - pnpm run typecheck - pnpm run lint - pnpm run check:circular - cargo check -p e2e-test - pnpm exec vitest run src/engines/ChatPanel/hooks/useAgentOrgGroupChatHistory.test.ts - Focused Agent Org lifecycle tests passed Pre-commit hook ran. Total eslint: 0, total circular: 0
Neonforge98
pushed a commit
that referenced
this pull request
Jul 30, 2026
…invariants fix(agent-org): address PR review correctness and performance findings
This was referenced Aug 1, 2026
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
Follow-up to #373 and the Agent Org work originally tracked in #272.
This PR addresses the correctness, performance, persistence, and test-fidelity findings from both review rounds on #373:
The product model remains unchanged:
This follow-up is intentionally limited to the two review rounds and the minimum integration dependencies required to make those fixes correct, independently testable, and production-compatible.
flowchart LR MODEL["Coordinator or worker proposes an action"] TOOL["Typed tool boundary"] TX["Short SQLite transaction"] WAKE["Budgeted Wake dispatch"] VIEW["Read-only compact Run View"] UI["Group Chat, Team Tasks, and Kanban"] MODEL --> TOOL --> TX --> WAKE TX --> VIEW --> UIFirst review
Resolution matrix
task_listused the global writer path. A read-only tool could serialize unrelated Task, Session, and Inbox work.task_listnow uses a read transaction and returns bounded summaries. Full Task results are retrieved throughtask_getonly when needed.TaskGraphIndexis built once and reused by Task mutation, readiness evaluation, and transactional outbox decisions.org_run_completehandles legitimate empty-task Runs.reserve → enqueue → commit/refundaccounting. Rejected and coalesced Wake requests do not consume an attempt.task_graph_createwas not recognized consistently. Communication cards could display raw JSON and replay could erase existing Kanban state.Second review
Resolution matrix
org_run_completepath records explicit completion intent and still passes through canonical finality validation.causation_inbox_idmake acknowledgement conditional on successful durable materialization.blocksdependencies were ignored by readiness checks. Old Tasks could unlock too early.blocksdata is normalized into the same canonical dependency graph used by all readiness checks.executionModecould be missing and TaskOutput could be duplicated.executionModeis explicit, and TaskOutput now has one canonical wire location.Required integration dependency
The review fixes required one additional dispatch-time invariant:
Resulting invariants
Verification
session_persistencesuiterustfmt --checkdevelopClean-develop baselines
orgtrack_corediagnostics reproduced on cleandevelop.agent_core --no-depsreports the same 45 clean-develop diagnostics.e2e-test --no-depsreports three diagnostics on this branch versus four on cleandevelop; this change introduces no additional diagnostic.specialization::external_importtests are filtered because the same nested non-reentrantlock_homedeadlock reproduces on cleandevelop.developwith the same assertion. It is not counted as passing and is not attributed to this follow-up.Scope boundary
This PR contains only:
It intentionally does not include the later red-team expansion, the full Revision Event architecture, or post-completion Follow-up Runs.
Follow-up: post-completion conversation and Follow-up Runs
A separate feature PR will address the distinction between a long-lived Group Chat and an individual Agent Org Run.
The planned behavior is:
Completedcontinues to mean that one round of work is finished; it does not permanently close the Group Chat.continued_from_run_id, creates fresh Worker Sessions, Tasks, Inbox state, and Recovery Budget, and never changes the old terminal Run.This will be implemented separately, rather than expanding this review follow-up.
Follow-up: Revision Event architecture
A separate architecture series will replace high-frequency full Snapshot polling with ordered incremental synchronization.
The planned model is:
Expected user-visible benefits:
This work will land through separate Event-contract, replay/transport, frontend-store, and polling-reduction PRs.
Follow-up: red-team hardening
Additional red-team findings were intentionally preserved outside this PR and will be reviewed in a separate dependent branch and PR.
The follow-up scope includes:
org_run_idownership for nested Turn Intents and multi-Run session chains;These changes are not required to resolve the two #373 review rounds and are deliberately excluded here to keep this PR reviewable.
Audit reports
docs/architecture-audit-2026-07-16/AgentOrgReviewSafetyAudit.mddocs/frontend-ui-audit-2026-07-16/AgentOrgReviewSafetyAudit.md