health

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package health monitors context health by detecting stale architecture maps and pruning expired state files.

Index

Constants

This section is empty.

Variables

View Source
var UUIDPattern = regexp.MustCompile(
	`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`,
)

UUIDPattern matches a UUID (v4) anywhere in a filename.

Functions

func AutoPrune

func AutoPrune(days int) int

AutoPrune silently removes session-scoped state files older than the given number of days. Called from context-load-gate on session start. Returns the number of files removed. Errors are swallowed - auto-prune is best-effort and must never block session startup.

Parameters:

  • days: Prune files older than this many days

Returns:

  • int: Number of files pruned

func CountModuleCommits

func CountModuleCommits(since string) int

CountModuleCommits counts git commits touching internal/ since the given date.

Parameters:

  • since: date string in YYYY-MM-DD format

Returns:

  • int: number of commits, or 0 on error or if git is unavailable

func EmitMapStalenessWarning

func EmitMapStalenessWarning(sessionID, dateStr string, moduleCommits int) string

EmitMapStalenessWarning builds the architecture map staleness warning box.

Parameters:

  • sessionID: session identifier for notifications
  • dateStr: last refresh date (YYYY-MM-DD)
  • moduleCommits: number of commits touching modules since last refresh

Returns:

  • string: formatted nudge box, or empty string if silenced

func FormatAge

func FormatAge(t time.Time) string

FormatAge formats a time.Time as a human-readable age string.

Parameters:

  • t: Time to format

Returns:

  • string: Age string (e.g. "5m", "3h", "2d")

Types

type MapTrackingInfo

type MapTrackingInfo struct {
	OptedOut bool   `json:"opted_out"`
	LastRun  string `json:"last_run"`
}

MapTrackingInfo holds the minimal fields needed from map-tracking.json.

func ReadMapTracking

func ReadMapTracking() *MapTrackingInfo

ReadMapTracking reads and parses the map-tracking.json file from the context directory.

Returns:

  • *MapTrackingInfo: parsed tracking info, or nil if not found or invalid

Jump to

Keyboard shortcuts

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