Skip to content

feat: publish the registration rules - #260

Merged
uniqueg merged 4 commits into
devfrom
feat/registration-rules
Oct 26, 2026
Merged

uniqueg merged 4 commits into
devfrom
feat/registration-rules

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

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:

"registration_rules": {
  "environments": ["prod", "test", "dev", "staging"],
  "url_schemes": ["https"],
  "service_types": "open",
  "max_unused_service_types": 10
}
  • 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).
  • Built from the custom config on each request through FOCA's service_info.runtime_fields (new module cloud_registry/ga4gh/registry/service_info.py), so the values always match the config in effect.
  • The app refuses to start if the config drops runtime_fields or sets service_info.service.registration_rules (even to null). FOCA gives config fields precedence over runtime fields, so a configured value could otherwise differ from the enforced rules.
  • The spec declares the field as an extension of the GA4GH Service schema (RegistryServiceInfo = allOf Service + RegistrationRules, in additions.openapi.yaml). Responses are validated against it.
  • Docs: new "Registration rules" section in docs/api.md (also listed under deviations and in the intro), and pointers in docs/configuration.md (environments, URL schemes, service types, service info) telling client authors to read the rules rather than configure them. The config.yaml comment no longer says clients should configure the same values.

Design choice: service-info extension field rather than a new endpoint

  • GA4GH convention: service-info is where GA4GH APIs publish a deployment's capabilities and limits, as extension fields of the Service schema (e.g., TesServiceInfo with storage, WES workflow_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.
  • Public with no extra work: GET /service-info is 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/:id policy pattern, and the patch would need another entry.
  • Framework support: FOCA's runtime_fields exists for this case (fields computed at runtime), so no own controller is needed and the FOCA controller keeps its traffic logging and error handling.
  • Naming: snake_case, like the registry's other own fields (may_add_service_types, verified_at) and the config keys they mirror.
  • Trade-off: FOCA drops None values from the service info, so "no limit" is shown by leaving the field out rather than by null. 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, …): passed
  • coverage run -m pytest with mongomock: 1279 passed, 230 skipped (Helm missing locally; MongoDB entry runs in CI); coverage report: 100%
  • mkdocs build --strict: passed
  • Tests added: defaults, changed settings via overlay and at runtime (including null, 0 and 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.
  • CI: all checks passed (CI passed, Test mongomock + MongoDB 7.0, Chart, Docs, Lint, Smoke test, Scan image, CodeQL, Read the Docs).

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 exact runtime_fields path 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

  • Medium: add an upgrade note for the new startup refusal. It can't affect existing deployments: both keys it checks (service_info.runtime_fields, service_info.service.registration_rules) are new, and FOCA merges overlays into config.yaml instead of replacing service_info. The refusal and the reason for it are in docs/configuration.md (Service info).
  • Low: drop additionalProperties: false on RegistrationRules. Kept on purpose: all of the registry's own schemas are closed. Together with test_registration_rules_in_spec, it keeps the schema and registration_rules() in step.
  • Low: the default rules appear in both test modules. The two modules test different levels (unit app config vs. config.yaml). Sharing a constant across test modules would couple them, and the values are the documented defaults.
  • Low: merge registration_rules() and runtime_fields(). The reviewer considered them acceptable as is. runtime_fields() is FOCA's hook, and registration_rules() is what clients and future callers (e.g., GET /me) can reuse.
  • Low: add a scope (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.0 is 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:

  • Publish deployment registration rules through the public GA4GH service-info response so clients can discover and follow them.

Enhancements:

  • Extend and validate the service-info OpenAPI schema with registry-specific registration rules, including deployment limits and modes.
  • Ensure registration rules are computed from the active configuration on every request and prevent conflicting service-info configuration at startup.

Documentation:

  • Document the registration-rules service-info field and guide clients to consume it instead of duplicating deployment configuration.

Tests:

  • Add coverage for default, overridden, runtime, schema-validation, and invalid-startup configurations for registration rules.

uniqueg and others added 2 commits October 26, 2026 17:52
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The 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 rules

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Publishes deployment registration constraints dynamically through the public service-info response.
  • Added a runtime service-info provider that derives environments, URL schemes, service-type access mode, and optional unused-type limits from the active custom configuration on every request.
  • Configured FOCA to include the runtime field and added startup validation preventing static or missing registration rules from overriding enforced configuration.
  • Documented null and zero limit semantics, including omission of an unlimited value.
cloud_registry/ga4gh/registry/service_info.py
cloud_registry/app.py
cloud_registry/config.yaml
Extends and validates the OpenAPI service-info contract with registry-specific registration rules.
  • Declared RegistryServiceInfo as a GA4GH Service extension containing a closed RegistrationRules schema.
  • Applied the extension schema to GET /service-info responses while retaining public access.
  • Added tests covering schema declaration and response validation failures.
cloud_registry/api/additions.openapi.yaml
tests/test_app.py
Updates API and configuration guidance so clients consume published rules instead of duplicating deployment configuration.
  • Added a Registration rules API section and linked it from API deviations and service-type guidance.
  • Updated configuration documentation and comments to direct clients to service-info.
  • Exposed the new module in generated reference documentation.
docs/api.md
docs/configuration.md
docs/reference.md
cloud_registry/config.yaml
Adds unit and integration coverage for defaults, configuration changes, runtime updates, and invalid service-info setup.
  • Covered empty environments, HTTP/HTTPS changes, moderated and controlled modes, null and zero limits, and defensive list copying.
  • Verified startup refusal when runtime fields are missing or static registration_rules are configured, including null.
  • Verified service-info output reflects config changes and conforms to the extension schema.
tests/ga4gh/registry/test_service_info.py
tests/test_app.py

Assessment against linked issues

Issue Objective Addressed Explanation
#256 Publish the configured environments, allowed URL schemes, service-type mode, and unused service-type limit through a public, read-only API location. ✅
#256 Ensure published rules always reflect the active configuration, and cover default and changed settings with tests. ✅
#256 Document the API representation and configuration behavior, and direct client authors to read the published rules rather than duplicate configuration. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2700ed5) to head (224c104).
⚠️ Report is 1 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review October 26, 2026 18:20

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@uniqueg
uniqueg merged commit 48059aa into dev Oct 26, 2026
17 checks passed
@uniqueg
uniqueg deleted the feat/registration-rules branch October 26, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: publish the registration rules

1 participant