inputqueue

package
v0.3.0-beta.23 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInputTextRequired = errors.New("inputqueue: text is required")

ErrInputTextRequired reports a queued input without text or attachments.

Functions

This section is empty.

Types

type Config

type Config struct {
	QueueCap     int
	MaxTextBytes int
}

Config controls queue admission.

type IDGenerator

type IDGenerator func() (string, error)

IDGenerator returns a stable queue entry ID or the entropy failure that prevented allocation.

type InputRequest

type InputRequest struct {
	SessionID        string
	Text             string
	TargetTurnID     string
	Generation       int64
	Runtime          store.SessionInputRuntime
	SkillInvocations []commandpkg.Invocation
	Attachments      []store.SessionInputAttachment
}

InputRequest carries the common fields for a non-admitted busy input.

type Option

type Option func(*Service)

Option customizes a Service.

func WithClock

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

WithClock injects a deterministic clock.

func WithIDGenerator

func WithIDGenerator(generator IDGenerator) Option

WithIDGenerator injects deterministic queue ids.

type Service

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

Service owns validation and admission policy for session busy input.

func New

func New(store Store, cfg Config, opts ...Option) (*Service, error)

New constructs a busy-input queue service.

func (*Service) Cancel

func (s *Service) Cancel(ctx context.Context, sessionID string, entryID string) (store.SessionInputQueueEntry, error)

Cancel cancels one pending queue entry.

func (*Service) CancelPendingSteer

func (s *Service) CancelPendingSteer(ctx context.Context, sessionID, entryID string) error

func (*Service) ClaimNext

func (s *Service) ClaimNext(
	ctx context.Context,
	sessionID string,
) (store.SessionInputQueueEntry, bool, error)

ClaimNext leases the next input eligible for dispatch.

func (*Service) CurrentGeneration

func (s *Service) CurrentGeneration(ctx context.Context, sessionID string) (int64, error)

CurrentGeneration reads the current persisted generation for queue fencing.

func (*Service) Enqueue

Enqueue appends operator input behind the active prompt turn.

func (*Service) EnqueueAdmitted

func (s *Service) EnqueueAdmitted(
	ctx context.Context,
	admission store.SessionPromptAdmissionRequest,
	generation int64,
	targetTurnID string,
) (store.SessionPromptAdmission, store.SessionInputQueueEntry, int, bool, error)

EnqueueAdmitted atomically persists one external command receipt and its queue entry.

func (*Service) EnqueueAdmittedInterrupt

func (s *Service) EnqueueAdmittedInterrupt(
	ctx context.Context,
	admission store.SessionPromptAdmissionRequest,
	targetTurnID string,
) (store.SessionPromptAdmission, store.SessionInputQueueEntry, bool, error)

EnqueueAdmittedInterrupt atomically persists a replacement command receipt and queue entry.

func (*Service) EnqueueInterrupt

func (s *Service) EnqueueInterrupt(
	ctx context.Context,
	req InputRequest,
) (store.SessionInputQueueEntry, int, error)

EnqueueInterrupt persists replacement input before the active turn is canceled.

func (*Service) EnqueueSynthetic

func (s *Service) EnqueueSynthetic(
	ctx context.Context,
	req InputRequest,
	turnID string,
	prompt *store.SessionInputSyntheticPrompt,
	taskRunID string,
) (store.SessionInputQueueEntry, error)

EnqueueSynthetic captures daemon work under the same capacity and claim policy as human input.

func (*Service) Get

func (s *Service) Get(
	ctx context.Context,
	sessionID string,
	entryID string,
) (store.SessionInputQueueEntry, error)

Get returns one exact durable queue entry.

func (*Service) List

func (s *Service) List(
	ctx context.Context,
	sessionID string,
) ([]store.SessionInputQueueEntry, error)

List returns current pending operator inputs in dispatch order.

func (*Service) MarkClearTraceProjected

func (s *Service) MarkClearTraceProjected(ctx context.Context, sessionID, entryID string) error

func (*Service) MarkFailed

func (s *Service) MarkFailed(ctx context.Context, sessionID string, entryID string, summary string) error

MarkFailed records failed dispatch.

func (*Service) MarkSent

func (s *Service) MarkSent(ctx context.Context, sessionID string, entryID string) error

MarkSent records successful dispatch.

func (*Service) PeekNext

func (s *Service) PeekNext(
	ctx context.Context,
	sessionID string,
) (store.SessionInputQueueEntry, bool, error)

PeekNext returns the next eligible input without mutating its queue state.

func (*Service) PendingClearTraces

func (s *Service) PendingClearTraces(ctx context.Context, sessionID string) ([]store.SessionInputClearTrace, error)

func (*Service) PrepareQueue

func (s *Service) PrepareQueue(req InputRequest) (store.SessionInputQueueInsert, error)

PrepareQueue validates queued input and allocates its durable insert without persisting it.

func (*Service) PromoteToSteer

func (s *Service) PromoteToSteer(
	ctx context.Context,
	sessionID string,
	entryID string,
	text string,
	targetTurnID string,
	messageID string,
	idempotencyKey string,
	skillInvocations []commandpkg.Invocation,
) (store.SessionInputQueueEntry, bool, error)

PromoteToSteer atomically replaces one queued input with priority steering input.

func (*Service) Release

func (s *Service) Release(ctx context.Context, sessionID string, entryID string) error

Release returns a leased entry to queued state after a dispatch race.

func (*Service) Replace

func (s *Service) Replace(
	ctx context.Context,
	sessionID string,
	entryID string,
	text string,
	messageID string,
	idempotencyKey string,
	skillInvocations []commandpkg.Invocation,
) (store.SessionInputQueueEntry, bool, error)

Replace atomically replaces one queued input with a new queue identity.

func (*Service) ReplayPromotion

func (s *Service) ReplayPromotion(
	ctx context.Context,
	sessionID string,
	entryID string,
	text string,
	targetTurnID string,
	messageID string,
	idempotencyKey string,
	skillInvocations []commandpkg.Invocation,
) (store.SessionInputQueueEntry, bool, error)

ReplayPromotion returns an exact prior queue-to-steer mutation without changing queue state.

func (*Service) ReserveSteer

func (s *Service) ReserveSteer(
	ctx context.Context,
	sessionID, entryID string,
) (store.SessionInputQueueEntry, bool, error)

func (*Service) ResolveSteer

func (s *Service) ResolveSteer(
	ctx context.Context, sessionID, entryID string, delivery store.SteerDeliveryMode,
) (store.SessionInputQueueEntry, error)

func (*Service) SettlePendingSteer

func (s *Service) SettlePendingSteer(
	ctx context.Context, sessionID, entryID string, delivery store.SteerDeliveryMode,
) (store.SessionInputQueueEntry, bool, error)

func (*Service) StageAdmittedSteer

func (s *Service) StageAdmittedSteer(
	ctx context.Context,
	admission store.SessionPromptAdmissionRequest,
	targetTurnID string,
	generation int64,
) (store.SessionPromptAdmission, store.SessionInputQueueEntry, bool, error)

StageAdmittedSteer atomically persists one external receipt and its steering entry.

func (*Service) StageSteer

func (s *Service) StageSteer(
	ctx context.Context,
	req InputRequest,
) (store.SessionInputQueueEntry, error)

StageSteer persists replacement steering guidance while a turn is active.

type Store

type Store interface {
	store.SessionInputQueueStore
}

Store is the persistence boundary for busy input.

Jump to

Keyboard shortcuts

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