Skip to content

factory: who is in an organization item, and who changed it (E3a) - #2635

Merged
santoshkumarradha merged 3 commits into
work/teamsfrom
w2/e3a-presence
Nov 13, 2026
Merged

santoshkumarradha merged 3 commits into
work/teamsfrom
w2/e3a-presence

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Wave-2 lane E3a — presence and actor, per ~/work/teams-wave/WAVE2.md §3 E3a as amended by §4 (no page hand: character-level co-editing in E7 replaces it; carets come from Yjs awareness).

What changes

Presence — POST /v1/presence {"item":{"kind","id"},"part"?,"editing"?,"left"?,"client"?}

  • A heartbeat every 10 s, TTL 30 s (api.PresenceBeat / api.PresenceTTL), answered with {"item","here":[{handle,part,editing}]}.
  • Kept in memory, never written as state. Only a change to who is here is published (arrive, part change, editing flip, left, silence via a timer like machine_events.go), as event presence, so unchanged beats cost the stream nothing.
  • Filtered per viewer by view (through orgWorkstreamAccess, so E1's private rule applies). A beat on an item you cannot view is 404; unknown kind 422.
  • Item kinds are a registry (h.presenceKinds); E4 registers canvas.

Actor

  • by on team.changed, workstream.changed and workstream.removed, stamped from the sign-in.
  • Hole 8: teams, workstreams, go-ahead policy, rules, routes, spending and settings write to the factory record (new kinds team_changed, workstream_changed, policy_changed, rules_changed, routes_changed, spending_changed, settings_changed; verbs fixed in record.OrgVerbs; detail names fields, never content). h.recordWorkstream is the door E2's part routes call.
  • A workstream's records are seen only by people who can see the workstream, in /v1/audit, /v1/activity and the live activity event.
  • GET /v1/workstreams/{id}/activity?since=&limit=: oldest first, at most 500, with people.

Engine

  • Methods factory.org_presence and factory.org_workstream_activity.
  • Event factory.org_presence {connection,item,here}; factory.org_changed gains by.
  • Hello: org_presence.
  • PROTOCOL.md updated.

Wire changes are also written into ~/work/teams-wave/WAVE2.md §4 ("E3a as built"). That file is outside the repo and was edited in place.

Proof

Two real sessions against one real bin/codeaf factory serve (team mode). The seeded sessions.json held owner, santosh and abir, with teams as in orgScene. Only the GitHub sign-in was skipped, because it is hardwired to github.com.

  • abir opens the page santosh is editing:
    {"here":[{"handle":"abir","part":"pg_retry"},{"handle":"santosh","part":"pg_retry","editing":true}]}
  • Activity as abir, in order: abir created workstream → santosh changed workstream (purpose) → abir changed go-aheads.
  • abir's live /v1/events:
    • workstream.changed … "by":"abir"
    • two presence frames
    • workstream.changed … "by":"santosh"
    • team.changed … "by":"owner"
  • Silence: santosh stopped beating while abir kept beating every 10 s. After 30 s the real timer published here:[abir]. abir's four unchanged beats published nothing (3 presence events in total).

Tests:

  • serve: TestPresenceSaysWhoIsEditingWhichPage, TestPresenceIsSeenOnlyByThoseWhoMayView, TestPresenceFoldsOnePersonsWindows, TestWorkstreamActivityNamesEveryoneInOrder, TestWorkstreamActivityIsPrivateToThoseWhoSee, TestOrgEventsCarryWhoAndTeamsAreRecorded.
  • engine: TestOrgPresenceAndActivityForwardToTheServer, TestOrgPresenceAndByAreRelayed.

Gate: make pr-ready BASE=origin/work/teams on head fbd9cfb9a.

  • Light gate passed (build, vet, fmt, laws, manual, change entries).
  • Touched packages appwire, factory/api, factory/record and factory/serve passed. Every new test passed on its first run.
  • The gate is still red, and no failure in it is from this change. Each one was checked against origin/work/teams @ da27602af:
    • cmd/codeaf: TestAppFactoryJobActionsTwoPeopleAgainstTheRealServer, TestAppFactoryIssueCommentAgainstTheRealServer and TestAppFactoryRejectPlanAgainstTheRealServer fail on the base with "only @alice can do this". That refusal is E5's (factory: a job in a workstream answers to that workstream (E5) #2634) job-owner check.
    • factory/serve: TestFactorySetupContinue* and TestFactorySetupDouble* fail on the base under load, and pass on this head when run alone. The classifier marked one of them "introduced"; that is wrong, because it failed at base when run back to back.
    • cmd/codeaf shard 7 hit its 15 m timeout on a box shared with several lanes. Its other failures (HostedTakeBack, PlanFilesAnswer, FinishSharesOneDeadline, TakeET1ET2, TakeF1P2, StartBadRepositoryFile) pass on this head when rerun.

Commits use the lane rules' CodeAF trailers.

santoshkumarradha and others added 3 commits November 13, 2026 13:51
POST /v1/presence is a heartbeat (10 s, 30 s TTL) kept in memory; only a
change to who is on an item is published as `presence`, filtered by view.
Every org event carries `by`. Teams, workstreams, go-ahead policy, rules,
routes, spending and settings are written to the record with the
server-resolved actor, and GET /v1/workstreams/{id}/activity lists a
workstream's changes. The engine relays presence as factory.org_presence
and serves factory.org_presence and factory.org_workstream_activity.

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
@santoshkumarradha
santoshkumarradha merged commit 2f20d33 into work/teams Nov 13, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the w2/e3a-presence branch November 13, 2026 19:24
ZeroPoint95 pushed a commit that referenced this pull request Nov 24, 2026
)

Presence heartbeat and events filtered by view, by on every org event, org changes in the record, workstream activity, engine relay and methods.

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