nodeauthority

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

README

Boot-local source authority

Unwired host adapter only. No RPC issuance endpoint, scheduler, listener, SQL credentials, runtime claim, source capture, provider URL or caller path. Construct one Authority per actual source-owner process boot. Owner is that node's existing membership identity/incarnation. A restarted process constructs a fresh empty registry, invalidating every old local binding and bearer; this says nothing about old remote encoders retiring or durable placement capacity being free.

New requires a fresh placement Lookup dependency (*placement.Service satisfies), current Policy, source-owner identity, clock and explicit bounded capacities. Policy receives Owner and the complete immutable Scope. It must check live viewer and source rights, controller membership/boot/current authority, local source-owner membership/boot and target membership/boot/transcode eligibility including drains or role changes. Placement Record.Role independently must be transcode. Every issuance, renewal, Verify and Acquire queries Lookup anew, rejecting lookup errors, retirement, Authority=false and any difference in the full durable fence. No cached DB authority or prior successful policy decision substitutes for a current check.

Trusted host code captures an existing playback SourceHandle using SourceAccess, then Bind(scope, handle, exactSize). Canonical handle Revision and Size must match; no network data enters Capture here. Bind checks Active and policy/placement. Handle.Value() is the stable immutable Start.Grant, never the bearer. Trusted host composition uses Resolve(ctx, authenticatedIntendedPeer, stableValue) to recover the same Handle, Scope and size after fresh Active/policy/DB/epoch checks; wrong peers, stale fences and sealed bindings fail closed. Resolve installs no endpoint and issues no credential. Issue produces one Lease. Lease.Grant() explicitly exports the nodesource transport credential; that existing DTO contains a raw string and MUST NOT be logged or formatted. Authority, Lease and Handle redact ordinary and Go formatting; errors suppress upstream details. Credentials and stable handles use independent crypto/rand 256-bit values. Never use a stable handle to resolve another source or scope.

Install Authority as nodesource.Options.Authority and Authority.Acquire as its Acquire callback only on the authenticated private handler. Verify binds the bearer to the exact intended target NodeID and Boot. It checks Active and live policy/fence at every HEAD/GET and at nodesource's reader revalidation cadence. Acquire independently checks current authority and exact binding, then invokes SourceHandle.Acquire under playback's atomic manager barrier. The handler must install its ReadRetirement tracker first and preserve Release even on errors. Acquire is a trusted adapter, not a bearerless public endpoint.

Revoke first seals the binding epoch and deletes all its credentials under the registry mutex. Outside that mutex it calls SourceHandle.Revoke, closing playback's acquisition barrier before returning. Calls in flight may have retained a reference before that barrier; their epoch recheck returns an error with Release preserved and no usable source facade. An acquisition that already completed its epoch check before sealing is an existing hold. Once Revoke returns, no late call can acquire a new generation reference. Repeated Revoke also crosses that barrier. All external policy, DB, clock, handle and metadata calls run outside registry locks. No callback can unseal or rebind an entry. Epoch changes once, so cannot wrap. Playback itself rejects replaced, sealed, detached and revoked handles at its own manager barrier.

Renew requires the current exact grant, unchanged Scope/handle/size and strictly later expiry. It rotates the bearer without mutating any existing grant. Prior bearers keep only their ORIGINAL expiry; a replay of a successful renewal cannot mint again. Concurrent renewals commit at most once. MaxGrantsPerBinding includes current and unexpired old grants, and MaxGrants caps all retained credentials. Expired credential eviction on mint only frees credential slots: no hold release, backend Close, binding release or placement.Retire occurs. MaxBindings is a total successful-binding limit for this Authority lifetime, including sealed tombstones; scopes and source-handle objects cannot be rebound. Exhaustion fails closed. Host must plan boot capacity and deliberate quiescent lifecycle rather than replacing a live Authority to bypass limits. Maps and scans never exceed explicit caps (4096). No timers, goroutines, unbounded operation history or per-producer work are added.

ClockBoundKnown is a trusted deployment assumption, not a measured guarantee: local source, durable DB and worker clocks must have pairwise skew <= ClockSkew, including drift throughout MaxLifetime. Unknown skew cannot mint. ClockSkew must be finite, nonnegative, at most a minute and below MaxLifetime (at most an hour). Expiry must be strictly after local now+skew, and at most local now+lifetime-skew and the freshly observed record deadline-skew. Old grants stop at their immutable expiry; Verify conservatively rejects within ClockSkew of raw Grant.Expires. Worker source-evidence composition must use this earlier effective deadline: raw Expires cannot promise availability through a worker deadline. All authority remains revocable at any time. Clock discontinuities beyond that bound violate the deployment assumption. All authority observations are point-in-time; external policy and DB transitions cannot be made atomic by this local registry.

Host owns nodesource.Handler.Reconcile and SourceAccess.Reconcile during activity, drain and after expiry with no traffic. The latter can BLOCK in backend Close and belongs on an explicit cleanup executor. Registry expiry/revocation never calls it. Release is accounting only. Actual SourceRetirement.Done/Err and independent encoder retirement proof govern cleanup and durable retirement. Request completion, expired credentials, canceled reads and zero pending local holds are never final source or remote encoder proof. Source lifetime release belongs only to the trusted owner flow. There is no automatic placement.Retire, even after permanent node loss.

Documentation

Overview

Package nodeauthority binds boot-local source capabilities to durable placement. It installs no routes and owns lease-expiry timers, never source retirement.

Index

Constants

This section is empty.

Variables

View Source
var ErrCapacity = errors.New("nodeauthority: capacity exhausted")
View Source
var ErrDenied = errors.New("nodeauthority: denied")

Functions

This section is empty.

Types

type Authority

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

func New

func New(o Options) (*Authority, error)

func (*Authority) Acquire

func (a *Authority) Acquire(ctx context.Context, s nodesource.Scope) (nodesource.Hold, error)

Acquire is installed only on the private nodesource handler, which checks Peer and bearer via Verify. It independently checks live binding authority before retaining the exact SourceHandle under playback's manager barrier.

func (*Authority) Bind

Bind accepts only an already captured local handle, never a URL or path. Size and revision must equal the handle's canonical trusted capture. Failed binds consume no slot; successful binds consume one for this authority's entire boot.

func (*Authority) CheckLocal

func (a *Authority) CheckLocal(ctx context.Context, p nodesource.Peer, key string) error

CheckLocal checks revocation and monotonic lease expiry without durable I/O. It supplements Verify during an already admitted streaming request.

func (*Authority) GoString

func (a *Authority) GoString() string

func (*Authority) Issue

func (a *Authority) Issue(ctx context.Context, h Handle, expiry time.Time) (Lease, error)

func (*Authority) Renew

func (a *Authority) Renew(ctx context.Context, h Handle, old nodesource.Grant, expiry time.Time) (Lease, error)

Renew accepts only the current bearer; a successful replay cannot create more grants. Old bearers remain valid only until their original immutable expiry.

func (*Authority) Resolve

func (a *Authority) Resolve(ctx context.Context, peer nodesource.Peer, stable string) (Handle, nodesource.Scope, int64, error)

Resolve is trusted host composition for immutable Start.Grant values. The caller supplies the authenticated intended worker identity; no wire endpoint is installed. Success does not issue a bearer or establish retirement proof.

func (*Authority) Revoke

func (a *Authority) Revoke(h Handle) error

Revoke seals registry admissions first and closes playback's acquisition barrier before returning. It never releases holds, closes sources or retires placement. Repeated calls also wait for the handle's barrier by calling Revoke.

func (*Authority) String

func (*Authority) String() string

func (*Authority) Verify

func (a *Authority) Verify(ctx context.Context, p nodesource.Peer, key string) (nodesource.Grant, error)

type Handle

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

Handle is the immutable Start.Grant identity, distinct from a bearer.

func (Handle) GoString

func (h Handle) GoString() string

func (Handle) String

func (Handle) String() string

func (Handle) Value

func (h Handle) Value() string

Value is an explicit secret export for trusted transport composition.

type Lease

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

Lease redacts ordinary formatting. Transport explicitly exports its Grant.

func (Lease) GoString

func (l Lease) GoString() string

func (Lease) Grant

func (l Lease) Grant() nodesource.Grant

func (Lease) String

func (Lease) String() string

type Lookup

type Lookup interface {
	Lookup(context.Context, string) (placement.Record, error)
}

Lookup must make a fresh authoritative observation on every call.

type Options

type Options struct {
	// ClockReady gates binds and minting (including renewal), never existing reads.
	ClockReady                                  func() bool
	Lookup                                      Lookup
	Policy                                      func(context.Context, placement.Target, nodesource.Scope) error
	Owner                                       placement.Target
	Now                                         func() time.Time
	ClockBoundKnown                             bool
	ClockSkew, MaxLifetime                      time.Duration
	MaxBindings, MaxGrants, MaxGrantsPerBinding int
}

Options are trusted host configuration. Policy checks current viewer/source rights, controller and target membership/boots, and target transcode eligibility. ClockBoundKnown asserts synchronized local/DB/worker clocks with absolute pairwise skew <= ClockSkew, including drift over MaxLifetime. Unknown fails closed.

Jump to

Keyboard shortcuts

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