refactor(users): drop the core's guests' New project policy — the new-project plugin's settings only #24

Closed
gabrielvidal wants to merge 0 commits from new-project-policy-plugin-only into main
pull from: new-project-policy-plugin-only
Owner

Summary

The core kept its own copy of the guests' New project policy (guestDefaults.newProjects: quota, templates, approve, visibility, visibilityDefault, level, domain), duplicating the new-project plugin's settings, which hold the same 7 keys and are what users/runs.new_project_access already reads. This PR removes the core copy. The plugin's settings become the only place the policy lives.

The one value the core still used was domain. users/domains.default_domain reads it for ship hosts, Matomo, users.read's address, and the Users page's domain hint. It now reads the plugin's Shared domain setting.

Key changes

  • backend/users/store.py: removed DEFAULT_NEW_PROJECTS, NEW_PROJECT_VISIBILITY, clean_new_projects and _TEMPLATE_NAME_RE. newProjects is gone from defaults() / set_defaults() and from a fresh users.json. Added UsersStore.legacy_new_projects(), which reads the stored guestDefaults.newProjects as is.
  • backend/users/domains.py: default_domain now checks, in order:
    1. the owner's new-project config domain (whether the plugin is enabled or not);
    2. the legacy guestDefaults.newProjects.domain;
    3. gabvdl.xyz.
      Each value is validated as a domain.
  • backend/plugins/carryover.py: new_project takes the policy from legacy_new_projects() instead of defaults().
  • backend/schemas/users.py: removed NewProjectPolicy. GuestDefaults gains a read-only domain.
  • backend/users/routes.py: removed GuestDefaultsBody.newProjects. GET/PUT /api/guest-defaults add domain from default_domain.
  • Frontend: User.tsx reads guestDefaults.domain. In the mock, guestDefaults.newProjects is gone and mockNewProjectMode uses a plugin-default quota constant. openapi.json was re-dumped and src/generated/ regenerated.
  • CLAUDE.md: new paragraph in the New project section. Tests added in test_plugin_new_project.py.

Key decisions

  • Root domain: it now comes from the plugin's own domain setting. The audit's alternative was a new guestDefaults.domain field, but that would recreate the duplicate this PR removes. Reading the plugin's setting means one value drives both the plugin's form and the core's addresses. Before this PR the two could disagree.
  • Plugin coverage: checked against ai-agent-plugins/plugins/new-project/plugin.json. Its settings.fields cover all 7 keys, with the same defaults. Nothing was kept in the core for lack of a plugin equivalent.
  • Existing data needs no manual step:
    • The carry-over (2026-11-25) has already copied the whole cleaned policy, domain included, into the plugin config on any hub where the plugin was installed. default_domain returns the same value as before.
    • A hub where the plugin isn't installed yet still gets the legacy domain. The carry-over still reads the stored policy when the plugin arrives.
    • The stored guestDefaults.newProjects key is left in users.json, unused except as that fallback.
    • No new carry-over was needed: the plugin lacks no value the core held.

Changelog

  • The guests' New project policy now lives only in the New project plugin's settings, and the guests' shared domain is that plugin's Shared domain.

Test notes

  • Backend: every test_*.py module was run under bwrap with a throwaway /data, one process per module, on the branch and on main (ad150f1f).
    • Branch: 160 pass, 1 fails: test_typed_plugins, which also fails on main.
    • test_mcp failed once on main only, so it looks flaky.
    • New: GuestsRootDomain checks the order (plugin setting, then legacy, then default) and that an invalid setting is ignored.
  • frontend/openapi.json was re-dumped under bwrap with the venv, then npm run gen:api. tsc --noEmit is clean.
  • vitest: 1085 pass, 3 fail. The 3 are useShareTarget ×2 and FreshContext CacheExpiredNotice, which already fail on main.
  • Not deployed from the EVOX2. Deploy from the Homelab after review. Merge after PR #13.

🤖 Generated with Claude Code

## Summary The core kept its own copy of the guests' **New project policy** (`guestDefaults.newProjects`: quota, templates, approve, visibility, visibilityDefault, level, domain), duplicating the `new-project` plugin's settings, which hold the same 7 keys and are what `users/runs.new_project_access` already reads. This PR removes the core copy. The plugin's settings become the only place the policy lives. The one value the core still used was `domain`. `users/domains.default_domain` reads it for ship hosts, Matomo, `users.read`'s address, and the Users page's domain hint. It now reads the plugin's *Shared domain* setting. ## Key changes - `backend/users/store.py`: removed `DEFAULT_NEW_PROJECTS`, `NEW_PROJECT_VISIBILITY`, `clean_new_projects` and `_TEMPLATE_NAME_RE`. `newProjects` is gone from `defaults()` / `set_defaults()` and from a fresh `users.json`. Added `UsersStore.legacy_new_projects()`, which reads the stored `guestDefaults.newProjects` as is. - `backend/users/domains.py`: `default_domain` now checks, in order: 1. the owner's `new-project` config `domain` (whether the plugin is enabled or not); 2. the legacy `guestDefaults.newProjects.domain`; 3. `gabvdl.xyz`. Each value is validated as a domain. - `backend/plugins/carryover.py`: `new_project` takes the policy from `legacy_new_projects()` instead of `defaults()`. - `backend/schemas/users.py`: removed `NewProjectPolicy`. `GuestDefaults` gains a read-only `domain`. - `backend/users/routes.py`: removed `GuestDefaultsBody.newProjects`. `GET`/`PUT /api/guest-defaults` add `domain` from `default_domain`. - Frontend: `User.tsx` reads `guestDefaults.domain`. In the mock, `guestDefaults.newProjects` is gone and `mockNewProjectMode` uses a plugin-default quota constant. `openapi.json` was re-dumped and `src/generated/` regenerated. - `CLAUDE.md`: new paragraph in the New project section. Tests added in `test_plugin_new_project.py`. ## Key decisions - **Root domain:** it now comes from the plugin's own `domain` setting. The audit's alternative was a new `guestDefaults.domain` field, but that would recreate the duplicate this PR removes. Reading the plugin's setting means one value drives both the plugin's form and the core's addresses. Before this PR the two could disagree. - **Plugin coverage:** checked against `ai-agent-plugins/plugins/new-project/plugin.json`. Its `settings.fields` cover all 7 keys, with the same defaults. Nothing was kept in the core for lack of a plugin equivalent. - **Existing data needs no manual step:** - The carry-over (2026-11-25) has already copied the whole cleaned policy, `domain` included, into the plugin config on any hub where the plugin was installed. `default_domain` returns the same value as before. - A hub where the plugin isn't installed yet still gets the legacy `domain`. The carry-over still reads the stored policy when the plugin arrives. - The stored `guestDefaults.newProjects` key is left in `users.json`, unused except as that fallback. - No new carry-over was needed: the plugin lacks no value the core held. ## Changelog - The guests' New project policy now lives only in the New project plugin's settings, and the guests' shared domain is that plugin's *Shared domain*. ## Test notes - Backend: every `test_*.py` module was run under bwrap with a throwaway `/data`, one process per module, on the branch and on main (ad150f1f). - Branch: 160 pass, 1 fails: `test_typed_plugins`, which also fails on main. - `test_mcp` failed once on main only, so it looks flaky. - New: `GuestsRootDomain` checks the order (plugin setting, then legacy, then default) and that an invalid setting is ignored. - `frontend/openapi.json` was re-dumped under bwrap with the venv, then `npm run gen:api`. `tsc --noEmit` is clean. - vitest: 1085 pass, 3 fail. The 3 are `useShareTarget` ×2 and `FreshContext` CacheExpiredNotice, which already fail on main. - **Not deployed from the EVOX2.** Deploy from the Homelab after review. **Merge after PR #13.** 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabrielvidal self-assigned this 2026-11-27 11:43:19 +01:00
gabrielvidal added 1 commit 2026-11-27 11:43:19 +01:00
The core still carried guestDefaults.newProjects (DEFAULT_NEW_PROJECTS /
clean_new_projects, schemas.NewProjectPolicy, GuestDefaultsBody.newProjects)
although the new-project plugin's settings hold the same 7 keys and nothing
read the core copy but default_domain and the Users page's domain hint.

- users/domains.default_domain: the plugin's Shared domain setting, else the
  legacy guestDefaults.newProjects.domain (read raw), else gabvdl.xyz.
- UsersStore.legacy_new_projects(): the stored policy, read raw, for the
  carry-over (which now reads it instead of defaults()) and the fallback.
- /api/guest-defaults reports the root domain read-only as `domain`.
- Mock, openapi.json, generated client, CLAUDE.md, tests updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner
Merged into `main` as d7f9a600 by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/12d75a3b-25dc-487a-ac3b-17782cba4214.
gabrielvidal closed this pull request 2026-11-27 12:19:31 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gabrielvidal/ai-agent#24