Skip to content

feat: select plugins and backends per task - #357

Merged
uniqueg merged 5 commits into
devfrom
feat/218-select-per-task
Oct 31, 2026
Merged

uniqueg merged 5 commits into
devfrom
feat/218-select-per-task

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Clients choose the plugins and TES instances of a task, as decided in #218 (update of 2026-10-25), on FOCA 0.18:

  • The tags gateway.pipeline (preset name or pipeline as JSON) and gateway.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 other gateway.* keys are rejected with 400.
  • FOCA's plugin listing (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 TES info wins), for the role user (new named rules users-list-plugins and users-get-plugins); without a token 401, others 403 (also admins without the role user).
  • The public service info gets FOCA's gateway field (plugins_url, whether clients may choose pipelines and backends, capabilities; no plugin identifiers or versions).
  • Docs: client guide in 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 values plugins.clientPipelines and plugins.clientBackends exist since #348.

For the release notes

  • Features: GET /plugins and GET /plugins/{plugin_id} list what users may choose per task (tags gateway.pipeline and gateway.backends); service info field gateway (feat: select plugins and backends per task #218).
  • Upgrading: custom policy lists must add users-list-plugins and users-get-plugins.

Closes #218

Verification

Local (venv with FOCA 0.18.0):

  • ruff format, ruff check: clean; mypy: no issues in 69 files
  • coverage run -m pytest: 1064 passed, 169 skipped; coverage report: 100%
  • mkdocs build --strict: clean
  • semgrep (.semgrep) and ast-grep (sgconfig.yml): no findings
  • The smoke test (tests/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_PATH from the spec's base path (low): kept as a constant, like TASKS_PATH; the rules in config.yaml name the path anyway.

  • Quality: test the ValueError guard of service_info_fields separately (medium): it is covered by test_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.yaml if 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:

  • Allow users to select task-specific plugin pipelines and TES backends through gateway tags.
  • Expose authenticated plugin and preset listings through the TES API.
  • Publish client-selection capabilities and the plugin listing URL in service information.

Enhancements:

  • Record discarded unknown backend selections in task provenance and enforce validation and access restrictions for client choices.

Documentation:

  • Document client task choices, plugin listing endpoints, access control, service information, and upgrade requirements.

Tests:

  • Add coverage for task-specific pipeline and backend selection, validation, authorization, service information, API specification merging, and smoke checks.

uniqueg and others added 4 commits October 31, 2026 17:10
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]>
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This 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 selection

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

Sequence diagram for authenticated plugin listing

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

File-Level Changes

Change Details Files
Adds per-task client selection of plugin pipelines and TES backends with FOCA validation and provenance safeguards.
  • Accepts preset or inline JSON pipelines via gateway.pipeline when enabled and caller-authorized.
  • Supports ordered, allowed, or forbidden backends via gateway.backends; unknown backends are discarded and recorded.
  • Rejects invalid, disabled, unauthorized, or reserved gateway choices before task storage or forwarding.
  • Adds focused coverage for successful selections, validation failures, role restrictions, disabled features, and provenance.
pro_tes/gateway.py
pro_tes/ga4gh/tes/backends.py
tests/ga4gh/tes/test_client_choices.py
Exposes FOCA's plugin listing through the TES API and documents access-controlled client capabilities.
  • Merges FOCA plugin API specifications into the TES specification under /ga4gh/tes/v1/plugins while preserving TES metadata precedence.
  • Adds users-list-plugins and users-get-plugins policies and verifies 401/403 behavior.
  • Publishes gateway service-info metadata without exposing plugin identifiers or versions.
  • Updates API, access-control, client, and upgrade documentation with configuration and usage examples.
pro_tes/app.py
pro_tes/config.yaml
docs/access-control.md
docs/api.md
docs/configuration.md
docs/plugins.md
docs/upgrading.md
tests/test_app.py
tests/test_gateway.py
tests/ga4gh/tes/test_backend_list.py
Extends smoke coverage to validate plugin discovery, service metadata, and authentication behavior.
  • Checks the plugin listing and gateway service-info field through the deployed API.
  • Verifies unauthenticated plugin-listing requests return 401.
tests/smoke/check.sh

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

@read-the-docs-community

read-the-docs-community Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35548107 | 📁 Comparing 3df1433 against latest (d0ef3e8)

  🔍 Preview build  

6 files changed · ± 6 modified

± Modified

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d0ef3e8) to head (3df1433).

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.
📢 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 31, 2026 17:27

@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="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


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

Comment thread pro_tes/config.yaml Resolved
Comment thread tests/ga4gh/tes/test_client_choices.py Resolved
@uniqueg
uniqueg merged commit 37428b1 into dev Oct 31, 2026
19 checks passed
@uniqueg
uniqueg deleted the feat/218-select-per-task branch October 31, 2026 17:49
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: select plugins and backends per task

1 participant