Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package store provides the single-host storage and authorization boundary. Every publication is one SQLite transaction, including its immutable content, current pointer, retry receipt, and audit record.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code           string
	Message        string
	CurrentVersion int64
}

Error is an expected application error, safe to return to an API client.

func (*Error) Error

func (e *Error) Error() string

type Principal

type Principal struct {
	AgentID   string
	Scope     string
	TokenHash string
}

Principal is established by Authenticate. Store operations verify it again, so constructing a Principal alone does not grant access.

type Store

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

func Open

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

Open creates or opens a local SQLite database. New directories are private; existing parent directories retain their permissions. SQLite must reside on a local filesystem, not a shared network volume.

func (*Store) Audit

func (s *Store) Audit(ctx context.Context, p Principal, limit int) ([]protocol.AuditEvent, error)

Audit returns at most 1000 events in the principal's scope, newest first. Nonpositive limits use the default of 100.

func (*Store) Authenticate

func (s *Store) Authenticate(ctx context.Context, token string) (Principal, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateToken

func (s *Store) CreateToken(ctx context.Context, agentID, scope string) (string, error)

CreateToken creates a new immutable agent identity. The plaintext token is returned once; only its SHA-256 digest is persisted. Revoked agent IDs cannot be recycled, preserving the meaning of audit and idempotency records.

func (*Store) Get

func (s *Store) Get(ctx context.Context, p Principal, key string) (protocol.Artifact, error)

func (*Store) Identity added in v0.8.0

func (s *Store) Identity(ctx context.Context, p Principal) (protocol.Identity, error)

func (*Store) List

func (s *Store) List(ctx context.Context, p Principal) ([]protocol.Artifact, error)

List returns metadata for at most the first 1000 current artifacts ordered by key. Content is deliberately omitted to keep list responses bounded; Get fetches an individual artifact's content.

func (*Store) Publish

Publish applies compare-and-swap within the authenticated scope. A successful operation ID is permanently bound to the complete original request. Retries return that original version even after newer versions have been published.

func (*Store) PublishPinned added in v0.8.0

PublishPinned adds a rejection-only identity precondition inside the existing CAS transaction. It never grants the supplied scope or agent any authority.

func (*Store) RevokeAgent

func (s *Store) RevokeAgent(ctx context.Context, agentID string) error

func (*Store) Sync added in v0.8.0

Sync reconstructs bounded historical snapshots and accepted-write deltas. It authenticates inside one read transaction and accepts no incoming writes.

Jump to

Keyboard shortcuts

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