Repository navigation
feat(rooms): the daemon hosts rooms, delivering posts to members and logging their replies - #1956
Conversation
…logging their replies The rooms Host in internal/rooms is a stage of the daemon's binding handler before the thread registry. post_room routes and logs a user post and answers the poster with room_posted, list_rooms answers rooms, follow_room answers room_snapshot and then streams room_post and room_activity, and leave_room or a disconnect stops the follow. Each member is a client of its session's thread, the way a Telegram chat is. A routed post becomes the member's next turn: resume_conversation with the member's agent, the room's project and an Origin recording room, then run_agent_input with the posts the member has not seen since its last turn (up to context_posts) and the post for it. Mentions of agents lose their @ in the turn, so the member's file expansion never inlines a file named like a member. The run's last assistant message is logged as the member's post. Members routed the same post run in parallel, a post for a busy member waits as its next turn, and a run that ends on an approval leaves it to the member's own chat and logs that the member waits. Idle members detach after the channel follow timeout, so the registry reaps their workers. - posts carry an id, so a held post is found in the log even when two posts share a time - sessionsdomain.Origin gains InvokedBy, which the worker hands on as INFER_INVOKED_BY, so a member session records room - rooms resolve against the agents of their own project (tools.ProjectAgents), which also spares infer rooms list and show the whole service container - container.NewRoomsDecider starts the gateway, or joins the running one, on the first decision only, and retries after a failed start - the CLI's daemon client moves to internal/daemon, shared by infer daemon and the new infer rooms post, which posts and prints the routing - docs/rooms.md, the Rooms frames in docs/browser-extension-protocol.md, a Rooms section in docs/daemon.md and the README feature list
A refused resume_conversation and its run_agent_input each answered with a RUN_ERROR. The first ended the turn and started the next held post, and the second ended that new turn too, so its answer was dropped. A member now keeps the run id of its turn and ignores the end of any other run. The registry tags a refused run_agent_input with the input's run id.
A room without a project resolves to the working directory of the process that reads it. The daemon logged under its own directory while infer rooms show read the shell's, so show printed an empty room right after a post went through. infer rooms list and show now ask the daemon with list_rooms and read the log at the project it reports. Without a daemon they resolve the rooms locally as before.
With INFER_GATEWAY_MOCK=true a post that pinged nobody still started or called the real gateway. The rooms decider now serves its own mock gateway in mock mode, sharing the setup with the container.
…ents Rooms, Telegram, the subagent tools and the TUI each defined their own copy of the resume_conversation and run_agent_input frames. sessionsdomain.ResumeFrame now carries resume_conversation, and the registry names the frame by the same constant. agui.RunInputFrame carries run_agent_input next to RunAgentInput, since a domain package cannot import agui.
|
@infer can you review this PR? any architecture issues? any code smell? wrong namings? is it ready for merge? use /ponytail:ponytail /ponytail:ponytail-review /clean-architecture /domain-driven-design /go /go-concurrency /cobra-viper |
|
Model: Todos
Pull Request✅ Infer Result: SuccessReview: PR #1956What this change does: The daemon now hosts rooms. A user's post is routed (by ping or by a decision model), logged to a JSONL log, and delivered to each routed member as that member's next turn on its own session through the thread registry; the member's last assistant message is logged back into the room and followers get every post and activity live. Wiring goes through the composition root ( Architecture (clean-architecture + DDD): No blocking issues. The dependency rule holds: Findings:
Everything else checked out: modern stdlib throughout ( Verdict: fix 1 first, 2 and 3 close behind. Not ready to merge this minute; after 1 (ideally 2-4) it ships. Lean: -8 lines possible. Model: Tokens: 944,544 in · 26,205 out · 970,749 total (14 requests) Tool calls: 33 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
startNext sends a turn's frames after releasing the member's lock, so a worker that stopped reading its pipe no longer blocks every room's view. A send lock keeps each turn's two frames together. A backed-up member drops streaming frames first and keeps room for the frames that start and end a run, so a turn always ends.
Resolves #1946
Summary
Third step of rooms (#1943). The daemon hosts rooms. It routes a user's post, delivers it to each member it reaches as that member's next turn on the member's own session, logs the member's answer, and streams every room to the clients that follow it.
Changes
internal/rooms/host.go: theHost, a stage ofbindingHandler.Handlebeforeregistry.Handle. It is built incmd/daemonstartThreadsafter the registry and closed with the threads.post_roomroutes and logs a user post and answers the poster withroom_posted: the logged post and the notices for its author.list_roomsanswersrooms.follow_roomanswersroom_snapshotand then streamsroom_postandroom_activity(running, waiting or idle).leave_room, or a disconnect, stops the follow.internal/rooms/member.go: one seat as a client of its session's thread, copying the Telegram adapter.resume_conversation(the member's agent, the room'sproject_dir, anOriginrecordingroom) andrun_agent_inputthroughregistry.Handle.context_posts, then the post for it.ChannelFollowTimeout, so the registry reaps their workers.internal/rooms/domain:Unseenpicks a turn's posts.PlainMentionswrites agent mentions without the@in a turn, so the member's file expansion never inlines a file named like a member. This is the delivery half of "a member's name wins over a file" from [FEATURE] Route a room post by mention or a decision model #1945.id, since two posts can share a time. Synctest's fake clock exposed it, and a coarse clock would too.sessionsdomain.OrigingainsInvokedBy, which the worker hands on asINFER_INVOKED_BY, so a member session recordsroom.tools.ProjectAgents(projectDir): rooms resolve"*"against the agents of their own project, in the daemon and ininfer rooms list/show, which no longer build the whole service container.container.NewRoomsDecider: the daemon's router asks the gateway through it. It starts the gateway, or joins the running one, on the first decision only, so mention-only rooms never touch it, and it retries after a failed start.infer rooms post <room> "<text>"posts through the daemon and prints the routing, with--format json. The CLI's daemon client moves fromcmd/daemontointernal/daemonso both commands share it.docs/rooms.mdis new.docs/browser-extension-protocol.mdgains the Rooms frames.docs/daemon.mdgains a Rooms subsystem row and section.internal/rooms/README.mdare updated.Tests
internal/rooms/host_test.go, in synctest bubbles with thetests/mocks/sessionsFakeThreadRouterandFakeClient, theDeciderfake and the real JSONL log:resume_conversationandrun_agent_inputframes and the originlist_roomsTestUnseen,TestPlainMentions,TestProjectAgents..., the room member row inTestWorkerArgsAndEnv,TestRoomsDeciderReportsAnUnreachableGatewayandTestPrintPosted.go test ./...passes (133 packages),-race -count=5oninternal/rooms/...is clean, and lint and markdownlint report nothing.Checked by hand against a scratch daemon with
INFER_GATEWAY_MOCK=true:infer rooms post public "@main ..."routed tomain, the worker answered, and the reply was logged.mainwere delivered one after the other.room-public-mainrecordedinvoked_by: room,agent: main,label: public.Not covered
registry.Handlelike any client, so the lease relay applies unchanged. No test runs a remote member.