Skip to content

feat(plugins): list plugin storage - #560

Merged
uniqueg merged 4 commits into
devfrom
feat/551-list-plugin-storage
Oct 29, 2026
Merged

uniqueg merged 4 commits into
devfrom
feat/551-list-plugin-storage

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Shows clients what plugins keep in the plugin store (#557) and where (second part of #545).

  • Plugin.data_stored: a new class attribute, a tuple of strings that the plugin declares (like data_transfers), e.g. ("geolocations of backend hosts", "daily lookup counts per user (hashed)"). Plugin classes with other values are refused at load time.
  • Plugin listing (GET <base>/plugins, GET <base>/plugins/{plugin_id}): each plugin gets data_stored and storage, the effective store mode: shared (database, all processes), local (no database) or off (the operator turned the shared store off for the plugin).
  • OpenAPI (foca/plugins/api.yaml): both fields are required properties of Plugin; storage is an enum. Approved spec change.
  • Docs: plugin guide (listing paragraph, store section).

Closes #551

Verification

  • coverage run -m pytest with a local MongoDB 7.0 on port 12345: 3221 passed, 2 skipped (pre-existing), coverage 100%.
  • ruff check, ruff format --check, mypy: clean.
  • pre-commit run --all-files (incl. semgrep and ast-grep): passed.
  • mkdocs build --strict: passed.
  • CI: all checks passed on f4726fb, after a merge of dev (CI passed, tests on Python 3.11 to 3.15 with MongoDB 7.0 and 8.0, Codecov, Read the Docs).

Declined review findings

  • No data_transfers/data_stored pointer in "Writing plugins" (low, optional): data_stored is documented where plugins use the store, and both in the listing section.
  • No test that a list (not a tuple) is accepted for data_stored (low): the check is shared with data_transfers.
  • No changelog entry: release notes are written at release time (docs/releases/).

Reviews: adversarial and quality review, two rounds. Fixed: the unquoted off in the storage enum, which YAML 1.1 reads as false (high; now quoted, and a test compares the spec's enum with StoreMode); a test that patched private host state (medium); docs wording.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 3 commits October 29, 2026 01:40
Plugins declare what they keep in their store in `data_stored`,
validated like `data_transfers`. The plugin listing shows it, with the
plugin's store mode (`storage`: shared, local or off), so that clients
see which data a plugin keeps and whether it is shared across
processes. The OpenAPI schema of plugins requires both fields.

Closes #551

Co-Authored-By: Claude Opus 5.5 <[email protected]>
YAML 1.1 reads the unquoted `off` as `false`, so the spec didn't allow
the mode `off`. Test that the spec lists the modes of the code, build
the host of the group test from a fake plugin instead of patching
private state, and shorten the listing docs.

Refs #551

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #551

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Adds a validated Plugin.data_stored declaration and exposes it, along with each plugin’s effective shared, local, or off storage mode, through plugin listings and the OpenAPI schema; documentation and focused tests are updated accordingly.

Sequence diagram for plugin storage metadata listing

sequenceDiagram
    participant Client
    participant API
    participant PluginHost
    participant PluginClass
    participant StoreSettings

    Client->>API: GET /plugins/{plugin_id}
    API->>PluginHost: describe_plugin(host, plugin_id)
    PluginHost-->>API: loaded plugin
    API->>PluginClass: read data_stored
    API->>PluginHost: store_settings(plugin_id)
    PluginHost->>StoreSettings: resolve effective mode
    StoreSettings-->>PluginHost: shared | local | off
    API-->>Client: Plugin with data_stored and storage
Loading

Flow diagram for plugin storage metadata exposure

flowchart LR
    Declaration[Plugin declares data_stored] --> Validation[check_plugin_class validates string items]
    Validation --> Listing[Plugin listing]
    Settings[Operator store settings] --> Mode[Effective storage mode]
    Listing --> Response[API response]
    Mode --> Response
    Response --> Fields[data_stored and storage: shared &#124; local &#124; off]
Loading

File-Level Changes

Change Details Files
Expose plugin-declared stored data and effective storage mode in plugin descriptions.
  • Add data_stored metadata to plugin descriptions.
  • Derive storage from host store settings and report shared, local, or off.
  • Require both fields in the OpenAPI Plugin schema and keep its storage enum aligned with StoreMode.
  • Document the new listing fields and plugin store declaration guidance.
foca/plugins/api.py
foca/plugins/api.yaml
docs/plugins.md
Validate plugin storage declarations during plugin loading.
  • Add the data_stored class attribute to the base plugin contract.
  • Reuse declaration validation for data_transfers and data_stored, requiring a tuple or list of strings.
  • Reject invalid storage declarations at load time.
foca/plugins/base.py
Cover metadata exposure, schema consistency, and invalid declarations with tests.
  • Test default and configured storage modes and declared stored data.
  • Verify the OpenAPI enum and required properties match the implementation.
  • Test rejection of invalid data_stored declarations and make plugin setup isolation safer.
tests/plugins/test_plugin_api.py
tests/plugins/test_plugin_basics.py

Assessment against linked issues

Issue Objective Addressed Explanation
#551 Add a validated plugin class attribute, data_stored, for declaring what data the plugin keeps in its store. ✅
#551 Expose each plugin’s data_stored declaration and effective storage mode (shared, local, or off) in the plugin listing API and its schema. ✅
#551 Document the stored-data declaration and storage modes for plugin authors and API users. ✅

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 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (8cac04e) to head (f4726fb).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #560   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines         7008      7010    +2     
=========================================
+ Hits          7008      7010    +2     
Flag Coverage Δ
test_unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 29, 2026 01:28

@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 reviewed your changes and they look great!

Sourcery assessment

Approved.


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

@uniqueg
uniqueg merged commit 17d4e00 into dev Oct 29, 2026
31 checks passed
@uniqueg
uniqueg deleted the feat/551-list-plugin-storage branch October 29, 2026 01:36
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(plugins): list plugin storage

1 participant