Help us shape the future of Go! Take the 2026 Go Developer Survey

acceptance

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package acceptance defines recoverable audit ingestion contracts.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupported  = errors.New("chronicle: reliable ingestion unsupported")
	ErrConflict     = errors.New("chronicle: acceptance conflict")
	ErrInvalid      = errors.New("chronicle: invalid acceptance")
	ErrHeadConflict = errors.New("chronicle: stream head conflict")
)

Functions

func Fingerprint

func Fingerprint(r Request) (string, error)

Fingerprint returns the digest your adapter can check against a receipt.

func Identity

func Identity(r Request) string

Identity encodes the source identity without delimiter collisions.

Types

type Appender

type Appender interface {
	AppendWithChain(context.Context, *audit.Event, *hash.Chain) error
}

Appender lets legacy writers share the backend's chain lock and configured hasher with reliable writers. It does not make legacy Record idempotent.

type Receipt

type Receipt struct {
	Producer          string `json:"producer"`
	Installation      string `json:"installation"`
	SourceKey         string `json:"source_key"`
	SourceFingerprint string `json:"source_fingerprint"`
	Fingerprint       string `json:"fingerprint"`
	AppID             string `json:"app_id"`
	OrgID             string `json:"org_id"`
	TenantID          string `json:"tenant_id"`
	EventID           id.ID  `json:"event_id"`
	StreamID          id.ID  `json:"stream_id"`
	Sequence          uint64 `json:"sequence"`
	Hash              string `json:"hash"`
	HashScheme        string `json:"hash_scheme"`
	HashKeyID         string `json:"hash_key_id"`
}

Receipt survives payload retention and erasure without an automatic expiry. HashScheme and HashKeyID describe the accepted digest, not signed checkpoints or external anchoring. A plain digest provides no protection from a database writer.

func Match

func Match(r *Receipt, fingerprint string) (*Receipt, error)

Match returns no receipt data when the immutable binding differs.

func NewReceipt

func NewReceipt(r Request, fingerprint string, e *audit.Event) *Receipt

NewReceipt captures durable identity and actual protection provenance.

type Request

type Request struct {
	Producer          string       `json:"producer"`
	Installation      string       `json:"installation"`
	SourceKey         string       `json:"source_key"`
	SourceFingerprint string       `json:"source_fingerprint"`
	OrgID             string       `json:"org_id"`
	Event             *audit.Event `json:"event"`
}

Request binds a trusted source delivery to explicit scope and event content. Your host must authenticate Producer and Installation and authorize scope. SourceFingerprint describes the source envelope, not the audit event digest. Timestamp is required and keeps nanosecond precision. Context never overrides scope.

func Normalize

func Normalize(r Request) (Request, string, error)

Normalize makes a private semantic snapshot before encryption or allocation. Backend identity and chain fields are excluded. Pre-sealed or erased inputs are rejected. JSON numbers normalize exactly without a float64 conversion.

type Store

type Store interface {
	Accept(context.Context, Request, *hash.Chain, func(*audit.Event) error) (*Receipt, error)
}

Store serializes receipt recovery before prepare, then atomically commits the event, stream creation/pin/head, and receipt. prepare seals only a new event. It must never run for a replay or the losing concurrent first request.

Jump to

Keyboard shortcuts

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