From cdcff126ef44c589c4cdf9942893f9fba5b5fbb1 Mon Sep 17 00:00:00 2001 From: Mathias Date: Mon, 5 Oct 2026 23:43:27 +0200 Subject: [PATCH] test(brain_edit): the rollback test proves the swap happened (#192) Review round 2 on PR #194: with the hook made a no-op the test still passed (no swap, the rollback wrote the real note, victim trivially untouched). It now asserts the error says the edit could NOT be rolled back and that the note path is still the swapped-in symlink; red when the hook does not fire. Co-Authored-By: Claude Opus 5.5 --- ingestion/internal/mcp/edit_pathio_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ingestion/internal/mcp/edit_pathio_test.go b/ingestion/internal/mcp/edit_pathio_test.go index 1fb2f45..ab6d35b 100644 --- a/ingestion/internal/mcp/edit_pathio_test.go +++ b/ingestion/internal/mcp/edit_pathio_test.go @@ -111,6 +111,12 @@ func TestBrainEditRollbackDoesNotWriteThroughASymlinkSwappedInForTheNote(t *test })() resp := authCall(t, srv, jwtAuthz, "brain_edit", map[string]any{"path": path, "old_str": "static body", "new_str": "injected"}) require.NotNil(t, resp["error"]) + // The swap happened and the rollback refused it: the error says so, + // and the note path is still the planted symlink. + assert.Contains(t, resp["error"].(map[string]any)["message"], "could NOT be rolled back") + fi, err := os.Lstat(note) + require.NoError(t, err) + assert.NotZero(t, fi.Mode()&os.ModeSymlink, "the note path is still the swapped-in symlink") got, _ := os.ReadFile(victim) assert.Equal(t, "untouched", string(got), "the rollback wrote through the swapped-in symlink") })