Repository navigation
Streamline agent approval flows and restore the Carina live voice - #804
Conversation
There was a problem hiding this comment.
Request changes (1 P1, 1 P2, 1 P3)
Scope: base main, merge base 665356a1, 2 commits, 35 files reviewed (TeamHub, contracts, teamhub-cli, node-services prompt, voice-runtime). Loaded coderbook, ponytail-review and karpathy-guidelines. Ran in a separate session.
P1
Immediate Room creation still admits any active Agent in the Tenant, with no Human approval — apps/teamhub/internal/typedcard/creation_approval_decision.go:182 (reached from room_creation_now.go:631)
createSnapshotRoomcallsroomcreation.CreatewithAgentsAuthorized: true.roomcreation/create.go:41-45documents that flag as valid only when "a Human approved the creation, or a Human opens a direct Room with an Agent visible to them". Without the flag, an Agent joins only when the owner sponsors it (create.go:279).- On the new path no Human approves anything.
freezeRoomSnapshot→resolveAndValidateActors(agentcreationapproval/service.go:407-433) checks only that each member is an active Agent with a management ID in the Tenant. Visibility and sponsor are not checked. - Failure scenario: an Agent runs
teamhub room create --member-id <another user's sponsor-scoped Agent>. This could come from a prompt injection, or from a non-Sponsor Human in a shared Room, because nothing on this path requires the Sponsor to be in the origin Room. TeamHub creates the Room at once and adds that private Agent, which then runs on its own Sponsor's Runtime. That Sponsor never consented, and the requesting Agent's Sponsor never saw a card either. Before this PR, the approval card was the Human authorization the flag relies on. - Fix: in
CreateRoomInTx, passAgentsAuthorized: false. The owner is the Sponsor, so only the Sponsor's own Agents are admitted at once. Alternatively, fall back to the existing approval card when the snapshot names an Agent the Sponsor does not sponsor, or when the Sponsor is not an active member of the origin Room. That second check would match the rule this PR already applies toagent create(agent_api.go:251-258). Add an integration test for each case, and update thecreate.go:41comment so it matches the rule.
P2
CreateRoomInTx copies the card path, and the card path is now dead in production — apps/teamhub/internal/typedcard/room_creation_now.go:564-630
- Lines 565-630 repeat the setup steps of
CreateCreationApprovalRequestInTx(typedcard/creation_approval.go:64-121): input validation, the advisory lock, source resolution, the expected-actor and tenant checks, the idempotency lock, legacy replay, owner lookup, and theBeforeCreatere-normalization. After this PR,CreateCreationApprovalRequestInTxhas no production caller. Onlytests/integration/work_item_fixture_test.go:110androom_message_batch_hydration_test.go:121call it. roomCreatedHandoffText(room_creation_now.go:670-697) is also a near-copy ofroomCreationHandoffText(creation_approval_decision.go:276-318). Both trim the purpose, default nildelivered, build the same payload fields, and use the same<room-handoff-pattern>block. Two copies of the handoff contract can drift apart.- Fix: move the shared setup into one helper used by both paths, or delete the card-creation function and seed legacy pending cards in tests through a test-only fixture. Build both handoff texts from one function, with the decision fields optional.
P3
Retrying a Direct-Room Agent creation can lose the announcement — apps/teamhub/internal/agentregistry/agent_api.go:283-300
settleDirectRoomCreationruns after the Agent creation has committed, outside any transaction. Suppose the first call creates the Agent and opens its Direct Room, then fails inGetActororCreateNotice. The retry with the sameInvocationIdseesreplay=trueand returns before posting the notice, so the original conversation never gets the "Agent created" notice. Fix: make the notice idempotent (a deterministic message ID from the invocation) and always attempt it, instead of keying it onreplay.
Verified as fine
- Legacy pending cards:
CreateRoomInTxcheckslookupCreationApprovalReplaybefore the new idempotency record (room_creation_now.go:597-601), andSubmitreturns the card shape whenDecisionIDis set (agentcreationapproval/service.go:234-240). - Atomicity: the Room, the Document bindings, the initial message, the handoff and the idempotency record are all written in the caller's transaction (
room_creation_now.go:631-664). Bindings use a submission-derived key (:634). - Profile-only
agent updatestill writes the change, a notice and an idempotency record in one transaction. A request with no Room context (auth.RoomID == "") still gets a card (agent_api.go:116-131). - The Notion split: create and append are now
judge, edit staysconfirm. The CLI (connector-approval.ts:34-36) and TeamHub (access.go:208-209) agree, andTestAccessRunsAdditiveNotionWritesAtOncecovers it. - The Go skipped-artifact JSON tags (
creation_approval_decision.go:320-323) match the newAgentRoomCreationSkippedArtifactschema. No CJK appears in added lines or commit messages. - Unverified: whether the published
collaborateSkill 1.0.1's outdated approval text misleads Agents. The PR body acknowledges this.
Process notes
- The branch is 2 commits behind
main. Rebase before merging.
CI
All checks pass. computer-go and computer-go-windows were skipped because the PR does not touch them. I ran no tests locally.
Automated review by Claude Code
Automated review of 06700f6 by Claude Code.
There was a problem hiding this comment.
Approve with nits (1 P2 carried over, 0 new findings)
Scope: follow-up on 06700f6. Base main, merge base 665356a1, 4 commits and 36 files reviewed, with a close look at the 10 files changed since the last review. Helper skills loaded: coderbook and ponytail-review. karpathy-guidelines was not loaded. The review ran in a separate session.
Previous findings
- P1, immediate Room creation admitted any Agent: Resolved.
createSnapshotRoomnow passesAgentsAuthorized: spec.humanApproved(apps/teamhub/internal/typedcard/creation_approval_decision.go:184). Only the approved-card path sets this to true (:77). The immediate path leaves it false (room_creation_now.go:100), sovalidateAgentAdmission(apps/teamhub/internal/roomcreation/create.go:279) rejects any Agent whosecreated_by_actor_idis not the owner, which is the caller's Sponsor (room_creation_now.go:81).ErrAgentSponsorRequiredmaps toErrForbidden(creation_approval_decision.go:397). The subtest "only a Human-approved snapshot admits an Agent with a different Sponsor" (tests/integration/mcp_creation_approval_test.go:423) covers both paths. - P2,
CreateRoomInTxduplicates the old flow and leaves dead code: Not resolved.CreateCreationApprovalRequestInTx(apps/teamhub/internal/typedcard/creation_approval.go:59) still has no production caller. It is used only bytests/integration/work_item_fixture_test.go:110androom_message_batch_hydration_test.go:121. Its roughly 50 lines of pre-checks are still duplicated inroom_creation_now.go. Delete it and move the fixtures toCreateRoomInTx, or extract the shared pre-checks into one helper. - P3, a failed Direct Room creation lost its notice on retry: Resolved.
settleDirectRoomCreation(apps/teamhub/internal/agentregistry/agent_api.go:228) no longer depends on the registration replay flag. It takes the Room row lock (LockTenantDeliveryRooms), checksHasAgentCreationNotice, and publishes the notice in the same transaction. Concurrent retries are serialized, and only the first one publishes. The integration test injects a failure on theroom_eventsinsert, then sends two concurrent retries and checks that exactly one notice and one event exist (tests/integration/agent_cli_agents_test.go:288-340).
Findings
No new findings.
Verified as fine
- The Sponsor Agent limit check moved into the
!sponsorMemberbranch (agent_api.go:184). Immediate creation is still capped by the registration path (agent_registration.go:346). A replayed creation for a Sponsor who has reached the limit now replays instead of failing. RemovingcreateSponsorAgent's replay return value leaves no stale callers (agent_agents.go:113). HasAgentCreationNoticematches the stored notice shape:AgentCreatedwritestype: agent_createdwithagentset to the new Agent's ref (messagecreation/room_notice.go:52). The query requiresroom_seq IS NOT NULL, so it counts only published notices.- The contract description, the CLI README and the regenerated TS types all match the same-Sponsor rule. Added lines and commit messages contain no CJK.
Process notes
- The branch is 2 commits behind
main. Rebase it before merge. 54fc846dand1a0f3008are review fixes to33800ace. Squash them into that commit, because rebase merges land every commit onmainas is.
CI
All checks pass. computer-go and computer-go-windows were skipped because their paths are untouched. I ran no tests myself.
Automated review by Claude Code
Automated review of 1a0f300 by Claude Code.
There was a problem hiding this comment.
Approve (0 findings)
Follow-up on 1a0f300. Merge base 665356a1; 5 commits and 39 files reviewed, focusing on the new commit 7591c43 (7 files) and re-checking the riskiest assumptions over the whole PR.
Verified as fine
- Removing
CreateCreationApprovalRequestInTxleaves no production caller.agentcreationapproval.SubmitcallsCreateRoomInTx(apps/teamhub/internal/agentcreationapproval/service.go:198). Pending cards from before the rollout still replay throughlookupCreationApprovalReplaybefore the generic idempotency lookup (apps/teamhub/internal/typedcard/room_creation_now.go:65). The new integration casereplaying a pending Room submission returns its original cardcovers this, plus the conflict on a changed proposal. - The merged
roomCreationHandoffText(apps/teamhub/internal/typedcard/creation_approval_decision.go:283) keeps both wire shapes. Withapproval == nilit emits the old immediate payload: the approval fields are omitted, and a blank purpose is dropped throughomitempty, the same as the old*string. With an approval it emits the approved payload and its prompt text, as before.go vetpasses oninternal/typedcardandtests/integration, and theinternal/typedcardunit tests pass. - The test-only
seedLegacyRoomCreationCardInTx(apps/teamhub/tests/integration/work_item_fixture_test.go:121) writes the same decision, published card and idempotency record that the removed writer wrote. It stores a view that still decodes intoroomCreationProposal(apps/teamhub/internal/typedcard/creation_approval.go:122).
Process notes
- The branch is 9 commits behind
main. Rebase it before merging.
CI: all checks pass (computer-go was skipped). I ran go vet and go test -count=1 ./internal/typedcard/ myself, and both passed.
Automated review by Claude Code
Automated review of 7591c43 by Claude Code.
What and why
An Agent can carry out a Sponsor's request with fewer confirmation cards.
How it was verified
Six PostgreSQL integration tests cover replay, approval and denial of persisted Room creation cards, deletion with a pending decision, and the message projection for pages of up to 200 cards. The old card writer was removed from production. Both creation paths share the handoff encoder.
TeamHub fast checks, formatting, layout tests, and seven focused PostgreSQL integration tests passed. The integration cases cover immediate creation, replay, membership, and cards issued before rollout.
Isolated PostgreSQL regression tests cover immediate and Human-approved admission with different Sponsors, plus notice publication failure followed by two concurrent retries.
Contract regeneration verification and all 74 contract tests passed. TeamHub CLI typecheck, lint, 993 tests, and bundle build passed.
Voice Runtime typecheck, lint, and build passed. The Live entry point selected Carina for a new session and the local LiveKit worker registered successfully.
One of 330 Voice Runtime tests failed. The same interruption test fails on the unmodified branch base. It expects one cancellation after a provider speech-start event and observes zero.
Node Services typecheck and lint passed. Two unit tests failed, covering log truncation after redaction and the provider import boundary. Both tests and their corresponding implementations match the target branch.
The full repository gate passed with Bash 5.3, including commit checks, changed-file formatting, script tests, and documentation links.
Boundary
The Agent API contract, CLI help and README, Agent prompts, and Voice Runtime README describe the new behavior. These changes add no network round trip or filesystem walk between a user message and provider readiness.
An older TeamHub CLI can display an approval request with an empty ID after the server has already created the Room. The updated CLI handles both immediate creation and pending cards. The published
collaborateSkill 1.0.1 still describes the old direct-chat approval rule.