Documentation
¶
Overview ¶
Package kernel is wowapi's infrastructure composition root: it owns the database pool, the transaction manager, and the kernel services (the authz evaluator, and later outbox/jobs/documents/…). It is built once, in explicit order, by the product's app.App — never by a service locator (blueprint 06 §3).
The authz evaluator is constructed over a SHARED permission-registry pointer. Modules register their permissions into that same registry during Module.Register; the registry is fully populated before any request is served, and the evaluator reads it at decision time. App gates boot on the registry's Err() so an unregistered/duplicate permission fails startup, not a runtime request (closes the Phase 4 deferral).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Pool *pgxpool.Pool
// Platform is the app_platform pool for cross-tenant kernel work (outbox relay,
// job runner, seed sync) and, in the api, cross-tenant API-key verification. Both
// the generated api and worker mains build it BEFORE Boot and wire it here, and
// app.Boot's RLS-enforcement check (M3) validates it when non-nil. It is nil only
// for the migrate process, which serves no tenant traffic and opts out of that
// check via app.SkipRLSEnforcementCheck. A custom api/worker main MUST wire it
// too — leaving it nil silently skips the M3 backstop for the platform pool.
Platform *pgxpool.Pool
Tx database.TxManager
Audit authz.AuditSink // optional; nil → a logging sink
// Storage is the object-storage adapter backing the document framework.
// Optional: when nil, Kernel.Documents is nil and modules that require it fail
// boot only if they actually register a document class (checked by app.Boot).
Storage storage.Adapter
// Secrets resolves secret references (webhook signing secrets, integration
// credentials). Optional; when nil, resolving a ref errors at use time.
Secrets secrets.Provider
// WebhookSender delivers outbound webhooks. Optional; nil → the real HTTP sender.
WebhookSender webhook.Sender
// Metrics is the observability sink (Prometheus adapter in production).
// Optional; nil → observability.NoOp so call sites never nil-check.
Metrics observability.Metrics
// Tracer is the distributed-tracing port (OTel adapter in production).
// Optional; nil → observability.NoOpTracer. Wired into the outbox writer so
// emitted events carry the request's trace context across the async boundary
// (roadmap O1/CA-9).
Tracer observability.Tracer
// AuthzCacheTTL, when > 0, wraps the authorization store in a per-actor
// ActiveAssignments cache with this TTL (roadmap R1/CA-2). DEFAULT OFF
// (zero) — enabling it accepts up-to-TTL stale-allow after a revocation on
// another pod, so keep the TTL short and call Kernel.AuthzCache.Invalidate
// from your role grant/revoke paths for immediate effect on this pod.
AuthzCacheTTL time.Duration
}
Deps injects the pools/tx (built by the product main, or provided by testkit) so the kernel does not hard-code pool construction and stays testable.
type Kernel ¶
type Kernel struct {
Cfg config.Framework
Log *slog.Logger
Pool *pgxpool.Pool
Platform *pgxpool.Pool // app_platform pool for cross-tenant kernel work; see Deps.Platform for the wiring contract (nil only for migrate)
Tx database.TxManager
Authz authz.Evaluator
Perms *authz.Registry
Resources *resource.Registry
Rules *rules.Registry
RulesResolver *rules.Resolver
Workflows *workflow.Registry
WorkflowRuntime *workflow.Runtime
// Data lifecycle (roadmap E2). RetentionClasses is the shared record-class
// registry modules register their dispose/export/erase callbacks into during
// boot; Retention is the engine that drives scheduled disposition and DSR
// fulfilment over them.
RetentionClasses *retention.Registry
Retention *retention.Engine
// Document / file framework (Phase 8). DocumentClasses + DocumentHooks are the
// shared registration pointers modules write into during Register; Documents is
// nil when no storage adapter is provided (an api-only process may run without
// object storage). Comments/Attachments need no storage.
DocumentClasses *document.Registry
DocumentHooks *document.Hooks
Documents *document.Service
Comments *comment.Service
Attachments *attachment.Service
// Notification / webhook / integration framework (Phase 9). NotifyTemplates
// and IntegrationProviders are the shared registration pointers modules write
// into during Register; Notify/Webhooks/Integrations are the runtime services.
NotifyTemplates *notify.Registry
Notify *notify.Service
Webhooks *webhook.Service
IntegrationProviders *integration.Registry
Integrations *integration.Store
// Metrics is the observability sink shared by kernel components (RED
// middleware, scheduler lag, DLQ depth, webhook breaker, rate-limit drops).
// Never nil — defaults to observability.NoOp when no adapter is wired.
Metrics observability.Metrics
// Tracer is the distributed-tracing port; never nil (NoOpTracer default). The
// outbox writer captures its trace context; the relay continues it (CA-9).
Tracer observability.Tracer
// AuthzCache is the per-actor assignment cache wrapping the evaluator's store
// when Deps.AuthzCacheTTL > 0; nil when caching is disabled. It caches
// ActiveAssignments (which pre-join role_permissions), so BOTH an actor's
// role grants/revokes AND a role's permission set can otherwise be served
// stale up to the TTL. To keep it fresh (CA-2):
// - actor_assignment grant/revoke (product-owned write): call
// AuthzCache.Invalidate(tenant, capacity) — or InvalidateTenant for a
// bulk change — right after the write commits.
// - seed / authorization-spine sync (roles + role_permissions): pass this
// handle to seeds.Sync, which calls InvalidateAll after the writes commit.
// ABAC policies and ReBAC relationship edges are NOT cached (they pass
// through / are checked directly each Evaluate), so a policy activation or a
// granted_via edge change is never stale and needs no invalidation.
AuthzCache *authz.CachingStore
// Evidence-layer services exposed to modules via module.Context (roadmap CA-11):
// Audit (field-level audit + hash chain), Sequence (gap-free numbering), Bulk
// (chunked resumable ops), Artifacts (immutable versioned artifacts).
Audit *kaudit.Writer
Sequence *sequence.Allocator
Bulk *bulk.Service
Artifacts *artifact.Pipeline
// contains filtered or unexported fields
}
Kernel owns infrastructure and kernel services. Fields are read-only after construction; the pool never leaves the kernel.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apikey provides machine authentication (roadmap S1): issuable, scoped, rotatable, revocable, expirable API keys / service principals so non-human callers authenticate without a user token.
|
Package apikey provides machine authentication (roadmap S1): issuable, scoped, rotatable, revocable, expirable API keys / service principals so non-human callers authenticate without a user token. |
|
Package artifact is the snapshot/artifact pipeline (roadmap E4): it turns a product-rendered dataset into an IMMUTABLE, versioned artifact — content plus its sha256, a structured sidecar, and the template version/effective date it was produced under.
|
Package artifact is the snapshot/artifact pipeline (roadmap E4): it turns a product-rendered dataset into an IMMUTABLE, versioned artifact — content plus its sha256, a structured sidecar, and the template version/effective date it was produced under. |
|
Package audit is the durable, append-only, field-level audit trail (roadmap E1): a standardized record of who changed what — entity, field, before/after, actor, capacity, impersonator, request id — written INSIDE the business transaction so an audit row commits iff the change does.
|
Package audit is the durable, append-only, field-level audit trail (roadmap E1): a standardized record of who changed what — entity, field, before/after, actor, capacity, impersonator, request id — written INSIDE the business transaction so an audit row commits iff the change does. |
|
Package auth is wowapi's authentication kernel: it verifies OIDC/JWT bearer tokens against an injectable KeySource (JWKS-over-HTTPS in production, a local signer in tests) and maps validated claims onto an authz.Actor after the app resolves the framework user id and active capacity (D-0037, 01 §3).
|
Package auth is wowapi's authentication kernel: it verifies OIDC/JWT bearer tokens against an injectable KeySource (JWKS-over-HTTPS in production, a local signer in tests) and maps validated claims onto an authz.Actor after the app resolves the framework user id and active capacity (D-0037, 01 §3). |
|
Package authz is wowapi's authorization kernel: a deny-by-default evaluator that layers RBAC (role→permission assignments), ReBAC (relationship-derived grants), and ABAC (attribute policies, deny-first) exactly as specified in blueprint 01 §3.
|
Package authz is wowapi's authorization kernel: a deny-by-default evaluator that layers RBAC (role→permission assignments), ReBAC (relationship-derived grants), and ABAC (attribute policies, deny-first) exactly as specified in blueprint 01 §3. |
|
Package bulk is the chunked bulk-operation framework (roadmap E6): start a set of items, process them in caller-sized chunks with per-item isolation, record a partial-failure ledger, and resume after an interruption.
|
Package bulk is the chunked bulk-operation framework (roadmap E6): start a set of items, process them in caller-sized chunks with per-item isolation, record a partial-failure ledger, and resume after an interruption. |
|
Package config defines wowapi's typed configuration contracts: the framework-owned Framework struct, the Secret type with structural redaction, and the ModuleView through which modules receive their namespaced configuration.
|
Package config defines wowapi's typed configuration contracts: the framework-owned Framework struct, the Secret type with structural redaction, and the ModuleView through which modules receive their namespaced configuration. |
|
Package database is wowapi's persistence kernel: the pgx pool, the TxManager that is the ONLY door to tenant data, and the RLS session plumbing (SET LOCAL app.tenant_id inside a transaction, never on a pooled connection).
|
Package database is wowapi's persistence kernel: the pgx pool, the TxManager that is the ONLY door to tenant data, and the RLS session plumbing (SET LOCAL app.tenant_id inside a transaction, never on a pooled connection). |
|
Package document is wowapi's document / file framework: modules register document CLASSES (the policy envelope for a kind of file — allowed MIME types, a size ceiling, a default sensitivity, and an optional retention window); the service manages metadata rows, presigned upload sessions, immutable versioned file pointers, authorized presigned downloads, explicit access grants, and a retention sweep.
|
Package document is wowapi's document / file framework: modules register document CLASSES (the policy envelope for a kind of file — allowed MIME types, a size ceiling, a default sensitivity, and an optional retention window); the service manages metadata rows, presigned upload sessions, immutable versioned file pointers, authorized presigned downloads, explicit access grants, and a retention sweep. |
|
Package errors is wowapi's error taxonomy: a closed set of Kinds that map deterministically to HTTP status codes and stable machine codes, plus the structured Error type carried across every layer.
|
Package errors is wowapi's error taxonomy: a closed set of Kinds that map deterministically to HTTP status codes and stable machine codes, plus the structured Error type carried across every layer. |
|
Package filtering is wowapi's allowlist-driven filter/sort builder — the mechanism behind docs/blueprint/05 §2, "Pagination / filtering / sorting (allowlist-driven; SQL injection impossible by construction)".
|
Package filtering is wowapi's allowlist-driven filter/sort builder — the mechanism behind docs/blueprint/05 §2, "Pagination / filtering / sorting (allowlist-driven; SQL injection impossible by construction)". |
|
Package httpx is wowapi's HTTP toolbox: response envelopes, the RFC 9457 problem-details error writer, strict JSON decoding, metadata-enforced route registration, and the request helpers module handlers compose.
|
Package httpx is wowapi's HTTP toolbox: response envelopes, the RFC 9457 problem-details error writer, strict JSON decoding, metadata-enforced route registration, and the request helpers module handlers compose. |
|
Package integration is wowapi's external-provider framework: modules register a Provider ADAPTER per provider key (a payment gateway, an SMS gateway, an identity source, …); per-tenant/platform rows in integration_providers hold the non-secret config plus a credential REFERENCE (never plaintext); and the kernel resolves an adapter + its config + its resolved credential on demand and aggregates provider health for readiness.
|
Package integration is wowapi's external-provider framework: modules register a Provider ADAPTER per provider key (a payment gateway, an SMS gateway, an identity source, …); per-tenant/platform rows in integration_providers hold the non-secret config plus a credential REFERENCE (never plaintext); and the kernel resolves an adapter + its config + its resolved credential on demand and aggregates provider health for readiness. |
|
Package jobs is wowapi's Postgres-backed job runner (D-0047 — a focused queue behind the framework interfaces, NOT River).
|
Package jobs is wowapi's Postgres-backed job runner (D-0047 — a focused queue behind the framework interfaces, NOT River). |
|
Package logging provides process-wide structured logging for wowapi processes.
|
Package logging provides process-wide structured logging for wowapi processes. |
|
Package model defines wowapi's base model primitives: embeddable structs for identity, tenancy, audit, versioning, temporal validity, and status; plus kernel-wide value objects for money, references, and time ranges.
|
Package model defines wowapi's base model primitives: embeddable structs for identity, tenancy, audit, versioning, temporal validity, and status; plus kernel-wide value objects for money, references, and time ranges. |
|
Package notify is wowapi's notification framework: modules register template keys with an allowlisted variable set and required channels (Registry); Send writes a notifications row + one notification_deliveries row per resolved channel inside the caller's tenant business transaction (atomicity with the business write); and SendPending is the async worker step that claims queued deliveries, calls channel-specific senders, and advances delivery status — dead-lettering after maxAttempts.
|
Package notify is wowapi's notification framework: modules register template keys with an allowlisted variable set and required channels (Registry); Send writes a notifications row + one notification_deliveries row per resolved channel inside the caller's tenant business transaction (atomicity with the business write); and SendPending is the async worker step that claims queued deliveries, calls channel-specific senders, and advances delivery status — dead-lettering after maxAttempts. |
|
Package observability is wowapi's observability port: the Metrics interface (RED signals + generic counters and gauges) and a no-op safe default.
|
Package observability is wowapi's observability port: the Metrics interface (RED signals + generic counters and gauges) and a no-op safe default. |
|
Package outbox is wowapi's transactional outbox: modules write domain events into events_outbox in the SAME transaction as their business writes, so an event is emitted if and only if the write commits (no lost or phantom events).
|
Package outbox is wowapi's transactional outbox: modules write domain events into events_outbox in the SAME transaction as their business writes, so an event is emitted if and only if the write commits (no lost or phantom events). |
|
Package pagination provides wowapi's page/cursor response envelopes and the opaque keyset cursor used for feed-style listing.
|
Package pagination provides wowapi's page/cursor response envelopes and the opaque keyset cursor used for feed-style listing. |
|
Package policy is wowapi's ABAC condition engine: it evaluates a policy's conditions against an attribute bag using a closed operator set.
|
Package policy is wowapi's ABAC condition engine: it evaluates a policy's conditions against an attribute bag using a closed operator set. |
|
Package relationship is wowapi's ReBAC edge store: the tenant relationships graph (subject —rel_type→ object) plus the adapter that answers the authz kernel's relationship questions.
|
Package relationship is wowapi's ReBAC edge store: the tenant relationships graph (subject —rel_type→ object) plus the adapter that answers the authz kernel's relationship questions. |
|
Package resource is the kernel resource registry and the thin tenant mirror that lets kernel services (authz record-scope, comments, documents, workflow, relationships) address any module row uniformly.
|
Package resource is the kernel resource registry and the thin tenant mirror that lets kernel services (authz record-scope, comments, documents, workflow, relationships) address any module row uniformly. |
|
Package retention is the data-lifecycle layer (roadmap E2): a generalized legal hold over any entity (not just documents) and a Data Subject Request ledger (export/erasure) with a statutory-override reason.
|
Package retention is the data-lifecycle layer (roadmap E2): a generalized legal hold over any entity (not just documents) and a Data Subject Request ledger (export/erasure) with a statutory-override reason. |
|
Package rules is wowapi's rule/configuration engine: modules register rule points (a key, a JSON-Schema'd value, a default, allowed scopes, and whether changes require approval); values are stored as versioned rows with temporal validity; and resolution picks the most specific active value for a (tenant, org, at) — org-ancestry → tenant → platform → code default.
|
Package rules is wowapi's rule/configuration engine: modules register rule points (a key, a JSON-Schema'd value, a default, allowed scopes, and whether changes require approval); values are stored as versioned rows with temporal validity; and resolution picks the most specific active value for a (tenant, org, at) — org-ancestry → tenant → platform → code default. |
|
Package secrets defines the secret-reference model and the provider port.
|
Package secrets defines the secret-reference model and the provider port. |
|
Package seeds loads a module's declarative catalog seeds (permissions, roles, resource types, relationship types) from embedded YAML and syncs them idempotently into the global catalogs at boot.
|
Package seeds loads a module's declarative catalog seeds (permissions, roles, resource types, relationship types) from embedded YAML and syncs them idempotently into the global catalogs at boot. |
|
Package sequence provides a gap-free, race-free per-tenant numbered-series allocator for statutory documents (receipts, vouchers, certificates) — the primitive that keeps products off MAX()+1 (roadmap E3).
|
Package sequence provides a gap-free, race-free per-tenant numbered-series allocator for statutory documents (receipts, vouchers, certificates) — the primitive that keeps products off MAX()+1 (roadmap E3). |
|
Package storage is the object-storage port for the document framework: the kernel never talks to S3/minio/GCS directly, it talks to an Adapter.
|
Package storage is the object-storage port for the document framework: the kernel never talks to S3/minio/GCS directly, it talks to an Adapter. |
|
Package validation wraps go-playground/validator/v10 and translates its FieldError slice into kernel/errors.FieldError values, producing a *errors.Error with Kind=KindValidation.
|
Package validation wraps go-playground/validator/v10 and translates its FieldError slice into kernel/errors.FieldError values, producing a *errors.Error with Kind=KindValidation. |
|
Package webhook implements wowapi's webhook subsystem: inbound signature verification + replay protection + async processing, and outbound signed HTTP delivery with per-endpoint circuit breakers.
|
Package webhook implements wowapi's webhook subsystem: inbound signature verification + replay protection + async processing, and outbound signed HTTP delivery with per-endpoint circuit breakers. |
|
Package workflow is wowapi's small custom Postgres-backed workflow engine: a closed-step-type approval/state-machine runtime that shares the caller's tenant transaction (RLS + outbox + audit) exactly as blueprint 02 §1 and decisions D-0051/D-0053 specify.
|
Package workflow is wowapi's small custom Postgres-backed workflow engine: a closed-step-type approval/state-machine runtime that shares the caller's tenant transaction (RLS + outbox + audit) exactly as blueprint 02 §1 and decisions D-0051/D-0053 specify. |