comparecache

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package comparecache is a server-private SQLite convenience store for comparison rows. It is not evidence or authority: every page read must re-authorize the retained snapshots that produced the comparison.

Index

Constants

View Source
const (
	DefaultByteCap = 32 << 20
	DefaultTTL     = 24 * time.Hour
	DefaultLimit   = 50
)

Variables

View Source
var (
	ErrNotConfigured = errors.New("comparison cache is not configured")
	ErrNotFound      = errors.New("cached comparison not found")
)

Functions

func ID

func ID(left, right apicontract.ExecutionRef) string

ID derives the cache key from the two execution receipts already present on CompareResult. Core does not mint a separate comparison identifier.

Types

type BeginRequest

type BeginRequest struct {
	PolicyFingerprint string
	QueryID           string
	Left              apicontract.ExecutionRef
	Right             apicontract.ExecutionRef
}

type CachedDelta

type CachedDelta struct {
	Column string                 `json:"column"`
	Value  apicontract.TypedValue `json:"value,omitempty"`
	Absent bool                   `json:"absent,omitempty"`
}

type CachedRow

type CachedRow struct {
	SortKey string                   `json:"sortKey"`
	Key     []apicontract.TypedValue `json:"key"`
	Row     []apicontract.TypedValue `json:"row"`
	Deltas  []CachedDelta            `json:"deltas,omitempty"`
}

type Meta

type Meta struct {
	PolicyFingerprint string
	ComparisonID      string
	QueryID           string
	Left              apicontract.ExecutionRef
	Right             apicontract.ExecutionRef
	Columns           []apicontract.Column
	Key               []string
}

type Options

type Options struct {
	PrivateDir string
	ByteCap    int
	TTL        time.Duration
	Now        func() time.Time
}

Options are trusted server configuration, never request-controlled.

type Page

type Page struct {
	ComparisonID string                   `json:"comparisonId"`
	State        string                   `json:"state"`
	QueryID      string                   `json:"queryId"`
	Left         apicontract.ExecutionRef `json:"left"`
	Right        apicontract.ExecutionRef `json:"right"`
	Columns      []apicontract.Column     `json:"columns"`
	Key          []string                 `json:"key"`
	Rows         []CachedRow              `json:"rows"`
	NextSortKey  string                   `json:"nextSortKey,omitempty"`
	Truncated    bool                     `json:"truncated"`
}

type PageRequest

type PageRequest struct {
	PolicyFingerprint string
	ComparisonID      string
	State             recordsetcompare.RecordState
	After             string
	Limit             int
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(options Options) (*Store, error)

func (*Store) Begin

func (s *Store) Begin(ctx context.Context, req BeginRequest) (*WriteSession, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Lookup

func (s *Store) Lookup(ctx context.Context, comparisonID string) (Meta, error)

func (*Store) Page

func (s *Store) Page(ctx context.Context, req PageRequest) (Page, error)

type WriteSession

type WriteSession struct {
	// contains filtered or unexported fields
}

func (*WriteSession) Abort

func (s *WriteSession) Abort()

func (*WriteSession) Commit

func (s *WriteSession) Commit(result apicontract.CompareResult) error

func (*WriteSession) Observer

Jump to

Keyboard shortcuts

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