Repository navigation
refactor(hub-zero): T5c-ii move agent-run machinery out of packages/chat (CL-8173) - #770
Merged
Merged
Conversation
The hub built its `ConditionRegistry` inline beside chat's grant store and threaded it through ~20 mounts under a chat-flavoured name, though nothing in it is chat-specific: `time_window` is `@intx/authz`'s own evaluator, the same default `mountHubRoutes` builds when no registry is supplied. It now lives in `apps/hub/src/grant-conditions.ts` as `grantConditionRegistry`, with every mount updated. No behavior change. Claude-Session: https://claude.ai/code/session_01RweuMUskU2nvcFhdckc7EG
Turn intake, the turn queue and its claims, the finalized-turn write claims, the client-id ledger and the turn/mail correlation store are the agent run loop, not the chat surface. They now live in `@corbits/agent-runtime` alongside the run definition builder that already lived there; `packages/chat` and `apps/hub` consume them from there. Relocation only: each module keeps its behavior and, for now, the `chat.*` tables it already wrote (`chat.agent_turns`, `chat.finalized_turn_write_claim`, `chat.message_client_ids`, `chat.turn_mail_correlation`), reached through the new `@corbits/chat/schema` subpath. Replacing those with native `session_mail`/run state is the next slice. Claude-Session: https://claude.ai/code/session_01RweuMUskU2nvcFhdckc7EG
`artifact-delivery.ts` maps a finalized turn's persisted-artifact facts onto the file-part wire shape. Its only consumer is the turn orchestrator, which now lives in `@corbits/agent-runtime`, so the module follows it there. Recognition stays in `@corbits/turn-artifacts` as before. Claude-Session: https://claude.ai/code/session_01RweuMUskU2nvcFhdckc7EG
The stub inference routes exist for the `E2E_PROVIDER`-unset path, which the hub mounts and nothing else consumes. They now sit with the hub, at `apps/hub/src/e2e/noop-inference.ts`, rather than shipping as part of the chat package's public surface. Claude-Session: https://claude.ai/code/session_01RweuMUskU2nvcFhdckc7EG
A rebase conflict with origin/main's removal of CreateWorkflowAuthorRegistryDeps's deployer field left a stray deployer: workflowDeployer line; drop it, and take origin/main's bun.lock refreshed via bun install.
TheGreatAxios
force-pushed
the
cl-8173-t5c-ii
branch
from
September 17, 2026 18:14
85bb989 to
627de2d
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.
Summary
Continues T5c: relocating agent-run machinery out of
packages/chat.apps/hub/src/grant-conditions.tspackages/agent-runtimepackages/agent-runtime(beside the turn loop)These moved modules still write to the
chat.*tables (chat_settings,chat_room_messages/timeline events, etc.) via theChatStore/room-message deps injected into them — the tables stayed put; only the code moved.Skipped (scope note)
Two moves from the original T5c-ii ask are not in this PR — both turned out to be more than a pure relocation:
settleConnectedService(packages/chat/src/connect-pending.ts, notplatform-adapter.tsas filed) settles pending connector cards by calling intopostRoomMessage,dispatchTurn,ChatStore,workbench-settings,blocks,mentions, andagent-address— allpackages/chatinternals.packages/connectionsis a dependency ofpackages/chattoday (chat depends on connections, not the reverse); moving this function there as-is would requireconnectionsto importchat, introducing a package cycle. Doing it properly needs either a smaller structural interface this function can depend on, or moving it somewhere both packages can reach — a design decision, not a relocation.packages/chat/src/workflow-participant-routes.ts, and the idle-sleep wiring inpackages/chat/src/platform-adapter.ts) are saturated with chat internals (ChatStore,workbench-service'slaunchAndJoinAgent/sendWorkbenchMessage,parts,blocks,connect-pending,mail-headers,room-messages). Moving this intopackages/agent-runtimewith zero@corbits/chatimport means either moving most ofpackages/chatalong with it, or redesigning these routes against a narrower structural dependency shape — real design work, not a same-day relocation.Filing these as follow-up scope rather than forcing an incomplete/behavior-risking move under this PR.
Test plan
bun run typecheckbun run lintbun run check:structuralorigin/main