sqlite

package
v0.16.1 Latest Latest
Warning

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

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

Documentation

Overview

Package sqlite implements ports.Store for standard-library facts using the shared mirror.db via modernc.org/sqlite (pure Go, no CGO). Facts are keyed by the canonical Go version so a tarball is acquired and verified at most once per version across projects.

Index

Constants

View Source
const RecordKind = "stdlib custody measurement"

RecordKind is how a set-aside measurement names its kind.

Variables

This section is empty.

Functions

func Migrations

func Migrations() []sqlitestore.Migration

Migrations returns the schema migrations for the stdlib module. Versioning is per-module (the schema_migrations key is (module, version)), so this is independent of the fetch and walk sequences.

Types

type Store

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

Store is the SQLite-backed standard-library fact store.

func New

func New(db sqlitestore.DB) *Store

New returns a Store using the provided database handle.

func Open

func Open(dsn string) (*Store, error)

Open opens (or creates) the SQLite database at dsn and runs migrations. Use ":memory:" for tests.

func (*Store) Get

func (s *Store) Get(ctx context.Context, goVersion string) (domain.Facts, bool, error)

Get returns the COMPOSED facts for goVersion. The bool is false when the ledger holds none.

Composition serves the most definite anchor, then the most recent — see domain.Compose. Recency alone never wins: a run that could not reach go.dev/dl states nothing about the published checksum, so it must not displace a run that matched it, which is the overwrite this conversion removed.

func (*Store) GetVia

func (s *Store) GetVia(ctx context.Context, goVersion string, route domain.AcquisitionRoute) (domain.Facts, bool, error)

GetVia answers the same question as Get but restricted to one acquisition route, so a caller that specifically wants the local toolchain's custody — or specifically the published tarball's — can ask for it rather than take the default.

func (*Store) ListFactsFor

func (s *Store) ListFactsFor(ctx context.Context, goVersion string) ([]domain.Facts, error)

ListFactsFor returns every measurement the ledger holds for one toolchain version, in the order they were appended, each with its seal verified.

This is what makes the ledger observable: a downgrade that was previously invisible — because it had replaced the record it downgraded — is now a row beside the one it lost to.

The secondary sort is the row id, not the content hash. acquired_at persists at second precision, which is the precision the seal covers, so two acquisitions within one second carry the same timestamp and only insertion order separates them.

A row whose stored values hash to its seal but which this build cannot reproduce is left out and named through ReportSetAside; when every row is, the answer is *recordseal.NothingServable. Any other seal mismatch is ErrFactsIntegrity and ends the read.

func (*Store) Put

func (s *Store) Put(ctx context.Context, f domain.Facts) error

Put APPENDS a measurement to the ledger.

It never updates. The key carries the acquisition route, the artefact digest, the time of measurement and the measurement's own seal, so two distinct acquisitions are always two rows; the same measurement written twice is a no-op, because it is one measurement rather than two — and it must not be an error, or a retried write would fail a run that had already succeeded.

func (*Store) ReportSetAside

func (s *Store) ReportSetAside(r func([]recordseal.SetAsideRow))

ReportSetAside states where the store names a measurement it set aside.

Jump to

Keyboard shortcuts

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