journal

package
v0.3.0-beta.27 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package journal owns terminal command persistence and retained byte artifacts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Databases *workspacedb.Pool
	HomeDir   string
	Logger    *slog.Logger
	Now       func() time.Time
	Entropy   io.Reader
}

Options configures the durable terminal journal.

type Service

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

Service implements the terminal journal over per-workspace SQLite stores.

func New

func New(ctx context.Context, options Options) (*Service, error)

New constructs a durable journal.

func (*Service) Artifact

func (s *Service) Artifact(
	ctx context.Context,
	workspaceID string,
	scope store.ReadScope,
	id string,
) (io.ReadCloser, error)

Artifact opens a profile-scoped spill artifact after containment validation.

func (*Service) CloseTerminal

func (s *Service) CloseTerminal(ctx context.Context, info terminalpkg.Info) error

CloseTerminal flushes and removes the writer lane owned by one terminal.

func (*Service) ConsumeMarkerFacts

func (s *Service) ConsumeMarkerFacts(
	ctx context.Context,
	info terminalpkg.Info,
	facts []terminalpkg.MarkerFacts,
) error

ConsumeMarkerFacts assembles authenticated shell facts without parsing bytes again.

func (*Service) LinkRecording

func (s *Service) LinkRecording(
	ctx context.Context,
	workspaceID string,
	terminalID terminalpkg.ID,
	recording terminalpkg.RecordingRef,
) error

LinkRecording persists a recording and links commands captured in its window.

func (*Service) ObserveInput

func (s *Service) ObserveInput(info terminalpkg.Info, actor terminalpkg.Actor, input []byte)

ObserveInput records accepted human input as an approximate fallback candidate.

func (*Service) ObserveOutput

func (s *Service) ObserveOutput(info terminalpkg.Info, output []byte)

ObserveOutput postpones approximate completion while the terminal is still producing bytes.

func (*Service) PendingCount

func (s *Service) PendingCount(info terminal.Info) int64

PendingCount reports retained, not-yet-durable rows for one terminal.

func (*Service) PersistRecording

func (s *Service) PersistRecording(
	ctx context.Context,
	workspaceID string,
	terminalID terminalpkg.ID,
	ref terminalpkg.RecordingRef,
	contents []byte,
) (terminalpkg.RecordingRef, error)

PersistRecording writes a redacted asciicast artifact and records its durable metadata.

func (*Service) PrepareWorkspaceRemoval

func (s *Service) PrepareWorkspaceRemoval(
	ctx context.Context,
	workspaceID string,
) (workspacepkg.UnregisterPreparation, error)

PrepareWorkspaceRemoval captures the database path before registration deletion makes the resolver unable to resolve it again.

func (*Service) PrepareWorkspaceRemovalAt

func (s *Service) PrepareWorkspaceRemovalAt(
	ctx context.Context,
	workspaceID string,
	rootDir string,
) (workspacepkg.UnregisterPreparation, error)

PrepareWorkspaceRemovalAt reconstructs removal ownership from a durable workspace snapshot.

func (*Service) Query

func (s *Service) Query(
	ctx context.Context,
	workspaceID string,
	scope store.ReadScope,
	query terminalpkg.Query,
) (*terminalpkg.Page, error)

Query returns one opaque-cursor page in descending start/id order.

func (*Service) Record

func (s *Service) Record(ctx context.Context, workspaceID string, row terminalpkg.CommandRow) error

Record appends one immutable command row.

func (*Service) RecordQueued

func (s *Service) RecordQueued(
	ctx context.Context,
	info terminalpkg.Info,
	row terminalpkg.CommandRow,
) error

RecordQueued persists one command through the bounded retry lane.

func (*Service) Recording

func (s *Service) Recording(
	ctx context.Context,
	workspaceID string,
	scope store.ReadScope,
	id string,
) (*terminalpkg.RecordingRef, io.ReadCloser, error)

Recording opens a profile-scoped recording and its asciicast artifact.

func (*Service) RegisterTerminal

func (s *Service) RegisterTerminal(
	info terminalpkg.Info,
	setBlocked func(bool),
	emit func(terminalpkg.Event),
)

RegisterTerminal creates the bounded writer lane before terminal bytes flow.

func (*Service) ReleaseCommandID

func (s *Service) ReleaseCommandID(workspaceID, commandID string)

ReleaseCommandID releases an identity after persistence or abandoned admission.

func (*Service) ReleaseRecordingID

func (s *Service) ReleaseRecordingID(workspaceID, recordingID string)

ReleaseRecordingID releases an identity after persistence or abandoned admission.

func (*Service) RemoveWorkspace

func (s *Service) RemoveWorkspace(ctx context.Context, workspaceID string) error

RemoveWorkspace closes and removes the workspace database during unregister.

func (*Service) ReserveCommandID

func (s *Service) ReserveCommandID(ctx context.Context, workspaceID string) (string, error)

ReserveCommandID returns an identity that is absent from durable and in-flight commands.

func (*Service) ReserveInput

ReserveInput reserves bounded journal capacity before input reaches the PTY.

func (*Service) ReserveRecordingID

func (s *Service) ReserveRecordingID(ctx context.Context, workspaceID string) (string, error)

ReserveRecordingID returns an identity absent from durable and in-flight recordings.

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

Shutdown closes every open workspace database.

func (*Service) SweepExpired

func (s *Service) SweepExpired(ctx context.Context, workspaceID string, at time.Time) error

SweepExpired removes expired rows and their retained files.

func (*Service) WriteArtifact

func (s *Service) WriteArtifact(
	ctx context.Context,
	workspaceID, profileID, commandID string,
	terminalID *terminalpkg.ID,
	contents []byte,
	expiresAt time.Time,
) (terminalpkg.SpillRef, error)

WriteArtifact redacts and retains one content-addressed spill artifact.

func (*Service) WriteFailureCount

func (s *Service) WriteFailureCount() uint64

WriteFailureCount reports durable append failures observed by retry workers.

Jump to

Keyboard shortcuts

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