In this video, you watched task 3 of the escape-room builder’s unreachable-puzzle report done tests first: for each puzzle a team can’t reach, the report names the needs that no reachable puzzle provides. It’s an example session written for the video rather than recorded. Your own session will differ, but its steps should be the same.
Key points:
- Task 1’s test held up because your task gave its expected values. Watch out: without them, tests an agent writes with its code come from its own reading of the task, so if it misread the task, they check the misreading and still pass.
- You start with the answers, in your own words. In The Smuggler’s Cellar, the strongbox needs the iron key, and nothing unlocks it. The trapdoor needs two things. The map gives the cellar code, so a team finds that one, but the trapdoor code is inside the strongbox, which no team can open. So the trapdoor misses only the trapdoor code. The Lighthouse Keeper’s Study misses nothing. Those three lines are your criteria.
- Your criteria go into your request, which asks for tests that check them and no code yet. In the example, the agent’s test calls a new function,
missingNeeds(), which returns one entry per unreachable puzzle: its id and the needs it’s missing. Its first test checked the Lighthouse Keeper’s Study and the strongbox, but not the trapdoor. - Even with your criteria in the request, an agent can drop one, so it’s up to you to read the tests against your criteria before any code exists. Suppose the code counts a need as missing only when nothing in the room unlocks it. The strongbox unlocks the trapdoor code, so that version says the trapdoor misses nothing, and the first test still passes. So you asked for the missing criterion, and the test now expects both cellar puzzles.
- The agent ran the tests, with no code for task 3 yet. The first run failed, but none of the file’s tests ran. The file stopped at its import, because the function it imports didn’t exist yet. Node counts the file that wouldn’t load as one failed test. That red says nothing about task 3.
- So you asked for an empty version of the function, which returns an empty list. It leaves task 3 undone and only lets the file load. On the next run, the two earlier tests passed and the new test failed. It expected the strongbox and the trapdoor, and got an empty list. That’s the right reason to fail, because the behavior is missing.
- You committed the tests, with the empty function. The new test still fails on purpose, and task 3’s box stays unticked. That commit records exactly what your tests expect. From then on, the tests should stay as they are. Nothing stops an agent from editing them, so you’ll check.
- Then you asked for code that passes these tests, with the test files unchanged. The agent filled in the empty function, and all three tests passed.
git statuslisted onlysrc/check-room.jsas changed, so the test file was as you committed it, unless the agent made a commit of its own. You don’t commit this code yet, because a green run doesn’t show how the tests passed. You’ll check that in Check What Made the Run Green.
Tests first runs in this order:
- Turn your criteria into tests.
- Read the tests against the criteria.
- See them fail because the behavior is missing.
- Commit them.
- Ask for the code that passes them, with the tests unchanged.