Repository navigation
Description
Problem
Clients must be able to choose the plugin pipeline per task from the
available plugins (maintainer requirement R7), and (Krini) to restrict
or order the backends their task may go to, without breaking GA4GH
compliance or letting clients reach plugins or backends the operator
did not allow.
Proposal
foca.plugins.selection, called by host.start(..., tags=...) before
any plugin runs:
- Reserved client tags: under
plugins.tags.prefix(default
gateway.), clients may set onlygateway.pipelineand
gateway.backends; any othergateway.*key →400(problem type
.../reserved-tag, key indetail; Q21). gateway.pipeline: a preset name (^[a-z0-9][a-z0-9-]{0,63}$) or
a JSON pipeline (≤ 8 KiB; schema of the admin pipeline minus
timeout/on_failure);client_pipelinesconfig:enabled(default
true, Q6; tag withenabled: false→400),allowed
(presets,inline),max_steps,max_alternatives,roles,
admin frameprepend/append(withif_missing_phase: route).
Authorization: plugins must be inavailable,client_selectable,
allowed for the principal's roles, and support the app's API; unknown,
non-selectable and non-installed plugins give the same400
("plugin not available: X"). Params validated against the plugin's
Params(extra=forbid).gateway.backends(Krini report 1): JSON string
{"type": "order"|"allow"|"forbid", "backends": [...]}(≤ 8 KiB,
1..client_backends.max_itemsstrings, default 32); config
client_backends.enabled(default true; tag when disabled →400).
Parsed at start, applied after the route phase on its output.
Items matchBackend.idor the normalised URL; items that are not
candidates (unknown, unverified, wrong type, removed by routing, own
URL) are discarded silently and recorded; no option to disable the
verified check.order: listed candidates first, in client order, then the
remaining ones in server order;allow: server order, unlisted discarded untried;forbid: server order, listed discarded untried.
Nothing left →NoBackendAvailable(503).
- The resolved pipeline is available to provenance (P3).
Acceptance criteria
- Property tests (Hypothesis if available, else table-driven) over
random client pipelines: never a plugin outside the allowlist, limits
enforced, uniform error messages. - Every branch of 1–3 tested, incl. disabled switches, invalid JSON,
oversized tags, unknown types, empty results. - Docs: configuration of
client_pipelines/client_backends; client
guide (tags, examples, re-run rule: drop server-writtengateway.*
keys). - 100% coverage, mypy, ruff,
mkdocs build --strict.
Surviving the Connexion 3 migration
Pure data in, data out: tags (a string map), Principal, config. No
request object involved; nothing to change in rc1.
Dependencies
- Blocked by feat(plugins): add plugin engine #486 (P1).
- Blocks: feat(plugins): list available plugins #489 (P4).
Open questions
type: order: append unlisted candidates after the listed ones
(chosen, matches "client order overrules server order" without
narrowing) or discard them (thenorder=allowwith client order)?
Added during pre-review: client pipelines replace plugins.pipeline (policies belong in prepend, documented with a warning); empty client pipelines stay allowed; tags that are not a mapping give 400 (reserved-tag); start() requires tags= for APIs other than TES; presets enforce plugin roles but not client_selectable; client_pipelines.allowed needs at least one value; the gateway.backends tag is capped at 8 KiB before parsing and needs at least one backend; client pipelines must be I-JSON (no NaN/Infinity, integers within ±(2^53−1)); preset step IDs must not clash with prepend/append.
Activity
fix(plugins): address Sourcery review of choices