routine

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Overview

Package routine finds recurring structure in the episodic tier.

This is deliberately not an LLM problem. "Slack → IDE at 09:40 ±12min on weekdays, 78% of the time" is a frequency count; prompting a model to notice it is slower, costs more, and is less reliable than the arithmetic. The model is used only to *name* a pattern that mining already found.

Index

Constants

View Source
const (
	MinOccurrences = 5
	MinWeeks       = 3
	// MinConsistency is the fraction of eligible days the pattern must appear
	// on. Below this it is a habit you have, not a routine you keep.
	MinConsistency = 0.4
)

Support thresholds. A pattern must clear all of these before it is ever shown.

Two coincidences are not a routine. A system that claims otherwise burns the user's trust faster than it earns it, and trust here is the whole product.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anomaly

type Anomaly struct {
	App         string
	LastSeenTS  int64
	TypicalGapD float64
	ActualGapD  float64
}

Anomaly is a departure from the established baseline.

func FindAnomalies

func FindAnomalies(events []event.Event, now int64) []Anomaly

FindAnomalies reports apps used regularly in the baseline but absent since.

This is what powers "you haven't touched the API repo in nine days" — the single most useful proactive signal, and the one most likely to be wrong if the thresholds are loose.

func (Anomaly) String

func (a Anomaly) String() string

type Periodic

type Periodic struct {
	App string
	// Weekday true means the pattern holds Mon–Fri; false means weekends.
	Weekday bool
	// MedianStart is seconds past local midnight.
	MedianStart int64
	// SpreadS is the median absolute deviation — how tight the cluster is.
	SpreadS     int64
	Occurrences int
	Weeks       int
	// Consistency is occurrences / eligible days, 0..1.
	Consistency float64
	EventIDs    []int64
}

Periodic is a recurring time-of-day pattern for one app.

func FindPeriodic

func FindPeriodic(events []event.Event) []Periodic

FindPeriodic looks for apps that are reliably opened around the same time.

Only the first substantial session per app per day counts. Someone opens Slack forty times a day; the routine is when they *start*, and counting every reopen would swamp the signal.

func FindPeriodicSites

func FindPeriodicSites(events []event.Event) []Periodic

FindPeriodicSites is the same analysis over browser history.

Worth having separately because it works on day one: browser history reaches back months, while focus events only exist from the moment the daemon first runs. A user should not have to wait three weeks to see the feature do anything.

func (Periodic) Cadence

func (p Periodic) Cadence() string

func (Periodic) Slug

func (p Periodic) Slug() string

Slug builds the note name for a periodic routine.

func (Periodic) Window

func (p Periodic) Window() string

type Sequence

type Sequence struct {
	From, To string
	Count    int
	// Share is how often From is followed by To rather than anything else.
	Share    float64
	EventIDs []int64
}

Sequence is an app-to-app transition that recurs.

func FindSequences

func FindSequences(events []event.Event) []Sequence

FindSequences counts adjacent app transitions.

Plain bigram counting rather than PrefixSpan or anything fancier: at vault scale the data does not justify it, and a transition table is something the user can check against their own memory.

func (Sequence) String

func (s Sequence) String() string

Jump to

Keyboard shortcuts

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