Skip to content

factory: organization changes reach the desk; go-ahead reads need sight of the workstream (G4) - #2625

Merged
santoshkumarradha merged 4 commits into
work/teamsfrom
teams/g4-events-policy
Nov 13, 2026
Merged

santoshkumarradha merged 4 commits into
work/teamsfrom
teams/g4-events-policy

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

Teams wave lane G4. Two gaps left after G1–G3.

1. Organization events reach the desk

The org server already publishes team.changed, workstream.changed and workstream.removed on GET /v1/events, filtered per viewer. Nothing relayed remote factory events to the app before this; now the engine follows a connection's stream once that connection has answered any org method (factory.teams, factory.org_workstreams, …), with the same session, and emits:

{"event":"factory.org_changed","seq":812,"data":{"connection":"fc_acme","kind":"workstream.changed","id":"ws_01JD…"}}
kind desk does
team.changed re-read factory.teams
workstream.changed re-read factory.org_workstream {id} (may now be not_found: unshared from you)
workstream.removed drop it
any kind with id: "" the stream dropped and the server could not replay the gap; re-read both lists
  • Reconnects send Last-Event-ID, so a short drop replays the missed events; a gap past the server's window becomes one team.changed + one workstream.changed with empty ids.
  • Other stream events (job ticks, activity, machines) are not relayed.
  • Following stops on detach, on a sign-in that changes/ends/is refused (4xx), and on engine shutdown; the next org call restarts it. One stream per connection.
  • Documented in docs/design/app-v3/PROTOCOL.md (Events table + the org methods section); the schema picks up FactoryOrgChanged from eventShapes.

Files: internal/appwire/factory_org_events.go, cmd/codeaf/appfactory_org_events.go, hooks in appfactory.go / appfactory_org.go.

2. Go-ahead policy reads need sight of the workstream

GET /v1/policy?group=<org workstream id> now answers 404 (workstream not found, the same words as GET /v1/workstreams/{id}) unless the caller can see the workstream (owner, owning team, shared team, operator). Groups that are not org workstreams are unchanged. orgWorkstreamWrite became orgWorkstreamAccess (see + write) in workstreams.go.

Tests

  • TestOrgEventsAreRelayedWithTheConnection, TestOrgEventsStopWhenTheConnectionIsDetached (cmd/codeaf, stub org server with a real SSE stream; -race -count=3 clean)
  • TestGoAheadReadOnOrgWorkstreamNeedsSight (internal/factory/serve, the org scene; red without the fix)
  • make pr-ready BASE=origin/work/teams: see comment below.

santoshkumarradha and others added 4 commits November 13, 2026 11:29
…are read only by those who see them

The engine follows an organization connection's event stream once it has
answered an organization method and relays team.changed, workstream.changed
and workstream.removed as factory.org_changed {connection, kind, id}. A gap
the server cannot replay is relayed as both list kinds with an empty id.

GET /v1/policy?group=<org workstream id> answers 404 to anyone who cannot
see that workstream, as the workstream's own route does.

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
@santoshkumarradha

Copy link
Copy Markdown
Member Author

make pr-ready BASE=origin/work/teams green on 564884f: light gate + laws, touched cmd/codeaf (8 shards), internal/appwire, internal/factory/serve; every selected test passed on its first run.

@santoshkumarradha
santoshkumarradha merged commit 384f15b into work/teams Nov 13, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the teams/g4-events-policy branch November 13, 2026 16:42
ZeroPoint95 pushed a commit that referenced this pull request Nov 24, 2026
…ht of the workstream (#2625)

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