watchdog

package
v0.2.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package watchdog keeps standing watches available when no codeaf terminal is open. The user-facing surfaces describe the consequence; this package owns the deliberately quiet operating-system details.

Index

Constants

View Source
const (
	// Interval is the cadence promised by the standing-watch ratification.
	Interval = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LastWakeFunc

type LastWakeFunc func() (time.Time, bool, error)

LastWakeFunc reads the newest durable wake observation from the graph journal. Keeping this as a callback prevents the OS package from owning or opening the user's brain file.

type Manager

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

Manager installs, removes, and inspects the current user's five-minute timer. It contains no process-local policy state.

func New

func New(options Options) (*Manager, error)

New resolves defaults and validates the immutable inputs once.

func (*Manager) Install

func (m *Manager) Install(ctx context.Context) error

Install writes the exact timer definition and asks the current user's OS to use it immediately. Reinstalling repairs drift and is safe.

func (*Manager) Status

func (m *Manager) Status() (Status, error)

Status derives installation from the definition files and timing from the journal plus the timer's fixed cadence. It never shells out.

func (*Manager) Uninstall

func (m *Manager) Uninstall(ctx context.Context) error

Uninstall stops the timer and removes its definition. Missing files are already uninstalled and therefore succeed without invoking host commands.

type Options

type Options struct {
	Platform   string
	HomeDir    string
	Executable string
	UID        int
	Runner     Runner
	LastWake   LastWakeFunc
	Now        func() time.Time
}

Options makes every host-specific input injectable for exact, hermetic tests. Empty values are filled from the current process by New.

type Runner

type Runner interface {
	Run(ctx context.Context, name string, args ...string) error
}

Runner is the complete process boundary used to load and unload the user timer. Tests provide a recorder; only commandRunner reaches os/exec.

type Status

type Status struct {
	Installed bool
	// Stale means the installed timer is from before the rename and startup
	// should replace it with the current generation.
	Stale    bool
	LastWake time.Time
	NextDue  time.Time
}

Status is the shared standing-watch view used by doctor and chat grounding.

Jump to

Keyboard shortcuts

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