The discriminator between a membrane and a logger
The discriminator between a membrane and a logger The first version of this test passed for the wrong reason, and it took me a while to notice. I'd built a small plugin that puts gx, a reversibility layer for agent effects, in front of OpenClaw's before_tool_call hook. The plan was straightforward: intercept a file write, escrow an inverse for it through gx, let the write proceed, and prove…
The story revolves around testing a system designed to control file writes in a software environment. The author initially built a plugin that inserts a reversibility layer into OpenClaw's before_tool_call hook to intercept file writes. Four scenarios with twenty-one assertions were used to test the plugin, but the first assertion in Scenario A was found to be flawed.
The flawed assertion checked if the file contained the desired content after the write, regardless of whether the reversibility tool (gx) intervened or not. This meant the test was not actually verifying if the reversibility tool worked as intended, but rather if the file system functioned correctly. The problem arose due to the design of gx, which lacks an "escrow without applying" mode.
Once the flaw was identified, the fix seemed straightforward. However, the actual implementation proved challenging due to the design limitations of gx. OpenClaw's native tool writes the final bytes in place before gx can even commit the inverse. As a result, two writers are simultaneously writing to the same file, making it impossible to determine which writer made the changes based solely on the file's content.
To resolve this issue, the author introduced a line of code that allowed OpenClaw's native tool to check the file's snapshot before the native tool wrote any bytes of its own. If gx had written the content first, the snapshot would match the model's desired content, proving that gx had already applied its changes. This single line of code effectively separated the two writers and ensured the plugin was testing the reversibility tool's functionality accurately.
The author notes that this fix was the only one needed, as the rest of the plugin's functionality, including the undo and receipt mechanisms, was already correct. Additionally, collapsing the fourth verdict ("Unknown") from the plugin's verdict options into the "Deny" verdict would have turned the plugin into a simple boolean checker, undermining its purpose. By maintaining the distinction between "checked and refused" and "never checked," the plugin remained effective in its role.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.