operation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package operation carries the transport-independent authorization contract attached by every network adapter before it invokes a service operation.

Index

Constants

View Source
const (
	ArtifactNone                = "none"
	ArtifactHumanSession        = "human-session"
	ArtifactMachineCredential   = "machine-credential"
	ArtifactDeveloperCredential = "developer-credential"
	ArtifactSCIMCredential      = "scim-credential"
	ArtifactInstanceCredential  = "instance-credential"
	ArtifactLocal               = "local"
)

Variables

This section is empty.

Functions

func AdmitPreauthentication

func AdmitPreauthentication(ctx context.Context) error

AdmitPreauthentication bounds artifact resolution before its first datastore read. Call after cheap grammar checks, independently of credential liveness. Source identity comes from transport middleware, not tokens. Nested reads and retries reuse the admission outcome, including a refusal.

func AdmitRequest

func AdmitRequest(ctx context.Context, sessionID string) error

AdmitRequest charges only a transaction-authenticated human session. Invalid credentials and machine callers cannot allocate or spend human buckets.

func IsNetwork

func IsNetwork(ctx context.Context) bool

IsNetwork reports whether a trusted adapter attached network provenance.

func WithContract

func WithContract(ctx context.Context, contract Contract) context.Context

WithContract attaches a trusted operation contract to a network request.

func WithNetwork

func WithNetwork(ctx context.Context) context.Context

WithNetwork marks work entered through a network adapter, including public metadata operations that have no authorization contract.

func WithPreauthenticationAdmission

func WithPreauthenticationAdmission(ctx context.Context, charge func() error) context.Context

WithPreauthenticationAdmission attaches trusted source admission to one request. Nested reads and transaction retries share accounting, never an authentication or authorization result.

func WithRequestAdmission

func WithRequestAdmission(ctx context.Context, charge func(sessionID string) error) context.Context

WithRequestAdmission attaches accounting, not identity or authorization, to one network request. Transaction retries and nested service reads share the receipt; authentication is still resolved live before every admission.

Types

type Contract

type Contract struct {
	ID                     string
	AuthorizationOperation string
	// contains filtered or unexported fields
}

Contract is one immutable network-operation admission row. It is built from trusted compiled registry data, never request input.

func FromContext

func FromContext(ctx context.Context) (Contract, bool)

FromContext returns the network operation contract, when one was attached.

func NewArtifactContract

func NewArtifactContract(id string, artifacts []string) (Contract, error)

NewArtifactContract constructs an immutable admission row for a network operation that has an artifact policy but no domain authorization formula.

func NewContract

func NewContract(id, authorizationOperation string, formula, artifacts []string) (Contract, error)

NewContract constructs a complete immutable operation contract.

func (Contract) AdmitsArtifact

func (c Contract) AdmitsArtifact(class string) bool

AdmitsArtifact reports whether class is explicitly admitted.

func (Contract) Artifacts

func (c Contract) Artifacts() []string

Artifacts returns a copy of the artifact allowlist.

func (Contract) Formula

func (c Contract) Formula() []string

Formula returns a copy of the authorization formula.

Jump to

Keyboard shortcuts

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