achrix

package module
v0.1.0 Latest Latest
Warning

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

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

README

AChrix

AChrix (pronounced ATCH-riks; Persian: اَچ‌ریکس) is an AChWorks Foundation being built as a reusable, versioned application base for web-connected products. A minimal Core and optional Modules share useful engineering capabilities while products own their business behavior.

The accepted starting stack is Go and ordinary PostgreSQL. Optional infrastructure is introduced for real workloads; see ADR-0002 and ADR-0003.

Start here

Implementation status

The initial executable baseline supplies minimal instance-owned Go composition, authorization and lifecycle contracts. The separately composed Notes consumer proves a pinned dependency, consumer-owned PostgreSQL persistence/migrations, direct invocation and one HTTP adapter through the same Application policy. Operations owns the supported matrix and the shared local/CI validation command. Issue #1 owns full executable acceptance and its exact evidence; this fixture does not establish a production product/deployment profile.

Suitable products will consume a versioned AChrix dependency rather than permanently copy its shared source. Product-specific behavior stays with the product. Koinon owns ecosystem governance/discovery and is not an AChrix runtime dependency.

Consume and extend

From your own Go module, pin the initial development release explicitly:

go get github.com/AChWorks/achrix@v0.1.0

GitHub Releases owns availability and exact source/artifact evidence. The initial release line defines compatibility/support limits; use the public contracts to compose trusted Modules. Products own authentication, policy and business/persistence behavior. Internationalization covers multilingual and RTL/LTR evolution; this Foundation release includes no UI or translation engine.

Licensing and participation

First-party repository content defaults to MPL-2.0. Compatible independent commercial/third-party Modules are possible; any Apache-2.0 SDK designation requires an explicit artifact scope. Licensing owns the details.

Governance, Trademark Policy and the Contribution Agreement cover canonical authority, honest representation and incoming rights. Publishing the agreement or opening a PR does not constitute signed consent.

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")
	ErrNotReady    = errors.New("application not ready")
	ErrComposition = errors.New("invalid composition")
)

Functions

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 its serialized lifecycle. 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 required 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 validation-dependent reads/writes; transport discovery grants no rights. During lifecycle exclusion it returns ErrNotReady without waiting or invoking policy.

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. During lifecycle exclusion it returns ErrNotReady without waiting or invoking modules.

func (*Application) Shutdown

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

Shutdown prevents new authorization and stops started modules in reverse order. Repeated shutdown is safe. Modules must wait for/terminate their owned work in Stop.

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.

type Config

type Config struct {
	// Timeouts bound the whole lifecycle phase, including all participating modules.
	StartupTimeout  time.Duration
	ShutdownTimeout time.Duration
	Logger          *slog.Logger
}

type Descriptor

type Descriptor struct {
	ID       string
	Version  string
	Provides []Capability
	Requires []Capability
}

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. Any non-nil result denies. It must honor context cancellation and must not mutate domain state.

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.

Jump to

Keyboard shortcuts

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