Skip to content

factory: an organization's workstreams live on its server - #2624

Merged
santoshkumarradha merged 1 commit into
work/teamsfrom
teams/g2-server-workstreams
Nov 13, 2026
Merged

santoshkumarradha merged 1 commit into
work/teamsfrom
teams/g2-server-workstreams

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Teams wave, lane G2: an organization's workstreams live on its server (codeaf factory serve).

What lands

Every /v1/workstreams* route in the wave SPEC (~/work/teams-wave/SPEC.md):

  • Store: factory-workstreams.json beside the go-ahead policies, written under a cross-process lock with an atomic replace, the same way factory-policies.json is (store/workstreams.go). One EditWorkstreams save can change several workstreams, so include_linked lands whole or not at all. Only the ids an edit names get their rev counted up.
  • Visibility: you see a workstream you own, one your team owns, or one shared with a team you are in. The operator sees all of them. A workstream you cannot see answers 404, exactly like one that does not exist.
  • Writes: allowed for the owner person, the owning team or a shared team. The operator is not a writer unless they are one of those. Owner and share changes are allowed for the owner person, the owning team or the operator.
  • PATCH needs If-Match: <rev>: 428 without it, 412 when it is stale. A sent array replaces the stored one. Page bylines (updated_at / updated_by) are stamped by the server, only on pages whose words changed.
  • DELETE sets archived_at. Archived workstreams leave the list (?archived=1 brings them back) and refuse PATCH with 409. ?purge=1 is operator-only.
  • Owner PUT: a person handle or a known team. A share with the owning team is dropped.
  • Shares PUT replaces the team list. include_linked adds the same teams to each linked workstream the caller may govern; it never removes a share there. also_shared names the linked workstreams that were changed. The preview (GET …/shares/preview?teams=) answers exactly that set and writes nothing.
  • Import is one shot: the caller owns the copy, and links to the laptop's other workstreams are dropped. Importing the same from_local_id again by the same person returns the existing copy with 200, not a second copy.
  • Events: workstream.changed / workstream.removed go into the live record with {"kind","id"} on the stream. They are filtered to anyone who could see the workstream before or after the change, so a team just taken off a share still learns to drop its row.
  • Go-aheads: PUT /v1/policy on a ws_… group that is an org workstream needs write access to it. Every other group keeps the old rule.
  • Workstream.go_aheads holds the allowances of the policy stored for that id. needs_you / merged / total count the jobs whose PolicyGroup is the workstream id.

The shape types (owner, page, decision, source) are defined once in internal/factory/workstream.go, and api aliases them.

Wired to G1 (#2622, merged first)

  • Visibility and write rules read h.Membership(), G1's TeamMembership. A team id is valid only if it is in G1's team store; an unknown one answers 422.
  • New calls h.SetTeamOwnership(config.Store). store.TeamOwnsWorkstream counts archived workstreams too, so DELETE /v1/teams/{id} now answers 409 while that team owns a workstream (tested end to end).
  • liveForViewer keeps G1's team.changed case and adds the workstream case.

Proof

  • internal/factory/serve/workstreams_test.go runs against the desk's org scene (santosh, abir, mia; Platform, Growth, Design; the four fixture workstreams) with the teams written through G1's store. It covers visibility per person and for the operator, rev/412/428 and array replace, owner and share rights, include_linked with its preview, archive then purge, one-shot import, event audience, and go-ahead write access.
  • internal/factory/store/workstreams_test.go covers the store.
  • make pr-ready BASE=origin/work/teams passed after the rebase onto factory: teams on the organization server (G1) #2622. Two TestFactorySetup* tests that this change does not touch were flagged flaky and passed on rerun.

@santoshkumarradha
santoshkumarradha force-pushed the teams/g2-server-workstreams branch from 73f075c to ac0631b Compare November 13, 2026 15:52
Every /v1/workstreams* route of the Teams wave contract: a durable store
beside the go-ahead policies, visibility and write rules, rev + If-Match
(412 when stale), soft delete with an operator-only purge, owner change,
shares with include_linked and its preview, one-shot import of a Personal
workstream, workstream.changed / workstream.removed events filtered to the
people who could see the workstream, and go-ahead approval on an org
workstream now needs write access to it.

Team membership is read through serve.TeamMembership (TeamsOf, Members,
optional HasTeam), which the teams lane fills; store.TeamOwnsWorkstream
answers whether a team owns any workstream.

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
@santoshkumarradha
santoshkumarradha force-pushed the teams/g2-server-workstreams branch from ac0631b to 308ab50 Compare November 13, 2026 16:00
@santoshkumarradha
santoshkumarradha merged commit fc1835e into work/teams Nov 13, 2026
@santoshkumarradha
santoshkumarradha deleted the teams/g2-server-workstreams branch November 13, 2026 16:01
ZeroPoint95 pushed a commit that referenced this pull request Nov 24, 2026
Every /v1/workstreams* route of the Teams wave contract: a durable store
beside the go-ahead policies, visibility and write rules, rev + If-Match
(412 when stale), soft delete with an operator-only purge, owner change,
shares with include_linked and its preview, one-shot import of a Personal
workstream, workstream.changed / workstream.removed events filtered to the
people who could see the workstream, and go-ahead approval on an org
workstream now needs write access to it.

Team membership is read through serve.TeamMembership (TeamsOf, Members,
optional HasTeam), which the teams lane fills; store.TeamOwnsWorkstream
answers whether a team owns any workstream.

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
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