Repository navigation
test: lock scopes so a shipped scope cannot be removed - #14206
Conversation
Keys, functions, sites and OAuth2 clients store scopes, and MCP hosts such as ChatGPT keep requesting the list they registered with. Removing assistant.read (#14167) broke those clients with invalid_scope until #14200 restored it. Record every shipped scope in app/config/scopes/lock.json and fail the unit suite when one disappears from the catalogs or a new one is not locked, so retiring a scope means deprecating it.
|
Review complete. No blocking issues — 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
This PR introduces an immutability contract for Appwrite's scope catalogs: a new
Reviewed commit: 9e7020e |
🔵 Tier A · Mergeable after minor fixes
Adds a committed lock of project, organization, and account scopes, plus six data-driven checks rejecting removed scopes and unlocked additions. Updates AGENTS.md to document scope deprecation and configuration contract checks. The latest change converts the catalog data provider to a generator without changing its datasets. Latest changes: Converts ScopesTest::catalogs() from an array-returning provider to an Iterator using three named yields.
Fix with agent prompt### Issue 1
tests/unit/General/ScopesTest.php:33-36
**Keep config-contract checks outside the restricted unit tier**
The base `AGENTS.md` Tests rule limits `tests/unit/` to local `src` libraries; this test checks static configuration rather than a library. Please run these snapshot checks through a dedicated config-validation/CI check outside the unit tier and update the documented path accordingly.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 3
⏳ Still open from earlier reviews · 1
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
|
@hansi-codes review |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Removing the Assistant in #14167 also removed the
assistant.readscope. MCP hosts such as ChatGPT keep requesting the scope list they registered with, so connecting the Appwrite app failed withinvalid_scope - Scope 'project:assistant.read' is not supported.until #14200 restored it as deprecated. Keys, functions and sites store scopes too. Scopes are a public contract and should only ever be deprecated.This adds
app/config/scopes/lock.json, the list of every shipped project, organization and account scope, andtests/unit/General/ScopesTest.php, which runs in the unit suite and fails when:Scope 'assistant.read' was removed from the project scopes. Clients that stored it would be rejected; keep it and mark it 'deprecated' => true instead.Scope 'widgets.read' is not in app/config/scopes/lock.json. Add it under 'project'; once shipped it cannot be removed.So adding a scope costs one line in the lock, which makes the contract change visible in review, and removing one fails CI.
compute.phpis left out because it lists the scopes granted to ephemeral keys, not a catalog clients pick from. AGENTS.md now says scopes are never removed and points to the test.The lock mirrors config on purpose: it is the reviewed snapshot of a published contract, like
composer.lockor the committed specs, not an implementation detail.Seen red: removing
assistant.readfromproject.phpand adding an unlockedwidgets.readfails both tests with the messages above; restoring the file passes (6 tests). Pint and PHPStan pass on the test.Closes #14207