Skip to content

factory: a workstream's parts live on the organization server (SQLite, per-page revs, versions) - #2639

Merged
santoshkumarradha merged 9 commits into
work/teamsfrom
w2/e2-parts
Nov 13, 2026
Merged

santoshkumarradha merged 9 commits into
work/teamsfrom
w2/e2-parts

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

Wave-2 lane E2 — workstream parts on the server (WAVE2.md §3 "E2", as amended by §4.4: page bodies are E7's Yjs docs, so no per-page body PATCH or drafts here).

What changes

  • Storage → SQLite. factory-workstreams.db replaces the one JSON document: one row per workstream, one per page version, plus parts (plan/wakes/suggestions) and posted spend. A save writes only the rows it changed, in one transaction, under the same cross-process lock. The old factory-workstreams.json is migrated once on first use and renamed .json.migrated. Store.Workstreams/Workstream/EditWorkstreams keep their signatures (E1's FoldShares runs on every read).
  • Pages one at a time with a per-page rev: create / rename / re-kind / move (index, parent) / delete (children move up; versions dropped; E7's dropDoc called when present). Two people changing two different pages both succeed; the same page from a stale read is 412.
  • Page versions + restore. Clients post versions (idle / manual; the server never parses Yjs); restore is a new version by the restorer, answered with the words + state to apply to the live doc. A version refreshes the page's body_md mirror without moving any rev.
  • Plan, wakes, suggestions on the server with their own revs and server-stamped authors.
  • Jobs membership (PUT|DELETE /jobs/{job}), one workstream per job; E5's jobWorkstreamID now reads membership first (fail-closed if the store cannot answer).
  • Unarchive works. Budget on the workstream, spend posted by the caller (Idempotency-Key), summed without moving the rev.
  • Decisions are never deleted: one a PATCH leaves out is kept as superseded.
  • Events carry part, part_id, by, rev, deleted, relayed in factory.org_changed.
  • Engine: hello org_workstream_parts and one factory.org_workstream_<part> method per route (spend's method is W8's, by agreement).

Seams with other lanes

Proof

  • make pr-ready BASE=origin/work/teams: build, vet, laws, manual, packed corpora green; touched appwire, factory, factory/api, factory/serve, factory/store green. Two serve tests failed once under box load and passed on retry (classifier: flaky) — TestPeopleCardAndQueueUseFakeForgeAndVisibleJobs (a timed CODEOWNERS fetch) and TestFactorySetupDoubleContinueEndsReadingOnce; both pass 20/20 on this branch and on base. The cmd/codeaf leg: see comment below.
  • Two signed-in people (santosh, abir, mia; Platform/Growth/Design) on the real serve.Handler: different pages concurrently both 200, same page 412; versions name by, restore by mia is version 3 restored_from:1; plan/wake revs; a job added by santosh shows in abir's workstream and leaves the other one; membership hides a job in santosh's private workstream from abir; view share = read-only; unarchive; budget; spend once per key; supersede.
  • Real binary: bin/codeaf factory serve on a root holding the old JSON → migrated (rev 5 kept, file renamed aside), then every route driven with curl.
  • Not proven with two real GitHub sign-ins against a running server (E0's harness is not merged).

WAVE2.md §4 is edited in place (outside the repo) — new section "E2 as built"; PROTOCOL.md carries the methods and event fields.

@santoshkumarradha
santoshkumarradha force-pushed the w2/e2-parts branch 2 times, most recently from 15cfaa0 to 0ff3596 Compare November 13, 2026 19:55
@santoshkumarradha

Copy link
Copy Markdown
Member Author

Gate on head 0ff3596 (rebased on #2637 E1 part 2, #2636 E7, #2635 E3a, #2634 E5):

  • make pr-ready BASE=origin/work/teams: light gate green; touched appwire, factory, factory/api, factory/serve, factory/store green (two setup-read timing tests failed once under box load and re-ran green, classified flaky).
  • The cmd/codeaf leg was refused by the per-box suite lock on all three pr-ready runs (other lanes' suites). Ran it through make test-focus PKGS=./cmd/codeaf RUN=. instead: 4 reds, none mine —
    • TestAppFactoryJobActionsTwoPeopleAgainstTheRealServer ("only @alice can do this") and TestAppFactoryIssueCommentOutcomesGuardAndRepoOff (hangs to the timeout) fail identically on base work/teams 58cb333 — E5's job gate (factory: a job in a workstream answers to that workstream (E5) #2634), as E3a also reported.
    • TestAppTakeC1bSavedModelTravelsBack and TestAppCreateGivesEachCellConversationItsFolderName pass when run alone on this branch (load flakes).
  • New since the PR opened: activity records for every part change (E3a's recordWorkstream), page delete drops its live doc (E7's dropDoc), decisions keep E1's stampDecisions on top of supersede-not-delete, unarchive needs full like archive.

santoshkumarradha and others added 9 commits November 13, 2026 15:37
…the JSON once

factory-workstreams.db keeps one row per workstream, one per page version,
the plan/wakes/suggestions parts and posted spend. The old JSON document is
copied in on first use and renamed aside. Pages carry a rev; workstreams
carry jobs and a budget.

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
…on server

Pages are added, renamed, moved and deleted one at a time under their own
rev; versions are saved by clients and restored as a new version by the
restorer; the plan, wakes and suggestions keep their own revs and the
server's authors; jobs are membership on the server, one workstream each;
unarchive works; a budget is set and spend posted by the caller; a dropped
decision stays as superseded. Every change says its part, id, author and rev.

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
…e organization

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
…on who made it

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
…es full, as archive does

Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
@santoshkumarradha
santoshkumarradha merged commit 1ad9f3b into work/teams Nov 13, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the w2/e2-parts branch November 13, 2026 20:39
ZeroPoint95 pushed a commit that referenced this pull request Nov 24, 2026
…e, per-page revs, versions (E2) (#2639)

Storage moves to factory-workstreams.db (migrated from the JSON once). Pages one at a time under their own rev, client-saved versions and restore, plan/wakes/suggestions, job membership (now deciding who reaches a job), unarchive, budget and spend, supersede-not-delete, part-level events and activity, and a factory.org_workstream_<part> engine method per route.

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