fix: keep task completion, cancel, pause, and undo honest

Pending earlier-revision jobs no longer skip completion repair; late
cancels preserve real exits; begin clears pause; partial undo keeps
snapshots; permissions and worktree failure paths are hardened.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WHC
2026-10-28 22:09:47 +08:00
co-authored by Cursor
parent d971cb02b0
commit acd6f1d998
7 changed files with 111 additions and 17 deletions
+15
View File
@@ -93,6 +93,21 @@ static void test_undo(void) {
EXPECT(cst_undo_snapshot(g_ws, sid, "t4", "../evil") != 0, "reject ..");
EXPECT(cst_undo_snapshot(g_ws, sid, "t4", "/etc/passwd") != 0,
"reject absolute");
/* Partial restore must keep the snapshot so a retry is possible. */
EXPECT(cst_undo_snapshot(g_ws, sid, "t5", "keep.txt") == 0, "snap keep");
wfile("keep.txt", "after\n");
{
char target[512];
snprintf(target, sizeof(target), "%s/keep.txt", g_ws);
unlink(target);
EXPECT(symlink("elsewhere", target) == 0, "make symlink");
EXPECT(cst_undo_restore_last(g_ws, sid, rep, sizeof(rep)) != 0,
"partial undo fails");
EXPECT(strstr(rep, "symlink") != NULL, "report names symlink skip");
EXPECT(cst_undo_count(g_ws, sid) == 1, "snapshot kept after partial fail");
unlink(target);
}
}
static void test_perms(void) {