Skip to main content

The two human steps

A study of regeneration has two steps that a person has to do. When a candidate module is rejected, a person says why. When a mutant survives, a person says what the survivor means. babregen coding and babregen gate are the commands for these two steps, and they work for a project of any kind: they read the run directories and mutation files that babregen score and babregen mutate wrote, give the person an offline page, and take the answers back in a file with a fixed format. The commands and their options are on the commands page; this page explains what the steps are for, what the person sees and what an archive of a finished session can and cannot prove.

What the two steps are for

Coding answers the question why a rejected run was rejected. The person puts each run into one of five categories, says how sure they are, says whether the gap report that the generator wrote names the dominant cause, and gives one line of reason. The categories are the same for every project, so that counts of different projects can be compared.

Table 1: The categories of a rejected run, from babregen.review.vocab.
word what it means how to tell it from its neighbour
missing knowledge the records do not say what the evaluations demand. The records are silent on the point. If they say something that can be read in two ways, it is ambiguous knowledge instead.
ambiguous knowledge the records allow the candidate’s reading. The records speak about the point, and the rebuild follows one fair reading of them. If only one reading is fair, it is a generator error instead.
byte-level pinning an evaluation pins text that no intent item states. The rebuild behaves as the records say, and only exact text differs (a heading, a blank, the wording of a message) that no intent item states. If an intent item states the text, it is a generator error instead.
generator error the records say it, the candidate does not do it. The records say it clearly, and the rebuild does not do it. If you cannot point to the place in the records, it is missing knowledge instead.
harness error the driver or the judge failed, not the candidate. The rebuild is not to blame: the driver or the judge failed, for instance a timeout or a broken scoring environment.

The gate answers the question what a surviving mutant means. A mutant survives when no evaluation notices the change. The person gives each survivor one of three verdicts.

Table 2: The verdicts on a surviving mutant.
word what it means
gap an evaluation is missing.
output the mutant changes only text that no intent item pins.
equivalent no behaviour changes.

The table gives the meaning of each word in one line, as the pages show it. Section 6 explains how to choose between them, with an example of each.

The gate has one more purpose. An agent writes a proposal for each survivor, and a proposal could sway the person. The gate records the rater’s judgement before and after a proposal is displayed. For a randomly drawn subset of the survivors, the second page displays an argument for another verdict than the one the first agent proposed. This is the plant, and the gate commits to it before the person starts. The archive lets a reader tell three cases apart for each survivor: the blind rating already matched the displayed proposal, the rater changed the rating to match it, or the rater did not follow it. Everything the gate does is meant to let a reader check afterwards that the plant was made in time and kept.

Agents write proposals from the briefs that the commands write, and the person decides.

The flow of commands

Both groups take a review directory DIR as the first argument. A review directory lies below regen/runs/, holds no run.toml, and is empty when a step starts it. babregen check reads only the run.toml files below regen/runs/, so a review directory does not disturb it.

Coding, with the files that each step writes:

Table 3: The flow of babregen coding.
step what happens files
coding start DIR RUN... opens the directory for runs that were judged and rejected coding.toml, BRIEF.md, BRIEF-CHECK.md, proposals/
coding page DIR the first page, built from the run directories only; no proposal is read or shown coding-own.html
the person answers on their own, in a browser, then downloads the answers coding-own-<hash8>.toml
coding intake DIR FILE takes the own answers in byte for byte answers-own.toml
commit answers-own.toml with git commit
an agent proposes (before or after the own answers) for each run, from BRIEF.md proposals/<run>.toml
a second agent checks (optional) from BRIEF-CHECK.md proposals/<run>.check.toml
coding check DIR [RUN] compares every quote of a proposal with its file; at any time verifies what exists nothing
coding page DIR the second page, for the runs that have a proposal, only if every proposal passes the check coding-final.html
the person answers again the final category, in a browser, then downloads the answers coding-final-<hash8>.toml
coding intake DIR FILE takes the final answers in and prints a summary answers-final.toml
commit answers-final.toml

Proposals may be written before or after the own answers: the first page and its answers do not depend on them, and building, checking and taking in the first stage read nothing below proposals/. coding check DIR reads the proposals only once the own answers are taken in; coding check DIR RUN reads the one it names, which is what the agent that writes the proposal runs.

A run is coded if it was judged and rejected. coding start refuses a run that was accepted, a run that was aborted and a canary, and it refuses a directory that is not empty. A run that has no proposal is coded by the person alone: it is finished after the first stage and does not appear on the second page. If no run has a proposal there is no second stage, and coding page says so. A project that wants to code a run first archives it with babregen score FILE --out DIR.

Gate, with the files that each step writes:

Table 4: The flow of babregen gate.
step what happens files
gate start DIR REPORT... reads mutation files and lists the survivors with an excerpt of the real source gate.toml, BRIEF-first.md, BRIEF-second.md, sealed/, .gitignore
the first agent proposes a verdict for every survivor from BRIEF-first.md sealed/first.toml
gate assign DIR draws for every survivor a verdict that differs from the first agent’s sealed/assignment.toml
the second agent argues for the assigned verdict from BRIEF-second.md sealed/second.toml
gate seal DIR draws which proposals are planted, commits to everything by salted hashes seal.toml, sealed/key.toml, sealed/shown.toml
commit seal.toml with git commit, and push it if the branch has an upstream
gate page DIR the blind page gate-blind.html
the person rates, downloads the file gate-blind-<hash8>.toml
gate intake DIR FILE takes the rating in rating-blind.toml
commit rating-blind.toml
gate page DIR the second page gate-second.html
rating and gate intake DIR FILE, then commit rating-second.toml
gate page DIR the third page, only if something was drawn gate-third.html
rating and gate intake DIR FILE the last intake also writes the verdicts rating-third.toml, verdicts.toml
gate check DIR at any time; verifies what the stage reached allows nothing

gate seal rewrites sealed/first.toml and sealed/second.toml: it adds a salt to each, so the files in sealed/ differ from what the agents wrote. The commands of babregen never commit; the person who operates the gate does. In babregen ui a commit happens only when the person presses the commit button of a step: the files that the page names, with the message that the page shows, under the git identity of that person. The push is a second button. gate page still refuses to build the next page until the step before is committed.

Both flows can be run from the browser interface. It serves the same pages, takes the downloaded answers file in through a file chooser and passes its bytes unchanged to intake. It has no button for the two agents of the gate, for gate assign or for gate seal: an operator runs them in a terminal, as in the table above. Answers are kept by the browser for one address, which includes the port, so a page is begun and finished either as a file or in the interface, and the port of a project stays the same.

Where a directory stands

The stage of a review directory is found from files with fixed names and from git, not from a log. babregen.review.gate.status(spec, DIR) and babregen.review.coding.status(spec, DIR) return the stage reached, the next step, why that step is blocked (the words that page or intake would refuse with, because both take them from one rule), the babregen version that started the directory and a few plain facts: for a gate the survivors, the drawn mutants from the second stage on and whether the seal is pushed; for a coding the runs and whether a proposal is present. Neither reads anything below sealed/ or proposals/; a coding reports whether its proposals pass the check only once answers-own.toml is committed. A program that serves a page file compares its bytes with gate.rebuild_pages or coding.rebuild_page, which rebuild a page and write nothing.

The files

The directory holds three kinds of files. The files that agents write (proposals, the first and the second proposal of the gate) follow the same formats as the files that the commands write. The files that the page exports are the answers of the person. The commands read every one of them strictly: a missing format, a key that the table does not know, a value of the wrong type or a word outside its vocabulary is an error that names the file. The fields of every file kind, generated from the table that the reader uses, are in the file formats of the two human steps.

Every file starts with format = 1. A file never holds a value that can be computed from the same file or from a rule alone: whether an answer was revised, whether it followed the proposal, the seconds that a step took, the key of a survivor and the stage that a verdict comes from are computed by the commands and stored nowhere. A value that sums up another file is kept only where check compares it with its source: the numbers of survivors and of drawn mutants in seal.toml, drawn in verdicts.toml, has_report in coding.toml and the counts of evaluations in a proposal.

What the rater sees

A page is one HTML file. Its style and script are inside it, it loads nothing from a network, it holds no timestamp and no absolute path, and it selects no answer for the person. The same inputs give the same bytes, so a reader can rebuild a page and compare. The answers are kept in the browser under a key that contains the hash of the page, so two pages never share their state. When the person has answered everything, the page offers a file to download.

The first coding page has one section for each run. The section opens with a button. After the person has pressed it, the section shows the facts of the run so that no other file needs to be opened: the unit, the protocol, the history of the attempts, the failing evaluations of the final attempt with their crash lines, the counts of the dependents and unit tests, the files with line numbers and the definition of every category. Then the person answers. The second page has a section for each run that has a proposal; see below.

The gate pages have one section for each survivor. A section shows the module and the line, the enclosing definition from the real source with the changed lines marked, the change as a diff, the evaluations that did not notice it and the intent items of the unit at the commit the mutants were made at. The person then chooses a verdict and writes one line of reason.

Two pages to try

Two pages of a real study can be opened here. They are byte-identical copies of the pages that babregen gate page and babregen coding page of release 0.2.0 built in the study on the example package mathregen (branch archive/study-v1 of babregen-examples, directory mathregen/regen/runs/study/).

Table 5: Two pages of the study on mathregen. The blind page shows the three surviving mutants of mathregen.primes without a proposal, and the first coding page shows the one rejected run.
page built by in the archive SHA-256
blind page of the gate babregen gate page gate/gate-blind.html f8c2d9e93d9d9a04…
first page of the coding babregen coding page coding/coding-own.html b8d8cf4f0f71a5de…

A page sends nothing. What a visitor enters stays in the local storage of the browser, and the button at the end writes a file on the visitor’s own machine. The file is of no use without the archive it belongs to: gate intake and coding intake take a file in only if the page hash that it names is that of the page rebuilt from the inputs of the directory.

How to choose a verdict

A surviving mutant is a small change to the module that every durable evaluation of the unit still passes. The verdict says why it survived. Two questions decide it.

  1. Is there an input for which the mutant and the original differ in something that can be observed: a return value, the type of an exception, a text, a side effect?
  2. If so: do the records promise the behaviour of the original at that point, or should they?
Table 6: How the two questions lead to a verdict. The examples are invented.
verdict answers what it means for the project example
gap 1 yes, 2 yes The mutant is wrong by the records, and no evaluation notices. An evaluation is missing, and sometimes the intent item as well. A function must reject negative input with ValueError. The mutant accepts -1 and returns 0. No evaluation calls the function with a negative number.
output 1 yes, 2 no The mutant differs only in text that no intent item pins, such as the wording of an error message or the format of a log line. Either variant satisfies the records, so nothing is missing. The original raises ValueError("n must be >= 0"), the mutant ValueError(""). The records require the type of the exception only.
equivalent 1 no No input tells the two apart. The mutant is the same program written differently, and no evaluation could kill it. A search for the maximum compares with x > best, the mutant with x >= best. The result is the same for every list.

Three boundaries need care.

  • Between gap and output: if the changed text should be promised, because users or other programs rely on it, the verdict is gap. The intent item and its evaluation are missing.
  • Between gap and equivalent: one input that shows a difference rules out equivalent. A rater who can name such a call does not choose equivalent.
  • The vocabulary does not say who observes the behaviour. It can be a caller of the public contract of the unit, or any code inside the module, such as a caller of a private helper. The choice is part of the rater’s judgement, and the line of reason should say which reading was used.

The one-line meanings of Table 2 are the vocabulary gate/1 and are part of every page. This section is an explanation for the rater and for a reader of an archive. It is no part of the vocabulary, and a page does not show it.

Own answer first: the two coding stages

The coding has two stages, each with its own page, as the gate has.

On the first page the person answers on their own: category, confidence, the answer about the gap report where the run has a report, and one line of reason, which is required. A button saves the answers, and a saved answer is final. The page is built from the run directories only and holds no proposal: the sentence of a proposal is in neither the markup nor the JSON block of the file, and the bytes and page_sha256 of the page do not depend on the proposals. A proposal that is written or changed later invalidates neither the page nor its answers.

coding intake takes the answers in as answers-own.toml. After that file is committed and unchanged, coding page builds the second page. It holds, for every run that has a proposal, the same facts, the own answer, the proposal with every quote that coding check compared to its file, and the verdict of a second agent where there is one. It asks for the final category and confidence, with a reason that is required where the final category differs from the own one. The second page is refused while a proposal fails coding check. The final answers carry the hash of answers-own.toml as previous_sha256, a chain that coding intake and coding check follow.

coding check verifies what exists: both pages and both answers files against a rebuild, the chain, that the own answers were committed before, and not together with, the final answers, that a committed answers file is unchanged, the order of the times across the stages and the checks of the proposals. A file that waits for its commit is a note, not a problem.

The limit: the first page does not contain the proposal, but a person who operates the commands and also rates could open proposals/ in the file system. As for the gate, the roles should be separated: another person or an agent operates the commands and writes the proposals, and does not show them to the rater. The archive shows that the own answers were committed before the second page was built, not that the rater did not look.

The three gate stages

The gate builds the pages one after the other. A page is built only after the step before it has been taken in and committed.

The blind page comes after the seal is committed. It holds the survivors, their excerpts, the diffs and the intent items, and no proposal. If the branch has an upstream, the commit of seal.toml must be on it, or gate page refuses. Without an upstream the page says pushed = false. Only the blind page carries this fact.

The second page comes after rating-blind.toml is taken in and committed. For each survivor it shows one proposal. For a survivor that was drawn, the proposal is the text that was written for the verdict assigned at random; for every other survivor it is the proposal of the first agent. The page does not say which survivors were drawn, it does not show the honest texts, and it does not show the blind rating.

The third page comes after rating-second.toml is taken in and committed. It holds the drawn survivors only. For each it shows the proposal that the person saw, the honest proposal of the first agent, and the two earlier ratings. The person rates once more.

The number drawn is the integer expression 0 if n == 1 else max(1, (n + 5) // 10) for n survivors: a tenth, rounded half up, and at least one (25 survivors give 3). The pages say “k of n”. With one survivor there is nothing to plant: a plant that is told “1 of 1” controls nothing. With zero drawn there is no third stage, and gate page does not build it. The verdict of a survivor is the third rating if it was drawn and the second rating if it was not. A proposal is never a verdict.

Each rating file holds the hash of the seal, the hash of the page and the hash of the rating file before it, so the files form a chain. After the last stage gate intake writes verdicts.toml and removes DIR/.gitignore. Until then sealed/ is kept out of every commit. After it, sealed/ can be committed with the ratings, and a reader can verify the hashes in seal.toml.

What gate check proves, and what it does not

gate check DIR can run at any stage. Before the last stage is taken in it only hashes the files of sealed/ and checks nothing that needs their content, so its output tells the person who rates nothing about the plant. It verifies, as far as the session has come:

  • the mutation files and gate.toml are the ones the session began with;
  • every sealed file existed unchanged when the seal was made, by its salted hash;
  • the seal was committed before the blind rating, and each rating file was committed before the next stage began, in this order;
  • the hashes of the chain fit, and no rating changed once the next stage began;
  • seal.toml, every rating file and verdicts.toml are in the commit history and equal their committed version, so an edit after the commit of the last rating is named too. A file that a later one follows must be committed. The newest ones, the last rating and verdicts.toml (the last intake writes both), may still wait for the commit that the next step asks for; gate check then prints the note not yet committed, never a problem. A file in the history that no commit is found to have added is a problem, because its place in the order of the commits cannot be checked;
  • each page file is the rebuild from the files, in particular the second page is the rebuild from shown.toml, so the person saw exactly the sealed proposals;
  • the plant and the draw follow the rule: the assigned verdict differs from the first agent’s, the shown proposal is the second for a drawn survivor and the first for the others, and the number drawn is the number the rule gives;
  • the verdicts are the second rating for a survivor that was not drawn and the third for one that was drawn;
  • the times are in a plausible order.

Two limits belong to every number that these steps give.

First, one person who operates the gate and also rates can read sealed/ at any time, clear the browser state and rate again, or rebuild a page. Nothing technical prevents this. The protection comes from separating the roles: another person or an agent operates the gate (assign, seal, the commits) and does not tell the rater what is in sealed/. The archive can show that the commitments were made in time and kept. It cannot show that the rater did not look. The commitment is strong only if seal.toml is pushed to a remote that other people can see, because local history can be rewritten.

Second, the times come from the clock of the browser and from the committer time of git. They show a plausible order and nothing more.

One rater serves each review directory. If two people rate, use two directories.

Which version of babregen verifies an archive

A page holds its wording, its vocabulary tables and its markup, and page_sha256 is the hash of all of it. A later release that rewords a sentence or changes the style therefore gives another hash and another file for the same inputs. So a page is verifiable with the babregen that built it, and every session records that version as babregen_version in gate.toml or coding.toml.

With another version, gate check and coding check still verify everything that does not depend on how a page is rendered: the hashes of the sealed files, the chain of previous_sha256, the order of the commits, the rules of the plant and of the verdicts, the vocabularies, the order of the times, every quote and every number. They do not compare page_sha256 with a rebuild and do not compare the page files. They print one note that names the version needed for that, note: the session was started with babregen 0.2.0, this is babregen 0.3.0: ... check with babregen 0.2.0 for that, and the exit code is decided by the checks that remain. page and intake refuse under another version, with exit 2 and the version to use: a page is built and taken in by the version that built it.

Exit codes

Every subcommand uses the same codes. Exit 0 is success. Exit 1 means that content which was checked fails: a quote that does not match, a number that does not hold, a hash or a chain that does not fit, and a format or vocabulary error in a file that an agent wrote or that was downloaded from a page. The line is printed as {path}:{line}: {message}. Exit 2 means an error of the input: a wrong argument, a missing file, a step taken out of its order or a target file that exists. The exit codes, the formats and the commands are part of the stability contract; the look of the pages is not.