Skip to content

Judge room invites by the invited agent's addressing policy - #1443

Open
Xuefeng-Zhu wants to merge 9 commits into
sandbox-quantum:mainfrom
Xuefeng-Zhu:feat/room-invite-addressing-805
Open

Xuefeng-Zhu wants to merge 9 commits into
sandbox-quantum:mainfrom
Xuefeng-Zhu:feat/room-invite-addressing-805

Conversation

@Xuefeng-Zhu

@Xuefeng-Zhu Xuefeng-Zhu commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #805

What this changes

Room invitations now use the invited agent's addressing policy, with a refusal that explains who can invite instead. A platform join with no identified adder can't be refused, so Switch tells the current owner in Console and Gateway.

How it was tested

At 57243689e, the live Gateway returned HTTP 403 when a guest invited Bluefin Helper. The refusal explained the addressing policy and directed the guest to the owner. Room membership stayed unchanged. A separate genuine Mattermost bot join without a reported inviter succeeded and produced a Console notice explaining that Switch could not verify who added the agent. The notice endpoint returned the notice to the current owner and did not expose it to the guest. A cold Core boot on an empty database hit expand-only merge 2de54af6031b. The test used a scratch database pre-migrated with only that merge's rollout bookkeeping skipped. The migration scripts and exact-head Core runtime image stayed unchanged.

Case Result Note
Stranger and owner invites Pass Recorded service test with real PostgreSQL and simulated transport.
  • At 57243689e, Core invite, room service, DM, owner notice, entry-point and migration tests passed against disposable PostgreSQL where required. Ruff and Core mypy passed.
  • Gateway and Console owner-notice Vitest files and both TypeScript checks passed. The local follow-up commit touched only Core.

Done when

  • Every invite path refuses someone the agent's policy doesn't allow, with a clear message — test_invite_command_policy.py, test_invite_addressing_policy.py, test_room_service_invites.py and test_invite_gateway_policy.py cover refusals by the shared gate. test_room_create_platform_error.py checks that the Gateway returns the refusal wording.
  • The owner (and anyone the policy allows) can still invite it — test_invites.py covers allowed principals; test_room_service_invites.py and test_invite_addressing_policy.py exercise accepted invitations.
  • Agents already in rooms aren't kicked out (or the PR documents and justifies a different choice) — test_room_service_invites.py checks that refusing a new invite preserves existing members and that existing members are not judged again.
  • Tests for each path, against a real Postgres for store logic — The shared gate, store, chat command, agent operation, Gateway and platform-join tests run against PostgreSQL 16 (62 passed at 57243689e).
  • Docs updated where addressing policies are described — docs/official/internals/identity-and-access.md now describes the invite rule and owner notices; test_room_service_invites.py covers that behavior.

How it works

  • InviteGate in RoomService checks the actual person, agent, template runner or platform-reported adder for new memberships. Existing room members keep their places.
  • An unverified join records the owner notice in the same transaction as the membership. The current owner can dismiss it without a linked platform account, even if they are outside the room.
  • An Alembic merge revision joins this PR's owner-notice migration with main's, without changing either existing revision.

Known limitations

  • The current owner sees notices when they open the workspace. An agent without an owner has no recipient until one is assigned.

PR details

These commits are dated after the PR was closed and reopened on November 7, 2026.

  • 5b644b0a3 Merge remote-tracking branch 'upstream/main' into HEAD
  • b995ed4ff test: cover existing room members and invite policy (Room invites should respect who can talk to an agent #805)
  • 97e8f1aa7 test: cover invitation policy at entry points
  • b72e3c32f feat(invites): notify owners of unverified platform joins
  • 0162c5f13 Merge upstream main into room invite addressing
  • 57243689e Reconcile invite tests and migrations with upstream

Video

Console recordings at 57243689e. The guest clip shows the room invite refused under the agent's addressing policy. The Gateway returned HTTP 403. The owner clip shows the fresh private notice after a separate Mattermost bot join where the platform did not report who added it.

Earlier recording

Service-level invite demo shows a stranger refused and the owner accepted. It predates the notice UI.

invitation-story-final.webm

Xuefeng-Zhu and others added 2 commits November 4, 2026 16:10
- AddressingResolver.judge is now the tail of permitted() exactly as it
  was: drop the open-policy shortcut in front of allows_on_behalf_of,
  which already answers an open policy itself.
- Drop InviteOutcome.refused_ids, which nothing reads.
- Drop the issue-number tags from code comments and test docstrings, as
  the codebase does not use them.
@Xuefeng-Zhu Xuefeng-Zhu closed this Nov 7, 2026
@Xuefeng-Zhu Xuefeng-Zhu reopened this Nov 7, 2026

This branch has not been deployed

No deployments
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.

Room invites should respect who can talk to an agent

1 participant