Skip to content

Workspaces phase 3j: what the review of phase 3 found (#277) - #342

Merged
antiv merged 1 commit into
mainfrom
workspaces-phase-3j
Nov 13, 2026
Merged

antiv merged 1 commit into
mainfrom
workspaces-phase-3j

Conversation

@antiv

@antiv antiv commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Phase 3j of #277 (documents/design/2.0-plan.md): a review of 3a–3i, run as in phase 2, and the fixes it calls for. The review used code-review at high over 027eb9f..04ef613, and I checked each finding by hand.

It found no cross-workspace path. 3i had already found one (/list-apps listing the default workspace's agents to someone who isn't a member) and fixed it.

Fixed

# Finding Fix Test
1 After 3e, removing admin on the Users page left the user owner of Default, so they kept its dashboard. In 1.x that took the dashboard away. The User listener makes an owner of Default a member when admin goes. Ownership of other workspaces stays. test_losing_the_admin_role_takes_the_default_workspace_s_ownership
2 Agent roles written to users.roles for a user who belongs only to another workspace were stripped and lost. The UPDATE matched no row of Default. The user joins Default as a member with those roles, which is what 1.x callers mean. test_agent_roles_written_for_a_member_of_another_workspace_are_kept
3 Two owners stepping down at once could both pass the last-owner check. The check first locks the workspace's row (with_for_update). none: SQLite has no row locks
4 An RBAC refusal named users.roles, which now holds platform roles only, in its message and audit entry. RBACMiddleware.roles_for returns the platform roles plus the agent roles in the agent's workspace. Both the ADK callback and the LangGraph hook use it. test_a_refusal_names_the_agent_roles_of_the_agent_s_workspace
5 The Users page accepted widget, and refused to save the profile of a system caller, whose roles are agent roles. It adds only admin or pending, and roles the user already has may stay. test_the_users_page_adds_admin_or_pending_only
6 A workspace budget with token limits scanned its logs three times on every check. One query with conditional sums (get_workspace_tokens_windows). test_a_workspace_s_token_windows
7 /dashboard/api/usage/logs, open to members since 3h, had no bounds. limit=0 divided by zero. limit 1–1000, page ≥ 1, hours 1–8784. test_the_usage_logs_page_size_is_bounded
8 Duplicate _session and _utc_now in platform_workspace_routes.py. Imported from member_routes and invitation_routes. existing tests
9 api_roles raised when there was no database session. It fails closed, returning the platform roles only. test_api_roles_without_a_database_session

Each of these tests fails when its fix is reverted (mutation check, 8 mutations).

Not taken

  • Return type hints on the new route handlers. The existing handlers don't have them either, so I kept to the file's style.
  • Folding the five "session, call, close" wrappers into one helper. Only the one that could raise (api_roles) is fixed.

Behaviour changes worth noting

  • Removing admin makes the user a member of Default, even if an owner had set them as owner on Members. A platform administrator restores the ownership on Members.
  • RBAC refusal messages and audit entries now list the agent roles of the agent's workspace, so the user_roles field changes value.

Tests and docs

  • 1971 tests pass, 1 skipped. test_client_contract is unchanged.
  • I updated users-and-roles.md (what removing admin does) and database-and-migrations.md (the listener's two new cases).
  • gen_docs drift lists other guides for the touched files. They describe nothing these fixes change: the pat_auth guides, agent-runtime, langgraph-runtime, agents, rate-limits, usage-and-audit, alerts, template-format and workspaces.

A review of 3a-3i (027eb9f..04ef613), each finding checked by hand, found no
cross-workspace path. Fixed here:

- Losing the admin role makes an owner of the default workspace a member, as
  1.x took the dashboard away; owners of other workspaces stay owners.
- Agent roles written to users.roles for a member of another workspace only
  join the default workspace instead of being lost.
- The last-owner check locks the workspace's row, so two owners stepping down
  at once can't leave none.
- An RBAC refusal names the agent roles of the agent's workspace, not
  users.roles (ADK callback and LangGraph hook).
- The Users page adds admin or pending only and keeps what a user already has,
  so a widget visitor or a system caller can still be saved.
- A workspace budget reads its hour, day and month tokens in one query.
- /dashboard/api/usage/logs bounds limit, page and hours.
- One _session helper and one clock for the new routers.
- api_roles fails closed without a database session.
@antiv
antiv merged commit 3550873 into main Nov 13, 2026
2 checks passed
@antiv
antiv deleted the workspaces-phase-3j branch November 13, 2026 08:37
This was referenced Nov 13, 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