achrix

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MPL-2.0 Imports: 10 Imported by: 6 modules, 12 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

AChrix

AChrix (pronounced ATCH-riks; Persian: اَچ‌ریکس) is a reusable Go application foundation from AChWorks. Build a product with a small Core and the optional Modules it needs, while keeping your product's behavior, data and deployment under your control.

Use AChrix when you want shared application capabilities that you can consume and upgrade as ordinary versioned dependencies. Core and official components have independent versions; you choose a compatible set and keep your product source in its own repository.

What you can use

Component What it provides
Core Application composition, authorization and startup/shutdown lifecycle
Identity and Audit Accounts, passwords, sessions and accountable operations
Media Private attachments and clean PNG/JPEG preparation
Multi-Site Site resolution, authorized inventory and per-site Module selection planning
Admin A composable administration shell with Identity and Media screens, including file-based English/Persian localization and RTL/LTR presentation
Installation Installation requirement assessment and safe re-entry planning

Supported failure paths preserve useful machine categories and corrective guidance. Runtime components provide structured local diagnostics, and products can compose a protected callback for the underlying operational cause; see diagnosis and audit for access, correlation and retention responsibilities.

The first supported stack is Go with ordinary PostgreSQL for the components that need persistence. See the supported environment before installing.

Get started

Create your product's Go module and choose an exact reviewed Core version from Releases:

mkdir my-product
cd my-product
go mod init example.com/my-product
ACHRIX_CORE_VERSION="<reviewed-core-version>"
go get "github.com/AChWorks/achrix@$ACHRIX_CORE_VERSION"

Follow the product quick start for a runnable application, compatible Module selection and explicit database setup. The Notes example shows a separately composed consumer.

AChrix is currently a pre-v1 developer foundation. Review each component's release notes before adoption. Existing consumers should follow the upgrade guide, especially when moving from a shared-version release to independent components. Products own their permission policy, actual installation/activation and deployment.

Learn more and contribute

Documentation

Overview

Package achrix supplies instance-owned composition, authorization and lifecycle for trusted, compiled modules. It owns no product data or authentication scheme.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDenied                   = errors.New("permission denied")
	ErrAuthorizationUnavailable = errors.New("authorization unavailable")
	ErrNotReady                 = errors.New("application not ready")
	ErrComposition              = errors.New("invalid composition")
)

Functions

func DependencyVersion added in v0.4.0

func DependencyVersion(modulePath string) string

DependencyVersion identifies an independently versioned component by its exact Go module path in the executable's build information. It never resolves a dependency or substitutes Core's version for another component. Development, replacement and absent metadata are explicitly not immutable release identity.

func Version

func Version() string

Version identifies the actual source-backed Foundation dependency in a consumer. Local unversioned builds explicitly report development; no release is invented.

Types

type Application

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

Application is immutable after composition except for lifecycle/admission state. Domain methods remain typed consumer-owned methods, not an untyped dispatcher.

func New

func New(config Config, policy Policy, modules ...Module) (*Application, error)

New rejects duplicate, missing, incompatible or cyclic composed contracts before any module starts. Module descriptors are snapshotted to prevent mutable registry state leaking between instances. No process-global registration exists.

func (*Application) Authorize

func (a *Application) Authorize(ctx context.Context, p Principal, capability, resource string) error

Authorize fails closed for empty principals, unknown capabilities, stopped applications or policy errors. Call it inside the owning Application operation before authorization-sensitive reads/writes; transport discovery grants no rights. resource is a product-owned opaque scope/reference, not trusted client claims. Callers must supply a deadline. Shutdown cancels/drains admitted policy work; calls outside ready return ErrNotReady without invoking policy. Policy errors never expose raw provider text: only explicit ErrDenied is a permission denial. Core emits DEBUG denials and ERROR evaluation failures; the product owns the bounded diagnostic sink and its protected cause callback.

func (*Application) Components

func (a *Application) Components() []Descriptor

Components returns a defensive snapshot for compatible build/recovery identity.

func (*Application) Ready

func (a *Application) Ready(ctx context.Context) error

Ready checks only composed local dependencies, under the caller's deadline. It never waits behind lifecycle callbacks and is canceled/drained by Shutdown. Repeated probe detail is DEBUG; the product owns bounded operational signals.

func (*Application) Shutdown

func (a *Application) Shutdown(parent context.Context) error

Shutdown closes admission immediately, cancels admitted Ready/Authorize work, drains it, then stops Modules in reverse order. Its deadline covers lifecycle waiting, drain and Stop together. If waiting/drain expires, the instance remains stopping and a later Shutdown may finish cleanup; Stop never races callbacks. Completed cleanup is not repeated and its result is retained. Modules must terminate their owned domain work in Stop; Core tracks only its own callbacks.

func (*Application) Start

func (a *Application) Start(parent context.Context) error

Start is a one-shot operation. A failed start cleans the failing module and all earlier modules in reverse order using a fresh bounded cleanup context. Lifecycle failures are diagnosed by component and phase without logging extension errors.

type Capability

type Capability struct {
	ID      string
	Version uint32
}

Capability identifies an owned public contract. Version is its positive ABI revision, not the implementation's release version. Compatible additive changes retain the revision; incompatible contracts increment it. Composition matches exact revisions and admits only one provider/revision for each capability ID.

type Config

type Config struct {
	// Timeouts bound the whole lifecycle phase, including all participating modules.
	StartupTimeout  time.Duration
	ShutdownTimeout time.Duration
	Logger          *slog.Logger
	// Diagnostic receives original causes only at a protected product boundary.
	// It is synchronous and must be safe for concurrent calls. Apply provider-aware
	// redaction before storage/export; never blindly serialize causes to public or
	// ordinary logs. The arguments identify operation and phase; context retains
	// the caller's trusted correlation. Nil keeps structured Logger diagnostics.
	Diagnostic func(context.Context, string, string, error)
}

type Descriptor

type Descriptor struct {
	ID string

	// Version identifies the Module implementation's packaged source dependency.
	// Independently versioned components report their own source module identity;
	// capability ABI remains separate from that implementation release.
	Version  string
	Provides []Capability
	Requires []Capability
	Optional []Capability
}

Descriptor is deterministic, side-effect-free, cheap composition metadata. Describing a Module must not read environment/secrets, acquire resources, call networks/databases or mutate registration. Optional providers may be absent; when present they must match the exact revision and precede their consumers.

type Module

type Module interface {
	Descriptor() Descriptor
	Start(context.Context) error
	Ready(context.Context) error
	Stop(context.Context) error
}

Module owns its resources. Start, Ready and Stop must honor context cancellation. Stop must clean resources acquired by a partially failed Start and be safe when Start acquired none. In-process code is trusted; contexts are not a sandbox.

type Policy

type Policy interface {
	Authorize(context.Context, Principal, string, string) error
}

Policy is the consumer-owned authorization decision: nil allows, ErrDenied (possibly wrapped) explicitly denies, and other errors fail closed as evaluation unavailable. It must honor cancellation and must not mutate domain state. Implementations must be safe for concurrent calls.

type PolicyFunc

type PolicyFunc func(context.Context, Principal, string, string) error

func (PolicyFunc) Authorize

func (f PolicyFunc) Authorize(ctx context.Context, p Principal, c, r string) error

type Principal

type Principal string

Principal is a product-authenticated opaque identity, never a bearer token.

Directories

Path Synopsis
admin module
audit module
bridge module
identity module
installation module
media module
multisite module
oauth module

Jump to

Keyboard shortcuts

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