Skip to content

Streamline agent approval flows and restore the Carina live voice - #804

Merged
muterC merged 5 commits into
mainfrom
zc/relax-approval-cards
Nov 26, 2026
Merged

muterC merged 5 commits into
mainfrom
zc/relax-approval-cards

Conversation

@muterC

@muterC muterC commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What and why

An Agent can carry out a Sponsor's request with fewer confirmation cards.

  • Creating a Room returns the Room ID immediately. The Sponsor owns it. Immediate creation checks that every invited Agent has the same Sponsor as the caller. The calling Agent receives the handoff in the new Room. Replaying the submission returns the original result. Pending cards issued before rollout still accept an approval or denial.
  • Creating an Agent in the Sponsor's direct chat opens a separate direct chat with the new Agent and announces it in the original conversation. A retry recovers a failed announcement. Concurrent retries publish one notice and one Room event. A Room without the Sponsor still requires confirmation.
  • Editing only an Agent's name or description takes effect immediately. Changes to an established Agent's instructions still require approval.
  • Notion page creation and appends go to the host's permission reviewer. Editing existing content still requires confirmation.
  • A separate commit restores Carina as the voice for new Live calls.

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 collaborate Skill 1.0.1 still describes the old direct-chat approval rule.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

  • createSnapshotRoom calls roomcreation.Create with AgentsAuthorized: true. roomcreation/create.go:41-45 documents 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, pass AgentsAuthorized: 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 to agent create (agent_api.go:251-258). Add an integration test for each case, and update the create.go:41 comment 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 the BeforeCreate re-normalization. After this PR, CreateCreationApprovalRequestInTx has no production caller. Only tests/integration/work_item_fixture_test.go:110 and room_message_batch_hydration_test.go:121 call it.
  • roomCreatedHandoffText (room_creation_now.go:670-697) is also a near-copy of roomCreationHandoffText (creation_approval_decision.go:276-318). Both trim the purpose, default nil delivered, 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

  • settleDirectRoomCreation runs after the Agent creation has committed, outside any transaction. Suppose the first call creates the Agent and opens its Direct Room, then fails in GetActor or CreateNotice. The retry with the same InvocationId sees replay=true and 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 on replay.

Verified as fine

  • Legacy pending cards: CreateRoomInTx checks lookupCreationApprovalReplay before the new idempotency record (room_creation_now.go:597-601), and Submit returns the card shape when DecisionID is 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 update still 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 stays confirm. The CLI (connector-approval.ts:34-36) and TeamHub (access.go:208-209) agree, and TestAccessRunsAdditiveNotionWritesAtOnce covers it.
  • The Go skipped-artifact JSON tags (creation_approval_decision.go:320-323) match the new AgentRoomCreationSkippedArtifact schema. No CJK appears in added lines or commit messages.
  • Unverified: whether the published collaborate Skill 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.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. createSnapshotRoom now passes AgentsAuthorized: 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), so validateAgentAdmission (apps/teamhub/internal/roomcreation/create.go:279) rejects any Agent whose created_by_actor_id is not the owner, which is the caller's Sponsor (room_creation_now.go:81). ErrAgentSponsorRequired maps to ErrForbidden (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, CreateRoomInTx duplicates 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 by tests/integration/work_item_fixture_test.go:110 and room_message_batch_hydration_test.go:121. Its roughly 50 lines of pre-checks are still duplicated in room_creation_now.go. Delete it and move the fixtures to CreateRoomInTx, 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), checks HasAgentCreationNotice, 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 the room_events insert, 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 !sponsorMember branch (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. Removing createSponsorAgent's replay return value leaves no stale callers (agent_agents.go:113).
  • HasAgentCreationNotice matches the stored notice shape: AgentCreated writes type: agent_created with agent set to the new Agent's ref (messagecreation/room_notice.go:52). The query requires room_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.
  • 54fc846d and 1a0f3008 are review fixes to 33800ace. Squash them into that commit, because rebase merges land every commit on main as 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.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CreateCreationApprovalRequestInTx leaves no production caller. agentcreationapproval.Submit calls CreateRoomInTx (apps/teamhub/internal/agentcreationapproval/service.go:198). Pending cards from before the rollout still replay through lookupCreationApprovalReplay before the generic idempotency lookup (apps/teamhub/internal/typedcard/room_creation_now.go:65). The new integration case replaying a pending Room submission returns its original card covers this, plus the conflict on a changed proposal.
  • The merged roomCreationHandoffText (apps/teamhub/internal/typedcard/creation_approval_decision.go:283) keeps both wire shapes. With approval == nil it emits the old immediate payload: the approval fields are omitted, and a blank purpose is dropped through omitempty, the same as the old *string. With an approval it emits the approved payload and its prompt text, as before. go vet passes on internal/typedcard and tests/integration, and the internal/typedcard unit 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 into roomCreationProposal (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.

@muterC
muterC added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit 6a511c1 Nov 26, 2026
16 checks passed
@muterC
muterC deleted the zc/relax-approval-cards branch November 26, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant