Skip to content

build: set up the plugin monorepo - #2

Merged
uniqueg merged 18 commits into
devfrom
feat/scaffold
Oct 25, 2026
Merged

uniqueg merged 18 commits into
devfrom
feat/scaffold

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR sets up the foca-plugins monorepo, following cloud-registry's conventions adapted to a monorepo of plugin packages.

  • Layout:
    • A uv workspace root, for development only and never published.
    • plugins/<group>/<subgroup>/<name>/ with one distribution per plugin, named foca-plugin-<group>-<subgroup>-<name>. The foca_plugins.* packages are PEP 420 namespace packages.
    • meta/ holds the foca-plugins meta distribution. It is calendar-versioned and has extras per group; the extras stay empty until the first plugins are released.
  • Example plugin: generic.example.noop is a copyable template. It is never published: it has the Private :: Do Not Upload classifier, belongs to no extra, and the release workflow refuses its tags. scripts/new_plugin.py creates new plugins from it.
  • Scripts (scripts.packages, scripts.checks, scripts.release):
    • change detection (with --no-renames) and the package matrix;
    • package convention checks (namespace layout, unique distribution names, no -v<digit> name parts);
    • wheel checks;
    • tag validation and release notes.
  • Tooling: ruff, mypy, pytest with 100% branch coverage, and pre-commit with actionlint, semgrep and gitleaks. There is also an ast-grep rule that forbids web framework imports in plugins.
  • CI (ci.yml):
    • Jobs: Changes, Lint, Test (per package, Python 3.11/3.13/3.15 × FOCA dev, Codecov per package flag), Test scripts, Docs.
    • The gate CI passed allows only the skip of Test when no plugin changed.
  • Release (release.yml):
    • Per-package tags <distribution>-v<version>, with one concurrency group per tag.
    • Before any build, the tag is validated against the package and must be on main.
    • Builds use pinned uv and setuptools and the commit time as SOURCE_DATE_EPOCH. twine comes from a locked group.
    • Publishing uses PyPI Trusted Publishing from the pypi environment, with attestations. The release starts as a draft and is published last.
    • This workflow is untested. It needs a dry run in a fork against TestPyPI before the first tag.
  • Docs: MkDocs on Read the Docs, with these pages:
    • overview;
    • installing (meta extras, single distributions, derived images);
    • writing plugins;
    • catalogue (generated from the plugin READMEs);
    • contributing;
    • releasing.
  • Policy files: CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, CITATION.cff, CODEOWNERS, Dependabot, .gitignore, .editorconfig. Maintainer setup notes are in MAINTAINERS.md, kept out of the public docs.

FOCA is installed from its dev branch until v0.18.0, the plugin engine, is released. The places to change are marked TODO(FOCA 0.18.0).

Closes #1

Verification

Run locally on the final tree:

  • uv sync, with FOCA dev installed from git: pass.
  • pre-commit run --all-files (ruff, mypy, actionlint and shellcheck, semgrep, ast-grep, gitleaks, package conventions): pass.
  • pytest: 55 script tests and 13 plugin tests pass, with 100% branch coverage.
  • mkdocs build --strict and uv lock --check: pass.
  • uv build --all-packages and the dist checks: pass.
  • Two builds of the same commit give identical wheel hashes.
  • A dry run of new_plugin.py tes routing distance passed its checks and tests. The generated plugin was then removed.

Review: two rounds of adversarial and quality review. Fixed:

  • release runs cancelled when several tags are pushed;
  • unpinned tools running before artifacts are attested;
  • renames escaping change detection;
  • previous-tag selection matching other packages, pre-releases and -v<digit> names;
  • non-reproducible wheels;
  • errors hidden in release lookups;
  • the Python matrix and requires-python wording;
  • oversized scripts;
  • maintainer notes in the public docs;
  • commit order.

CI (first run): all 12 checks pass. That covers CI passed, Changes, Lint, Test on Python 3.11, 3.13 and 3.15 against FOCA dev, Test scripts, Docs, and Codecov patch and project per package.

Sourcery: 13 findings. 12 were fixed in the commits on top of c028e9a; one, the subprocess audit rule, is suppressed inline with a reason in 211d24f. After that, CI is all green again, including the Sourcery review check.

Declined review findings

  • Reproducible sdists: setuptools stores file and gzip times in sdists and ignores SOURCE_DATE_EPOCH, so sdists of the same commit still differ. This is harmless as long as only failed jobs are re-run, which the docs and the workflow comment require. Fully reproducible sdists would need another build backend, e.g. hatchling or uv_build. That can be a follow-up if wanted.

🤖 Generated with Claude Code

uniqueg and others added 12 commits October 25, 2026 05:33
Add the code of conduct, the security policy, code owners, editor
settings and the ignore list from cloud-registry, adapted to a
repository of plugin distributions, with the caches of a monorepo, and
fill in the license's copyright line.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the root `pyproject.toml`, a virtual uv workspace root for
development only (never built or published), with the meta
distribution and every `plugins/<group>/<subgroup>/<name>/` as
members. It holds the shared configuration of ruff, mypy, pytest and
coverage (100%), following cloud-registry, the dependency groups `dev`,
`docs` and `release` (twine, locked), and pins the build backend for
reproducible release builds.

FOCA comes from its dev branch, where the plugin engine is, until
0.18.0 is released (marked with TODOs).

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the plugin `generic.example.noop`, a complete minimal distribution
against the plugin API on FOCA's dev branch (`foca.plugins.Plugin`,
entry point group `foca.plugins`): settings models, metadata with an
explicit description, `request` and `route` hooks that change nothing
and record annotations, PEP 420 namespace packages, unit tests and a
pipeline test through FOCA's engine (100% coverage), a README and a
changelog.

It is the template of new plugins and is never published: it carries
the `Private :: Do Not Upload` classifier, which PyPI refuses.
`requires-python` is FOCA's (>=3.11).

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the meta distribution `foca-plugins`: no code, calendar-versioned
(a release train), with extras per group (`generic`, `tes`, `wes`),
`all` (stable plugins) and `experimental`. The extras stay empty until
the first plugins are released; the example plugin is never published,
so it is in none of them.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the repository's scripts, run as `python -m scripts.<name>`, each
command used by a workflow or hook (named in the module docs):

- `packages`: discovery of the packages, CI's change detection
  (`changed`, without rename detection, so that moves affect both
  packages) and mypy with the plugins' `src/` on the search path;
- `checks`: the package conventions (`check`) and built wheels (`dist`);
- `release`: the package of a release tag, refusing other versions and
  the example plugin, and its notes from the changelog;
- `new_plugin`: copies the example plugin to a new group, subgroup and
  name.

Add their tests, at 100% coverage.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the pre-commit hooks of cloud-registry (pre-commit-hooks, ruff,
semgrep, gitleaks, actionlint, ast-grep with rule tests, mypy) and a
hook for the package conventions.

Add the ast-grep rule `no-framework-imports`, which refuses imports of
Flask, Werkzeug, Connexion, Starlette and `foca.plugins.adapter` in the
plugins' code, with tests; keep cloud-registry's `pydantic-v1-dict`.
Add semgrep rules for unverified tokens and disabled TLS verification,
and the Sourcery configuration.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add READMEs to `plugins/` and to the groups `generic`, `tes` and `wes`:
groups follow the gateway API, subgroups the function (routing, policy,
data, identity, example).

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the generated README with one in the structure of
cloud-registry's: badges, what the repository is and how it relates to
FOCA, proTES and proWES, its status, installation, layout and naming
conventions, and contributing, with sections that the docs include.

Add CONTRIBUTING.md, MAINTAINERS.md (repository settings, done and open
setup tasks; not part of the published docs) and CITATION.cff, without
a version, as every distribution has its own.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the documentation, set up as in cloud-registry (MkDocs with
Material, strict builds, Read the Docs): overview, installing (meta
extras, single distributions, the derived-image recipe; nothing is
published yet), writing a plugin (FOCA's plugin docs for the API, plus
the conventions of this repository), the plugin catalogue, contributing
and releasing.

A docs hook generates the catalogue from the plugins' READMEs; its
tests run with those of the scripts, at 100% coverage. Read the Docs
installs the `docs` dependency group with pip.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add `ci.yml` (`CI`), named and gated as in cloud-registry and FOCA:

- `changes` maps the changed files to the affected plugins;
- `lint` runs pre-commit (incl. mypy of all packages and the package
  conventions), gitleaks and cffconvert, and builds and checks all
  distributions, with `uv.lock` checked to be up to date;
- `test` runs per affected plugin, on FOCA's lowest and highest
  declared Python (3.11, 3.15) and the default 3.13, with FOCA dev:
  ruff, ast-grep, mypy, pytest at 100% coverage (uploaded to Codecov
  with the distribution name as the flag) and pip-audit, each plugin
  installed alone;
- `scripts` tests the scripts and docs hooks; `docs` builds the docs;
- `passed` (`CI passed`) is the gate, which allows only the skip of
  `test` when no plugin is affected.

uv comes from `astral-sh/setup-uv`, pinned by commit. No `paths:`
filters. Add `codecov.yml` with 100% targets and carried forward
flags.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add `release.yml` (`Release`) as an untested draft, marked as such: a
tag `<distribution>-v<version>` releases that package, in a run of its
own (concurrency per tag). Before anything is built, it checks the tag
against the package's version and refuses the example plugin, then
that the commit is on `main`. It builds with pinned tools (setup-uv by
commit, the pinned build backend, twine from `uv.lock`), attests the
build provenance, publishes to PyPI with trusted publishing from the
`pypi` environment and PEP 740 attestations (as in FOCA), and creates
the GitHub release from the package's changelog. `## Commits` holds
GitHub's notes since the package's own previous tag or, on a first
release, the commits of the package's directory.

The build uses the commit's time as `SOURCE_DATE_EPOCH`, which makes the
wheels reproducible; sdists of the build backend are not, so only
"Re-run failed jobs" may complete a partial release (documented). The
previous tag is the package's newest among the tag's ancestors; only a
missing GitHub release counts as none, other errors fail.

It needs a dry run in a fork before the first release.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Update the uv workspace (`uv.lock` and all `pyproject.toml` files), the
actions and the pre-commit hooks monthly, against `dev`, grouped as in
cloud-registry. FOCA is left out while it comes from its dev branch.

Refs #1

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

sourcery-ai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Sets up the complete foca-plugins monorepo: a uv-managed workspace with a template plugin and meta distribution, convention and release tooling, comprehensive CI/security automation, documentation, and operational policy files. Review the package-discovery and validation rules first, then the isolated CI matrix and draft release workflow, with particular attention to tag handling, artifact reproducibility, trusted publishing prerequisites, and the documented FOCA 0.18.0 transition.

Sequence diagram for the per-package release workflow

sequenceDiagram
    participant Maintainer
    participant GitHub as GitHub Actions
    participant Validator as scripts.release
    participant Builder as uv and setuptools
    participant Attestor as Attestation service
    participant PyPI
    participant Release as GitHub Release

    Maintainer->>GitHub: Push <distribution>-v<version> tag
    GitHub->>Validator: release TAG
    Validator-->>GitHub: Package, version and path
    GitHub->>Validator: checks check and notes TAG
    GitHub->>Builder: uv build --package NAME
    Builder-->>GitHub: Wheel and sdist
    GitHub->>Attestor: Attest build provenance
    Attestor-->>GitHub: Provenance attestation
    GitHub->>PyPI: Publish distributions with trusted publishing
    PyPI-->>GitHub: PEP 740 attestations
    GitHub->>Release: Create draft release and upload distributions
    GitHub->>Release: Publish release
Loading

Flow diagram for affected-plugin CI testing

flowchart TD
    Changes["scripts.packages changed"] --> Affected["Affected plugin matrix"]
    Affected --> Lint["Lint and build distributions"]
    Affected --> Test["Test each plugin"]
    Test --> Matrix["Python 3.11 / 3.13 / 3.15\nFOCA dev"]
    Lint --> Gate["CI passed"]
    Test --> Gate
    Scripts["Test scripts"] --> Gate
    Docs["Build docs"] --> Gate
    Lint --> Gate
Loading

File-Level Changes

Change Details Files
Establishes the uv workspace and package conventions for independently versioned FOCA plugin distributions plus a calendar-versioned meta distribution.
  • Adds the workspace root, dependency groups, lockfile, shared tool configuration, and metadata for the meta package.
  • Defines PEP 420 namespace layout, entry-point registration, licensing, naming, and wheel validation rules.
  • Adds the generic example plugin as a non-publishable template with comprehensive tests.
pyproject.toml
uv.lock
meta/pyproject.toml
meta/README.md
meta/CHANGELOG.md
plugins/README.md
plugins/generic/README.md
plugins/generic/example/noop/**
plugins/tes/README.md
plugins/wes/README.md
LICENSE
Adds repository automation for discovering packages, scaffolding plugins, validating conventions and distributions, and preparing release metadata.
  • Implements affected-package detection with rename-safe Git diffs and per-package mypy execution.
  • Implements plugin generation from the template, including name/path/class substitutions and generated documentation.
  • Validates package structure, namespace packages, unique names, meta extras, licenses, wheel contents, release tags, and changelog sections.
scripts/packages.py
scripts/new_plugin.py
scripts/checks.py
scripts/release.py
tests/**
Builds CI and release workflows around isolated package testing, security checks, reproducible wheels, attestations, and trusted publishing.
  • Adds lint, type, security, package-build, per-plugin test matrices across Python 3.11/3.13/3.15, script tests, documentation builds, coverage, and a single CI gate.
  • Adds tag-scoped release concurrency, pre-build tag/main validation, pinned build tooling, artifact attestations, PyPI Trusted Publishing, and draft GitHub releases.
  • Documents the release workflow's untested status and non-reproducible sdist limitation.
.github/workflows/ci.yml
.github/workflows/release.yml
.pre-commit-config.yaml
.github/dependabot.yml
codecov.yml
Adds static-analysis rules and project policies to constrain plugin security and framework independence.
  • Forbids web-framework and FOCA adapter imports and flags Pydantic v1 .dict() usage in plugin code.
  • Adds Semgrep rules for unverified JWT decoding and disabled TLS verification.
  • Adds pinned pre-commit checks for actionlint, Ruff, mypy, gitleaks, package conventions, ast-grep, and security scans.
.ast-grep/**
sgconfig.yml
.semgrep/foca-plugins.yml
.sourcery.yaml
Adds the public documentation, contributor guidance, governance policies, and maintainer operational notes for the monorepo.
  • Documents installation, plugin authoring, catalogue generation, development, versioning, changelogs, and releases.
  • Adds dynamic MkDocs catalogue generation from plugin READMEs and strict Read the Docs configuration.
  • Adds contribution, security, conduct, citation, ownership, dependency-update, and maintainer setup policies.
docs/**
mkdocs.yml
.readthedocs.yaml
README.md
CONTRIBUTING.md
MAINTAINERS.md
SECURITY.md
CODE_OF_CONDUCT.md
CITATION.cff
.github/CODEOWNERS

Assessment against linked issues

Issue Objective Addressed Explanation
#1 Establish the plugin monorepo structure, shared tooling, CI gate, per-package release workflow, and repository policy files. ✅
#1 Provide a copyable example plugin and plugin-generation script, with the example passing checks at 100% coverage against FOCA dev. ✅
#1 Provide the requested documentation, including maintainer setup notes at docs/maintainers.md. ❌ The documentation covers the requested public topics, but maintainer setup notes are placed in the repository-root MAINTAINERS.md rather than the docs/maintainers.md file required by the acceptance criteria.

Possibly linked issues

  • build: set up the plugin monorepo #1: The PR directly implements the issue's monorepo setup and acceptance criteria, including CI gate, checked example plugin, and strict MkDocs build.

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 25, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@uniqueg
uniqueg marked this pull request as ready for review October 25, 2026 04:58

@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 security issue, and 12 other issues

Security issues:

  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="scripts/checks.py" line_range="158" />
<code_context>
+            if PRIVATE_CLASSIFIER in project.get("classifiers", []):
+                problems.append(f"[{extra}] {plugin.name} is never published")
+            listed.setdefault(plugin.name, set()).add(extra)
+    for name, names in listed.items():
+        group, subgroup, _ = projects[name][0].parts
+        for extra in (group, f"{group}-{subgroup}"):
</code_context>
<issue_to_address>
**Omitted plugins pass meta checks**

When a publishable plugin is absent from every optional-dependency list, `_check_meta` iterates only over plugins already in `listed`, so it never checks the omitted plugin in `projects` and `scripts.checks check` passes; users installing its group or `[all]` do not receive it.

Validate every non-private plugin in `projects` and require it in its group extras and exactly one of `[all]` or `[experimental]`.
</issue_to_address>

### Comment 2
<location path="scripts/checks.py" line_range="232-233" />
<code_context>
+            problems.append(f"{wheel.name}: no package of this repository")
+            continue
+        current = package_version(package, root)
+        if version != current:
+            problems.append(f"{wheel.name}: version is not {current!r}")
+        info = f"{name}-{version}.dist-info/"
+        module = (
</code_context>
<issue_to_address>
**Prerelease wheels fail release checks**

When a package uses a valid hyphenated prerelease version, `check_dist` compares the normalized wheel filename version with the raw project version, so CI and release builds reject the wheel; the release workflow also looks for a wheel using the raw version.

Use the normalized version consistently when validating wheel filenames and locating release artifacts.

Also at `.github/workflows/release.yml:81`, `.github/workflows/release.yml:124`, `.github/workflows/release.yml:258-259`.
</issue_to_address>

### Comment 3
<location path=".github/workflows/release.yml" line_range="258" />
<code_context>
+              # `--match` takes globs: check the tag exactly (names have no
+              # parts like `-v<digit>`, so other packages' tags don't match)
+              if [[ -n "${previous}" ]] \
+                  && ! grep -qE "^${NAME}-v[0-9][^-]*$" <<< "${previous}"; then
+                  echo "::error::Unexpected previous tag ${previous}"
+                  exit 1
</code_context>
<issue_to_address>
**Prerelease tags block release completion**

When the newest ancestor tag for the package is a SemVer prerelease, such as `foca-plugin-example-v1.0.0-rc.1`, the `grep` check rejects a valid SemVer prerelease tag such as `-rc.1`, so the release job exits after PyPI has accepted the distribution and leaves the GitHub release unfinished.

Validate previous tags with a pattern that accepts valid prerelease versions, or use a version parser instead of excluding hyphens.
</issue_to_address>

### Comment 4
<location path=".github/workflows/release.yml" line_range="55" />
<code_context>
+    outputs:
+      packages: ${{ steps.detect.outputs.packages }}
+    steps:
+      - name: Check out repository
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+        with:
</code_context>
<issue_to_address>
**Release artifacts use different commits**

When the tag is moved to another main commit while a release run is between build and publish, `build` validates and packages the original tag target, but the later `publish` checkout resolves the tag again and reads its new target for release notes. `--verify-tag` checks only that the tag exists, so GitHub can publish the original distributions with notes for the new commit.

Pin both checkouts and tag-based Git operations to the event commit, and fail before publishing if the tag no longer points to it.

Also at `.github/workflows/release.yml:198`.
</issue_to_address>

### Comment 5
<location path=".github/workflows/release.yml" line_range="188" />
<code_context>
+          attestations: true
+          # PyPI files are immutable; skip those already uploaded, so that
+          # re-running a partially failed upload completes the release
+          skip-existing: true
+
+  publish:
</code_context>
<issue_to_address>
**Moved tags leave stale release artifacts**

When an existing release tag is force-updated to another `main` commit that retains the same package version, the release job skips existing PyPI files, then exits when it finds an already-published GitHub release. If a release tag is moved to a different `main` commit with the same package version, the tag points at the new code while PyPI and the GitHub release retain the old artifacts.

Protect release tags from updates and fail a run if an existing published release does not match the tagged commit and its artifacts.

Also at `.github/workflows/release.yml:246-248`.
</issue_to_address>

### Comment 6
<location path="scripts/checks.py" line_range="164" />
<code_context>
+            if extra not in names:
+                problems.append(f"{name} is missing in [{extra}]")
+        if len(names & {"all", "experimental"}) != 1:
+            problems.append(f"{name} must be in exactly one of [all], [experimental]")
+    return problems
+
</code_context>
<issue_to_address>
**Maturity mismatches pass checks**

When a plugin's pin is in the extra that does not match its declared maturity, `_check_meta` checks only that a listed plugin appears in exactly one of `[all]` or `[experimental]`; it does not compare that extra with the plugin's maturity, so users receive the wrong plugin set.

Have `_check_meta` verify that each plugin's `[all]` or `[experimental]` placement matches its declared maturity.
</issue_to_address>

### Comment 7
<location path="scripts/checks.py" line_range="91" />
<code_context>
+                f"{namespace.relative_to(root)} must be a namespace package"
+                " (no __init__.py)"
+            )
+    for required in ("README.md", "CHANGELOG.md", "tests"):
+        if not (directory / required).exists():
+            problems.append(f"{required} is missing")
</code_context>
<issue_to_address>
**Typed plugins lack their marker**

When a plugin's `py.typed` marker is missing from its source or built wheel, `check` and `check_dist` accept the plugin without `py.typed`, so it can be published with `Typing :: Typed` while downstream type checkers treat its inline types as unavailable.

Require `py.typed` in the plugin source and in the built wheel.

Also at `scripts/checks.py:251`.
</issue_to_address>

### Comment 8
<location path="scripts/release.py" line_range="76-81" />
<code_context>
+    package = release(tag, root)
+    text = (root / package["path"] / "CHANGELOG.md").read_text()
+    heading = re.compile(rf"^## {re.escape(package['version'])}(\s.*)?$", re.M)
+    match = heading.search(text)
+    if match is None:
+        raise ValueError(
+            f"{package['path']}/CHANGELOG.md has no section '## {package['version']}'"
+        )
+    following = re.compile(r"^## ", re.M).search(text, match.end())
+    body = text[match.end() : following.start() if following else None].strip()
+    if not body:
</code_context>
<issue_to_address>
**Duplicate versions hide release notes**

When a package changelog contains two `## <version>` headings for the release version, `heading.search` selects the first matching version section and `notes` stops at the next level-two heading. The release workflow publishes only that section, silently omitting content in a second section with the same version.

Reject changelogs with more than one matching version heading before returning release notes.
</issue_to_address>

### Comment 9
<location path="scripts/new_plugin.py" line_range="209" />
<code_context>
+    target = root / new["directory"]
+    if target.exists():
+        raise FileExistsError(f"{new['directory']} exists")
+    shutil.copytree(root / old["directory"], target, ignore=IGNORED)
+    src = target / "src"
+    shutil.rmtree(src / "foca_plugins")
</code_context>
<issue_to_address>
**Failed generation blocks retries**

When generation stops or a filesystem error occurs after package creation starts, `create` writes directly into the final target, leaving partial files behind; the next call rejects the existing target, so the caller must remove it manually before retrying.

Build the package in a temporary directory and move it to the final target only after generation succeeds.
</issue_to_address>

### Comment 10
<location path="docs/hooks.py" line_range="82" />
<code_context>
+    """
+    rows = []
+    for package in packages.plugins(packages.discover(root)):
+        project = packages.load_pyproject(root / package.path / "pyproject.toml")
+        published = packages.PRIVATE_CLASSIFIER not in project["project"].get(
+            "classifiers", []
</code_context>
<issue_to_address>
**Unreleased plugins appear published**

When a generated plugin has not yet had a release, `catalogue` treats the absence of `Private :: Do Not Upload` as proof of publication, so it marks the plugin as available before its distribution exists.

Determine publication status from release availability rather than the absence of the private classifier.

Also at `docs/hooks.py:83-85`.
</issue_to_address>

### Comment 11
<location path="tests/test_packages.py" line_range="164" />
<code_context>
+        monkeypatch: Patches.
+    """
+    monkeypatch.setattr(packages, "changed_files", lambda *_: ["docs/index.md"])
+    assert packages.main(["changed", "a", "b"], repo) == 0
+
+
</code_context>
<issue_to_address>
**Wrong plugin selection passes test**

When `packages.main` prints a matrix that selects the wrong plugins, `test_main_changed` checks only the zero exit status, so it passes without verifying the printed selection.

Capture and assert the expected output, including `[]` for the docs-only change.
</issue_to_address>

### Comment 12
<location path="tests/test_packages.py" line_range="174" />
<code_context>
+        repo: Repository root.
+        monkeypatch: Patches.
+    """
+    monkeypatch.setattr(packages, "mypy", lambda paths, root: len(paths))
+    assert packages.main(["mypy", "a", "b"], repo) == 2
</code_context>
<issue_to_address>
**Mypy invocation can go unchecked**

When the mypy command returns the path count instead of invoking mypy, when `packages.main` returns the number of requested paths without invoking mypy, `test_main_mypy` still passes: its mock returns `len(paths)`, which is also 2 for the two supplied paths. Use a distinct mock exit code and assert the mock was called with the expected arguments.

Have the mock return a value distinct from the path count and assert it was called with the paths and root.
</issue_to_address>

### Comment 13
<location path="scripts/packages.py" line_range="255-257" />
<code_context>
    return subprocess.run(
        [sys.executable, "-m", "mypy", *targets], cwd=root, env=env, check=False
    ).returncode
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 13 findings to address first, and a mistake in the release workflow could publish incorrect distributions to PyPI; those files and published releases cannot be fully undone by reverting this PR. Reverting would stop future runs, but any artifacts already published would remain.

Blocking findings: scripts/checks.py:158, scripts/checks.py:233, .github/workflows/release.yml:258, .github/workflows/release.yml:55, .github/workflows/release.yml:188, and 8 more


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

Comment thread scripts/checks.py Resolved
Comment thread scripts/checks.py Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread scripts/new_plugin.py Resolved
Comment thread docs/hooks.py Resolved
Comment thread tests/test_packages.py Resolved
Comment thread tests/test_packages.py Resolved
Comment thread scripts/packages.py Resolved
uniqueg and others added 6 commits October 25, 2026 06:18
Check the meta distribution's extras for every plugin that may be
published and is released (has a version section in its changelog) or
listed, not only for listed ones: it must be in its group's and
subgroup's extras, and in `[all]` or `[experimental]` according to the
`maturity` of its class (read from the code). Pins must name released
versions.

Require normalized PEP 440 versions (no epoch or local part), so that
versions, wheel names and release tags agree, and `py.typed` in each
plugin's module and wheel.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check out and use the pushed commit (`github.sha`) instead of the tag,
and fail before publishing to PyPI and before creating the GitHub
release if the tag no longer points to it. Fail if a published release
exists whose assets differ from the built distributions.

Find the previous tag with `python -m scripts.release previous`, which
checks the found tag exactly (normalized PEP 440 versions, pre-releases
included), and refuse changelogs with several sections of the released
version. Mark post releases of pre-releases as GitHub pre-releases.
Document the tag ruleset that the maintainer must add.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build the new package in a temporary directory next to the plugins and
move it into place, so that a failure leaves nothing behind.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the column "Published", which called unreleased plugins
published, with "Latest release": the topmost version section of the
plugin's changelog, "not yet released" without one, and "never" for the
example. No network lookups at build time.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assert the printed matrix of `changed`, including `[]`, and that the
`mypy` command passes its arguments and returns mypy's status.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sourcery's opengrep check blocks on the subprocess audit rule. The
arguments are lists built from repository data and no shell is
involved, so suppress the rule inline with that reason.

Refs #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit a05aa01 into dev Oct 25, 2026
13 checks passed
@uniqueg
uniqueg deleted the feat/scaffold branch October 25, 2026 14:28
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: set up the plugin monorepo

1 participant