Undo one agent's change#
When an AI agent's change has been merged into your game (a "landing") and you later decide against it, you can take that one landing back and keep everything that was made after it. The editor's Landing tab lists every landing, and each can be undone on its own; over the protocol it is one command:
{"jsonrpc":"2.0","id":1,"method":"project.undo","params":{"landing":1}}What it does, and when it is refused#
- It reverses that landing only. Later edits that do not depend on it stay. The undo is merged field by field and line by line, the same way a landing is.
- It is tested before anything is written. The undo is played against what the landing said it would change (its
says). If a later edit touched the same field, or the undo would move something the landing never said it changes, it is refused withE0470and a reason. Resolve the conflict, or undo the change that depends on it first. - Your tests stay in step. The game's replay checksums and any changed shots are accepted together with the undo. A game with shots needs a graphics adapter: the undo is refused when the picture check cannot run.
- A shot the landing added goes with it. Its entry leaves the project file and its picture is removed from
shots/; both come back if you undo the undo.
The landing must belong to the current session, and its original change must still be among the latest 64 changes of the session's journal. copy.landed lists the landing numbers (they are not the journal's change numbers), and copy.landed and copy.diff answer undone: true for a landing you took back, for the rest of the session.
Try it#
You need no window for this. Make a game with these two files:
# game.toml
scene = "s.toml"
replay = { steps = 20, checksum = "0000000000000000" }# s.toml
[ball]
Transform = { x = 0, y = 0 }Run frost test --write game.toml, then frost serve game.toml. Send each JSON-RPC request as one line on standard input and read its reply before sending the next:
{"jsonrpc":"2.0","id":1,"method":"copy.make","params":{"name":"x"}}In the returned folder's s.toml, change x to 10, then send:
{"jsonrpc":"2.0","id":2,"method":"copy.land","params":{"copy":"x","says":["ball.Transform.x"]}}
{"jsonrpc":"2.0","id":3,"method":"copy.make","params":{"name":"y"}}In that second folder's s.toml, keep x = 10 and change y to 20. Send:
{"jsonrpc":"2.0","id":4,"method":"copy.land","params":{"copy":"y","says":["ball.Transform.y"]}}
{"jsonrpc":"2.0","id":5,"method":"project.undo","params":{"landing":1}}The game's s.toml now has x = 0, y = 20, and frost test game.toml passes. The undo reply's change is a new inverse change. Ordinary project.undo takes that inverse back, restoring x = 10, y = 20; project.redo applies it again. copy.diff {"landing": 1} and copy.landed report whether landing 1 is undone.
When two changes pass alone and fail together#
Two agents' changes can each pass their own test and still break the game once both are in. To find out why, test one copy with the other changes underneath it:
{"jsonrpc":"2.0","id":6,"method":"change.test","params":{"copy":"thud","with":[{"copy":"lip"}],"says":[]}}When the combined run fails, the answer shows you the same value in each run side by side. For a first differing component field, differs names step, entity, component, field, value, was and writer. was is the reference run's value. The added differs.comparison gives the columns directly:
| Field | Meaning |
|---|---|
window | Always 5: the differing step plus up to four preceding steps. |
from, to | max(0, differs.step - 4) and differs.step, inclusive. |
alone | One run per hands entry, in the same order (with, then the tested change). Each has copy and who, or folder. |
together | The combined run that failed the test. |
extra_steps | The number of attempted simulation steps replayed for all comparison columns. |
Each run has present, value, writer, samples, and error. Its top-level value and writer are at to. samples contains at most five {step, present, value, writer} records in step order. Values use the same JSON scalar types as world.get; writers are the structured objects from blame.value, including script callers, or null when unknown. These are observations after each completed step; step 0 is after loading and scene initialization.
present: false means the named thing, component or field does not exist at that step; its value and writer are null. This is distinct from a present field with a null JSON value. If an alone cannot load or reach the differing step, has no replay, or its own replay ends before that step, its error explains why, samples is empty, and present, value and writer are null. The original together failure remains the answer.
Each with alone applies only that change over before when supplied, otherwise over the served game. The final hand uses the served game plus folder. Each uses its own recording, including its own tuning and script state. It is not a prefix of the with stack. These values do not assert that an alone passes: use that copy's own change.test verdict. Files saved since that verdict are read afresh, as in every change test. who names the copy's hand; writer names the scene, script or system that last wrote the value in that run.
A passing test keeps no field snapshots and enables no writer tracking. Only after finding a component-field difference does the comparison load each returned run, one at a time, and replay to to with writer tracking. It samples only the reported field, at steps max(0, to - 4) through to; no pictures are taken. Each alone and together is played once. For two changes this costs 3 * to extra steps; for H hands it costs at most (H + 1) * to, counted in extra_steps (failed attempts count too). With one with and no before the test's reference is the same game as that change alone; it is played again like every other column.
The comparison keeps at most five samples and the final value for each run, however long the recording is, and nothing is cached between requests. The added work is included in ms; comparison data contains no clock times.
There is no comparison for a passing test, a failure without a component-field path (such as a script-state or entity-list difference), or a request without with. No picture is added to the answer.
An example: two copies, lip and thud, each pass alone. At step 76, player.Player.vy is 590 in lip alone, 590 in thud alone and 586 together. The window is steps 72–76; steps 72–75 hold 0 in all three runs. Lip's writer is demo.luau:51 in move, called from line 70; thud and together use line 52, called from line 71. The comparison reports extra_steps: 228.