* feat: introduce User-backed workspace identities Replaces workspace core.Agent subjects with identities stored as Django Users, so permissions, execution and attribution use the same record. - User.objects and WorkspaceUser.objects are human-only; permission and identity code opts in through objects_and_identities. is_human and is_identity classify a user at runtime. - Login, tokens, seats, notification recipients, personal views and last-admin checks stay human-only. Roles, teams and field grants work for identities unchanged. - Agent applications run as an identity, never as a person. Every shared tool rechecks the identity's authority on each call, and MCP refuses a tool that skips that boundary. - Migrations add the profile metadata and index, remove the Agent model and delete or clear legacy Agent data: trash entries, role assignments, team memberships, integration authorizations and run-as bindings. - Rename the management API, UI, events and feature flag to identity. Squashed and rebased onto develop; the previous history is kept on backup/6556-before-develop-rebase. * refactor: remove generic subject options endpoint * refactor: simplify identity selection and Agent run-as options * feat: distinguish identity notification senders * fix: restrict identity bindings to identity managers * docs: record users and identities verification * fix: restore snapshots as the person restoring A restore checked the snapshot creator's permission and used the creator to decide whether an Agent keeps its identity binding. It now checks the person restoring, passed to the import as `restored_by`. `copied_by` stays unset on restore, so credential checks keyed on it behave as on develop. Restoring a snapshot whose creator was deleted works again. The copy rule for identity bindings covers Agent run-as only; a copied Local Baserow integration keeps its authorized subject. * fix: leave settings pages the user may not open A settings route without a permitted tab rendered an empty page, as the Identities page did with its feature flag off. It now opens the first page the user may see. * fix: renumber the legacy Agent cleanup migrations Develop added agent 0016 and integrations 0043, so the migrations that clear legacy Agent run-as bindings and integration authorizations move to agent 0017 and integrations 0044. * test(agent): run the trigger self-event test as an identity The test added on develop created a `core.Agent`, which this branch removes. It now uses an identity user as the Agent's run-as subject. * perf: load user types once per batched permission check * refactor: state the stored subjects in each subject type * fix: give every user a profile * fix: keep identity attribution on rows copied in their workspace * refactor: give people and identities their own subject type UserSubjectType stays the type both are registered and stored under. It forwards what differs to HumanSubjectType and IdentitySubjectType, so get_specific_type is the only place in subject code that inspects the user type. The registry returns the specific type on request and get_by_model keeps returning the stored type, which never reads the profile. An identity's membership is checked in one query instead of two. * fix: keep the roles of identities when a database is duplicated The role import read subjects through the model's default manager, which only returns people, so duplicating or restoring a database failed when an identity held a role on it. It now resolves the subject through the subject registry. A subject that no longer exists is skipped instead of failing the whole duplicate or restore. * refactor: look up a subject type from its content type in one place * fix: reload a cached token whose profile is incomplete A token cached by the previous release has a profile without the user type, which reads as not a person, so its requests were refused until the entry expired. The token cache now treats it as a miss, with the check the user cache already used. * refactor: check the user type once where the check was repeated The MCP endpoint loader, the personal view permission manager and the identity trash type each asked the same question several times. The rule that an identity is never selected by email moves from the team handler to the identity subject type. * refactor: leave trashed workspaces out of the identity membership manager WorkspaceUser.objects_and_identities was named after objects but also returned memberships of trashed workspaces, so callers filtered them by hand. It now follows the existing pair: it leaves trashed workspaces out, and objects_and_identities_and_trash includes them, as objects_and_trash does for people. * test: state the behaviour of every user type The table fails when a user type is added and says what has to be decided first. An unknown type is checked to be denied. * refactor: refuse to say whether a stored user subject is interactive The answer differs between a person and an identity, so reading it from the stored type would be wrong for one of them. It now raises and points to the specific type. * refactor: lock the person in membership writes instead of checking the type Leaving a workspace, removing a member and adding a user lock the user through the people manager, which refuses an identity or an unknown type in the same query. Nothing adds an identity through add_user_to_workspace, so its branch for identities goes. The last admin check compares the membership with the people who are admin, which needs no type check. * test: leave no rows behind in the legacy authorization migration test The test left an integration that pointed at a user that didn't exist and a workspace, in the database the migration tests share. Tests that ran after it then failed on the foreign key or on the workspace id. It now uses a real user and empties the two tables. * docs: describe the subject types and compare the Subject table alternative ADR 013 is shorter and states that people and identities each have a specific subject type under the stored auth.User type. It compares shared User storage with a Subject table that users and identities would both point to. * chore: run the legacy run-as cleanup after the agent actions migration Develop added agent migration 0017, so the cleanup becomes 0018 and depends on it. * test: leave no rows behind in the legacy agent migration tests Like the legacy authorization test, these left a workspace in the database the migration tests share, which a later test that creates workspaces with fixed ids collides with. * fix: write and read the workspace role of an identity in one place The role assignment API wrote the role of an identity through the membership update of people, which told every member of the workspace about it and stored Builder as MEMBER, while the identities API stored BUILDER and returned the stored value. Both now write through the identity handler, which stores the role like the role of a person, and the role is read with the resolver the workspace members use. * fix: take no row lock in the membership writes of a person Leaving a workspace locked the user before the membership while removing or updating a member locks the membership first, so the two could deadlock. The user type never changes and these operations refuse an identity, so the lock protected nothing: they now only check that the user is a person. Leaving no longer locks the admin memberships and removing a member no longer checks for the last admin, as before identities. * fix: find an identity by its name only in the subject options The search also matched the email and username, which for an identity hold an internal key, so searching a part of that key returned every identity. * chore: run the identity migrations after the new ones on develop Develop added core 0138, integrations 0044 and enterprise 0073, so the identity migrations become core 0139 and 0140, integrations 0045 and enterprise 0074 and depend on them. * fix: keep the identity of a copied integration only for identity managers A duplicated application or a restored snapshot kept the identity its Local Baserow integration acts as, without checking the person who made the copy. Restoring a snapshot could so bring back a binding an admin had removed. The copy now keeps the identity only when that person may bind identities, as the Agent application already did, and is otherwise authorized as that person. * docs: follow the renumbered migrations and the copy rule in the test plan The test plan named the identity migrations and their tests by their old numbers and still said a copied integration keeps its subject. * test(agent): run the row trigger tests as an identity The row trigger tests added on develop created a `core.Agent`, which this branch removes. They now use an identity user as the Agent's run-as subject, and the e2e fixture creates it through the identities endpoint.
7.2 KiB
Code quality
The quality of the code is very important. That is why we have linters, unit tests, API docs, in-code docs, developer docs, modular code, and have put a lot of thought into the underlying architecture of both the backend and the web-frontend.
Running linters and tests
If you have the development environment up and running you can easily run the linters using just commands.
Backend (from project root or backend/ directory):
just b fix: run Ruff checks with automatic fixes and format Python code. Aliases:just b format,just b f.just b lint: check Python code with Ruff. Alias:just b check,just b l.
Frontend (from project root or web-frontend/ directory):
just f lint: check the frontend trees with ESLint (JS/TS/Vue), Stylelint (SCSS), and Prettier (also CSS/JSON/Markdown/HTML/YAML).just f fix: auto-fix issues with the same tools.
All of the above accept an optional list of file paths and restrict the run to just those files:
just b fix backend/src/baserow/core/utils.py
just f fix web-frontend/modules/core/jobTypes.js
A few things to know when passing paths:
-
Paths must be repo-root-relative (for example
backend/src/baserow/..., notsrc/baserow/...), even when you invoke the recipe from insidebackend/orweb-frontend/. This keeps the behavior identical regardless of where you run it from and matches whatpre-commitpasses in. -
Paths outside the linted trees (
backend/{src,tests},{premium,enterprise}/backend/{src,tests},web-frontend/,{premium,enterprise}/web-frontend/) are silently skipped, as are files with extensions the tools don't handle. This lets you pipe in a mixed file list without filtering it yourself. -
With no arguments each recipe lints its full component tree (
just bwalks all backend trees,just fwalks all frontend trees; running both covers the monorepo). This matters when you scope to a diff with$(...)— if the diff is empty, the expansion produces no arguments and you'll accidentally trigger a full-tree run. Guard the call when scripting:# Scope to your branch's changes, skipping the run if nothing changed: files=$(git diff --name-only origin/develop...HEAD) if [ -n "$files" ]; then just b fix $files just f fix $files fi
Running tests
There are also commands to easily run the tests.
just b test(backend): run all backend Python tests with pytest.just b test -n=auto(backend): run tests in parallel for faster execution.just f test(frontend): run all frontend tests with Vitest.
Concurrent database indexes
Use RetryableAddIndexConcurrently from baserow.core.migration_utils when adding
an index to an existing PostgreSQL table. It accepts the same model_name and
models.Index arguments as Django's AddIndexConcurrently and updates migration
state directly; SeparateDatabaseAndState is not needed. Set atomic = False on
the migration and keep transactional schema changes in a separate migration.
An interrupted concurrent build can leave an invalid index. On rerunning
migrate, this operation drops that index concurrently and rebuilds it. It keeps
a valid, ready index and tolerates an already removed index during rollback.
Recovery resolves the index in its table's schema and refuses a same-name relation
belonging to another table. Keep index names and definitions immutable and run only
one migration process at a time. Errors propagate; this does not retry builds in a
loop. sqlmigrate shows ordinary concurrent DDL, without the runtime recovery.
Git pre-commit hooks
Baserow uses pre-commit to automatically run linters and
formatters before commits are created. This ensures your changes comply with repo-wide
code quality rules without waiting for CI feedback.
The lint/format hooks delegate to the same just b fix and just f fix recipes used
by CI and manual runs, so pre-commit will never produce changes that differ from
running just fix yourself.
Installation
To set up the pre-commit hooks locally in your .git/ folder, run the following command from the repository root:
just pre-commit-install
This registers a few general hygiene hooks (YAML syntax checks, merge-conflict
markers, large files) plus the backend and frontend lint/format hooks. Trailing
whitespace and end-of-file fixes are intentionally left to ruff/prettier to
avoid touching legacy files.
To remove the hooks again:
just pre-commit-uninstall
Running manually
You can also run pre-commit manually at any time against all files or staged changes:
# Run against all files
just b run pre-commit run --all-files
# Run against specific files
just b run pre-commit run --files path/to/file1.py path/to/file2.js
Tip: lint everything you've touched on this branch
A normal git commit runs the hooks on staged files only, and pre-commit run
with no arguments does the same. To lint every file you have changed relative to
HEAD (staged and unstaged), pass the diff explicitly:
just b run pre-commit run --files $(git diff --name-only HEAD)
This is handy before opening a pull request: it scopes the run to your
work-in-progress without re-linting the entire monorepo the way
--all-files does. Swap HEAD for a base ref (for example origin/develop) to
lint everything your branch changes:
just b run pre-commit run --files $(git diff --name-only origin/develop...HEAD)
If you only want to run the Ruff or ESLint/Stylelint/Prettier steps (and skip the
ancillary pre-commit hooks like check-yaml), call the just recipes directly
with the same file list — they accept a list of paths and route each file to the
appropriate tool. Remember to guard against an empty diff, otherwise an empty
expansion will lint the whole monorepo:
files=$(git diff --name-only origin/develop...HEAD)
if [ -n "$files" ]; then
just b fix $files
just f fix $files
fi
See the pre-commit documentation for more advanced usage (skipping hooks for a commit, running a single hook, updating hook versions, etc.).
Continuous integration
To make sure nothing was missed during development we also have a continuous integration pipeline that runs every time a branch is pushed. All the commands explained above will execute in an isolated environment. In order to improve speed they are separated by lint and test stages. It is not allowed to merge a branch if one of these jobs fails.
The pipeline also has a build job. During this job plugin boilerplate Baserow will be installed as a dependency to ensure that this still works.
Running CI locally
You can run the same checks locally before pushing:
# Run all linters
just lint
# Run all tests
just test
# Or run backend/frontend separately
just b lint && just b test
just f lint && just f test
For Docker-based CI testing (matches the CI environment more closely):
just ci build # Build CI images
just ci lint # Run linters in containers
just ci test # Run tests in containers
just ci run # Full CI pipeline