Skip to content

refactor(team): extract pkg/team store from cmd (#326b) - #342

Merged
scttfrdmn merged 1 commit into
mainfrom
audit/326b-team-store
Jul 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
audit/326b-team-store

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Part of #326 (store-layer extraction, audit #328). Second of 4 domain PRs. No behavior change; wire format preserved and asserted.

What changed

cmd/team.go talked to DynamoDB directly across all six subcommands (create/list/show/add/remove/delete), with teamRecord/memberRecord structs and a teamDDBClient helper in cmd/. Added pkg/team (Client mirroring pkg/alerts.Client, NewClient/NewClientWithTableNames) holding TeamRecord/MemberRecord and the domain methods:

  • Teams: PutTeam, GetTeam, DeleteTeam, IncrementMemberCount, DecrementMemberCount (keeps the member_count > 0 guard).
  • Memberships: PutMembership, DeleteMembership, GetMembership, ListTeamsForMember (via the member_arn-index GSI), ListMembers.

STS caller-ARN derivation stays in cmd/ (passed into the store methods, not baked into the store). resolveTeamMembership became a thin requireMembership over GetMembership.

Wire format preserved

The dynamodbav tags moved verbatim — a diff against the old cmd/team.go structs on main confirms them byte-identical. The dashboard-api Lambda (separate module) shares this item format, so nothing on the wire changed. Table names unchanged (spawn-teams / spawn-team-memberships).

Verification

  • go build ./..., go vet ./cmd ./pkg/team, gofmt clean.
  • New pkg/team/team_substrate_test.go passes against the Substrate emulator: create→list→show flow (GetTeam round-trip + missing→nil, GetMembership present/absent, GSI ListTeamsForMember), and add/remove with member_count inc/dec + delete.
  • go test ./cmd green (excl. pre-existing TestCatalogValid / feat(plugin): permissions declaration block (#388) #392).
  • Rebuilt bin/spawn; recursive command+flag tree byte-identical vs main.

Next: sweep store + collect account-fix (#326c), then pkg/bot (#326d).

Second store-layer extraction (#326). cmd/team.go talked to DynamoDB
directly across all six subcommands with item structs + a teamDDBClient
helper in cmd/. Added pkg/team (Client mirrors pkg/alerts.Client) holding
TeamRecord/MemberRecord and the CRUD/query methods (PutTeam/GetTeam/
DeleteTeam, Inc/DecrementMemberCount with the >0 guard, PutMembership/
DeleteMembership/GetMembership, ListTeamsForMember (GSI)/ListMembers).
Rewired all handlers; STS caller-ARN derivation stays in cmd (passed into
methods). resolveTeamMembership → requireMembership over the store.

Wire format preserved: the dynamodbav tags moved verbatim (a diff vs the
old cmd structs confirms them byte-identical — the dashboard-api Lambda,
a separate module, shares this format). Table names unchanged
(spawn-teams / spawn-team-memberships).

Verified: go build ./..., go vet, gofmt clean; new pkg/team substrate
tests pass (create/list/show flow, add/remove + member_count, GSI lookup);
tag-equivalence check; cmd tests green; command tree byte-identical vs main.
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 84 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/team.go 0.00% 44 Missing ⚠️
pkg/team/team.go 72.41% 27 Missing and 13 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 08a22ea into main Jul 12, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the audit/326b-team-store branch July 12, 2026 02:45
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