Skip to main content

babregen

babregen checks the knowledge about a Python package, kept as TOML records in a tracked regen/ tree, against the source tree, and regenerates a module from that knowledge. It is the successor of spotregen: version 0.0.1 starts from spotregen 0.15.0, and spotregen gets no further release.

The idea is Chad Fowler's Regenerative Software: code is disposable, the knowledge around it is the asset. A module is safely replaceable when it can be deleted and rebuilt from knowledge that lives outside its implementation.

  • Standard library only: zero runtime dependencies, Python 3.13 or later.
  • It never imports the modules it describes; it reads the source with ast.
  • A deterministic static check, babregen check, for CI and make guard, with text or JSON output.
  • Commands that write records without rewriting them, explain and example that teach the format, reports, measures, a judge for a candidate module and one driver for a local model.

Install

pip install babregen

or, as a development dependency of a project:

uv add --dev babregen

babregen --version prints the version; python -m babregen works as well.

The first records in ten minutes

In a project with src/acme/util.py and an evaluation in tests/test_regen_eval_util.py, write the architecture record once (babregen example architecture prints a model), then let the commands write the rest:

babregen new-unit util --pace fast
babregen new-decision why-clamp --title "Values are clamped in one place" \
    --driver "Three modules had their own copy of the range check." \
    --decision "acme.util.clamp is the only place that limits a value." \
    --approved-by maintainer
babregen add-intent util --scope clamp --invariant "clamp(v, lo, hi) lies between lo and hi" \
    --reason "Callers use the result as an index." \
    --evaluation test_clamp_limits_the_value --decision why-clamp
babregen check

A finding names the file, the line and, when one exists, the name you probably meant, and babregen explain ID says what an ID means. Prose in a record is wrapped over several lines and needs no backslash. The complete walk-through, with a project that you build and a sample repository that you break and repair, is the Quickstart.

Commands

babregen check [--strict] [--format json]  # the static check: exit 1 on errors
babregen deletion-test UNIT          # blast radius and knowledge gaps
babregen context UNIT [-o FILE]      # regeneration bundle, no bodies
babregen compact                     # compaction candidates
babregen measures                    # pace, intent coverage and specification size
babregen mutate UNIT [--out FILE]    # mutation score: planted mutants
babregen new-unit MODULE --pace P [--dry-run]
babregen new-decision ID --title T --driver T --decision T --approved-by NAME [--dry-run]
babregen add-intent UNIT --scope T --invariant T --reason T [--evaluation NAME]... [--dry-run]
babregen add-consumer UNIT REF [--kind K] [--note T] [--dry-run]
babregen explain ID                  # what a check means: a wrong and a right fragment, the fix
babregen example KIND                # one complete, commented record of a kind
babregen schema KIND [-o FILE]       # JSON Schema of architecture, unit or decision, for editors
babregen score UNIT FILE [--base REV] # judge a candidate module: evaluations, unit tests, dependents
babregen local UNIT --model M --model-sha256 HEX --context-length N --protocol ID [...]
                                      # regenerate with a local LM Studio model
babregen coding start DIR RUN...     # code why rejected runs were rejected: steps start,
babregen coding check DIR [RUN]      #   check, page and intake; the rater answers on an
babregen coding page DIR             #   two offline pages: own answer, then final answer
babregen coding intake DIR FILE
babregen gate start DIR REPORT...    # rate the surviving mutants with a sealed plant: steps start,
babregen gate assign DIR             #   assign, seal, page, intake and check, on three
babregen gate seal DIR               #   offline pages
babregen gate page DIR
babregen gate intake DIR FILE
babregen gate check DIR

--root DIR selects the repository (default: search upwards for regen/architecture.toml). A repository carries:

  • regen/architecture.toml: the compilation target (allowed imports, accepted cycles, pace policy, conventions, scan directories).
  • regen/units/<stem>.toml: one regenerable unit with intent, evaluations and consumers. The unit is <package>.<stem> and the module path follows from the name.
  • regen/decisions/<id>.toml: provenance records.

coding and gate are the two human steps of a study; see The two human steps.

score, local and mutate need a git repository with a commit; the project (the folder with regen/) may be the repository itself or a subfolder of it.

A command that writes a record only creates a file or appends one complete block; it never rewrites existing text, checks the result with the strict loader first, prompts for nothing and has --dry-run. The loaders are strict: a key outside the schema stops the tool with exit code 2.

The seven primitives

The tool presents Fowler's seven primitives. Each has a record artefact, a family of check IDs named after it, and a command that a reader can run. A test reads the IDs from the table of checks, so this table cannot go stale.

primitive record artefact IDs command
intent [[intent]] of regen/units/<stem>.toml INTENT01–INTENT02 context (section Intent)
compilation regen/architecture.toml; unit public and depends_on COMPILE01–COMPILE08 check
evaluation evaluation files; unit evaluations, item evaluations EVAL01–EVAL05 mutate, score
provenance regen/decisions/<id>.toml; regen/runs/*/run.toml PROV01–PROV10 context (section Provenance), check
pace unit pace; [pace] of architecture.toml PACE01–PACE04 measures (column pace), context (the policy of the pace)
deletion [[consumers]] of a unit DELETE01–DELETE03 deletion-test, score, local
compaction known_cycles; decision status COMPACT01–COMPACT07 compact

Develop

make sync && make test-fast     # environment and fast tests
make verify                     # guard + lint + test + doc, the pre-release verification

See CONTRIBUTING.md and RELEASING.md.

License

AGPL-3.0-or-later.

Metadata

Release files for babregen 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for babregen 0.2.0
File Size Uploaded Provenance Actions
babregen-0.2.0.tar.gz 203.7 kB Without provenance Details for babregen-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for babregen 0.2.0
File Interpreter ABI Platform Actions
babregen-0.2.0-py3-none-any.whl Python 3 none any Details for babregen-0.2.0-py3-none-any.whl

Total release size: 432.2 kB

Release files / babregen-0.2.0.tar.gz

Download URL babregen-0.2.0.tar.gz
Size 203.7 kB
Tags Source
SHA-256 checksum
How to use checksums
97d4697025d32735519bc910b69e9e462ae4da6d5a432c3d48986202ab333d61
BLAKE2b-256 checksum
How to use checksums
ed2714952dee97e2c688a8b09abd929ac6a9c80c60da20faa382aa82891008f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / babregen-0.2.0-py3-none-any.whl

Download URL babregen-0.2.0-py3-none-any.whl
Size 228.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d81db8d030349f0c62951e558efb638ac29198f274b23e0ec271db512367a31c
BLAKE2b-256 checksum
How to use checksums
699018ab9ce07800afd738e671615fa5c978eea414eacb6a8258c4960a3547df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for babregen 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page