Documentation
¶
Index ¶
- Constants
- func LoadConfig(cm forge.ConfigManager, prefix string) fabriq.Config
- type Config
- type Extension
- func (e *Extension) Dependencies() []string
- func (e *Extension) Description() string
- func (e *Extension) Fabriq() *fabriq.Fabriq
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) Migrate(ctx context.Context) (*forge.MigrationResult, error)
- func (e *Extension) MigrationStatus(ctx context.Context) ([]*forge.MigrationGroupInfo, error)
- func (e *Extension) Name() string
- func (e *Extension) Register(app forge.App) error
- func (e *Extension) ResolveGrove() *grove.DB
- func (e *Extension) Rollback(ctx context.Context) (*forge.MigrationResult, error)
- func (e *Extension) Run(ctx context.Context) error
- func (e *Extension) Shutdown(ctx context.Context) error
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(_ context.Context) error
- func (e *Extension) Stores() *fabriq.Stores
- func (e *Extension) Version() string
- type GatewayConfig
- type GatewayExtension
- func (g *GatewayExtension) Dependencies() []string
- func (g *GatewayExtension) Description() string
- func (g *GatewayExtension) Name() string
- func (g *GatewayExtension) Register(app forge.App) error
- func (g *GatewayExtension) Start(_ context.Context) error
- func (g *GatewayExtension) Stop(ctx context.Context) error
- func (g *GatewayExtension) Version() string
- type GatewayOption
- func WithGatewayBasePath(p string) GatewayOption
- func WithGatewayHeartbeatTTL(d time.Duration) GatewayOption
- func WithGatewayID(id string) GatewayOption
- func WithGatewayRouteOptions(opts ...forge.RouteOption) GatewayOption
- func WithGatewaySSEHeartbeat(d time.Duration) GatewayOption
- func WithGatewayWriteTimeout(d time.Duration) GatewayOption
- type Option
- func WithBlobGCGrace(d time.Duration) Option
- func WithClusterer(c agent.Clusterer) Option
- func WithConfig(c fabriq.Config) Option
- func WithCustomAppliers(a ...projection.CustomApplier) Option
- func WithDistillDebounce(d time.Duration) Option
- func WithDistillFailOpenGuard(v bool) Option
- func WithDistillMaxWait(d time.Duration) Option
- func WithDistillRecipeVersion(v string) Option
- func WithEmbedder(e agent.Embedder) Option
- func WithGroveDatabase(name string) Option
- func WithGuard(g agent.Guard) Option
- func WithReconcileInterval(d time.Duration) Option
- func WithSummarizer(s agent.Summarizer) Option
- func WithWorker(on bool) Option
Constants ¶
const Version = "0.1.0"
Version is the fabriq forge extension version.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
func LoadConfig(cm forge.ConfigManager, prefix string) fabriq.Config
LoadConfig builds a fabriq.Config from a forge ConfigManager. prefix is "" for the top-level key contract (cmd/fabriq serve) or "extensions.fabriq." for the first-class host-app convention. Relocated and parameterized from cmd/fabriq's loadFabriqConfig; the elasticsearch.addrs GetStringSlice handling is preserved (confy does not split a comma env string into a Go slice).
Types ¶
type Config ¶
type Config struct {
Fabriq fabriq.Config
RunWorker bool
ReconcileInterval time.Duration
// BlobGCGrace protects freshly-created CAS entries and orphan bytes from
// collection for this window. Zero falls back to 1h at run time.
BlobGCGrace time.Duration
// Embedder enables the embedding worker: each write to an entity with an
// EmbedSpec is embedded + vector-upserted asynchronously. Nil = disabled.
Embedder agent.Embedder
// Summarizer enables the distillation worker: each write to an entity with
// a DistillSpec is summarized into its digest tree asynchronously (debounced,
// per-tenant single-flight). Nil = distillation disabled.
Summarizer agent.Summarizer
// Guard is the optional PII/guardrail seam for distillation (nil = identity).
Guard agent.Guard
// DistillFailOpenGuard flips the guard from fail-closed (default) to fail-open.
DistillFailOpenGuard bool
// DistillRecipeVersion salts the digest ContentHash; bump to rebuild the tree.
DistillRecipeVersion string
// DistillDebounce is the per-tenant coalescing window for L0+rollup sweeps.
DistillDebounce time.Duration
// DistillMaxWait caps how long a continuously-written tenant's sweep can be
// deferred by debounce resets. Zero falls back to 10×DistillDebounce.
// A value smaller than DistillDebounce is clamped up to DistillDebounce.
DistillMaxWait time.Duration
// Clusterer overrides the default in-core multi-probe SimHash clusterer.
Clusterer agent.Clusterer
// GroveDatabase names the *grove.DB to borrow from the host DI container
// when no Postgres DSN/shards are configured. Empty resolves the default
// (unnamed) grove.DB. Mirrors xraph/authsome's GroveDatabase knob. Read
// from extensions.fabriq.groveDatabase when unset programmatically.
GroveDatabase string
}
Config is the fabriq forge extension's configuration: the data-fabric config plus worker knobs. Build it with options; the extension overlays values from the config manager under extensions.fabriq.* at Register (options win).
type Extension ¶
type Extension struct {
forge.BaseExtension
// contains filtered or unexported fields
}
Extension exposes the fabriq data fabric as a first-class Forge extension: the facade as a DI service (alias "fabriq"), auto health, fabriq's migrations (Task 3), and an opt-in background worker (Task 4).
func (*Extension) Dependencies ¶
func (*Extension) Description ¶
func (*Extension) Migrate ¶
Migrate runs fabriq's pending migrations forward (forge MigratableExtension).
It opens a fresh grove Orchestrator against the primary DSN, runs all pending migrations, and translates the grove MigrateResult into a forge.MigrationResult.
func (*Extension) MigrationStatus ¶
MigrationStatus returns the current state of fabriq's migrations grouped by migration group (forge MigratableExtension).
grove's Status method returns []*migrate.GroupStatus, each with Applied and Pending []*migrate.MigrationStatus slices. This is translated to the forge type hierarchy: one *forge.MigrationGroupInfo per grove GroupStatus, with *forge.MigrationInfo entries in Applied and Pending.
func (*Extension) Register ¶
Register implements forge.Extension. It MUST call e.BaseExtension.Register first.
func (*Extension) ResolveGrove ¶ added in v0.0.3
ResolveGrove best-effort resolves a *grove.DB from the host app's DI container (honouring GroveDatabase), returning nil when none is available. It is the exported seam wrapping extensions (e.g. TwinOS's fabriqkg) use to borrow the same handle fabriq serves and migrates against.
func (*Extension) Rollback ¶
Rollback rolls back the last applied fabriq migration (forge MigratableExtension).
grove's Rollback rolls back exactly one migration (the most recently applied in the group). RolledBack will be 0 or 1.
func (*Extension) Run ¶
Run implements forge.RunnableExtension: supervise the leader-elected relay until shutdown. If RunWorker is false this is a no-op.
func (*Extension) Shutdown ¶
Shutdown implements forge.RunnableExtension: SIGTERM drain. If RunWorker is false (or Run was never called), this is a no-op.
type GatewayConfig ¶
type GatewayConfig struct {
// GatewayID is this gateway's cluster identity (deltas are routed back to it
// over lq:delta:{id}). Defaults to "gw-<host>-<pid>".
GatewayID string
// BasePath is the SSE endpoint path; the WebSocket endpoint is BasePath+"/ws".
// Defaults to "/api/v1/live".
BasePath string
// HeartbeatTTL is the membership liveness window of the Redis cluster
// transport (default 6s). Shards must refresh within it.
HeartbeatTTL time.Duration
// SSE and WS tune the per-connection delivery loops (heartbeat, write
// deadlines/watchdog).
SSE gateway.SSEOptions
WS gateway.WSOptions
// RouteOptions are forwarded verbatim to router.SSE/router.WebSocket, so the
// host app attaches its own auth middleware and AsyncAPI/OpenAPI schemas
// (e.g. pkgAuth.RequirePermission(...), forge.WithSSEMessage(...)). fabriq
// stays auth-scheme-agnostic.
RouteOptions []forge.RouteOption
}
GatewayConfig configures the standalone live-query gateway tier: the edge that terminates client SSE/WebSocket connections and routes them over the sharded control/delta protocol to the matcher shards.
type GatewayExtension ¶
type GatewayExtension struct {
forge.BaseExtension
// contains filtered or unexported fields
}
GatewayExtension exposes the fabriq live-query gateway as a Forge extension: it builds a cluster.Gateway over the fabriq facade's Redis transport, runs its demux pump, and registers the SSE + WebSocket controllers. It depends on the "fabriq" extension (it reads its Stores().Redis), so it starts after it.
func NewGateway ¶
func NewGateway(fab *Extension, opts ...GatewayOption) *GatewayExtension
NewGateway builds the gateway extension wired to a started fabriq Extension.
func (*GatewayExtension) Dependencies ¶
func (g *GatewayExtension) Dependencies() []string
func (*GatewayExtension) Description ¶
func (g *GatewayExtension) Description() string
func (*GatewayExtension) Name ¶
func (g *GatewayExtension) Name() string
func (*GatewayExtension) Register ¶
func (g *GatewayExtension) Register(app forge.App) error
Register registers the SSE and WebSocket controllers. Their handlers resolve the backend lazily (it is built in Start), the same lazy-DI pattern the fabriq facade uses — safe because requests only arrive after Start.
func (*GatewayExtension) Start ¶
func (g *GatewayExtension) Start(_ context.Context) error
Start builds the cluster.Gateway over the facade's Redis transport and runs its demux pump.
func (*GatewayExtension) Stop ¶
func (g *GatewayExtension) Stop(ctx context.Context) error
Stop stops the gateway demux pump.
func (*GatewayExtension) Version ¶
func (g *GatewayExtension) Version() string
type GatewayOption ¶
type GatewayOption func(*GatewayConfig)
GatewayOption is a functional option for GatewayConfig.
func WithGatewayBasePath ¶
func WithGatewayBasePath(p string) GatewayOption
WithGatewayBasePath sets the SSE endpoint path (WS is BasePath+"/ws").
func WithGatewayHeartbeatTTL ¶
func WithGatewayHeartbeatTTL(d time.Duration) GatewayOption
WithGatewayHeartbeatTTL sets the cluster membership liveness window.
func WithGatewayID ¶
func WithGatewayID(id string) GatewayOption
WithGatewayID sets the gateway's cluster identity.
func WithGatewayRouteOptions ¶
func WithGatewayRouteOptions(opts ...forge.RouteOption) GatewayOption
WithGatewayRouteOptions appends route options forwarded to the SSE/WS routes (auth, AsyncAPI/OpenAPI documentation).
func WithGatewaySSEHeartbeat ¶
func WithGatewaySSEHeartbeat(d time.Duration) GatewayOption
WithGatewaySSEHeartbeat sets the SSE keep-alive interval.
func WithGatewayWriteTimeout ¶
func WithGatewayWriteTimeout(d time.Duration) GatewayOption
WithGatewayWriteTimeout bounds a single SSE/WS write before the connection is torn down (the client reconnects to a fresh snapshot).
type Option ¶
type Option func(*Config)
Option is a functional option for Config.
func WithBlobGCGrace ¶
WithBlobGCGrace sets the grace window before an unreferenced CAS entry or orphan byte becomes GC-eligible. Defaults to 1h when zero.
func WithClusterer ¶ added in v0.0.3
WithClusterer overrides the default multi-probe SimHash clusterer (e.g. a vector-based gmmclusterer). Nil = default.
func WithConfig ¶
WithConfig sets the underlying fabriq data-fabric configuration.
func WithCustomAppliers ¶
func WithCustomAppliers(a ...projection.CustomApplier) Option
WithCustomAppliers appends consumer-supplied projection appliers to the fabriq config. They are unioned after the built-in declarative applier for their Target and MUST be pure (see projection.CustomApplier).
func WithDistillDebounce ¶
WithDistillDebounce sets the per-tenant coalescing window for L0+rollup sweeps.
func WithDistillFailOpenGuard ¶
WithDistillFailOpenGuard flips the guard from fail-closed (default) to fail-open.
func WithDistillMaxWait ¶ added in v0.0.3
WithDistillMaxWait caps how long a continuously-written tenant's sweep can be deferred by debounce resets. Zero falls back to 10×DistillDebounce. A value smaller than DistillDebounce is clamped up to DistillDebounce.
func WithDistillRecipeVersion ¶
WithDistillRecipeVersion salts the digest ContentHash; bump to rebuild the tree.
func WithEmbedder ¶
WithEmbedder enables the embedding worker: each write to an entity with an EmbedSpec is embedded + vector-upserted asynchronously. Nil = disabled.
func WithGroveDatabase ¶ added in v0.0.3
WithGroveDatabase names the *grove.DB to borrow from the host DI container when no Postgres DSN/shards are configured (empty = the default unnamed grove.DB). Mirrors xraph/authsome's grove-database selection.
func WithReconcileInterval ¶
WithReconcileInterval sets the interval at which the background worker reconciles projection state.
func WithSummarizer ¶
func WithSummarizer(s agent.Summarizer) Option
WithSummarizer enables the distillation worker: each write to an entity with a DistillSpec is summarized into its digest tree asynchronously. Nil = disabled.
func WithWorker ¶
WithWorker enables or disables the background reconcile worker.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agentmcp exposes the fabriq agent toolkit over MCP (JSON-RPC 2.0).
|
Package agentmcp exposes the fabriq agent toolkit over MCP (JSON-RPC 2.0). |
|
Package gmmclusterer is an optional, host-wired vector clusterer for fabriq context distillation.
|
Package gmmclusterer is an optional, host-wired vector clusterer for fabriq context distillation. |
|
Package shieldguard adapts github.com/xraph/shield to the agent.Guard seam.
|
Package shieldguard adapts github.com/xraph/shield to the agent.Guard seam. |