Skip to content

build: use FOCA 0.18.0 from PyPI - #11

Merged
uniqueg merged 4 commits into
devfrom
build/foca-0.18.0
Oct 28, 2026
Merged

uniqueg merged 4 commits into
devfrom
build/foca-0.18.0

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Summary

FOCA 0.18.0, with the plugin engine and its test kit, is on PyPI. This PR resolves the TODO(FOCA 0.18.0) items of the scaffold (MAINTAINERS.md, step 5):

  • FOCA from PyPI: removes the Git source of FOCA (tool.uv.sources) and re-locks; uv.lock now has foca 0.18.0 from PyPI, with hashes.
  • Bounds: the example plugin and the meta distribution require foca>=0.18.0,<0.19.
  • CI: the test matrix runs FOCA 0.18.0 (the lowest supported version) and FOCA dev (early warning for plugin API changes). Only the 0.18.0 entry with Python 3.13 uploads coverage, chosen by a coverage: true flag on its include entry.
  • Dependabot: updates FOCA again.
  • Template tests: the example plugin's tests use FOCA's test kit (check_plugin_contract, PluginHarness, the builders). Plugins created with scripts/new_plugin.py inherit the contract test. Tasks and backends are built per use, so hooks that change their input in place can't make comparisons pass.
  • Docs: README status, docs/writing-plugins.md (test kinds, contract-check inputs, compatibility), docs/contributing.md, MAINTAINERS.md (step 5 now covers new FOCA minor versions) and the example's README.

The M2 (#7) and M3 (#8) plugins build on this branch.

Closes #6

Verification

Local, on the final tree:

  • uv lock --check: pass; uv sync --locked: foca 0.18.0.
  • pre-commit run --all-files (ruff, mypy, semgrep, ast-grep and its rule tests, gitleaks, actionlint, package conventions): all 15 hooks pass.
  • Example plugin with FOCA 0.18.0 (Python 3.13): 15 tests pass, 100% branch coverage, contract check included.
  • Example plugin as CI installs it (uv sync --locked --package ... --group dev, then FOCA dev from Git; Python 3.11): 15 tests pass, 100% coverage.
  • pytest tests (scripts and docs hooks): 74 pass, 100% coverage.
  • uv build --all-packages and python -m scripts.checks dist dist: pass.
  • mkdocs build --strict: pass.

CI (run 40561276557): all checks pass: CI passed, Changes, Lint, Docs, Test scripts, CodeQL, and Test for the example plugin on Python 3.11, 3.13 and 3.15 × FOCA 0.18.0 and dev.

Review: adversarial and quality reviewers, two rounds. Round 1 had two medium findings (a misleading CI comment about the contract checks, and a shared mutable task in the template tests) and several lows: a hard-coded FOCA version in the Codecov condition, stale or inaccurate comments and docs. All fixed. Round 2 found only lows, all fixed (backends built per use, comment wrapping and wording).

Declined review findings

  • CI-level enforcement of contract tests (e.g., a check that every plugin's tests call check_plugin_contract): the template carries the test and the docs require it; a check of test contents would be brittle. Can follow if plugins from outside contributors start skipping it.
  • A third CI leg with the locked FOCA (skipping the reinstall): with only 0.18.0 released, the locked version is the lowest one. Worth adding once the lock moves past the lowest supported version.
  • Generated test imports exceeding the line length for long plugin names: happens before this branch too; ruff format fixes them, as the docs' checks run it.

🤖 Generated with Claude Code

Summary by Sourcery

Use the released FOCA 0.18.0 plugin API across the workspace, CI, and example plugin template.

Enhancements:

  • Adopt FOCA 0.18.0 from PyPI and constrain plugins and the meta distribution to the supported 0.18 release range.
  • Expand plugin testing to use FOCA’s contract checks and test kit, including harness-based engine tests.
  • Update CI to test both the lowest supported FOCA release and the development branch, with coverage reported only for the designated release matrix entry.
  • Refresh compatibility guidance, maintainer instructions, and plugin documentation for the released FOCA plugin API.

Build:

  • Remove the development Git source override for FOCA and update the lockfile to the PyPI package with hashes.

CI:

  • Allow Dependabot to update FOCA and adjust the CI matrix and coverage selection for FOCA 0.18.0 and dev.

Tests:

  • Update the example plugin tests to use FOCA’s contract checks, harness, builders, and isolated test inputs.

uniqueg and others added 3 commits October 27, 2026 11:31
FOCA 0.18.0, with the plugin engine and its test kit, is on PyPI.
Remove the Git source of FOCA, require foca>=0.18.0,<0.19 in the
example plugin and the meta distribution, and re-lock. CI tests
FOCA 0.18.0 and dev; Dependabot updates FOCA again. The template's
tests use FOCA's test kit (contract checks, harness), so new
plugins inherit them. Docs updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Template tests build a new task per use instead of sharing a
mutable dict. The Codecov upload follows a coverage flag of the
matrix entry instead of a hard-coded FOCA version. Comments and
docs say how contract checks run, that both CI entries replace
the locked FOCA, and which sample inputs plugins should pass;
a stale note on the Git source of FOCA is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The template's tests build their candidate backends per use, like
their tasks, so that hooks that change their input in place can't
make comparisons pass. Rewrap a comment in release.yml; say in the
CI matrix comment which entry reports coverage.

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

sourcery-ai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR completes the FOCA 0.18.0 migration: dependencies now resolve from PyPI with explicit compatibility bounds, CI tests both the lowest supported release and FOCA dev, and the example plugin/template adopt FOCA's contract-testing kit with corresponding documentation and maintenance guidance.

Sequence diagram for plugin contract testing

sequenceDiagram
    participant Tests
    participant Contract as FOCA Contract Checks
    participant Harness as PluginHarness
    participant Plugin
    Tests->>Contract: check_plugin_contract
    Contract->>Plugin: validate metadata and settings
    Tests->>Harness: build plugin test inputs
    Harness->>Plugin: invoke hooks through engine
    Plugin-->>Harness: hook results
    Harness-->>Tests: contract and harness assertions
Loading

File-Level Changes

Change Details Files
Switch FOCA dependency resolution from the development Git branch to the released PyPI package and pin plugin compatibility to the 0.18 minor line.
  • Remove the uv Git source and regenerate the lockfile with FOCA 0.18.0 hashes.
  • Set the example plugin and meta distribution bounds to foca>=0.18.0,<0.19.
  • Allow Dependabot to update FOCA again and update maintainer guidance for future FOCA minor releases.
pyproject.toml
uv.lock
plugins/generic/example/noop/pyproject.toml
meta/pyproject.toml
.github/dependabot.yml
MAINTAINERS.md
Expand CI coverage to validate plugins against both the lowest released FOCA version and FOCA's development branch, while limiting coverage upload to the designated stable matrix entry.
  • Add FOCA 0.18.0 and Git-based dev specifications to the test matrix.
  • Mark the Python 3.13/FOCA 0.18.0 entry as the sole coverage reporter.
  • Update CI comments and dependency auditing behavior for PyPI and Git installations.
.github/workflows/ci.yml
.github/workflows/release.yml
Adopt FOCA's plugin test kit in the example plugin tests and template documentation.
  • Add contract validation, PluginHarness, and FOCA test-kit builders to the example tests.
  • Build task and backend inputs independently for each assertion to prevent shared mutable payloads from masking hook mutations.
  • Document unit, contract, harness, and pipeline test types plus FOCA compatibility requirements.
plugins/generic/example/noop/tests/test_noop.py
docs/writing-plugins.md
Refresh repository and example-plugin status documentation to reflect the released FOCA 0.18 API.
  • Remove references to the unreleased FOCA state and development-only dependency setup.
  • Update the example README and repository status to identify FOCA 0.18 compatibility.
README.md
docs/contributing.md
plugins/generic/example/noop/README.md

Assessment against linked issues

Issue Objective Addressed Explanation
#6 Use FOCA 0.18.0 from PyPI: remove the Git source, update the example and meta distribution's FOCA bounds, re-lock dependencies, and re-enable Dependabot updates for FOCA. ✅
#6 Test plugins against FOCA 0.18.0 and FOCA dev in CI, and add FOCA test-kit contract checks to the template tests while retaining the installed-entry-point pipeline test. ✅
#6 Update compatibility, testing, and maintenance documentation to reflect FOCA 0.18.0 and the new testing and version-update process. ✅

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

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev       #11   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           29        29           
  Branches         3         3           
=========================================
  Hits            29        29           
Flag Coverage Δ
foca-plugin-generic-example-noop 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 27, 2026 18:40

@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 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="plugins/generic/example/noop/tests/test_noop.py" line_range="160" />
<code_context>
     ctx = make_context()
     plugin.on_request(request, ctx)
-    assert request == make_inbound()
+    assert request == make_inbound(make_task())
     assert ctx.annotations == {"label": "gateway-1"}

</code_context>
<issue_to_address>
**Fixed samples allow hard-coded outputs**

When the hooks overwrite requests with the fixed task or return fixed `a`/`b` backends regardless of their inputs, `test_on_request_keeps_request` compares only the fixed `{"name": "task"}` payload, and the route, harness, and pipeline assertions compare only backends `a` and `b`. A regression that replaces every request and candidate list with those constants therefore passes these checks.

Use input payloads and backends with values distinct from the expected constants, then assert the hooks preserve those supplied values.

Also at `plugins/generic/example/noop/tests/test_noop.py:173`, `plugins/generic/example/noop/tests/test_noop.py:214`, `plugins/generic/example/noop/tests/test_noop.py:230-231`.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: plugins/generic/example/noop/tests/test_noop.py:160


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

Tests that check that the template's hooks keep their input pass
values of their own (a task name, backend identifiers), so that a
hook returning the builders' defaults can't pass them. The template's
comment on namespace packages no longer names its own subgroup, which
copies kept.

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

@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.

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 2f79722 into dev Oct 28, 2026
18 checks passed
@uniqueg
uniqueg deleted the build/foca-0.18.0 branch October 28, 2026 00:22
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.

build: use FOCA 0.18.0 from PyPI

1 participant