Repository navigation
feat: publish the registration rules - #260
Conversation
Serve the rules for registrations of the deployment in the service info (`registration_rules` of `GET /service-info`): the allowed environments and service URL schemes, the service type mode and the limit of unused types. FOCA adds them via `service_info.runtime_fields`, built from the custom config on each request; the app refuses to start if the config drops the function or sets the field itself. The API specification declares them as an extension of the GA4GH `Service` schema (`RegistryServiceInfo`), which responses are validated against. Document the rules in the API and configuration docs, and tell client authors to read them instead of configuring them. Closes #256 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR publishes the registry's active registration rules as a dynamically computed, publicly accessible extension of GA4GH service-info, with startup safeguards, OpenAPI response validation, comprehensive tests, and updated client-facing documentation. Sequence diagram for dynamically publishing registration rulessequenceDiagram
actor Client
participant FOCA as FOCA service-info
participant Runtime as runtime_fields()
participant Rules as registration_rules()
participant Config as custom config
Client->>FOCA: GET /service-info
FOCA->>Runtime: runtime_fields()
Runtime->>Rules: registration_rules()
Rules->>Config: get_custom_config()
Config-->>Rules: Active registration settings
Rules-->>Runtime: registration_rules
Runtime-->>FOCA: registration_rules
FOCA-->>Client: RegistryServiceInfo response
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #260 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 18 +1
Lines 1757 1778 +21
=========================================
+ Hits 1757 1778 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="cloud_registry/ga4gh/registry/service_info.py" line_range="83" />
<code_context>
+ service_info = get_config().service_info
+ if (
+ service_info is None
+ or service_info.runtime_fields != RUNTIME_FIELDS
+ or RULES in service_info.service
+ ):
</code_context>
<issue_to_address>
**Existing runtime extensions prevent startup**
When a deployment already configures a different `service_info.runtime_fields` hook, `check_service_info_fields()` rejects every `service_info.runtime_fields` function except this module's exact function path, so deployments using another supported runtime-fields hook cannot start, even if that hook adds the registration rules alongside its existing fields.
Compose the registration rules with existing runtime fields, or validate that the configured hook supplies them without requiring an exact function-path match.
</issue_to_address>
### Comment 2
<location path="cloud_registry/api/additions.openapi.yaml" line_range="928" />
<code_context>
+ type: integer
+ minimum: 0
+ description: |
+ How many service types that no service has a user other than an
+ admin may have added (`409` above; see `POST /services/types`);
+ `0` if they can't add types (explicitly or with services). Not
</code_context>
<issue_to_address>
**Concurrent additions exceed published limit**
When a user is one unused type below the configured limit and concurrently adds two distinct types, `check_unused_types()` counts unused types before either request inserts its new type, so both additions succeed and the user ends up over the published limit; clients see a limit the registry did not maintain.
Enforce the limit atomically for each user, or describe the concurrency exception alongside the published limit in the API documentation.
Also at `docs/api.md:98`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and unauthenticated clients can now read the deployment’s allowed environments, service-type admission mode, and unused-type limit, even where other reads require login. Reverting stops future publication, but cannot retract values already observed or cached.
Blocking findings: cloud_registry/ga4gh/registry/service_info.py:83, cloud_registry/api/additions.openapi.yaml:928
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Publishes the deployment's registration rules in the service info, so that clients (UIs, ELIXIR Cloud Components, cf. elixir-cloud-aai/cloud-components#453 and #461) can read them instead of configuring them:
environments: empty list = any value (as in the config).max_unused_service_types: left out if there is no limit (null);0= users other than admins can't add types (explicitly or with services).customconfig on each request through FOCA'sservice_info.runtime_fields(new modulecloud_registry/ga4gh/registry/service_info.py), so the values always match the config in effect.runtime_fieldsor setsservice_info.service.registration_rules(even tonull). FOCA gives config fields precedence over runtime fields, so a configured value could otherwise differ from the enforced rules.Serviceschema (RegistryServiceInfo=allOfService+RegistrationRules, inadditions.openapi.yaml). Responses are validated against it.docs/api.md(also listed under deviations and in the intro), and pointers indocs/configuration.md(environments, URL schemes, service types, service info) telling client authors to read the rules rather than configure them. Theconfig.yamlcomment no longer says clients should configure the same values.Design choice: service-info extension field rather than a new endpoint
Serviceschema (e.g.,TesServiceInfowithstorage, WESworkflow_type_versions). The service-info spec describes it as "basic metadata ... alongside a set of capabilities and/or limitations of the service". A new endpoint would be a registry-only convention.GET /service-infois already public, also with the login-for-reads patch, and needs no new access control policy. A path under/services/...would also collide with the/services/:idpolicy pattern, and the patch would need another entry.runtime_fieldsexists for this case (fields computed at runtime), so no own controller is needed and the FOCA controller keeps its traffic logging and error handling.snake_case, like the registry's other own fields (may_add_service_types,verified_at) and the config keys they mirror.Nonevalues from the service info, so "no limit" is shown by leaving the field out rather than bynull. This is documented in the schema and the docs.No changes to authentication, so it stays compatible with LS Login.
Closes #256
Verification
pre-commit run --all-files(ruff, mypy, semgrep, ast-grep, …): passedcoverage run -m pytestwith mongomock: 1279 passed, 230 skipped (Helm missing locally; MongoDB entry runs in CI);coverage report: 100%mkdocs build --strict: passednull,0and empty environments), spec declaration, response validation against the extension schema (500 on invalid rules; checked that this test fails without the schema), and startup refusal for configured or dropped rules.Review
Light lane doesn't apply (API change). Both reviewer subagents ran. The adversarial review found nothing. From the quality review, the two rewrap lows were fixed. No second round: the only medium was declined without code changes, and the fixes were whitespace only.
Sourcery: two medium threads. (1) Concurrent additions can exceed the published limit: documented in the schema and
docs/api.md(behaviour unchanged since #254). (2) The exactruntime_fieldspath check blocks other hooks: declined, because no earlier release set the option and only the app's own hook guarantees the rules match what is enforced. Both threads are answered and resolved, and CI is green again after the fix.Declined review findings
service_info.runtime_fields,service_info.service.registration_rules) are new, and FOCA merges overlays intoconfig.yamlinstead of replacingservice_info. The refusal and the reason for it are indocs/configuration.md(Service info).additionalProperties: falseonRegistrationRules. Kept on purpose: all of the registry's own schemas are closed. Together withtest_registration_rules_in_spec, it keeps the schema andregistration_rules()in step.config.yaml). Sharing a constant across test modules would couple them, and the values are the documented defaults.registration_rules()andruntime_fields(). The reviewer considered them acceptable as is.runtime_fields()is FOCA's hook, andregistration_rules()is what clients and future callers (e.g.,GET /me) can reuse.feat(api)) to the commit and title. Recent CR history uses unscoped subjects (e.g.,feat: use tokens sent with public reads).Open questions
None.
Merge
This is a 0.6.0 feature (tracker #250). Don't merge before
v0.5.0is tagged.🤖 Generated with Claude Code
Summary by Sourcery
Publish deployment registration rules in service info so clients can discover the constraints enforced by the registry.
New Features:
Enhancements:
Documentation:
Tests: