Skip to content

feat(compat): the workspace half of boot and onboarding: S08, S09, S12 to S16, S18 - #82

Merged
aRustyDev merged 1 commit into
mainfrom
feat/compat-workspace-stage
Oct 25, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
feat/compat-workspace-stage

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

What

Stage 3 of #44, second half: the workspace half of boot and onboarding. A person makes a workspace and becomes its admin; the app lists their workspaces, asks whether a slug is free, opens a workspace by slug, and reads its member list, their own membership and their project roles.

Row Route Answer
S08 GET /api/users/me/settings/ the workspace the app opens: the last one used if the caller is still an active member of it, else the earliest-made of theirs
S09 GET /api/users/me/workspaces/ the caller's active workspaces, newest first, 17 keys each (role, total_members)
S12 GET /api/users/me/workspaces/invitations/ []: a stub (D-021) until invitations exist
S13 GET /api/workspace-slug-check/ {"status": true} when the slug is free; case sensitive, a reserved slug is never free
S14 POST /api/workspaces/ 201 and the workspace, or the pin's two kinds of refusal (the view's {"error"}, the serializer's {field: [message]})
S15 GET /api/workspaces/{slug}/workspace-members/me/ the caller's member row (with the pin's view-settings defaults), or the pin's blank 200 for a stranger
S16 GET /api/users/me/workspaces/{slug}/project-roles/ {project id: role number}
S18 GET /api/workspaces/{slug}/members/ everyone, deactivated members too; a guest sees no email or sign-in method

S01, S08, S09 and S13 are recorded again after the first workspace exists.

How it works

  • Migration 0009 gives workspaces a name, owner, size, time zone and colour, and workspace_members an id of its own, a role, an active flag, a company role and per-member view settings (a JSON object). Rows that exist already (a test's seed) get the slug as their name, role member, active.
  • WorkspaceScope is the proof for workspace-level reads, minted only by authorize_workspace, and scripts/check-deps.sh enforces that exactly as it does for Scope and SystemScope. A stranger and an unknown slug look the same to core (NotFound), so nobody can probe for workspaces; the compat layer then answers each route the way the pin does.
  • insert_workspace writes the workspace and its first member in one transaction. A taken slug is a unique-index violation, so two creations racing for one slug cannot both win (tested with sixteen real tasks).
  • membership now requires an active workspace member, so deactivating someone takes the workspace's projects away too.
  • The 62 reserved slugs are read from the running pin (tools/compat-record/gen-reserved-slugs.py), not copied from anywhere.
  • Validation follows the pin in its two stages and its order; Python's truthiness decides "both name and slug are required", so 0 is missing and 5 is given.

Deviations (for your decision)

  • D-024 (your decision, recorded): creating a workspace does not run Plane's workspace_seed task (a demo project with states, labels, work items, pages, cycles, modules and views, owned by a bot member). The oracle is recorded with its Celery workers stopped (fresh-oracle.sh runs dc stop worker beat-worker), so the fixtures show the workspace as Thrust makes it. The follow-up issue that ports the seed after M1 is not filed yet; I will confirm its text with you at M1's close, as planned.
  • D-025 (proposed, pending you): GET /api/instances/ reports workspaces_exist from the live database. The pin answers from a two-hour cache, so after the first workspace is made it keeps saying false; a stale false would send someone who has just made their first workspace back through setup. The recorder drops the cache key before the exchange after the first workspace, so S01-after shows the live answer.
  • D-022 and D-023 from the auth stage are still waiting for your confirmation.

A bug an existing test caught

migration_0003_backfills_a_database_created_before_it failed on my first run. Migration 0003's backfill, INSERT INTO workspaces (id, slug) ... ON CONFLICT DO NOTHING, runs on every start (migrate applies every file every time). Once 0009 makes name NOT NULL, Postgres checks that constraint on the proposed row before it looks for the conflict, so the statement fails for any database that already has a workspace and a project: the server would not have started on a deployed database. 0003's backfill now skips workspaces that exist (WHERE NOT EXISTS). Every other test starts from an empty database; this one did not, which is why it was the one that saw it.

Controls

Control Result
Postgres membership, workspace_access, workspaces_of ignoring is_active (three separate breakages) each fails the model on the call that checks it
total_members counting inactive members; the listing oldest first; a case-insensitive slug check fail the model
insert_workspace without its transaction (the member insert fails, the workspace stays) fails the model on slug taken
project_roles without the join on the project's workspace fails the model (the stray row)
the member list hiding inactive members; dropping the display name fail the model
0009 backfilling the wrong name; no role check; no props check; a non-unique membership id each fails the matching new pg_adapter test
the creation swallowing the unique-violation fails the sixteen-task race test
compat handlers: admin as 21; the two different 403 bodies changed each turns exactly one contract test red (48 of 49 pass)
a stray WorkspaceScope::mint in a compat source file check-deps.sh fails with FORBIDDEN: a proof minted outside its owner

Every breakage was one line, applied from a backup and restored byte for byte (checked with cmp). The model's generator-coverage control reaches all 97 classes, seven of them new.

Mutation testing (cargo-mutants 27.1.0, nextest 0.9.140):

Scope Result
compat workspaces.rs 66: first run 5 missed (the truthiness of a number; both length limits at their exact edge), now 31 caught, 35 unviable, 0 missed
core workspace.rs 43: 37 caught, 6 unviable
memory adapter workspace methods 30: 25 caught, 5 unviable
compat error.rs, instance.rs, lib.rs 24: 11 caught, 13 unviable
core lib.rs workspace use-cases 3: 2 caught, 1 unviable

Not mutated: the Postgres adapter, which the generated model and pg_adapter.rs cover.

Recording

Twelve fixtures: eight rows, and four of them again after the first workspace exists. Recordings on two independent fresh stacks are byte-identical, and the earlier fixtures did not change. The creation exchanges record a missing field, both length limits, a URL in the name, a name with no letter or number, a reserved slug, a slug with a space, an over-long size, an unknown zone, and a taken slug.

Gaps (G-18)

The journey has one admin and no project, so S18 is recorded with one member and S16 with {}. Read from the pin's source rather than recorded: a guest's member list (no email, no sign-in method), the role numbers of a member and a guest, the non-empty project-roles map, and a deactivated member's view. tests/workspaces.rs states each as a rule over generated or exhaustive inputs; a recording with a guest and a project would check them against the pin, and the project stage can add one. What the Postgres model cannot reach: the seeded workspaces' timestamps are the database's own, so it compares their lists as sets, and its fixture has one project per workspace, so the order of several members or several projects is checked against the memory adapter only (Postgres orders by the same keys).

Verified

  • cargo nextest run --profile ci --workspace: 1463 passed, 4 skipped. Doctests pass.
  • scripts/contract.sh native-memory and native-pg: 49 of 49 (EXPECT_MAIN 47 to 49). The Worker targets are for CI.
  • Postgres adapter and model: 19 passed (binary(pg_adapter)), up from 16.
  • scripts/check-deps.sh clean; cargo check -p thrust-worker --target wasm32-unknown-unknown builds.
  • I did not commit mod.proptest-regressions changes: three seeds from my deliberately broken builds had been appended, and they only fail against a broken adapter. Restored to main's version, as in the last stage.

Effort

Modelled for the rows (research/0003 §8.1): S08 0.15, S09 1.0, S12 0.15, S13 0.15, S14 0.9, S15 1.0, S16 0.15, S18 0.15, which is 3.65 pd (3.15 with the S14 reduction in the adjustments table). Most of this PR is the workspace tables, WorkspaceScope, the model extension and the recorder, which the model prices separately or not at all. I did not time the work, so there is no actual pd to report.

Refs: plane-byd.12.2

🤖 Generated with Claude Code

…2 to S16, S18

Stage 3b of #44. A person makes a workspace and becomes its admin; the app lists their workspaces, asks whether a slug is
free, opens a workspace by slug, and reads its member list, their own membership and their project roles. Answered from
real tables: migration 0009 gives a workspace a name, an owner, a size, a time zone and a colour, and a membership an id of
its own, a role, an active flag, a company role and per-member view settings.

Core gets WorkspaceScope (minted only by authorize_workspace, enforced by check-deps like Scope and SystemScope) and the
use-cases create_workspace, my_workspaces, slug_available, members, my_member and my_project_roles. The 62 reserved slugs
are generated from the running pin (tools/compat-record/gen-reserved-slugs.py). Ports and both adapters get
insert_workspace (the workspace and its first member together or not at all), workspace_slug_taken, any_workspace,
workspaces_of, workspace_access, set_workspace_member_active, workspace_member, workspace_members and project_roles.
membership now requires an ACTIVE workspace member.

Twelve fixtures (eight rows, and four of them again after the first workspace exists) are recorded from the pin with its
Celery workers stopped (D-024: the
workspace_seed task is not reproduced in M1; a follow-up issue ports it). S01, S08, S09 and S13 are recorded again after the
first workspace exists; the pin caches /api/instances/ for two hours, so the recorder drops that cache key first, and
Thrust reports workspaces_exist live (D-025, pending owner). S12 is a stub (D-021). Recordings on two fresh stacks are
byte-identical and the earlier fixtures did not change.

Bug found by an existing test: 0003's backfill names no `name`, and 0009 makes `name` NOT NULL; Postgres checks NOT NULL
before ON CONFLICT, so every start of a database that already had a project would have failed. The "applied twice" test
caught it; 0003's backfill now skips workspaces that exist.

Controls shown red: ten one-line breakages of the Postgres adapter (membership, access and listing ignoring is_active,
the member count including inactive members, the listing oldest first, a case-insensitive slug check, a creation that is
not atomic, project roles ignoring the project's workspace, the member list hiding inactive members or dropping the display
name) each fail the model on the call that checks them; five breakages of 0009 and the creation fail the three new
pg_adapter tests (schema and constraints, the upgrade path of a database that has data, sixteen creations racing for one
slug); three broken compat handlers each turn exactly one contract test red; a stray WorkspaceScope::mint fails check-deps.
Memory adapter tests (exhaustive over member state and clash, orderings, a property for project roles) and compat tests
(guest view, role numbers, project roles, deactivation, Python truthiness, the 80 and 48 character limits) state the rules
the journey's recording cannot show; G-18 lists what is read from the pin's source rather than recorded.

cargo-mutants 27.1.0: compat workspaces.rs 66 tested, first run 5 missed (the truthiness of a number, both length limits),
now 31 caught, 35 unviable, 0 missed; core workspace.rs 43 (37 caught, 6 unviable); memory adapter workspace methods 30
(25 caught, 5 unviable); compat error.rs, instance.rs and lib.rs 24 (11 caught, 13 unviable); core lib.rs workspace
use-cases 3 (2 caught, 1 unviable). Not mutated: the Postgres adapter (generated model and pg_adapter.rs).

EXPECT_MAIN 47 -> 49; native-memory and native-pg 49/49; workspace nextest 1463 passed; doctests pass; Postgres adapter
tests 19 passed; worker builds for wasm32; check-deps clean. proptest-regressions seeds written by the deliberately broken
builds are not committed.

Refs: plane-byd.12.2
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 7e4e858 into main Oct 25, 2026
28 checks passed
@aRustyDev
aRustyDev deleted the feat/compat-workspace-stage branch October 25, 2026 14:31
This was referenced Nov 15, 2026
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