cassette

package
v0.43.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cassette defines schema-independent cassette contracts shared by versioned cassette manifest packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchors

type Anchors struct {
	// Health is the cassette's liveness path.
	Health string

	// OpenAPI is where the cassette publishes its own document.
	OpenAPI string

	// Prefix is the normalized head the cassette mounts its API beneath,
	// empty when it mounts directly under its own name.
	Prefix string
}

Anchors are the paths a cassette serves on its own listener, lifted out of whichever manifest schema declared them.

They exist as a schema-independent type so that everything downstream of admission — registration, proxying, republication — works the same way for every manifest version. Without it each consumer would type-assert its way back to a concrete schema, which is both a panic waiting to happen and a reason every new schema version would ripple outward.

type ContractVersion

type ContractVersion string

ContractVersion names a major revision of the tapes read surface — the tapes_<version> schema and the /v1 API — that a cassette declares it reads.

It is deliberately major-only ("v1", "v2"), not a full release version: a cassette depends on the shape of the contract, not on the build of core serving it. The set of contracts any particular core serves is owned by that core and injected into Validate; nothing in this package names one.

type Digest

type Digest string

Digest is a content digest in "sha256:<hex>" form.

type GrantPlan

type GrantPlan struct {
	Role      string   `json:"role"`
	Schema    string   `json:"schema"`
	OwnSchema bool     `json:"own_schema"`
	Selects   []string `json:"selects,omitempty"`
	Tables    []string `json:"tables,omitempty"`

	// CoreSelects are the views this cassette publishes for core's read role
	// to SELECT — the reverse direction of Selects. Declaration only, exactly
	// like the rest of the plan: the deployment renders and applies the
	// grant, and tapes never verifies the view exists.
	CoreSelects []string `json:"core_selects,omitempty"`
}

GrantPlan is the schema-independent database state desired by a cassette. Tapes publishes this declaration but does not apply it; the deployment system that starts the cassette owns roles, credentials, grants, and schema setup.

type Manifest

type Manifest interface {
	// SchemaKind returns the manifest's kind string (i.e., "v1alpha1", "v1").
	SchemaKind() string

	// CassetteName returns the cassette's validated identity.
	CassetteName() Name

	// Anchors returns the paths the cassette serves on its own listener.
	Anchors() Anchors

	// Validate checks the manifest's intrinsic constraints, and checks its
	// declared contract dependency against the set the caller says it serves.
	// The supported set is a parameter rather than a package constant because
	// this package describes what a cassette declares about itself; which
	// contracts are actually served is a fact about a running core, and a
	// cassette must never have to know which core will mount it.
	Validate(supported []ContractVersion) error

	// MarshalCanonical returns the manifest's deterministic representation.
	MarshalCanonical() ([]byte, error)

	// Digest returns the identity of the canonical representation.
	Digest() (Digest, error)

	// GrantPlan returns the database access desired by deployment tooling.
	GrantPlan() GrantPlan
}

Manifest is the common behavior exposed by every supported cassette manifest schema. Version-specific wire types and parsers live in child packages such as v1alpha1.

type Name

type Name string

Name is a validated cassette identity. Construct names with ParseName.

func ParseName

func ParseName(value string) (Name, error)

ParseName validates and constructs a cassette name.

func (Name) RoleName

func (n Name) RoleName() string

RoleName returns the cassette's Postgres role name.

func (Name) SchemaName

func (n Name) SchemaName() string

SchemaName returns the cassette's Postgres schema name.

type Problem

type Problem struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

Problem identifies one invalid field without stopping validation of the rest of a manifest.

type ValidationError

type ValidationError struct {
	// Subject names what failed validation. Empty means the cassette manifest,
	// so manifest validators need not set it; tapes config validation sets it
	// so one error shape can serve every document
	// without every message claiming to be about a manifest.
	Subject  string    `json:"subject,omitempty"`
	Problems []Problem `json:"problems"`
}

ValidationError contains every problem found during one validation pass.

func (*ValidationError) Error

func (validationError *ValidationError) Error() string

type Version

type Version string

Version identifies a cassette release.

Directories

Path Synopsis
Package manifest decodes a cassette manifest of any supported schema version into the schema-independent cassette.Manifest contract.
Package manifest decodes a cassette manifest of any supported schema version into the schema-independent cassette.Manifest contract.
Package v1alpha1 defines the versioned cassette metadata embedded in an OpenAPI document, including strict parsing, validation, and pure derivations.
Package v1alpha1 defines the versioned cassette metadata embedded in an OpenAPI document, including strict parsing, validation, and pure derivations.

Jump to

Keyboard shortcuts

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