An open-source, faster Devin alternative
TypeScript
hash whole thing
Brian Reardon5285a76eb40b
diff --git a/internal/qemu/golden_version.go b/internal/qemu/golden_version.goindex 931dc4b3..d0e63d2c 100644--- a/internal/qemu/golden_version.go+++ b/internal/qemu/golden_version.go@@ -8,9 +8,15 @@ import ()// computeGoldenVersion computes a version hash for a golden snapshot by hashing-// the first 1MB of the base image. Two workers with the same base image will-// produce the same hash. This is fast (1MB read) and sufficient to detect-// different base images (kernel, OS, packages).+// the entire base image. Two workers with byte-identical base images produce+// the same hash; any difference — even bytes past the first megabyte — yields+// a different hash. ~20s for a 4GB base on NVMe, called only on worker startup.+//+// History: previously hashed only the first 1MB, which collided when bases+// were rebuilt with the same superblock/boot region but different userspace.+// That caused ensureCheckpointRebased to miss real mismatches and silently+// serve stale overlays against fresh bases, producing ext4 directory-block+// checksum errors in guests.func computeGoldenVersion(baseImagePath string) (string, error) {f, err := os.Open(baseImagePath)if err != nil {@@ -19,7 +25,7 @@ func computeGoldenVersion(baseImagePath string) (string, error) {defer f.Close()h := sha256.New()- if _, err := io.CopyN(h, f, 1024*1024); err != nil && err != io.EOF {+ if _, err := io.Copy(h, f); err != nil {return "", fmt.Errorf("read base image: %w", err)}return fmt.Sprintf("%x", h.Sum(nil))[:16], nil