t27.aiРусский

Ask, run, read, fix

You will learn

How a round of ask, run, read and fix removes one problem, and why a round that skips the reading hides the rest.

A round has 4 steps. Ask the agent for one change. Run the program. Read what came back, all of it. Fix one problem and go round again. Each round removes one problem, so a program with 3 problems is green after 3 rounds. The spec keeps a table of the problems left after each round: 3, 2, 1, 0. The shortcut that breaks the loop is a round that says done without reading the result. In the widget you can switch the reading off and watch the counter lie. In the spec the same shortcut is one changed number, and exactly one test goes red.

Try it

Run the three rounds in the widget, then switch the reading off and run one round. In the spec change the 1 in the table to 0 and name the test that goes red.

Open the interactive lesson →

Ask, run, read, fix ↗

Run rounds of ask, run, read and fix on a program with three problems. Each round fixes one thing. Switch the reading off and the problems stay hidden.

specs/vibecoding/the_loop.t27

// SPDX-License-Identifier: Apache-2.0
; specs/vibecoding/the_loop.t27 -- vibecoding lesson: ask, run, read, fix
; One idea: a round is ask, run, read the result, fix ONE thing. Each round removes one problem,
; so a program with 3 problems is green after 3 rounds. ROUND_STATE[i] is how many problems are
; left after i rounds. Run it in the player, then change ROUND_STATE[2] from 1 to 0 (a round that
; says "done" without reading the result) and read which test goes red.
; ASCII only, English only.
; phi^2 + 1/phi^2 = 3 | TRINITY

module vibecoding_the_loop;

pub const STEPS_PER_ROUND : u8 = 4;
pub const START_PROBLEMS : u8 = 3;
pub const ROUND_STATE : [4]u8 = [3, 2, 1, 0];

test a_round_has_four_steps {
    assert STEPS_PER_ROUND == 4;
}

test the_loop_starts_with_every_problem {
    assert ROUND_STATE[0] == START_PROBLEMS;
}

test each_round_fixes_exactly_one_thing {
    assert ROUND_STATE[0] == ROUND_STATE[1] + 1;
    assert ROUND_STATE[1] == ROUND_STATE[2] + 1;
    assert ROUND_STATE[2] == ROUND_STATE[3] + 1;
}

test green_comes_after_one_round_per_problem {
    assert ROUND_STATE[START_PROBLEMS] == 0;
}

Open the lesson's spec in the player ↗

All lessons