Artifact b5d84c60053f8efcd9d7e6bd621e9f3660767c0dd7821f3975c539a08706e35d:
- File
conformance/horizon_delta_test.go
— part of check-in
[f0354673e2]
at
2026-10-22 22:54:46
on branch feat/horizon-cones
— fix(sync): label the parents of every held manifest at a structural horizon
A structural clone holds the manifests of the held set and everything they reach through B and S cards (draft-fossil-horizon-00 §5.1), so a delta manifest's baseline below C is held. Its parents were labelled by nobody: boundaryOf took the parents of K's check-ins only. The clone then classified such a parent as transit and requested it, and the origin, which withholds manifests below C, never sent it; the clone stalled with one phantom outstanding. zit's origin has the same gap (sparse.zig 758-783), and zit's author agreed the draft will define a boundary hash as an unheld parent of any manifest the clone holds. boundaryOf now labels the parents of K and of every check-in the reach holds.
The regression is the HZ-3.1-4 case for a delta manifest in K whose baseline lies below C: the clone completes, the baseline is held but not a leaf, and K's check-ins derive the dense repository's tags. (user: [email protected], size: 3493) [annotate] [blame] [check-ins using]
package conformance import ( "context" "path/filepath" "slices" "testing" "time" "github.com/danmestas/go-libfossil/internal/cone" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" "github.com/danmestas/go-libfossil/internal/manifest" "github.com/danmestas/go-libfossil/internal/sync" ) // A delta manifest in K whose baseline lies below C (draft-fossil-horizon-00 // §3.1, §5.1): the baseline is held without being in K, and the structural // store derives the same branch and leaf state for K as the dense origin and // shows the baseline as no leaf. var horizonDeltaBaseline = Case{ID: "horizon.3.1.delta-baseline-below", Req: "HZ-3.1-4"} func horizonDeltaCases() []Case { return []Case{horizonDeltaBaseline} } func TestHorizonDeltaBaseline(t *testing.T) { check(t, horizonDeltaBaseline, func() error { return hzDeltaBaseline(t) }) } func hzDeltaBaseline(t *testing.T) error { f := newSCSyncRepo(t, scSyncFiles()) commit := func(parent libfossil.FslID, x string, delta bool) libfossil.FslID { t.Helper() files := []manifest.File{{Name: "x", Content: []byte(x)}} for name, body := range scSyncFiles() { files = append(files, manifest.File{Name: name, Content: []byte(body)}) } f.when = f.when.Add(time.Hour) rid, _, err := manifest.Checkin(f.r, manifest.CheckinOpts{ Files: files, Comment: x, User: "u", Parent: parent, Delta: delta, Time: f.when, }) if err != nil { t.Fatal(err) } return rid } c2 := commit(f.c1, "v2\n", false) c3 := commit(c2, "v3\n", true) c4 := commit(c3, "v4\n", true) for _, rid := range []libfossil.FslID{c3, c4} { d := hzDeckOf(t, f.r, rid) if d.B != hzUUID(t, f.r, c2) { return expectf("fixture: check-in %d B card %q, want the baseline %s", rid, d.B, hzUUID(t, f.r, c2)) } } u3, u2 := hzUUID(t, f.r, c3), hzUUID(t, f.r, c2) h, err := cone.NewHorizon(u3, cone.RuleDescendants, cone.DepthStructural) if err != nil { return err } sc, err := cone.NewWithHorizon(nil, nil, h) if err != nil { return err } r, result, err := sync.Clone(context.Background(), filepath.Join(t.TempDir(), "delta.fossil"), &scSyncPeer{r: f.r}, sync.CloneOpts{StoreCone: sc, PullPhantoms: true}) if err != nil { return expectf("structural clone with a baseline below C: %v", err) } t.Cleanup(func() { r.Close() }) if result.HorizonFallback || result.StructuralServed == 0 { return expectf("clone fell back %v, served structural in %d rounds", result.HorizonFallback, result.StructuralServed) } if err := hzHeld(r, map[string]bool{u2: true}, true); err != nil { return expectf("baseline below C: %v", err) } for _, rid := range []libfossil.FslID{c3, c4} { u := hzUUID(t, f.r, rid) want, err := hzTagState(f.r.DB(), u) if err != nil { return err } got, err := hzTagState(r.DB(), u) if err != nil { return err } if !slices.Equal(got, want) { return expectf("check-in %.10s carries %v, dense %v", u, got, want) } var leafGot, leafWant int r.DB().QueryRow("SELECT count(*) FROM leaf JOIN blob USING(rid) WHERE uuid=?", u).Scan(&leafGot) f.r.DB().QueryRow("SELECT count(*) FROM leaf JOIN blob USING(rid) WHERE uuid=?", u).Scan(&leafWant) if leafGot != leafWant { return expectf("check-in %.10s leaf %d, dense %d", u, leafGot, leafWant) } } var leaf int r.DB().QueryRow("SELECT count(*) FROM leaf JOIN blob USING(rid) WHERE uuid=?", u2).Scan(&leaf) if leaf != 0 { return expectf("the baseline %.10s below C is shown as a leaf", u2) } return nil }