Create a lab and connect an agent

Create a lab, use it by hand, run the scripted reference, then connect Claude Code or Codex.

Create a lab

Terminal
python3 -m slean lab init --dir /tmp/lab --mode blackbox --proposals 60 --cells 200000
  • --mode blackbox hides the rules; whitebox, the default, gives them.
  • --proposals and --cells set the two budgets: proposals and cell updates.
  • --suite-seed chooses the suite of worlds, 7 by default.

The directory then holds the task description, in README.md, and the ./lab command. The hidden answers are stored elsewhere, outside the directory.

The lab commands

Terminal
./lab worlds                          # list of worlds (and their tables in whitebox mode)
./lab experiment w3 0120010 5         # run w3 from 0120010 for 5 steps
./lab check w3 0 12 8                 # does block 12 on background 0 return within 8 steps?
./lab propose '{"kind":"conservation","world":"w3","w":1,"f":[0,1,2]}'
./lab propose '{"kind":"structure","world":"w3","background":0,"block":[1,2],"t":2,"d":5}'
./lab status                          # budget used and accepted results
  • experiment accepts 1 to 200 steps and at most 400 cells. Its cost is the number of cells times the number of steps.
  • check accepts a maximum delay of 1 to 24 steps and a block of at most 24 cells. If the block returns, it gives the number of steps, the shift and the velocity.
  • propose costs one proposal, accepted or not. A conservation law gives the width w (1 or 2) and the table f. A structure gives the background, the block, the number of steps t and the shift d.

In a lab, new cell i reads cells i, i+1 and i+2: this is the Lean world’s offset reading. See World.

Run the scripted reference

Terminal
python3 -m slean lab init --dir /tmp/lab-ref --mode blackbox --proposals 60 --cells 200000
python3 -m slean lab baseline --dir /tmp/lab-ref

The reference is a scripted scientist that uses exactly the same commands and the same budget: short experiments, exact data fitting for the laws, then an exhaustive search for structures, smallest first. It is the bar to clear. It works in its own lab.

Connect an agent

Terminal
python3 -m slean lab run --dir /tmp/lab --agent claude --model sonnet --max-usd 3

The agent, claude or codex, works in the lab directory with ./lab, python3 and file reading and writing tools. Its transcript is recorded and audited, then the run is scored. --max-usd caps the agent’s spending.

Score a run

Terminal
python3 -m slean lab score --dir /tmp/lab

The score compares the accepted results with the hidden answer. It is described on the page Reading a score.