Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

build: ship the security layer as its own distribution, codebud-sec - #25

Merged
mkhellat merged 2 commits into
mainfrom
build/codebud-sec-dist
Nov 25, 2026
Merged

mkhellat merged 2 commits into
mainfrom
build/codebud-sec-dist

Conversation

@mkhellat

Copy link
Copy Markdown
Owner

Ships the security layer as its own PyPI distribution, codebud-sec, released together with codebud at one version (option B, decided before 0.1.0). Splitting after a release would have taken codebud-sec away from existing installs on upgrade.

  • pip install codebud is the coding agent.
  • pip install codebud-sec adds the security layer: profiles, engagements, scope guard, network fence, evidence log and the codebud-sec command. It depends on exactly codebud[crypto]==X.Y.Z, because the evidence log is always encrypted.
  • The GNU tarball and make install still carry both.

How

  • The source stays in src/codebud_sec, beside codebud: the core finds the shipped profiles only there.
  • packaging/codebud-sec/ holds its pyproject.toml template and PyPI README. scripts/stage-codebud-sec copies the package, README and COPYING into a build directory and fills in the version.
  • The core's pyproject.toml packages codebud only, and MANIFEST.in prunes src/codebud_sec from its sdist.
  • Builds: make dist-python, the release workflow and release-check build both. release-check also checks that the installed core finds codebud-sec's profiles, which is the point of the split.

Commits

  1. d5b34c2 build: the split, its tests (tests/test_packaging.py) and the docs (README, NEWS, the installation, security, architecture and development chapters).
  2. 6ac6e97 ci(release): the workflow and release-check build, check and publish both.

Verification (local, before CI)

  • Both built for real (python -m build in a throwaway venv):
    • the codebud wheel holds only codebud;
    • the codebud_sec wheel holds the layer (17 files, both profiles), the codebud-sec command and Requires-Dist: codebud[crypto]==0.1.0;
    • twine check --strict passes on all four files.
  • Installed: the core alone lists only default and unattended. Installed with codebud-sec, it also finds security-ir and security-pentest; codebud-sec runs, and pyrage comes in through the dependency.
  • make check (1810 passed), make distcheck, make info and HTML builds without warnings, ruff clean.

CI

This PR changes the build configuration, so CI is needed and runs once on this final head. The review happened locally first; its two findings are already fixed in these commits (see the review comment).

Needed from the maintainer before the first release

A pending publisher for the project codebud-sec on PyPI (and on TestPyPI, for the rehearsal). The values are the same as for codebud: owner mkhellat, repository codebud, workflow release.yml, environment pypi / testpypi.

Decided with the maintainer before 0.1.0 (option B): codebud and
codebud-sec are two PyPI distributions from this repository, released
together at one version.  `pip install codebud` is the coding agent;
`pip install codebud-sec` adds the security layer (profiles,
engagements, scope guard, network fence, evidence log, the codebud-sec
command) and depends on exactly the same codebud with the crypto extra,
since the evidence log is always encrypted.  Splitting after a release
would have taken codebud-sec away from existing installs on upgrade.

The source stays in src/codebud_sec, beside codebud: the core finds
the shipped profiles only there.  packaging/codebud-sec/ holds its
pyproject.toml template and PyPI README; scripts/stage-codebud-sec
copies the package, README and COPYING into a build directory and
fills in the version.  The core's pyproject packages codebud only, and
MANIFEST.in prunes src/codebud_sec from its sdist whatever a stale
egg-info lists.  The GNU tarball and `make install` still carry both.

Verified by building both for real: the codebud wheel holds only
codebud; the codebud_sec wheel holds the layer, both profiles, the
codebud-sec command and Requires-Dist codebud[crypto]==0.1.0; twine
check --strict passes.  Installed alone the core lists no security
profiles; installed together it finds them and codebud-sec runs.

* pyproject.toml (tool.setuptools.packages.find): codebud only.
(project.scripts, tool.setuptools.package-data): Drop codebud_sec.
* MANIFEST.in: New file.
* packaging/codebud-sec/pyproject.toml, packaging/codebud-sec/README.md:
New files.
* scripts/stage-codebud-sec: New script.
* Makefile.am (dist-python): Build both.
(EXTRA_DIST): Ship the new files.
(clean-local): Remove the staging directory.
* .gitignore: Ignore it.
* tests/test_packaging.py: New file.
* README.md, NEWS: Install codebud-sec separately.
* docs/chapters/installation.texi, docs/chapters/security.texi
(Security Work): Likewise.
* docs/chapters/development.texi (Publishing a release): Two
distributions, one pending publisher each; list test_packaging.py.
* docs/chapters/architecture.texi: Mention packaging/codebud-sec.
The release workflow stages and builds codebud-sec beside codebud, runs
twine check on both, and uploads both to TestPyPI and PyPI; each
project needs its own pending publisher with the same workflow and
environments.  release-check's full run builds and checks both,
installs both wheels into its throwaway venv, runs both commands, and
checks that the core finds codebud-sec's profiles -- the point of the
split.

* .github/workflows/release.yml (build): Build codebud-sec too.
* scripts/release-check: Build, check and install both; check that the
core finds the security profiles.
@mkhellat

Copy link
Copy Markdown
Owner Author

Review summary: correct, after two fixes made before CI

One sweep over the delegated implementation, done locally before CI: conditions → scenarios → each checked against the code and against real builds → De Morgan.

Conditions.

  • The codebud wheel holds codebud only.
  • The codebud-sec wheel holds codebud_sec with every profile file, the codebud-sec script, and Requires-Dist: codebud[crypto]==<the core's version>.
  • The installed core lists the security profiles ⇔ codebud_sec is installed beside it.

Verified, with real builds (python -m build in a throwaway venv, then fresh venvs):

  • Both wheels and sdists build, and twine check --strict passes on all four.
  • The wheel contents, metadata and entry points are as above.
  • Core alone: profiles default, unattended, and no codebud-sec. Both installed: security-ir and security-pentest found, codebud-sec runs, pyrage installed.
  • stage-codebud-sec:
    • refuses a non-empty OUTDIR;
    • a failure inside its copy loop propagates (the while subshell's exit status becomes the group's status);
    • the version comes from the root pyproject.toml, and no placeholder is left.
  • The GNU tarball ships MANIFEST.in and packaging/; make distcheck passes; 1810 tests pass.

Findings (both fixed in these commits before pushing):

  1. release-check didn't check the point of the split. It ran both commands but never confirmed the core finds codebud-sec's profiles, which only holds when the two share a site directory. Fixed: it now checks that codebud profiles lists security-pentest.
  2. The core sdist carried part of src/codebud_sec, taken from a stale src/codebud.egg-info (SOURCES.txt) left by an older editable install. Fixed: MANIFEST.in prunes src/codebud_sec, and a test guards it.

Erring on the safe side, as designed: codebud-sec pins codebud==X.Y.Z exactly, because the layer uses core internals (CORE_API), not a public API.

Verdict: correct. I'll merge once CI passes on all five jobs. CI is needed here because the build configuration changed.

@mkhellat

Copy link
Copy Markdown
Owner Author

Merging. The review (two findings, fixed before the push) is above. CI is green on all five jobs at 6ac6e97, macOS included, plus the docs build. CI on the merge is skipped: main has not moved since the branch was cut (b119cef), so the merged tree is exactly the one CI tested. The merge commit carries [skip ci], and I start the docs workflow by hand afterwards to publish the manual changes. A merge commit keeps the two commits as written.

@mkhellat
mkhellat merged commit d49199e into main Nov 25, 2026
7 checks passed
@mkhellat
mkhellat deleted the build/codebud-sec-dist branch November 25, 2026 16:37
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.

1 participant