Repository navigation
feat(compat): the workspace half of boot and onboarding: S08, S09, S12 to S16, S18 - #82
Merged
Merged
Conversation
…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]>
This was referenced Nov 15, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
GET /api/users/me/settings/GET /api/users/me/workspaces/role,total_members)GET /api/users/me/workspaces/invitations/[]: a stub (D-021) until invitations existGET /api/workspace-slug-check/{"status": true}when the slug is free; case sensitive, a reserved slug is never freePOST /api/workspaces/{"error"}, the serializer's{field: [message]})GET /api/workspaces/{slug}/workspace-members/me/GET /api/users/me/workspaces/{slug}/project-roles/{project id: role number}GET /api/workspaces/{slug}/members/S01, S08, S09 and S13 are recorded again after the first workspace exists.
How it works
workspacesa name, owner, size, time zone and colour, andworkspace_membersan 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, rolemember, active.WorkspaceScopeis the proof for workspace-level reads, minted only byauthorize_workspace, andscripts/check-deps.shenforces that exactly as it does forScopeandSystemScope. 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_workspacewrites 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).membershipnow requires an active workspace member, so deactivating someone takes the workspace's projects away too.tools/compat-record/gen-reserved-slugs.py), not copied from anywhere.0is missing and5is given.Deviations (for your decision)
workspace_seedtask (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.shrunsdc 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.GET /api/instances/reportsworkspaces_existfrom the live database. The pin answers from a two-hour cache, so after the first workspace is made it keeps sayingfalse; a stalefalsewould 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, soS01-aftershows the live answer.A bug an existing test caught
migration_0003_backfills_a_database_created_before_itfailed on my first run. Migration 0003's backfill,INSERT INTO workspaces (id, slug) ... ON CONFLICT DO NOTHING, runs on every start (migrateapplies every file every time). Once 0009 makesnameNOT 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
membership,workspace_access,workspaces_ofignoringis_active(three separate breakages)total_memberscounting inactive members; the listing oldest first; a case-insensitive slug checkinsert_workspacewithout its transaction (the member insert fails, the workspace stays)slug takenproject_roleswithout the join on the project's workspacepg_adaptertestWorkspaceScope::mintin a compat source filecheck-deps.shfails withFORBIDDEN: a proof minted outside its ownerEvery 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):
workspaces.rsworkspace.rserror.rs,instance.rs,lib.rslib.rsworkspace use-casesNot mutated: the Postgres adapter, which the generated model and
pg_adapter.rscover.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.rsstates 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-memoryandnative-pg: 49 of 49 (EXPECT_MAIN47 to 49). The Worker targets are for CI.binary(pg_adapter)), up from 16.scripts/check-deps.shclean;cargo check -p thrust-worker --target wasm32-unknown-unknownbuilds.mod.proptest-regressionschanges: three seeds from my deliberately broken builds had been appended, and they only fail against a broken adapter. Restored tomain'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