watch

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package watch turns external edits to trace files (Obsidian, VS Code, Finder drags, iCloud sync, etc.) into first-class mutation events. It runs as a goroutine under `noema serve` on both the stdio and http transports, watching the cortex's traces/, archive/traces/, and trash/traces/ directories with fsnotify and dispatching to existing Cortex mutation methods so events, vector clocks, and the SQL write path are shared with MCP-initiated mutations. Federation propagation is still HTTP-only (peers need a network endpoint), but external-edit events land in the local log under stdio too and flow outward the next time an HTTP serve runs on this cortex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

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

Watcher observes the three trace directories and reconciles external filesystem changes into Cortex mutation events. Lifecycle mirrors federation.Syncer: construct, Start, Stop (cancels context and waits for the goroutine to drain).

func New

func New(cx *cortex.Cortex, cfg *cortex.WatchConfig) (*Watcher, error)

New creates a Watcher for the given cortex. An empty cfg is equivalent to the defaults (enabled=true, debounce=300ms); callers that want to gate on the enabled bit should check cfg.WatchEnabled() before calling.

func (*Watcher) Start

func (w *Watcher) Start() error

Start registers the three trace directories with fsnotify and spawns the event-loop goroutine. Returns an error only if adding a directory fails (e.g. permission denied); transient fsnotify errors during runtime are logged, not surfaced.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop cancels the context, closes fsnotify, and blocks until the run goroutine exits. Pending debounce timers are cancelled so no reconcile fires after Stop returns.

Jump to

Keyboard shortcuts

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