pkg/corpus¶
GGUF seed generation, in-memory corpora, and format-agnostic minimization.
Generation¶
func GenerateSeeds() ([]*gguf.File, error)
func GenerateCorpus(outputDir string) error
func GenerateArchitectureSeeds(outputDir string) error
func GenerateClipSeeds(outputDir string) error
func GenerateTalosSeeds(outputDir string) error
GenerateCorpus creates the destination and writes seed_NNN.gguf files.
Directory loading¶
func LoadCorpus(dir string) ([]*gguf.File, error)
func LoadCorpusBytes(dir string) ([][]byte, error)
Both functions inspect only direct, non-directory children ending in .gguf; they are not recursive. LoadCorpus fails if a selected file cannot be read or parsed.
Corpus¶
This package uses the legacy math/rand API for Corpus, distinct from the mutator package's math/rand/v2.
func (c *Corpus) Len() int
func (c *Corpus) Add(f *gguf.File)
func (c *Corpus) AddBytes(data []byte) error
func (c *Corpus) Get(i int) *gguf.File
func (c *Corpus) GetBytes(i int) ([]byte, error)
func (c *Corpus) Pick() *gguf.File
func (c *Corpus) PickBytes() ([]byte, error)
func (c *Corpus) Seeds() []*gguf.File
func (c *Corpus) LoadInto(dir string) error
The type synchronizes access. Get and Pick return stored pointers; callers that mutate them should clone first when isolation matters.
Format-agnostic minimization¶
type CorpusEntry interface {
Serialize() ([]byte, error)
}
type GGUFEntry struct {
File *gguf.File
}
type RawFileEntry struct {
Path string
Data []byte
}
func WrapGGUF(files []*gguf.File) []CorpusEntry
func UnwrapGGUF(entries []CorpusEntry) []*gguf.File
func Minimize(entries []CorpusEntry) []CorpusEntry
func MinimizeWithCoverage(entries []CorpusEntry, harness string) ([]CorpusEntry, error)
Minimize removes entries with identical serialized SHA-256 content, retaining the first. Serialization failures are preserved.
MinimizeWithCoverage expects a harness that accepts one file path and was built with LLVM source coverage. It bounds each probe, performs greedy set cover, and preserves zero-coverage entries after content dedup. An empty harness requests content dedup. If no usable coverage is collected, the implementation logs the condition and falls back to content dedup.