fix: make worker handoff rotation durable

This commit is contained in:
kami
2026-07-30 01:30:59 +04:00
parent ce02c60106
commit 1ff0af2e69
16 changed files with 1488 additions and 1566 deletions
+48
View File
@@ -12,6 +12,54 @@ import (
"orchestra/internal/store"
)
func TestScratchCommitCapturesAllGitStatesExceptProtocolMarkers(t *testing.T) {
repo := t.TempDir()
run := func(args ...string) {
t.Helper()
if out, err := exec.Command("git", append([]string{"-C", repo}, args...)...).CombinedOutput(); err != nil {
t.Fatalf("git %v: %v: %s", args, err, out)
}
}
run("init")
run("config", "user.email", "t@t")
run("config", "user.name", "t")
for _, name := range []string{"TASK.md", "deleted.txt", "renamed.txt", "staged.txt"} {
if err := os.WriteFile(filepath.Join(repo, name), []byte(name), 0644); err != nil {
t.Fatal(err)
}
}
run("add", "-A")
run("commit", "-m", "base")
if err := os.WriteFile(filepath.Join(repo, "staged.txt"), []byte("staged change"), 0644); err != nil {
t.Fatal(err)
}
run("add", "staged.txt")
if err := os.Remove(filepath.Join(repo, "deleted.txt")); err != nil {
t.Fatal(err)
}
run("mv", "renamed.txt", "renamed-new.txt")
if err := os.WriteFile(filepath.Join(repo, "untracked.txt"), []byte("new"), 0644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(repo, ".orchestra-handoff-report.md"), []byte("protocol"), 0644); err != nil {
t.Fatal(err)
}
if err := ScratchCommit(repo, "orchestra/scratch/test", "checkpoint"); err != nil {
t.Fatal(err)
}
for _, want := range []string{"staged.txt", "renamed-new.txt", "untracked.txt"} {
if err := exec.Command("git", "-C", repo, "cat-file", "-e", "HEAD:"+want).Run(); err != nil {
t.Fatalf("checkpoint omitted %s: %v", want, err)
}
}
if err := exec.Command("git", "-C", repo, "cat-file", "-e", "HEAD:deleted.txt").Run(); err == nil {
t.Fatal("checkpoint retained deleted file")
}
if err := exec.Command("git", "-C", repo, "cat-file", "-e", "HEAD:.orchestra-handoff-report.md").Run(); err == nil {
t.Fatal("checkpoint committed protocol marker")
}
}
func TestHandoffCASAndPickup(t *testing.T) {
root := t.TempDir()
run := func(a ...string) {