Function reference
Reading the spec
Parse the regen/ tree of a repository into frozen dataclasses.
| spec.load_spec | Read the whole regen/ tree below root. |
| spec.load_architecture | Read regen/architecture.toml. |
| spec.load_unit | Read one regen/units/<stem>.toml file. |
| spec.load_decision | Read one regen/decisions/<id>.toml provenance record. |
| spec.find_repo_root | Walk up from start to the first directory that holds regen/architecture.toml. |
| spec.resolve_unit | Find a unit by its dotted name or by a unique suffix of it. |
| spec.RegenSpec | Everything under regen/: the architecture, the units and the decisions. |
| spec.Architecture | The compilation target every regenerated module must fit into. |
| spec.Unit | A regenerable unit: one module plus the knowledge needed to rebuild it. |
| spec.IntentItem | One intent item of a unit, in the three parts of Fowler, Regenerative Software, ch. 3. |
| spec.Consumer | Something that depends on a unit and would notice its deletion. |
| spec.Decision | A provenance record: why the system has a particular shape. |
| spec.Alternative | A rejected option of a decision, kept because negative knowledge is the most fragile. |
| spec.Field | One field of a record kind: the unit of the schema of regen/. |
| spec.SpecError | A file under regen/ is missing a field or holds a value outside its vocabulary. |
| spec.locate | Find the line of a TOML key such as id = "C-1", or of a table header, in a file. |
| spec.locate_name | Find the line of a name inside the array that holds it. |
| spec.similar | The one candidate that is close to word, or None. |
| spec.hint | The text that a message ends with when a similar name exists, else the empty string. |
| spec.fold | The folded value of a prose string: stripped, every line break one space. |
| spec.has_line_break | Whether value holds a line break: a line feed or a carriage return. |
| spec.skip_string | The end of the TOML string that opens at text[i], and its line-end backslashes. |
| spec.toml_tokens | Split TOML text into strings, comments, line breaks and single characters. |
| spec.module_path | The repository-relative path of the module of a unit, derived from its name. |
| spec.toml_string | The TOML basic string for value; the one string writer of the package. |
Checks
The static check: architecture, units and decisions against the source tree.
| checks.run_checks | Run every check: architecture, all units, all decisions, all archived runs. |
| checks.check_architecture | Check every package import under the source directory against the allowed dependencies. |
| checks.check_unit | Check one unit against its implementation, its evaluations and its consumers. |
| checks.check_decisions | Check every provenance record: evidence resolves, review dates, orphans. |
| checks.Finding | One result of a check. |
| checks.exit_code | The exit code of babregen check for a list of findings. |
| checks.summary_line | The last line of babregen check: units, errors and warnings. |
| scan.find_importers | Every file below root that depends on the module unit. |
Reports and drafts
Markdown reports, the regeneration bundle, compaction candidates, unit drafts and the writers of records.
| reports.deletion_test | Fowler’s deletion test for one unit: the report and the verdict. |
| reports.DeletionResult | The outcome of the deletion test of one unit. |
| context.public_contract | The public contract of a unit: module docstring, signatures and docstrings, no bodies. |
| context.build_context | The regeneration bundle of one unit, as Markdown. |
| compact.compaction_report | The sediment of the spec: what could be removed, merged or has to be re-examined. |
| compact.compaction_summary | The summary line of babregen compact. |
| write.scaffold_unit | Draft regen/units/<unit>.toml for a module that has no unit record yet. |
| write.write_unit | Write the draft of scaffold_unit to disk, reload it and check it. |
| write.new_decision | Create regen/decisions/<id>.toml: the writer behind babregen new-decision. |
| write.add_intent | Append one [[intent]] block to a unit record: the writer behind babregen add-intent. |
| write.add_consumer | Append one [[consumers]] block to a unit record: the writer behind babregen add-consumer. |
| write.Written | What a writer did: the record, the text and, after a write, what is still open. |
Measures
Intent coverage and specification size (read from the files), and the mutation score (planted mutants; runs the evaluations, never part of make guard).
| measures.unit_measures | Measure the intent coverage and the specification size of one unit. |
| measures.measures_table | Pace, intent coverage and specification size of every unit, as a Markdown table. |
| measures.measure_units | The measures of every unit, the rows of babregen measures. |
| measures.UnitMeasures | The pace, the coverage and the size of the specification of one unit. |
| mutation.mutation_score | Run the unit’s evaluations against every mutant of its module. |
| mutation.generate_mutants | All mutants of a module, in source order. |
| mutation.score_markdown | The surviving mutants and the mutation score, as Markdown. |
| mutation.score_toml | The full result as TOML, one [[mutant]] table per mutant, for archiving. |
| mutation.ScoreReport | Mutation score of one unit. |
| mutation.MutantResult | The outcome of running the evaluations against one mutant. |
| mutation.Mutant | One planted change of a module. |
Judge
Judge a candidate module by the acceptance rule accept/1 and record the run (babregen score; calls no model).
| judge.score | Judge a candidate module for unit against a base commit (babregen score). |
| judge.accept | The acceptance rule accept/1. |
| judge.Tally | Counts of one pytest run, or of the dependents of a unit. |
| judge.evaluate | Run tests like run_pytest, counting a timeout as one error. |
| judge.run_pytest | Run tests in worktree against its source directory. |
| judge.run_dependents | Run the unit’s dependents against the module in worktree. |
| judge.scratch_worktree | A detached worktree of rev in which the unit’s module is deleted or replaced. |
| judge.base_commit | The full SHA of HEAD, if the working tree is clean. |
| judge.head_state | The full SHA of HEAD and whether the working tree differs from it. |
| judge.base_inputs | Read a unit, its bundle and its module from commit, not from the working tree. |
| judge.BaseInputs | What the repository recorded about a unit at a commit. |
| judge.tool_versions | The Python and pytest versions and the installed distributions of the scorer. |
| judge.run_keys | The keys that a run.toml of protocol has when the conditions hold. |
| judge.final_table | The [final] table of a run.toml. |
| judge.resolve_python | The interpreter that scores candidates. |
| judge.sha256 | Hex SHA-256 of a file. |
| judge.utc_now | The current UTC time as YYYY-MM-DDTHH:MM:SSZ. |
| judge.write_run_toml | Write run.toml into out and return its text. |
Sample repository
A minimal consistent repository for tests, examples and tutorials.
| sample.make_sample_repo | Write a minimal, consistent repository below root. |
Command line
| cli.main | Run the babregen command line. |
| cli.build_parser | Build the argument parser of the babregen command line. |
| cli.USER_ERRORS | Exceptions that report a problem of the input, not of the tool: main prints them |
| jsonout.check_document | The document of a check: the format number, the summary and the findings. |
| jsonout.error_document | The document of records that do not load: the format number and the error. |
| commands.add_command | Add one command to the sub-parsers and return its parser. |
| commands.registrars | The register function of every module of this package that has one. |
| commands.order | The registers in the order of their position (then of their module and name). |
| commands.position | Decorator that gives a register function its place in the order of --help. |
| schema.json_schema | The JSON Schema of one record kind, as a dict. |
| schema.schema_text | The JSON text of the schema of kind: indent 2, a trailing newline, stable. |
| explain.explain_text | The explanation of one check ID, as babregen explain prints it. |
| explain.example_text | The example record of a kind, as babregen example prints it. |
| explain.Explanation | The explanation of one check ID: a wrong fragment, the corrected one and the fix. |
| explain.EXPLANATIONS | One Explanation per check ID of babregen.checks.CHECKS, in the order of that table. |
| explain.EXAMPLES | One complete, commented, valid record for each record kind. |
| explain.TEMPLATES | Templates of files that are no record: what babregen example prints for them. |
Review
The two human steps of a study (babregen coding and babregen gate): the file formats, the vocabularies, the offline page engine, the reader of a run directory and the steps of the coding and of the gate.
| review.formats.FIELDS | The file kinds and their keys, in the order dump writes them. A key outside the |
| review.formats.FORMAT | The number of the format every review file starts with, as format = 1. |
| review.formats.KINDS | The names of the 13 file kinds. |
| review.formats.Field | One key of a file kind. |
| review.formats.dump | Write a file of kind as TOML text: the one writer of all review files. |
| review.formats.load | Read a review file strictly. |
| review.formats.parse_time | The moment a time stamp of the files names, in UTC; None if it names none. |
| review.formats.validate | Check data against the table of kind. |
| review.vocab.Term | One word of a vocabulary with its definition and a reading hint. |
| review.vocab.names | The words of a vocabulary. |
| review.vocab.drawn_count | The number of drawn survivors, by DRAWN_RULE. |
| review.vocab.CATEGORIES | The categories of a rejected run, in the order of the codebook. |
| review.vocab.CONFIDENCE | How sure the coder is of a category. |
| review.vocab.GAP_ANSWERS | Whether the gap report names the dominant cause; asked only if report.md exists. |
| review.vocab.VERDICTS | The verdicts on a surviving mutant. |
| review.vocab.GATE_STAGES | The three stages of a gate, in order. |
| review.vocab.CODING_STAGES | The two stages of a coding, in order: the own answer, then the final answer after the |
| review.vocab.GATE_STATUS | The stages that babregen.review.gate.status reports, in the order of the gate. |
| review.vocab.GATE_STEPS | The next steps that babregen.review.gate.status reports. |
| review.vocab.CODING_STATUS | The stages that babregen.review.coding.status reports, in the order of the coding. |
| review.vocab.CODING_STEPS | The next steps that babregen.review.coding.status reports. |
| review.vocab.PROTOCOLS | The protocols of the runs that can be coded. |
| review.vocab.QUOTE_ROLES | What a quoted passage of a proposal is. |
| review.vocab.CODING_VOCABULARY | Version of the coding vocabulary, recorded in coding.toml. |
| review.vocab.GATE_VOCABULARY | Version of the gate vocabulary, recorded in gate.toml. |
| review.vocab.DRAWN_RULE | How many of n survivors get a proposal that was written for a verdict assigned at |
| review.page.PageSpec | Everything a page shows and exports. |
| review.page.Item | One thing to answer on a page. |
| review.page.Question | One field of a field set. |
| review.page.MetaField | A text the person types once for the whole page, such as the rater’s name. |
| review.page.Column | One column of the export table: where the value of a key of the file comes from. |
| review.page.build_page | Build the page as one HTML text. |
| review.page.page_sha256 | The hash of a page: SHA-256 of the canonical JSON of its data. |
| review.page.details | A <details> element for long material. |
| review.page.terms_table | A table of the words of a vocabulary, for the intro of a page. |
| review.page.STYLE | The style sheet of a review page. The pages of babregen ui use it too, so that the |
| review.runs.SUMMARY | The line after which evaluations-<n>.txt lists the failing evaluations: the text |
| review.runs.Run | A run directory, read. |
| review.runs.Attempt | One [[attempt]] of run.toml. |
| review.runs.Failure | One failing evaluation as the runner printed it. |
| review.runs.read_run | Read the run directory path. |
| review.runs.failing_evaluations | Parse the block of failing evaluations of an evaluations-<n>.txt. |
| review.runs.evaluation_failures | The failing evaluations of an attempt of run. |
| review.runs.dependents_failures | The lines FAIL ... of dependents.txt, without the word FAIL. |
| review.runs.candidate_file | The kept module of attempt n (<stem>-<n>.py), or None. |
| review.runs.file_at | The text of a project file at commit, wherever the project lies in its repository. |
| review.coding.start | Open a coding: write the manifest, the two briefs and proposals/. |
| review.coding.check | Verify what exists of a coding: the proposals, both pages and both answers files. |
| review.coding.page | Write the page of the next stage: coding-own.html or coding-final.html. |
| review.coding.intake | Take the downloaded answers of the next stage in, byte for byte. |
| review.coding.summary_table | The table printed after the last intake: both answers and the values derived from them. |
| review.coding.Problem | One thing that fails a check, printed as path:line: message. |
| review.coding.Evidence | A proposal of a run that passed, its hash and the check of a second agent. |
| review.coding.Paged | What page wrote. |
| review.coding.Taken | What intake took in. |
| review.coding.status | Where a coding directory stands, and what blocks the next step. |
| review.coding.rebuild_page | The bytes of the page of stage, rebuilt from the files; nothing is written. |
| review.coding.next_stage | The stage whose page is the next one. |
| review.gate.start | Begin a gate session in an empty review directory. |
| review.gate.assign | Assign to every survivor, at random, a verdict that the first agent did not propose. |
| review.gate.seal | Draw the planted proposals and commit to everything by salted hashes. |
| review.gate.page | Build the page of the next stage. |
| review.gate.intake | Take in the downloaded rating file of the next stage. |
| review.gate.check | Verify a gate directory as far as it has come, before and after the reveal. |
| review.gate.excerpt | The definition that holds the changed lines, numbered, the changed lines marked >. |
| review.gate.Started | What start wrote. |
| review.gate.Paged | What page wrote. |
| review.gate.Intaken | What intake did. |
| review.gate.Checked | What check found. |
| review.gate.Failed | Content was checked and fails: the exit code is 1. |
| review.gate.status | Where a gate directory stands, and what blocks the next step. |
| review.gate.rebuild_pages | The bytes of the page of stage, rebuilt from the files; nothing is written. |
| review.gate.next_stage | The stage whose page is the next one. |
| review.gate.ReviewStatus | Where a gate or a coding directory stands, from files with fixed names and git only. |
Drivers
Regeneration with a local model. Non-deterministic: never part of make guard.
| drivers.local | Regeneration with a local model in short sessions (babregen local). |
Browser interface
babregen ui: a server on this machine for the choice of the pilots, the overview and the jobs. Standard library only; reachable from this machine only.
| ui.serve | Serve the interface of the project at root until the process is stopped. |
| ui.check | Load the configuration of the project at root and return the address. |