teamintent

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package teamintent records team namespace intent in the platform transaction.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDisabled is returned when PLATFORM_TEAM_INTENT_JOURNAL is not enabled.
	ErrDisabled = errors.New("team intent journal is disabled")
	// ErrStaleReceipt is returned when a worker receipt fails fence, revision,
	// or incarnation ownership validation.
	ErrStaleReceipt = errors.New("stale team intent receipt")
	// ErrStaleObservation is returned when an observer epoch, revision, or UID
	// fails conditional validation.
	ErrStaleObservation = errors.New("stale team intent observation")
	// ErrInvalidInput is returned when a team intent API request is malformed.
	ErrInvalidInput = errors.New("invalid team intent request")
)
View Source
var ErrIdempotencyConflict = errors.New("idempotency key already accepted different input")

ErrIdempotencyConflict rejects reusing an actor/action replay key for different normalized input without changing the original acceptance.

Functions

This section is empty.

Types

type OperationAcceptance

type OperationAcceptance struct {
	Team      apikit.Team
	Operation apikit.Operation
}

OperationAcceptance includes the immutable accepted team representation. Actor and replay metadata stay in storage and are not part of the wire shape.

type OperationRequest

type OperationRequest struct {
	ID             string
	RevisionID     string
	ActorID        string
	Kind           string
	IdempotencyKey string
	RequestHash    string
	Team           apikit.Team
}

OperationRequest binds immutable accepted contents to the authenticated request's replay scope and the revision enqueued in the same transaction.

type Writer

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

Writer owns the insert-only River client and team intent persistence.

func Open

func Open(ctx context.Context, db *sql.DB, dsn string) (*Writer, error)

Open prepares storage for the opt-in team journal. The DSN must point to the same PostgreSQL database as db and support session-level advisory locks.

func (*Writer) ClaimFence

func (w *Writer) ClaimFence(ctx context.Context, teamID, workerID string) (apikit.TeamIntentFenceResponse, error)

ClaimFence atomically bumps the per-team execution fence epoch and returns the authoritative current desired intent.

func (*Writer) ClaimObserverLease

func (w *Writer) ClaimObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.TeamIntentObserverLeaseResponse, error)

ClaimObserverLease atomically increments the monotonic observer epoch for clusterKey so older observers cannot overwrite fresher observations.

func (*Writer) GetIntent

func (w *Writer) GetIntent(ctx context.Context, teamID string) (apikit.TeamNamespaceIntent, bool, error)

GetIntent returns the authoritative desired intent for one team incarnation.

func (*Writer) GetOperation

func (w *Writer) GetOperation(ctx context.Context, operationID, actorID string) (OperationAcceptance, bool, error)

GetOperation is actor-scoped even when an operation UUID is guessed or copied.

func (*Writer) ListIntents

func (w *Writer) ListIntents(ctx context.Context) ([]apikit.TeamNamespaceIntent, error)

ListIntents returns all recorded team namespace intents with their latest receipts and independent observations.

func (*Writer) LookupAcceptance

func (w *Writer) LookupAcceptance(ctx context.Context, tx *sql.Tx, actorID, kind, key, requestHash string) (OperationAcceptance, bool, error)

LookupAcceptance serializes only requests for the same actor/action/key for the lifetime of tx. Hash collisions can serialize unrelated requests but cannot make one actor observe another actor's acceptance.

func (*Writer) Record

func (w *Writer) Record(ctx context.Context, tx *sql.Tx, teamID string, deleted bool) error

Record stores the latest desired revision for the team ID and schedules its job using the same transaction that changes the team. The caller owns commit and rollback.

func (*Writer) RecordAcceptance

func (w *Writer) RecordAcceptance(ctx context.Context, tx *sql.Tx, request OperationRequest) (OperationAcceptance, error)

RecordAcceptance persists the immutable accepted contents and their operation in the caller's domain/intent/River transaction. Only lifecycle columns change later; receipts never replace this snapshot with current resource contents.

func (*Writer) RecordObservation

RecordObservation persists independent Kubernetes health observations for a team incarnation without modifying desired intent, receipts, or River jobs.

func (*Writer) RecordReceipt

RecordReceipt stores a worker execution receipt conditional on the team incarnation, current desired revision, and execution fence epoch.

func (*Writer) RecordWithOperation

func (w *Writer) RecordWithOperation(ctx context.Context, tx *sql.Tx, teamID string, deleted bool, operationID string) (string, error)

RecordWithOperation records the same transactional intent and queue payload, optionally linking it to the public acceptance operation created by the caller.

Jump to

Keyboard shortcuts

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