daemon

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package daemon hosts Ozy's runtime: it owns configuration, the catalog store, and the in-process broker that every adapter shares (SPEC.md §6.1). The runtime is hosted by the serving process (the MCP adapter) rather than a standalone command: Start provisions the sidecar and conditionally indexes, then returns once ready. The Broker seam is swappable under a lock so a background provisioning pass can upgrade lexical search to hybrid semantic in place, visible to an adapter that reads Broker() per request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

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

Daemon holds the runtime wiring shared by the CLI and MCP adapter.

func New

func New(cfg *config.Loaded) (*Daemon, error)

New constructs the runtime from already-loaded configuration. It initializes the persistent catalog store and the broker. Configuration validation happens in config.Load, so an invalid config never reaches this point.

Semantic search is wired during Start() when the sidecar can be provisioned; New returns the lexical-only baseline that works without Python.

func NewWithStore

func NewWithStore(cfg *config.Loaded, store catalog.Store) *Daemon

NewWithStore constructs a daemon with an injected store. It keeps tests and focused in-memory callers from touching the user's durable catalog. The logger defaults to a discard logger; the serving process installs a real one via SetLogger.

func (*Daemon) Broker

func (d *Daemon) Broker() broker.Broker

Broker returns the shared broker used by all adapters. It is read under a lock so a background sidecar swap is visible and race-free.

func (*Daemon) Config

func (d *Daemon) Config() *config.Loaded

Config returns the loaded configuration.

func (*Daemon) Index

func (d *Daemon) Index(ctx context.Context) *index.Summary

Index provisions the embedding sidecar (idempotently) and runs the indexer, attaching the embedding sink when semantic search is available. It is the one index path shared by Start and the standalone `ozy index` command, so both index identically — catalog plus vectors when semantic is enabled.

func (*Daemon) SemanticDegraded

func (d *Daemon) SemanticDegraded() bool

SemanticDegraded reports whether semantic search is configured but the sidecar is not actually serving (provisioning failed, health check failed, or the sidecar crashed), so callers can surface the graceful fallback to lexical search (SPEC.md §4.10, §10.1). Returns false when semantic is disabled or when it is enabled AND the sidecar is healthy.

func (*Daemon) SetLogger

func (d *Daemon) SetLogger(log *slog.Logger)

SetLogger installs the structured logger used for lifecycle and degradation events. The serving process points this at the config-dir log file; tests may install a capturing handler. A nil logger is ignored.

func (*Daemon) Shutdown

func (d *Daemon) Shutdown()

Shutdown stops the embedding sidecar if one is running. It is safe to call when no sidecar was provisioned. The serving adapter and the standalone `ozy index` / `ozy search` paths use it to avoid leaking the subprocess.

func (*Daemon) Start

func (d *Daemon) Start(ctx context.Context)

Start provisions the embedding sidecar (when semantic search is enabled) and runs a conditional index, then returns once the runtime is ready. It does NOT block: the serving process owns the lifetime and calls Shutdown on exit. A cold model download or provisioning failure degrades to the lexical baseline rather than failing Start, so a serving adapter can launch Start in the background and keep answering from lexical until semantic becomes ready.

func (*Daemon) Store

func (d *Daemon) Store() catalog.Store

Store returns the catalog store.

Jump to

Keyboard shortcuts

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