transcript

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Overview

Package transcript is the box's durable transcript: every settled entity revision, kept on the workspace volume (~/.plural/transcripts) so it survives suspends, snapshots and daemon restarts, and served to the gateway by Daemon.GetTimeline.

Layout, under one gocloud.dev/blob bucket (fileblob on the box, memblob in tests):

sessions/<session>/segments/<seq>-<nanos>-<rand>.ndjson.zst  append-only batches of AcpEntity revisions
sessions/<session>/snapshot/index.json                        position index of the current compacted snapshot
sessions/<session>/snapshot/g<gen>/<chunk>.ndjson.zst         latest revision of every entity, by position

Segments are written once and never modified. Records are idempotent on (type, id, revision) and every reader keeps the highest revision per key. The compactor folds segments into a new snapshot generation, then deletes the folded segments and the previous generation. Readers tolerate objects disappearing under them by retrying.

Index

Constants

View Source
const (
	// DefaultChunkSize is the number of entities per compacted snapshot chunk, i.e. the paging granularity.
	DefaultChunkSize = 500
	// DefaultCompactThreshold is the number of segments that makes a session worth compacting.
	DefaultCompactThreshold = 16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

func WithChunkSize

func WithChunkSize(n int) Option

func WithClock

func WithClock(now func() time.Time) Option

func WithCompactThreshold

func WithCompactThreshold(n int) Option

type Page

type Page struct {
	Entities     []*devboxv1.AcpEntity
	NextPosition uint64
	HasMore      bool
}

Page is one page of a session's timeline, in position order.

type Store

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

Store is a box's transcript.

func Memory

func Memory(opts ...Option) *Store

Memory returns an in-memory transcript (tests).

func New

func New(b *blob.Bucket, opts ...Option) *Store

New wraps a bucket.

func Open

func Open(dir string, opts ...Option) (*Store, error)

Open opens (creating) the transcript in dir.

func (*Store) Append

func (s *Store) Append(ctx context.Context, entities []*devboxv1.AcpEntity) error

Append durably writes one batch of entity revisions, one segment per session. Entities without a session are rejected.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Compact

func (s *Store) Compact(ctx context.Context, session string) error

Compact folds a session's segments into a new snapshot generation. It is a no-op without segments.

func (*Store) CompactAll

func (s *Store) CompactAll(ctx context.Context, force bool) error

CompactAll compacts every session with at least the configured number of segments, or every session with any segment when force is set.

func (*Store) Reset

func (s *Store) Reset(ctx context.Context) error

Reset deletes the whole transcript (a snapshot restored as a new instance starts with an empty history).

func (*Store) Timeline

func (s *Store) Timeline(ctx context.Context, session string, after uint64, limit int, overlay []*devboxv1.AcpEntity) (*Page, error)

Timeline returns up to limit entities with position > after, merging the compacted snapshot, uncompacted segments and overlay (revisions the caller holds in memory; they win when their revision is higher).

func (*Store) TimelineBefore

func (s *Store) TimelineBefore(ctx context.Context, session string, before uint64, limit int, overlay []*devboxv1.AcpEntity) (*Page, error)

TimelineBefore returns the newest limit entities with position < before (0: the newest of all), in position order. HasMore says older entities exist and NextPosition is the cursor for them.

Jump to

Keyboard shortcuts

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