artifact

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package artifact persists base indexes — ngram (KURNIDX1: magic header, JSON meta, then length-prefixed gram/bitmap pairs) and exact (KURNEXA1, see exact.go). Saves are atomic (temp+rename, fsynced) and deterministic (keys written in sorted order, so identical indexes produce byte-identical files). Corruption rejection is structural only (no checksum): a bit-flip inside a payload can deserialize as different valid data — acceptable for the experiment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(path string, idx *ngram.Index, analyzerDigest string, build BuildInfo) error

func SaveExact

func SaveExact(path string, idx *exact.Index, analyzerDigest string, build BuildInfo) error

SaveExact atomically writes idx to path in KURNEXA1 format.

Types

type BuildInfo added in v0.2.0

type BuildInfo struct {
	// BaseID is the content-addressed identity of the base.jsonl the index
	// was built from (the version stamp's hash half). An index is a map
	// from grams to ORDINAL POSITIONS in that specific file: against any
	// other content of the same length every check can pass while the
	// postings point at different entities, so a query returns entry X
	// carrying entry Y's matching evidence. Counts cannot detect that;
	// only identity can.
	BaseID         string `json:"base_id"`
	Entries        int    `json:"entries"`
	DroppedKeys    int    `json:"dropped_keys"`
	KeylessEntries int    `json:"keyless_entries"`
}

BuildInfo travels with an index so its loss counters survive a reload, and — the load-bearing half — binds the index to the exact base content whose ordinal assignments it encodes.

func Load

func Load(path string) (*ngram.Index, string, *BuildInfo, error)

func LoadExact

func LoadExact(path string) (*exact.Index, string, *BuildInfo, error)

LoadExact reads a KURNEXA1 file back into an exact.Index, also returning the analyzer digest recorded in the header ("" for pre-digest artifacts). Any structural problem — bad magic, implausible header, short section, trailing bytes, inconsistent lengths — is an error; the caller falls back to a rebuild.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址