refactor(api-keys): answer which workspace owns a key, for other domains - #1452
Merged
Merged
Conversation
|
Warning Review limit reachedNext included review available in 39 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: mozilla-ai/otari/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
peteski22
force-pushed
the
feat/api-key-lookups
branch
from
September 21, 2026 19:01
c7902aa to
c620080
Compare
peteski22
marked this pull request as ready for review
September 21, 2026 19:01
tbille
approved these changes
Sep 21, 2026
Which workspace owns a key, and which keys sit in a set of workspaces, asked through an `ApiKeyService` on a Unit of Work. Both lookups raise outside a block. The file fails at this commit with `ModuleNotFoundError`, because neither package exists yet. `ruff check` also reports its import order until then, since it takes a missing module for a third-party one.
Two queries, copied from the organization budget surface, which keeps its own copies for now: which workspace owns a key, and the IDs of the keys in a set of workspaces. The repository runs on a Unit of Work and takes `Never` for its create and update schemas, so the generic `create` cannot be called on it. The tests still fail at this commit: the service does not exist yet.
`ApiKeyService` is the api-keys domain's service in the target shape: it receives its repository and imports no database library. Its two methods delegate to the repository and open no block of their own, so they run in the caller's transaction. Nothing in `src` calls it yet.
The api-keys domain gains `services/api_keys/` and `repositories/api_keys/`. The counts of service modules, repository modules and domain packages go up by one each.
peteski22
force-pushed
the
feat/api-key-lookups
branch
from
September 21, 2026 19:10
c620080 to
b21d629
Compare
15 tasks
This branch was successfully deployed
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.
Description
Nothing changes for someone using Otari. This adds the first part of the api-keys domain in its target shape: a service that another domain can ask which workspace owns an API key, and which keys sit in a set of workspaces.
Today the budgets domain answers both questions with its own queries on the API key table. In the target shape, a domain asks the owning domain's service instead of reading its tables. This PR adds that service and its repository. The two queries are copied from the organization budget module, which keeps its own copies for now.
Nothing in
srccalls the new service yet. The caller comes in Task 5.5 of the #1202 plan, which moves the organization budget surface onto aBudgetServicethat asks this service, and deletes the copied queries from the budgets module.Three points about the design:
OutsideUnitOfWorkErrorwhen none is open.Neveras its create and update schema types, so the genericcreatecannot be called on it. It writes no keys.This builds on #1451, which is now merged: the repository only type-checks with that change, because the API key table is a declarative table.
No rule or baseline in
scripts/check_architecture.pychanges. The new service imports no database library, as the rule for new modules underservices/requires.docs/domains.mdlists the two new packages under the api-keys domain, and four of its counts go up by one: service modules, repository modules, service packages and repository packages.How to test it locally
All of these pass on this branch, except
tests/integration/test_mcp_dependency_ceiling.py, as in #1451.tests/integration/test_api_key_service_lookups.pycovers both lookups through the service: the owning workspace for a key,Nonefor an unknown key, exactly the keys of the given workspaces, an empty list for no workspaces, andOutsideUnitOfWorkErroroutside a block. The commit that adds it comes first and fails withModuleNotFoundError.ruff checkalso reports its import order at that commit, because ruff takes a module that does not exist yet for a third-party one.PR Type
Relevant issues
Part of #1202: Task 5.2 of its plan. Builds on #1451 (Task 5.1). The first caller comes in Task 5.5.
Checklist
tests/unit,tests/integration).make lint,make typecheck,make test).uv run python scripts/generate_openapi.py).ARCHITECTURE.mdorscripts/check_architecture.py, the description names the rule and says why.AI Usage
AI Model/Tool used:
Claude, via Claude Code.
Any additional AI details you'd like to share:
This was shared work. The change comes from the plan for #1202, and I set the scope and the rules it ran under: no edit to the budget service modules, no database import in the new service package, the domain map updated, a failing test as its own first commit, one small commit per step, and the project's comment standard for every text it adds or touches. Claude wrote the code and the tests under that direction, ran the checks, and drafted this description. Using
Neverfor the schema types was Claude's proposal. I reviewed all four commits, and every added docstring, before the push.