Documentation
¶
Overview ¶
Package core holds the foundation every layer shares: identifiers, the clock, the error taxonomy and the tenant carried by a context. It imports nothing else from this module. See docs/architecture/overview.md §3.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRetryable ¶
IsRetryable reports whether err is marked retryable.
func WithTenant ¶
WithTenant returns a context that carries id as the tenant. A later call on the same context replaces the earlier id; the parent context is unchanged. Every id is stored as is, valid or invalid: TenantFrom decides validity when the context is read, so an invalid id reads as no tenant.
Types ¶
type Clock ¶
Clock is the only source of wall time for production code outside the composition root. Durable flow code uses DurableContext.Now instead.
type Code ¶
type Code string
Code is a closed, stable error taxonomy shared by every layer and mapped to API problem responses. Add codes; never rename or remove them.
const ( CodeInvalidArgument Code = "invalid_argument" CodeNotFound Code = "not_found" CodeConflict Code = "conflict" CodePermissionDenied Code = "permission_denied" CodeUnauthenticated Code = "unauthenticated" CodeBudgetExceeded Code = "budget_exceeded" CodeRateLimited Code = "rate_limited" CodeTimeout Code = "timeout" CodeUnsupported Code = "unsupported" CodeVendor Code = "vendor_error" CodeAmbiguousStart Code = "ambiguous_start" CodeCancelled Code = "cancelled" CodeInternal Code = "internal" CodeRecordingMissing Code = "recording_missing" CodeDeterminismBroken Code = "determinism_violation" )
type Error ¶
type Error struct {
Code Code
Message string // English, for logs; never shown to end users as-is
Retryable bool // safe to retry the same request
RetryAfter time.Duration // provider hint, zero when unknown
MessageKey string // i18n key for user-facing text, optional
Params map[string]any // i18n params; must not contain secrets
Details map[string]any // redacted before leaving the process
Cause error
}
Error is the platform error. It carries retry semantics (for runtimes and clients) and an optional message key (for localized presentation at the edge).
type Ids ¶
Ids issues entity identifiers of the form "<kind>_<26 Crockford base32 chars>".
Identifiers are unique across process restarts and sort lexicographically by creation time (REQ-CORE-001, REQ-CORE-002). Production code obtains an Ids from the composition root; deterministic fakes live in core/coretest and are importable from tests only (enforced by `gate layering`).
type SystemClock ¶
type SystemClock struct{}
SystemClock reads the operating-system clock.
type TenantID ¶
type TenantID string
TenantID identifies the tenant a call acts for: the isolation boundary for data and spend. Every layer reads it from the context with TenantFrom, which reports no tenant for an id outside the grammar (REQ-CORE-005).
func TenantFrom ¶
TenantFrom returns the tenant carried by ctx, and false when ctx is nil, carries no id, or carries an id that is not a valid tenant id. Callers that must not run without a tenant check the second result instead of comparing against "".
A valid id satisfies REQ-CORE-005: non-empty, at most 128 bytes, valid UTF-8, free of control characters from U+0000 to U+001F and U+007F, neither "." nor "..", free of "/" and "\", and neither begins nor ends with a Unicode White_Space character. Dots and whitespace inside a longer id are allowed. An invalid id never falls back to the parent context's id: it reports no tenant.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package coretest holds deterministic fakes for core ports.
|
Package coretest holds deterministic fakes for core ports. |
|
Package schema generates JSON Schema from Go types, compiles and validates instances, and produces RFC 8785 canonical JSON for content-addressing.
|
Package schema generates JSON Schema from Go types, compiles and validates instances, and produces RFC 8785 canonical JSON for content-addressing. |