small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
albedo robot-docs testing.md

test execution #

test/resources.py owns test concurrency. test.sh and test/quick.sh source test/resources.sh before starting work. That freezes one plan so later suites do not each budget the same remaining memory again. The full gate starts unit and E2E suites together within that plan. Standalone Python E2E and Gleam runners read the same policy.

The planner uses Linux MemAvailable, limited by memory.max - memory.current for the current cgroup and every ancestor. On macOS it uses free, inactive and speculative VM pages. Unknown hosts receive a conservative 2 GiB budget. A quarter remains outside the test budget. CPU affinity bounds scenarios; Linux CPU quota also bounds active build threads.

The ordinary E2E limits remain four shared Python tests, eight private daemons and four Go scenarios. Half of the shared budget covers E2E scenarios, at 384 MiB per group of one shared case, two private daemons and one Go scenario. The remainder is divided between Gleam modules, Python harness files and build workers. Lower available memory reduces every pool. Less than 1 GiB available fails before work starts. Explicit Python -j and -x arguments override the plan for experiments. The exported ALBEDO_TEST_*_JOBS values can also pin a plan. These are concurrency limits, not hard limits on a test's allocations. The cell-limit scenarios deliberately run 384 MiB child processes.

Gleam runs timed modules first and the remaining modules in bounded EUnit batches. Python harness files run in a bounded subprocess pool. Build limits also set Go package parallelism, GOMAXPROCS, Cargo jobs and Gleam's scheduler count. Large machines do not start an unbounded number of compilers or test VMs just because they have many CPUs.

fixture teardown #

A Python test owns every Albedo fixture and fake provider it creates. Successful session-creation PUTs record root IDs, independent of later workspace moves. After unittest cleanups, the runner deletes each shared fixture's captured session trees with fresh configuration and family revisions. This stops kernels and background jobs before the shared lane admits another test. A missing root is already cleaned; stale revisions are refreshed up to five times. Other failures fail the test.

A private daemon is discarded synchronously in its worker. Finished tests no longer leave an unbounded queue of daemon-shutdown threads. Provider routes, recorded requests and scripts are released only after session teardown; held provider responses are then cancelled. Successful unittest objects are removed from discovery containers and outcomes retain their names rather than fixtures. Failure diagnostics read a bounded daemon-log tail.

A test that needs a second daemon, such as the target of a session move, calls peer_daemon(name) from test/e2e/harness.py rather than building a Daemon itself. The peer boots at once from the run's daemon snapshot (ALBEDO_DAEMON), in its own ALBEDO_HOME, with the offline extension settings, ALBEDO_PARENT_PID set to the runner and ALBEDO_STANDBY=0; an optional prepare(daemon) writes its settings first. It works on every lane, beside concurrent tests, because nothing in it is shared. Each test boots its own peer, which costs about a second: a peer shared by a class would outlive the tests that use it, since shared-lane tests finish in no fixed order, and one test's imports or restarts would reach the next. The runner discards the test's peers in finish_test, after its sessions and before its providers are released, whether the test passed or not, and a failing test's report includes each peer's log tail. A peer whose boot fails is still discarded, and the run's exit handler stops any that remain.

Go session helpers register subtree deletion with t.Cleanup. Provider-route cleanup follows session cleanup. Test daemons use explicit idle, grace and preload settings rather than the production ten-minute idle default.