Skip to content

[WPB-27169] Do not count apps and collaborators as members in get-team-size. - #5445

Open
fisx wants to merge 13 commits into
developfrom
WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size
Open

[WPB-27169] Do not count apps and collaborators as members in get-team-size.#5445
fisx wants to merge 13 commits into
developfrom
WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size

Conversation

@fisx

@fisx fisx commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This is a follow-up to #5173, #5213, #5452, where we added data about number of apps and collaborators to the get-team-size response.

Changes:

  • The teamSize field works again as it did in the olden days, only counting team members, which are regular users by definition.
  • There are two more fields apps, collaborators, which contain the resp. counts.
  • Now all 3 counts add up to the legalhold limit, which is enforced correctly again.
  • The protobuf is also adjusted. I went for backwards-incompatible, because the change I undid was very recent, and has probably not been used. (I'll double-check this!)

https://wearezeta.atlassian.net/browse/WPB-27169

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Aug 13, 2026
@fisx
fisx force-pushed the WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size branch from 9bbc19f to 5f5d7d0 Compare August 14, 2026 06:52
@fisx
fisx force-pushed the WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size branch from 5f5d7d0 to 7c986b7 Compare August 26, 2026 14:58
@fisx
fisx marked this pull request as ready for review August 26, 2026 14:58
@fisx
fisx requested review from a team as code owners August 26, 2026 14:58
@fisx
fisx requested a lite review from Copilot August 26, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR (WPB-27169) changes the meaning/shape of “team size” so that API-visible teamSize represents paid seats (regular users) while apps and collaborators are reported separately, and propagates that change through Galley/Brig, the indexed user store, journaling, and tests.

Changes:

  • Redefines TeamSize to {teamSize, apps, collaborators} and updates JSON/OpenAPI schema plus golden fixtures.
  • Updates Galley/Brig logic and integration tests to treat apps/collaborators as non-members for get-team-size.
  • Extends indexed user store implementations and team journaling/protobuf definitions to carry separate app/collaborator counts.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
services/galley/src/Galley/API/Teams.hs Adjusts team-size bookkeeping and LegalHold-related checks to the new TeamSize shape.
services/galley/src/Galley/API/LegalHold/Team.hs Updates LegalHold activation size check to use the new TeamSize representation.
services/brig/test/integration/API/Team.hs Updates expected TeamSize JSON payload in Brig integration tests.
libs/wire-subsystems/test/unit/Wire/MockInterpreters/IndexedUserStore.hs Updates mock team-size computation and adds collaborator counting.
libs/wire-subsystems/src/Wire/UserSubsystem/Interpreter.hs Updates max-team-size checks to use teamSize (paid seats) only.
libs/wire-subsystems/src/Wire/TeamJournal.hs Updates journal event payload generation for new app/collaborator fields.
libs/wire-subsystems/src/Wire/IndexedUserStore/ElasticSearch.hs Updates ES-based team-size result mapping to the new TeamSize fields.
libs/wire-api/test/golden/testObject_TeamSize_1.json Refreshes golden JSON to new TeamSize schema.
libs/wire-api/test/golden/testObject_TeamSize_2.json Refreshes golden JSON to new TeamSize schema.
libs/wire-api/test/golden/testObject_TeamSize_3.json Refreshes golden JSON to new TeamSize schema (large-number case).
libs/wire-api/test/golden/testObject_Event_meeting_update_manual_1.json Golden fixture update (field ordering/structure adjustment).
libs/wire-api/test/golden/testObject_Event_meeting_member_add_manual_2.json Golden fixture update (field ordering/structure adjustment).
libs/wire-api/test/golden/testObject_Event_meeting_member_add_manual_1.json Golden fixture update (field ordering/structure adjustment).
libs/wire-api/test/golden/testObject_Event_meeting_delete_manual_1.json Golden fixture update (field ordering/structure adjustment).
libs/wire-api/test/golden/testObject_Event_meeting_create_manual_1.json Golden fixture update (field ordering/structure adjustment).
libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/TeamSize.hs Updates manual golden Haskell objects for TeamSize.
libs/wire-api/src/Wire/API/Team/Size.hs Redefines TeamSize and updates its schema/Arbitrary instance.
libs/types-common-journal/proto/TeamEvents.proto Changes TeamEvents event-data fields for app/collaborator counts.
integration/test/Test/TeamCollaborators.hs Adds integration assertion that collaborators are counted separately in team size.
integration/test/Test/Apps.hs Adds integration assertion that apps are counted separately in team size.
changelog.d/1-api-changes/WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size Documents the API schema change for get-team-size and TeamEvents protobuf.
Suppressed comments (1)

services/galley/src/Galley/API/Teams.hs:1082

  • The LegalHold size check now sums teamSize + apps + collaborators here, but ensureNotTooLargeToActivateLegalHold (and the PR intent of “do not count apps/collaborators as members”) suggests only teamSize should be relevant. This inconsistency will make activation vs. later member/app changes apply different limits; please align the definition of what counts toward the LegalHold fanout size across all call sites.
    pure case uType of
      UserTypeFilterRegular -> n {teamSize = n.teamSize + 1}
      UserTypeFilterApp -> n {apps = n.apps + 1}
  ensureNotTooLargeForLegalHold tid (sizeAfterAdd.teamSize + sizeAfterAdd.apps + sizeAfterAdd.collaborators)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread services/galley/src/Galley/API/Teams.hs
Comment thread services/galley/src/Galley/API/Teams.hs Outdated
Comment thread libs/wire-api/src/Wire/API/Team/Size.hs Outdated
Comment thread libs/types-common-journal/proto/TeamEvents.proto
Comment thread libs/wire-subsystems/src/Wire/IndexedUserStore/ElasticSearch.hs
Comment thread services/galley/src/Galley/API/Teams.hs Outdated
@@ -1,5 +1,5 @@
{
"teamSize": 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it an intended breaking change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it just moved to the end of the object, shouldn't be breaking.

@fisx
fisx requested a review from blackheaven August 27, 2026 09:36
@fisx
fisx force-pushed the WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size branch 2 times, most recently from c9c245d to 7a33606 Compare August 27, 2026 14:07
@fisx
fisx marked this pull request as draft August 27, 2026 14:31
@fisx
fisx force-pushed the WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size branch from 7a33606 to b61404d Compare August 29, 2026 07:53
@fisx
fisx marked this pull request as ready for review August 29, 2026 07:56

@battermann battermann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I could not find a guard so far that prevents an app/collaborator to be added to it's own team. In this case it would be counted twice, right? But I guess that is ok?

// they are missing.
required int32 member_count_regular = 4;
required int32 member_count_app = 5;
// fields optional, and assume '0' if missing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why does it say optional in the comment while the fields are tagged with required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread libs/wire-subsystems/src/Wire/TeamSubsystem.hs
Comment on lines +43 to +47
( \zuid tid (NewTeamCollaborator uid perms) -> do
n <- getSize tid
TeamSubsystem.ensureNotTooLargeForLegalHold tid (n.teamSize + n.apps + n.collaborators + 1)
createTeamCollaborator zuid uid tid perms
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit-pick] This would be candidate to extract

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

760fa11

I thought so, too, but turns out this caused a bit of a mess... :-)

I think it's still an improvement, but I am wondering if there isn't a way to throw around fewer constaints (or constraint sets)?

Comment thread services/galley/src/Galley/API/Teams.hs Outdated
-- lower-bounding the fields before the substraction.
--
-- We apply (2).
E.getSize tid <&> \s -> s {teamSize = min 1 s.teamSize, apps = min 1 s.apps}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what if teamSize or apps is 0? shouldn't we actually max 1 s.teamSize ... ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(\zuid tid (NewTeamCollaborator uid perms) -> createTeamCollaborator zuid uid tid perms)
( \zuid tid (NewTeamCollaborator uid perms) -> do
n <- getSize tid
TeamSubsystem.ensureNotTooLargeForLegalHold tid (n.teamSize + n.apps + n.collaborators + 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would do the permission check before the size check somehow.

@fisx
fisx force-pushed the WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size branch from fb319cb to 565a5bb Compare September 1, 2026 13:39
@fisx
fisx force-pushed the WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size branch from 565a5bb to a8de0ac Compare September 1, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants