Artifact d4d7253c3b25e83dacf0ce95279d5b7ac101582bde440e15a6c39f1b7f0b77a9:
- File
internal/content/cone_successor_test.go
— part of check-in
[065f76e22f]
at
2026-10-21 00:36:41
on branch feat/submanifest-reader
— feat(sync): index prepared sparse clone successors
Prepare verified raw references under explicit byte, card, artifact and index-slot budgets before allocating payload expansions. Use request-local cone spans over a cone-independent range index to skip excluded RID gaps without empty clone continuation pages.
Keep this internal: selected-content reconstruction still uses dense allocation behavior, ordinary pull still scans inventory, and retaining every tree node is not proof of tree-minimal emission. No public wrapper, capability grammar or client continuation changes. (user: [email protected], size: 2989) [annotate] [blame] [check-ins using] [more...]
package content import ( "context" "fmt" "testing" "github.com/danmestas/go-libfossil/internal/cone" "github.com/danmestas/go-libfossil/internal/deck" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" ) func TestConeSuccessorConeIntervalsAndOverrides(t *testing.T) { paths := []string{"src", "src-x", "src/a", "src/private/a", "src/private/open/a", "zzz/a"} facts := &ConeReferenceFacts{names: map[libfossil.FslID]string{}, held: map[string]libfossil.FslID{}} visible := make([]libfossil.FslID, len(paths)+1) manifest := &deck.Deck{} for i, path := range paths { rid := libfossil.FslID(i + 1) uuid := fmt.Sprintf("%040x", rid) facts.names[rid], facts.held[uuid], visible[i] = uuid, rid, rid manifest.F = append(manifest.F, deck.FileCard{Name: path, UUID: uuid}) } // The outside artifact has an inside alias; structural references override // excluded aliases. The last RID is unknown and must remain dense. manifest.F = append(manifest.F, deck.FileCard{Name: "src/alias", UUID: facts.names[6]}) manifest.B = facts.names[4] visible[6], facts.names[7] = 7, "unknown" facts.records = []coneReferenceRecord{{uuid: "manifest", deck: manifest}} index, err := NewConeSuccessors(context.Background(), facts, visible, 100, 10000) if err != nil { t.Fatal(err) } c, err := cone.New([]string{"src", "src/private/open"}, []string{"src/private"}) if err != nil { t.Fatal(err) } query := index.Query(c) want := []libfossil.FslID{1, 3, 4, 5, 6, 7} first := libfossil.FslID(1) for _, expected := range want { got := query.Next(first, 7) if got != expected { t.Fatalf("next(%d)=%d want=%d", first, got, expected) } first = got + 1 } if got := query.Next(first, 7); got != 0 { t.Fatalf("exhaustion returned %d", got) } } func TestConeSuccessorSkipsExcludedGap(t *testing.T) { facts := &ConeReferenceFacts{names: map[libfossil.FslID]string{}, held: map[string]libfossil.FslID{}} visible := make([]libfossil.FslID, 10001) manifest := &deck.Deck{} for i := range visible { rid := libfossil.FslID(i + 1) uuid := fmt.Sprintf("%040x", i+1) facts.names[rid], facts.held[uuid], visible[i] = uuid, rid, rid name := fmt.Sprintf("zzz/%05d", i) if i == len(visible)-1 { name = "src/final" } manifest.F = append(manifest.F, deck.FileCard{Name: name, UUID: uuid}) } facts.records = []coneReferenceRecord{{uuid: "manifest", deck: manifest}} index, err := NewConeSuccessors(context.Background(), facts, visible, 20000, 1<<20) if err != nil { t.Fatal(err) } c, err := cone.New([]string{"src"}, nil) if err != nil { t.Fatal(err) } query := index.Query(c) if rid := query.Next(1, 20000); rid != 10001 { t.Fatalf("next eligible=%d", rid) } if query.Work.IndexVisits > 32 || query.Work.RIDComparisons > 64 { t.Fatalf("excluded gap was scanned: %+v", query.Work) } if _, err := NewConeSuccessors(context.Background(), facts, visible, 20000, 1); err == nil { t.Fatal("index allocation budget not enforced") } }