Skip to main content

The browser interface

babregen ui puts the commands of babregen behind pages in a browser. It starts a small server on this machine, shows for every unit what is done and what comes next, and runs each step by a button. Records and source files are still written in an editor; the pages link to the file and line. Every command of the command line works as before, and the interface calls the same functions, so a result is the same in both places.

This page is a guide for a person who uses the interface. The options of the command are on the commands page, the two human steps are explained on their own page, and the reasons for the design are in ADR 0002 of the repository (docs/adr/0002-browser-interface.md).

Three words are used with a fixed meaning. A pilot is a package directory whose modules become units. A step is one command with its form and its result page. A job is one run of a step, with an address that still works after the server was restarted.

Start and stop

cd my-project          # the directory that holds regen/, inside a git repository
uv run babregen ui

The server binds 127.0.0.1 and opens the start page in the browser. It prints its address; Ctrl-C stops it, together with a long step that still runs. The interface needs a git repository, because it keeps its jobs below the git directory and because the steps of the evidence chain are commits. It runs on macOS and Linux.

The browser gets in by a launch token that is valid once. The server writes a small file that only the user can read, and the browser is started with that file, not with the token. With --no-browser the server prints the address with the token instead, which is the way to use another browser. After the first request the browser holds a session cookie, and the token is worth nothing.

The port is fixed for a project (8765 unless the settings page or --port says otherwise). If the port is taken, babregen ui stops with the reason and does not choose another one. The reason is the review pages: the browser keeps the answers of a page for one address, and the port is part of the address. babregen ui --check loads the configuration, prints the address and serves nothing.

The start page: choose the pilots

Figure 1: The start page lists the package directories. Nothing is ticked in advance.

The start page lists the package of regen/architecture.toml and its subpackages, with the number of modules and of unit records in each. Tick the directories where babregen is applied and save. The interface writes the choice to regen/ui.toml, a small file that belongs to the project and is committed; the result page offers the commit button for it.

A repository without regen/architecture.toml still gets a start page. It then says how to print the example record, because the first architecture record is written in an editor.

The overview

Figure 2: The overview: one line per module of the pilots, and the review directories below.

The overview has one line for every module of the pilots. The columns are the steps in the order that the interface proposes: the unit record, check, the deletion test, the mutation report, the gate, the run and the coding. The first step that is not done decides the line and says what comes next; the steps after it show “waits”. A step is blocked only when a real precondition is missing. The cell then gives the reason in plain words, with a link that opens the file at the line in VS Code.

A mutation report or a run is marked stale when the module or the evaluations it was made from have changed, and the overview then proposes the rerun. The top bar shows the pilots, the job that runs and the number of files of the interface that are not committed.

Below the units, the overview lists every gate and coding directory under regen/runs/ with its stage and its next step, also those that were started in a terminal.

A step

Every cell of the overview opens its step in a new tab. The tab has an address, so it can be kept open, reloaded and bookmarked. Pressing the button of a step makes a job and sends the browser to the page of that job, which is why a reload never runs a step twice.

check, deletion-test, context, compact, measures, schema, explain and example show their result as tables or text. The four commands that write a record (new-unit, add-intent, add-consumer, new-decision) first show the text that would be written and write only on a second press with the same fields. Every value of a form comes from a list that the server made, or is a number within a limit; no form takes a path or a command line.

Figure 3: The result of a step: tables, the files that were written and the commit button.

A result page lists the files that the step wrote, each with its hash, and offers one commit button for them. The page shows the files and the message before the press. The commit holds exactly these files and no other change of the working tree, it is made under your git identity, and hooks run as they always do. The push is a second button; it is never forced, and the page lists the commits it would send. After a refused push the interface does not pull, rebase or merge. That is left to you, because a rebase gives the commits of an evidence chain a new time.

Long steps

mutate, score and local can run for minutes or hours. The first press shows the exact command line, and the second starts it as a process of its own. The page of the job refreshes itself and shows the elapsed time, the end of the log and a cancel button. For mutate it counts the mutants that are done.

One long step runs per project. A second one is refused with a link to the one that runs, and a step that writes a file waits until it has ended; steps that only read stay available. The exit code 1 of a command is a result (survivors, a rejected candidate) and is shown as one; only exit code 2, a time limit and a crash are failures.

The commands write where they always write, below regen/runs/. A repeated run of the same day gets the suffix -r2, -r3 and never overwrites. After a restart of the server the overview finds the reports and runs again, because it reads them from these files.

local needs a model server on this machine. The settings page holds the model, its hash, the context length and the endpoint, in a file below the git directory that belongs to this clone and cannot be committed. Until these values are set, the step says what is missing instead of offering its button.

The gate and the coding

The overview links a page for every gate and coding directory. The page says who acts next: a person in the browser, an operator in a terminal, an agent, or git by a button. It offers only the buttons of the stage that is reached. What it shows comes from the files with fixed names and from git, and from nothing below sealed/ or proposals/.

Figure 4: The page of a gate directory when the blind page is built: who acts, the link to the page and the file chooser for the answers.

gate start and coding start are steps with forms: the mutation reports that have survivors, or the runs that were judged and rejected, as lists to tick.

The gate needs a second role

Every gate page says that whoever drew and sealed the proposals does not rate. The interface is used by the rater. It therefore has no button for the two agents of the gate, for gate assign or for gate seal. An operator, who is another person or an agent session, runs these steps in a terminal, and the page of the directory shows which command is next and the new state when it is loaded again:

Table 1: Who does what in a gate that is run with the interface.
who what where
rater gate start with a mutation report interface
operator the first agent writes its proposal from BRIEF-first.md terminal
operator babregen gate assign DIR terminal
operator the second agent, in a fresh session, from BRIEF-second.md terminal
operator babregen gate seal DIR terminal
rater commit seal.toml, then push it interface
rater build the blind page, rate, take the answers in, commit interface
rater the same for the second page and, if a mutant was drawn, the third interface
rater gate check interface

The interface starts no agent. Until the operator acts, the overview shows “waiting for” and a link to the page of the directory. For each agent that page shows the brief, the file to write, a prompt to copy and the command that follows. The session of the operator, in the project root, with DIR for the gate directory:

  1. Open a fresh agent session with the prompt Follow DIR/BRIEF-first.md exactly. It writes DIR/sealed/first.toml.
  2. Run babregen gate assign DIR.
  3. Open another fresh session, not a continuation of the first, with the prompt Follow DIR/BRIEF-second.md exactly. It writes DIR/sealed/second.toml.
  4. Run babregen gate seal DIR.

The rater does not watch these sessions and does not open DIR/sealed/.

Do not upgrade babregen while a gate is open. The directory is bound to the version that started it, and another version can only check it.

After the commit of seal.toml comes the push, because the blind page records whether the seal is on the upstream. A branch without an upstream has no push step, and the blind page then records that the seal was not pushed.

Answer, download, take in

A review page is built by a button and opens in its own tab. It is the same offline page that gate page and coding page write, byte for byte. The server sends it only if the file equals what the records give for that stage, so a page of a later stage cannot be opened early and a file that somebody placed in the directory is not served.

The answers are kept by the browser while you work, for the address of the server. Nothing is sent to the server while you answer. When every section is saved, press the download button of the page, go back to the page of the directory and choose the downloaded file there. The interface passes exactly the bytes of that file to gate intake or coding intake, which checks them and decides as it does on the command line. The file that is written to the directory is equal to the download.

Three things follow from this:

  • Begin and finish a page at the same address. Answers that were begun in a page opened as a file are not visible when the interface serves the same page, and the reverse. The file chooser takes a download from either.
  • The times of the answers are compared with the commit times. The page of a directory warns if the clock of the browser differs from the clock of the server.
  • Each rating and each answers file is committed by its button before the next page can be built. The list of files of such a commit is fixed: a rating goes with its page; the last rating goes with verdicts.toml, the sealed files and the removal of .gitignore; the own answers go with coding.toml, the briefs and the first page; the final answers go with the final page and the proposals.

The agents of the coding

In a coding, the own answer comes first. After answers-own.toml is committed, the page of the directory can run the agent that writes the proposals, and the one that checks them, by a button. The commands are yours:

babregen example agents > regen/agents.toml   # a template; edit it in an editor
babregen ui --approve                         # shows each command, asks once

regen/agents.toml holds one argument list per role (coding-propose, coding-check) and a time limit. Only {brief} and {target} are replaced, by the path of the brief and of the proposals/ directory, and no shell is involved. A command runs only after you approved it in a terminal. The browser cannot approve one, so a cloned repository cannot bring a command that runs on a press. The approval is kept in a file of your user, outside every repository. It is bound to the project, the role, the text of the command, the program that its first word resolves to, and the content of every file of the project that the command names. If one of them changes, the button disappears until you approve again. The program is resolved with the PATH of the server, so approve in a terminal that has the same environment as the one that started babregen ui.

An agent command runs with your rights and your environment, without a sandbox. The approval covers what --approve shows, not what the program does or which other files it reads.

While and after an agent runs, the page shows its state and its exit and nothing of its output, because the output can hold the proposal. The log becomes visible on the page of the job once the final answers are taken in. No agent runs once the final page exists, because the hash of that page depends on the proposals.

Directories of another version

A review directory is bound to the babregen version that started it. For a directory of another version, an archive of 0.2.0 for example, the interface offers check only, as the command line does.

A walk through one unit

The table gives the order for one unit, from the first start to a finished gate and coding. Steps that are marked terminal are not buttons.

Table 2: One unit from the start page to a finished gate and coding.
# who what result
1 person, terminal uv run babregen ui in the project the start page opens
2 person ticks the pilots, saves, commits regen/ui.toml
3 person opens check, the deletion test and measures from the overview findings as tables
4 person opens mutate for a unit, starts it a job; then the report with the survivors
5 person commits the report the report is evidence for the gate
6 person opens gate start and ticks the report the gate directory with two briefs
7 operator, terminal first agent, gate assign, second agent, gate seal seal.toml
8 person commits and pushes the seal the blind page can be built
9 person builds each page, rates, downloads, takes the file in, commits the ratings, at the end verdicts.toml
10 person opens score for a candidate, or local a run directory, accepted or rejected
11 person commits the run, opens coding start and ticks a rejected run the coding directory
12 person builds the first page, answers, takes the file in, commits answers-own.toml
13 person, terminal writes regen/agents.toml, babregen ui --approve (once) the agent commands are approved
14 person runs the proposing agent, then builds the final page, answers, takes the file in, commits answers-final.toml
15 person gate check and coding check no problem

What protects the server and the evidence

The server can start commands, commit and push, and a port on this machine can be reached by any page in the same browser and by any local process. These rules hold, and tests pin them:

  • The server binds 127.0.0.1 and refuses a request whose Host is not its own address.
  • Every request needs the session cookie. A request that changes something is a POST from the own origin with a token of the form.
  • No address is mapped to the disk, and there is no file viewer. A request never carries a path or a command line; units, reports, runs and directories are chosen from lists that the server made.
  • Commands run as argument lists, never through a shell.
  • The pages of the interface carry one script file and no inline code, and every response has a content security policy. A review page gets a policy of its own that allows exactly its own inline style and script.
  • The scripts of the interface never read or write the stored answers of a review page.
  • A commit names only files that the server derived from the step, and the server checks after the hooks that the commit holds exactly these files with the content that the page showed. Nothing is amended, forced or rebased.
  • No response shows a file below sealed/ or proposals/, the output of an agent, or the content of a rating file before the stage that shows it on a review page.

Limits

  • One project per server, on this machine only, for one user. There are no accounts.
  • macOS and Linux. The process groups of the long steps are not built for Windows.
  • The interface does not edit records or source files. It links to them.
  • The roles of a gate are not enforced. A process of the same user can read sealed/, the logs and the files of the server; blindness rests on the interface showing nothing sealed and on the rater not opening these files.
  • A browser sends the cookies of 127.0.0.1 to every port of that address. Another server on this machine that the same browser visits can therefore see the session cookie of the interface. On a machine with one user this adds nothing, because a process of that user can read the files of the server anyway. On a machine that is shared with other users it is a risk, and the interface is not made for that case.
  • The download of a review page under its policy is tested in Chrome. Firefox and Safari are not tested yet.
  • The stored answers of a review page belong to the browser. A changed port or a cleared browser store hides answers that were begun and not downloaded.