commandwalapply

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package commandwalapply exposes the narrow internal boundary between future R3a deterministic-entry lowering and TreeDB's local command WAL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abort

func Abort(db *backenddb.DB, handle Handle)

Abort releases an appended apply handle that cannot be finalized by the caller. If the frame is still beyond AppliedCommandLSN, the open DB handle is poisoned so the next writer fails closed and reopen recovery owns the gap.

func Append

func Append(db *backenddb.DB, frame LoweredFrame, _ ApplyMetadata, opts Options) (Handle, Result, error)

Append validates and appends a lowered local command-WAL frame. It does not publish roots or AppliedCommandLSN; callers must run the normal executor and then call Finalize with the returned handle.

Types

type ApplyMetadata

type ApplyMetadata struct{}

ApplyMetadata is the explicit metadata slot future R3a apply code will carry beside a lowered frame. It is intentionally empty here; this package must not define #3038's entry/result/idempotency contract or #3040's apply metadata.

type Handle

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

Handle is the append token required to publish the same local command-WAL frame after the normal executor has made the command locally visible.

func (Handle) CommandWALIntent

func (h Handle) CommandWALIntent() *backenddb.CommandWALIntent

CommandWALIntent returns the pre-appended local command-WAL intent. Normal executors use it to publish roots and AppliedCommandLSN for the same frame.

func (Handle) LSN

func (h Handle) LSN() uint64

LSN returns the local command-WAL sequence number assigned at append time.

type LoweredFrame

type LoweredFrame struct {
	Class         LoweredFrameClass
	Kind          commitlog.CommandKind
	Scope         commitlog.CommandScope
	PayloadFormat commitlog.PayloadFormat
	Payload       []byte
}

LoweredFrame is the command-WAL payload produced after deterministic-entry classification and lowering. It is not a native-wire request and does not encode a Raft log entry.

func CatalogCreateCollectionFrame

func CatalogCreateCollectionFrame(payload []byte) (LoweredFrame, error)

CatalogCreateCollectionFrame returns the first accepted catalog mutation frame for R3a apply. Payload must be the canonical commitlog CatalogCreateCollection v1 payload produced by the collections catalog path.

func CollectionDeleteBatchByIDFrame

func CollectionDeleteBatchByIDFrame(payload []byte) (LoweredFrame, error)

CollectionDeleteBatchByIDFrame returns the accepted collection delete mutation frame. Payload must be the canonical command-WAL payload produced from deterministic document IDs.

func CollectionInsertBatchByIDFrame

func CollectionInsertBatchByIDFrame(payload []byte) (LoweredFrame, error)

CollectionInsertBatchByIDFrame returns the accepted collection insert mutation frame. Payload must be the canonical command-WAL payload produced from deterministic document IDs and documents, without local physical IDs.

func CollectionUpdateBatchByIDFrame

func CollectionUpdateBatchByIDFrame(payload []byte) (LoweredFrame, error)

CollectionUpdateBatchByIDFrame returns the accepted collection replacement mutation frame. Payload must be the canonical command-WAL payload containing final replacement documents keyed by deterministic document IDs.

func TestNoopFrame

func TestNoopFrame() (LoweredFrame, error)

TestNoopFrame returns the only frame class accepted by this issue's spike: a canonical empty RawKVBatch command. It exercises append/finalize without accepting user mutations or bypassing collection/catalog executors.

type LoweredFrameClass

type LoweredFrameClass uint8

LoweredFrameClass identifies which already-classified lowering path produced a frame. Classes are intentionally explicit so future command widening cannot accidentally piggyback on a generic command-WAL append path.

const (
	LoweredFrameClassTestNoop LoweredFrameClass = iota + 1
	LoweredFrameClassCatalogCreateCollection
	LoweredFrameClassCollectionInsertBatchByID
	LoweredFrameClassCollectionDeleteBatchByID
	LoweredFrameClassCollectionUpdateBatchByID
)

type Options

type Options struct {
	Sync bool
}

Options controls local command-WAL durability for this apply boundary.

type RecoverabilityStatus

type RecoverabilityStatus string

RecoverabilityStatus names the local recovery boundary reached by an apply step. These are local TreeDB states, not Raft consensus states.

const (
	StatusLocallyApplied         RecoverabilityStatus = "locally_applied"
	StatusLocallyWALRecoverable  RecoverabilityStatus = "locally_wal_recoverable"
	StatusLocallyRootRecoverable RecoverabilityStatus = "locally_root_recoverable"
)

type Result

type Result struct {
	LSN               uint64
	Status            RecoverabilityStatus
	AppliedCommandLSN uint64
}

Result describes the local apply/recoverability boundary reached.

func ApplyNoop

func ApplyNoop(db *backenddb.DB, frame LoweredFrame, meta ApplyMetadata, opts Options) (Result, error)

ApplyNoop appends and finalizes the scoped no-op frame. It exists only to test the boundary end-to-end without adding accepted replicated commands.

func Finalize

func Finalize(db *backenddb.DB, handle Handle, _ ApplyMetadata, opts Options) (Result, error)

Finalize publishes the current roots with AppliedCommandLSN covering the command frame represented by handle. The no-op frame used by this spike has no mutation effects, but the publish path is the same root/AppliedLSN boundary future executor-backed commands must use.

Jump to

Keyboard shortcuts

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