Skip to content

feat: add gateway plugin engine #485

Closed
9 of 9 issues completed
Closed

Description

@uniqueg

Problem

proTES runs task "middlewares" with its own engine: classes imported by
dotted path from config, rebuilt per request, alternatives sharing one
mutable Flask request, no provenance, routing output smuggled through the
task body (tes_urls). proWES and later gateways need the same stack.
The maintainer decided (2026-10-24) that the engine lives in FOCA,
framework-free, with plugins in a separate monorepo (foca-plugins),
admin control by config only, per-task pipelines chosen by clients, and
full provenance.

Proposal

Add foca.plugins to FOCA 0.18, in these sub-issues (stack order):

Not in v0.18.0: P8 feat(plugins): support async hooks (plugins-08,
milestone v1.0.0-rc1, sub-issue of #188); P9 remote plugins (after 1.0).

Key decisions (copied from the design, section 0 and 20):

  • Names: plugin / pipeline / step; entry-point group foca.plugins;
    config section plugins.
  • Phases request, route, forward, response; plugins only after
    authentication, validation, access control and sanitation.
  • Allowlist + pins; no runtime install, no runtime management API, no
    runtime enable/disable (config kill switch enabled: false).
  • Client tags gateway.pipeline and gateway.backends; any other client
    gateway.* tag → 400; per-task pipelines on by default.
  • No capability grants ("everything for all"); capabilities are generic
    descriptors in /plugins and public /service-info.
  • Default router foca.routing.ordered (ordered failover; registry
    entries shuffled); 5xx/read timeout = outcome unknown (stop);
    forward_timeout 60 s → 503; Via + self-exclusion against loops.
  • Old middlewares key → startup error with a migration hint.

Surviving the Connexion 3 migration

Hard constraint of the maintainer: nothing here may block FOCA
1.0.0-rc1 (Connexion 3 AsyncApp, no Flask). So foca.plugins has no
flask/werkzeug/connexion/starlette types in interfaces, hook
signatures, models, provenance or the test kit (enforced by an ast-grep
rule); all Connexion 2/Flask glue is in foca.plugins.adapter, which
rc1 replaces; the engine gets an explicit context object instead of
Flask g/request context; hooks become async in P8 by async def
only; the HTTP client and router don't use Werkzeug.

Acceptance criteria

  • All sub-issues closed; foca.plugins documented (operator config,
    author guide, API reference); "Migrating to 0.18.0" mentions the new
    plugins section and the middlewares startup error.
  • proTES can adopt the engine (proTES lane drafts T1–T5) without further
    FOCA changes.

Dependencies

  • None outside this list (no longer blocked by H1-S draft C or D, which
    moved to v0.19.0).

Open questions

  • See the sub-issues (gateway.backends order semantics, 508 vs
    400 for loops, curation of the capability vocabulary).

Sub-issues

Sub-issues

9 of 9 Issues completed
Loading 9 sub-issues

Activity

  1. added this to the v0.18.0 milestone on Oct 24, 2026
  2. added
    priority: high
    status: in progress
    type flag: meta
    type: feature
    workload: weeks
    on Oct 24, 2026
  3. uniqueg commented on Oct 27, 2026

    @uniqueg
    MemberAuthor

    All nine sub-issues (#486 to #494) are closed, and the 0.18 migration guide now covers the plugin engine (#523, PR #531). Closing as completed for 0.18.0. Follow-up design for client backend selection: #528.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: highstatus: in progresstype flag: metatype: featureworkload: weeks

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions