Repository navigation
feat: select plugins and backends per task - #357
Conversation
Serve FOCA's plugin listing (GET /plugins and /plugins/{plugin_id})
under the TES base path for the role user (rules users-list-plugins and
users-get-plugins), and add its gateway field to the service info. Test
the choices of clients per task (gateway.pipeline, gateway.backends)
through the API.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge FOCA's plugin listing before the TES spec files, so that the served spec keeps the TES title and OpenAPI version. Test plugins for other roles, reserved tags and the discarded backends; document the rules for custom policy lists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR enables authenticated clients to choose authorized plugin pipelines and TES backends per task, validates and safely records those choices through FOCA, exposes the available choices via TES plugin endpoints and service metadata, and adds comprehensive documentation and integration coverage. Sequence diagram for per-task pipeline and backend selectionsequenceDiagram
actor Client
participant TESAPI
participant FOCA
participant PluginEngine
participant TES
participant Provenance
Client->>TESAPI: POST /ga4gh/tes/v1/tasks with gateway.pipeline and gateway.backends
TESAPI->>FOCA: validate_task
FOCA->>PluginEngine: validate client choices
alt invalid, unavailable, or disabled choice
PluginEngine-->>FOCA: validation error
FOCA-->>TESAPI: 400 Bad Request
else valid choices
PluginEngine->>PluginEngine: select pipeline and backend policy
PluginEngine->>TES: forward task using selected backend order
PluginEngine->>Provenance: record discarded unknown backends
TES-->>TESAPI: task state
TESAPI-->>Client: task response
end
Sequence diagram for authenticated plugin listingsequenceDiagram
actor Client
participant TESAPI
participant Auth
participant PluginAPI
Client->>TESAPI: GET /ga4gh/tes/v1/plugins
TESAPI->>Auth: apply users-list-plugins
alt missing token
Auth-->>TESAPI: unauthorized
TESAPI-->>Client: 401 Unauthorized
else caller has role user
Auth->>PluginAPI: list available plugins and presets
PluginAPI-->>TESAPI: plugin listing
TESAPI-->>Client: 200 OK
else caller lacks role user
Auth-->>TESAPI: forbidden
TESAPI-->>Client: 403 Forbidden
end
File-Level Changes
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 #357 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 2209 2232 +23
=========================================
+ Hits 2209 2232 +23 ☔ 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="pro_tes/config.yaml" line_range="92-93" />
<code_context>
+security:
+ access_control:
+ policies:
+ users-list-plugins: [p, user, /ga4gh/tes/v1/plugins, (GET)|(HEAD)]
+ users-get-plugins: [p, user, "/ga4gh/tes/v1/plugins/:id", (GET)|(HEAD)]
+```
+
</code_context>
<issue_to_address>
**Older replicas remove plugin rules**
When an old-version replica restarts after a new-version replica has synchronized the rules during a rolling deployment, an older API replica starting against the shared policy database atomically replaces the configured rules with its older list, deleting `users-list-plugins` and `users-get-plugins`; newer replicas then return `403` for the plugin endpoints until a newer replica starts and restores the rules.
Ensure no old-version instance can start after the new rules are synchronized, or make the policy update backward-compatible across the rollout.
</issue_to_address>
### Comment 2
<location path="tests/ga4gh/tes/test_client_choices.py" line_range="34" />
<code_context>
+# Settings of `plugins` that let clients choose pipelines, with a preset
+CHOICES: dict[str, Any] = {
+ "presets": {"renamed": [step("test.rename")]},
+ "client_pipelines": {"enabled": True},
+}
+
</code_context>
<issue_to_address>
**Pipeline default stays off**
The issue update specifies that per-task pipelines are enabled by default. This test setup explicitly enables them, while the change leaves FOCA’s default off, so clients cannot choose a pipeline without operator configuration.
</issue_to_address>Linked issues
#218 feat: select plugins and backends per task · 5 of 6 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Per-task pipelines are enabled by default and apply only to the chosen task. | 🟡 Partly met | Preset and inline pipelines are tested as task-specific, but the change leaves client_pipelines disabled by default, contrary to the issue update. |
| 2 | gateway.backends orders, restricts or excludes backends; unknown or unverified backends are not used and discarded selections are recorded. |
✅ Met | API tests cover all three selection types and verify that an unknown backend is not used and is recorded in provenance. |
| 3 | Reject invalid, unavailable, disabled and reserved gateway.* selections with 400, and document them. |
✅ Met | The API tests cover these rejection cases, and the client guide describes them. |
| 4 | Serve the plugin listing to authenticated users under the TES API. | ✅ Met | The listing is registered under the TES API; tests check successful access for users, 401 without a token, and 403 for callers without the user role. |
| 5 | Keep client choice tags on the stored task and strip gateway.* tags before forwarding it. |
✅ Met | Tests check stored tags and verify that gateway tags are absent from the relayed task. |
| 6 | Provide chart values, documentation and API tests for client choices. | ✅ Met | The chart values are already present, and the change adds client guidance and API coverage. |
Sourcery assessment
Needs a human reviewer. 2 findings to address first, and a client can now steer a task to a different configured or verified TES backend, which receives the task payload; if that backend is not an appropriate destination, reverting cannot undo the disclosure. Plugin choices are constrained by the admin's available-plugin settings, but data already sent to a backend cannot be recalled.
Blocking findings: pro_tes/config.yaml:93, tests/ga4gh/tes/test_client_choices.py:34
Summary
Clients choose the plugins and TES instances of a task, as decided in #218 (update of 2026-10-25), on FOCA 0.18:
gateway.pipeline(preset name or pipeline as JSON) andgateway.backends(order/allow/forbid) were already passed to FOCA's plugin engine since refactor!: run task plugins with FOCA #321; this PR tests them through the API: a chosen preset or pipeline runs for its task only, backends are ordered, restricted or excluded, unknown backends are never used and are recorded in the provenance (selection.discarded), and unknown presets, plugins that aren't available to the caller (also by role), invalid JSON, disabled choices and othergateway.*keys are rejected with400.GET /ga4gh/tes/v1/plugins,GET /ga4gh/tes/v1/plugins/{plugin_id}) is served with the TES API (pro_tes.gateway.add_plugin_listing, FOCA's spec fragment merged before the TES files, so the TESinfowins), for the roleuser(new named rulesusers-list-pluginsandusers-get-plugins); without a token401, others403(also admins without the roleuser).gatewayfield (plugins_url, whether clients may choose pipelines and backends, capabilities; no plugin identifiers or versions).plugins.md(rules, examples with curl and py-tes, re-running fetched tasks), API endpoints, access control, service info, upgrading (rules for custom policy lists). Smoke test checks the listing and the service info field.Per-task pipelines stay off by default (FOCA's
plugins.client_pipelines.enabled: false, as documented since #321); the issue's update said "on by default", but the default is FOCA's. The Helm valuesplugins.clientPipelinesandplugins.clientBackendsexist since #348.For the release notes
GET /pluginsandGET /plugins/{plugin_id}list what users may choose per task (tagsgateway.pipelineandgateway.backends); service info fieldgateway(feat: select plugins and backends per task #218).users-list-pluginsandusers-get-plugins.Closes #218
Verification
Local (venv with FOCA 0.18.0):
ruff format,ruff check: clean;mypy: no issues in 69 filescoverage run -m pytest: 1064 passed, 169 skipped;coverage report: 100%mkdocs build --strict: clean.semgrep) and ast-grep (sgconfig.yml): no findingstests/smoke/check.sh, Docker Compose) runs in CI only; shellcheck isn't installed locally.pre-commit itself couldn't fetch its hook repositories through the sandbox proxy; its hooks were run directly as above.
CI: all checks passed (CI passed, Test (MongoDB 7.0), Test (mongomock), Lint, Docs, Chart, Smoke test, Scan image, CodeQL).
Declined review findings
Quality: derive
PLUGINS_PATHfrom the spec's base path (low): kept as a constant, likeTASKS_PATH; the rules inconfig.yamlname the path anyway.Quality: test the
ValueErrorguard ofservice_info_fieldsseparately (medium): it is covered bytest_plugins.py::test_unknown_plugin(unknown plugins make FOCA's service info fail while the app is created; the guard lets FOCA's own error about the plugin surface).Sourcery: enable per-task pipelines by default, as the issue's update said (high): kept FOCA 0.18's default (off), as documented since refactor!: process tasks with FOCA plugins #346; flipping it is one line in
config.yamlif the maintainers want it.Sourcery: older replicas started during a rolling update remove the new rules (medium): the documented limit of FOCA's configured rules (docs/upgrading.md); not fixable in proTES.
Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Enable clients to choose permitted plugin pipelines and TES backends for individual tasks while exposing the available choices through the TES API.
New Features:
Enhancements:
Documentation:
Tests: