Documentation
¶
Index ¶
- Constants
- Variables
- func Profile(info embedding.Info) embedding.Profile
- type ChunkOptions
- type ChunkProgress
- type ChunkStore
- type CompactionOptions
- type CompactionResult
- type CompactionStore
- type EmbedBatchOptions
- type EmbedBatchResult
- type EmbedOptions
- type EmbedStore
- type FlushOptions
- type FlushResult
- type FlushStore
- type Progress
- type ProjectionBatchOptions
- type SegmentCompactionClass
- type SegmentCompactionInput
- type SegmentCompactionKind
- type SegmentCompactionOutput
- type SegmentCompactionPlan
- type SegmentPayloadBuilder
- type Status
- type StatusStore
- type StreamingSegmentPayloadBuilder
- type StreamingSegmentPayloadSession
- type VerifyOptions
- type VerifyProgress
- type VerifyStore
- type WorkProgress
Constants ¶
const ( MaxEmbeddingBatchSize = 5_000 MaxConsecutiveProviderFailures = 3 DefaultRetryInitialBackoff = time.Second DefaultRetryMaxBackoff = 30 * time.Second )
Variables ¶
var ErrEmbedCircuitOpen = errors.New("semantic embedding circuit opened after three consecutive retryable provider failures")
Functions ¶
Types ¶
type ChunkOptions ¶
type ChunkOptions struct {
Limit int
// Deprecated: nonblank source cursors are rejected because the durable dirty
// ledger provides the resume position.
AfterSourceKey string
Progress func(ChunkProgress) error
MaxDuration time.Duration
UntilIdle bool
Now func() time.Time
// contains filtered or unexported fields
}
type ChunkProgress ¶
type ChunkProgress struct {
Progress
Created int `json:"created"`
Updated int `json:"updated"`
Deleted int `json:"deleted"`
// Deprecated: the durable dirty ledger resumes automatically.
NextAfterSourceKey string `json:"next_after_source_key,omitempty"`
HasMore bool `json:"has_more"`
Checkpoint *store.RetrievalProjectionCheckpoint `json:"checkpoint,omitempty"`
}
func RunChunk ¶
func RunChunk(ctx context.Context, st ChunkStore, opts ChunkOptions) (ChunkProgress, error)
func RunProjectionBatch ¶
func RunProjectionBatch(ctx context.Context, st ChunkStore, opts ProjectionBatchOptions) (ChunkProgress, error)
RunProjectionBatch performs exactly one page of projection work at the caller-supplied watermark. It never reads or advances ProjectionWorkRevision.
type ChunkStore ¶
type ChunkStore interface {
ProjectionWorkRevision(context.Context) (int64, error)
RetrievalPurgeEpoch(context.Context) (int64, error)
ListDirtyRetrievalParents(context.Context, int64, int) ([]store.RetrievalParentWork, error)
ApplyRetrievalProjection(context.Context, store.ApplyRetrievalProjectionInput) (store.ChunkReplaceResult, error)
LoadRetrievalProjectionStaging(context.Context, retrievalchunk.Parent, int64) (store.RetrievalProjectionCheckpoint, bool, error)
StageRetrievalProjectionBatch(context.Context, store.StageRetrievalProjectionInput) (store.RetrievalProjectionCheckpoint, error)
PromoteRetrievalProjectionStaging(context.Context, store.RetrievalProjectionCheckpoint) (store.ChunkReplaceResult, error)
BlockRetrievalProjectionTooLarge(context.Context, retrievalchunk.Parent, int64, string, int64) error
}
type CompactionOptions ¶
type CompactionOptions struct {
Profile embedding.Profile
Backend, BackendVersion, DistanceMetric, CacheDir string
Progress func(WorkProgress) error
}
CompactionOptions identifies the immutable embedding profile and derived backend provenance for one replacement-root attempt.
type CompactionResult ¶
type CompactionResult struct {
Plan SegmentCompactionPlan
GenerationID string
ReplacementSegmentHashes []string
Indexed, StreamedLiveMembers int
}
CompactionResult records the pure selection outcome. Later fields are added only after payload/root publication succeeds.
func Compact ¶
func Compact(ctx context.Context, st CompactionStore, builder StreamingSegmentPayloadBuilder, opts CompactionOptions) (CompactionResult, error)
Compact is the entrypoint for bounded physical compaction. The initial implementation establishes the injected, non-serving selection boundary; it never falls back to a whole-corpus scan.
type CompactionStore ¶
type CompactionStore interface {
RetrievalDatabaseID(context.Context) (string, error)
RetrievalActiveSegmentCompactionSnapshot(context.Context, string) (store.RetrievalActiveSegmentCompactionSnapshot, error)
StreamRetrievalActiveSegmentMembers(context.Context, store.RetrievalActiveSegmentMemberStreamRequest, store.RetrievalActiveSegmentMemberVisitor) (int, error)
RetrievalIndexGenerationSegments(context.Context, string) ([]store.RetrievalIndexSegmentRow, error)
CompleteRetrievalIndexGeneration(context.Context, store.CompleteRetrievalIndexGenerationInput) error
}
CompactionStore is the non-serving persistence boundary for one bounded physical compaction. The executor will use only the selected snapshot rows and existing generation activation CAS.
type EmbedBatchOptions ¶
type EmbedBatchResult ¶
type EmbedBatchResult struct {
Progress
Revision int64 `json:"revision"`
HasMore bool `json:"has_more"`
}
func RunEmbedBatch ¶
func RunEmbedBatch(ctx context.Context, st EmbedStore, provider embedding.Provider, opts EmbedBatchOptions) (EmbedBatchResult, error)
type EmbedOptions ¶
type EmbedStore ¶
type EmbedStore interface {
ListChunksNeedingEmbeddingForProfileAt(context.Context, embedding.Profile, string, int, time.Time) ([]store.RetrievalChunkRow, error)
CountChunksNeedingEmbeddingForProfileAt(context.Context, embedding.Profile, time.Time) (int, error)
RetrievalPurgeEpoch(context.Context) (int64, error)
RetrievalEmbeddingProfile(context.Context, string) (store.RetrievalEmbeddingProfileRow, error)
PutRetrievalEmbeddingBatch(context.Context, store.PutRetrievalEmbeddingBatchInput) (int64, error)
}
type FlushOptions ¶
type FlushResult ¶
type FlushResult struct {
GenerationID, SegmentHash string
Indexed, Flushed, L0Ready int
SnapshotRevision int64
}
func Flush ¶
func Flush(ctx context.Context, st FlushStore, builder SegmentPayloadBuilder, opts FlushOptions) (FlushResult, error)
Flush creates exactly one immutable segment from the oldest revision-prefix of the L0 tail. The caller supplies an opaque backend payload builder; this package never selects or links a native backend itself.
type FlushStore ¶
type FlushStore interface {
RetrievalDatabaseID(context.Context) (string, error)
NextRetrievalFlushWindow(context.Context, string, int) (store.RetrievalFlushWindow, error)
RetrievalIndexGenerationSegments(context.Context, string) ([]store.RetrievalIndexSegmentRow, error)
CompleteRetrievalIndexGeneration(context.Context, store.CompleteRetrievalIndexGenerationInput) error
}
type Progress ¶
type Progress struct {
Stage string `json:"stage"`
Interrupted bool `json:"interrupted"`
Scanned int `json:"scanned"`
Current int `json:"current"`
Generated int `json:"generated"`
Quarantined int `json:"quarantined"`
Blocked int `json:"blocked"`
Failed int `json:"failed"`
Remaining int `json:"remaining"`
SnapshotCount int `json:"snapshot_count"`
SnapshotsTruncated bool `json:"snapshots_truncated"`
LastSnapshot *Progress `json:"last_snapshot,omitempty"`
Snapshots []Progress `json:"-"`
}
func RunEmbed ¶
func RunEmbed(ctx context.Context, st EmbedStore, provider embedding.Provider, opts EmbedOptions) (Progress, error)
type ProjectionBatchOptions ¶
type ProjectionBatchOptions struct {
Watermark int64
ExpectedPurgeEpoch int64
Limit int
Progress func(ChunkProgress) error
Now func() time.Time
}
ProjectionBatchOptions selects one bounded projection page from an immutable caller-owned work watermark. It deliberately cannot allocate a watermark: refresh runs allocate successor watermarks after their pinned work is idle.
type SegmentCompactionClass ¶
type SegmentCompactionClass string
const ( SegmentCompactionClassExactL0 SegmentCompactionClass = "exact_l0" SegmentCompactionClass5K SegmentCompactionClass = "5k" SegmentCompactionClass10K SegmentCompactionClass = "10k" SegmentCompactionClass20K SegmentCompactionClass = "20k" SegmentCompactionClass40K SegmentCompactionClass = "40k" SegmentCompactionClass80K SegmentCompactionClass = "80k" SegmentCompactionClassCapped SegmentCompactionClass = "capped" SegmentCompactionClassInvalid SegmentCompactionClass = "invalid" )
func ClassifySegmentCompactionCount ¶
func ClassifySegmentCompactionCount(live int) SegmentCompactionClass
ClassifySegmentCompactionCount maps an already-filtered live membership count to its storage tier. Counts below the minimum belong in exact L0; a physical ANN segment never exceeds the capped upper bound.
type SegmentCompactionInput ¶
type SegmentCompactionKind ¶
type SegmentCompactionKind string
const ( SegmentCompactionNone SegmentCompactionKind = "none" SegmentCompactionSingleton SegmentCompactionKind = "singleton" SegmentCompactionPair SegmentCompactionKind = "pair" )
type SegmentCompactionOutput ¶
type SegmentCompactionOutput struct {
LiveCount int
Class SegmentCompactionClass
}
type SegmentCompactionPlan ¶
type SegmentCompactionPlan struct {
Kind SegmentCompactionKind
Inputs []SegmentCompactionInput
Outputs []SegmentCompactionOutput
}
func PlanSegmentCompaction ¶
func PlanSegmentCompaction(inputs []SegmentCompactionInput) (SegmentCompactionPlan, error)
PlanSegmentCompaction chooses one bounded maintenance action from immutable segment facts. It deliberately does not inspect vectors, SQLite membership, or cache paths; later orchestration must revalidate this plan before writing.
type SegmentPayloadBuilder ¶
type Status ¶
type Status struct {
Status string `json:"status"`
Reason string `json:"reason"`
Searchable bool `json:"searchable"`
Mode string `json:"mode"`
ProfileID string `json:"profile_id"`
BackendCapability semanticindex.Capability `json:"backend_capability"`
Store semanticreadiness.Snapshot `json:"store"`
LatestRun *store.SemanticRefreshRun `json:"latest_run"`
Problems []string `json:"problems"`
Next []string `json:"next_steps"`
}
func ReadStatus ¶
func ReadStatus( ctx context.Context, st StatusStore, profile embedding.Profile, configured bool, enabled bool, exactMaxChunks int, capability semanticindex.Capability, now time.Time, ) (Status, error)
func ReadStatusWithNativeValidation ¶
func ReadStatusWithNativeValidation( ctx context.Context, st StatusStore, profile embedding.Profile, configured bool, enabled bool, exactMaxChunks int, capability semanticindex.Capability, now time.Time, validateNativeRoot func(context.Context, semanticreadiness.Snapshot) error, ) (Status, error)
ReadStatusWithNativeValidation reports status after optionally checking that an admitted native root can be opened by the runtime.
type StatusStore ¶
type StreamingSegmentPayloadBuilder ¶
type StreamingSegmentPayloadBuilder interface {
Begin(context.Context, int) (StreamingSegmentPayloadSession, error)
}
StreamingSegmentPayloadBuilder creates a bounded session that accepts source embeddings one at a time. It is separate from SegmentPayloadBuilder so the established flush contract remains stable while compaction can avoid materializing its full source-row slice.
type StreamingSegmentPayloadSession ¶
type StreamingSegmentPayloadSession interface {
Add(context.Context, store.RetrievalEmbeddingRow) error
Finish(context.Context) (func(io.Writer) error, error)
Close() error
}
StreamingSegmentPayloadSession accepts exactly the count declared at Begin. Finish returns a self-contained opaque payload writer and releases any native state; Close is idempotent and releases a session abandoned before Finish.
type VerifyOptions ¶
type VerifyProgress ¶
type VerifyProgress struct {
Progress
Resume string `json:"resume,omitempty"`
HasMore bool `json:"has_more"`
CountersRepaired bool `json:"counters_repaired"`
}
func RunVerify ¶
func RunVerify(ctx context.Context, st VerifyStore, opts VerifyOptions) (VerifyProgress, error)
type VerifyStore ¶
type VerifyStore interface {
RepairRetrievalRuntimeReadinessCounters(context.Context) error
RetrievalEmbeddingVerificationState(context.Context, string) (store.RetrievalEmbeddingVerificationState, error)
ListRetrievalVectors(context.Context, string, store.VectorPage) ([]store.RetrievalVectorRow, error)
BlockCorruptRetrievalEmbedding(context.Context, *store.RetrievalEmbeddingCorruptionError) error
}
type WorkProgress ¶ added in v0.8.9
WorkProgress reports absolute processed units for one bounded semantic-build operation. Callers accumulate these operation-local measurements into their own stage-level progress.