RedMachine Buy

ยท Blog

Using RedMachine with a coding assistant

The loop

RedMachine is built to sit beside a coding assistant, not to replace it. The roles are split on purpose.

  1. The assistant writes the change and the tests for it.
  2. RedMachine judges the change. It breaks each changed line, runs the tests, and reports which lines no test noticed.
  3. The assistant writes a test for each SURVIVED line, using the broken version RedMachine printed as the thing the new test must catch.
  4. RedMachine runs again. The loop ends when the result is PASS.

The reason for the split is simple. An assistant that checks its own tests is marking its own work. RedMachine has no opinion. A line is killed or it survived.

What you need first

RedMachine works in a git repository with at least one commit, and it needs a command that runs your tests. Judging also needs a licence key. You buy the key on the buy page and run redmachine activate YOUR-KEY yourself, on the machine, one key per machine. The instruction you give the assistant tells it to stop and ask you if the licence is missing, because buying and activating are yours to do.

The instruction

RedMachine comes with a block of text to paste into your assistant's chat, in the project where it works. In six steps, it tells the assistant to do the following.

  1. Find the program and confirm it runs. Work in a git repository. Add redmachine-receipt.jsonl to .gitignore. Stop and tell you if there is a licence problem.
  2. Run redmachine --list and keep the base:, test: and changed lines: lines for the final answer. If it counts no lines, stop.
  3. Run redmachine. Exit 0 is PASS and 1 is FAIL. For any other code, show you the message and stop. If the tests already fail with nothing broken, fix that first.
  4. For each SURVIVED line, read the line: and broken as: text. Write a test that fails with the broken version and passes with the real line. Do not change the line, do not weaken or delete tests, and do not add anything to the waiver file.
  5. Run again and repeat until PASS, or until only UNVIABLE lines are left. If a line still survives after two tries at a test, stop and say which line and what was tried.
  6. In the final answer, show you the three lines from step 2 and the last RESULT line. List every UNVIABLE line with its text. Leave the receipt alone.

The instruction also says what to do in a few special cases. If a surviving line is redundant, because other code already does its job, the assistant must not weaken tests or waive the line. It names the line, explains why, proposes deleting it, and stops for you to decide. If lines come back NOT_TRIED because of the --max limit, the assistant runs redmachine --max 200.

Notice who decides what. The assistant does the writing. You decide about UNVIABLE lines, redundant lines, and anything the assistant could not fix.

Which models we tried

The instruction is a request. What an assistant does with it depends on the assistant. We gave several models the same job with no help: install RedMachine, add a function with tests to a Python project, run RedMachine, and fix what it found by following the instruction. The models page has the full table. The results:

The page is clear about what this is. "Tried" does not mean "supported". These are our own results, on one task, with few runs each. No model added a waiver, weakened a test or edited a receipt. If you run a local model, the page suggests a 27B-class model: 32 GB of memory runs one at Q4, and 48 GB runs it at q8.

Checking that it did what you asked

A PASS says that no counted line survived. It does not say the code does what you asked. One way to close that gap is to name the tests. Ask the assistant to write one test for each thing you asked for and to name each test after it, for example heavy_orders_get_the_surcharge. The receipt lists the tests that ran with nothing broken and, for each KILLED line, the tests seen to fail with it broken. With Python's built-in commands, which stop at the first failure, that is only the first one. You can read that list against your request. The command redmachine verify RECEIPT --ran heavy_orders_get_the_surcharge answers yes or no from the record. If the receipt holds no names, it says it cannot tell.

The names come from what your test runner printed, and a test that sets out to deceive can imitate one. You can also give the receipt and your original request to a second assistant and ask whether everything you asked for has a test that went red.

Before you run it

RedMachine runs your tests against code it has broken on purpose, and a break can do whatever the broken code can do. If your project deletes files, kills processes or sends anything, run it in CI, a container or a throwaway account. To see how to read what comes back, read how to read a RedMachine receipt.

Buy RedMachine

Related

Back to the blog