freshness

package
v0.9.9-dev.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package freshness binds a conservative source inventory to a generation. It never infers graph completeness from filesystem stability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(ctx context.Context, repositories []workspace.Repository) (string, error)

Capture includes names as well as contents, including uncommitted and untracked sources. Configured exclusions are honored; source extensions come from the same language registry as the indexer.

func Save

func Save(ctx context.Context, root string, generation uint64, digest string) (err error)

Save is deliberately separate from CURRENT. A missing attestation makes a generation unverified, never corrupt, and cannot make a stale graph fresh.

Types

type Cache

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

Cache holds the latest content-freshness observation for a published generation. It deliberately contains no filesystem-derived mutable state: graph_status can read it without walking or hashing a repository.

func NewCache

func NewCache(initial Status) *Cache

NewCache creates a cache with an initial, already classified observation.

func (*Cache) Load

func (cache *Cache) Load() Status

Load returns the last observation. A nil cache is treated as an unverified observation so an optional fast-path integration fails closed.

func (*Cache) MarkStale

func (cache *Cache) MarkStale(detail string)

MarkStale invalidates the cached result after a watched registered input changes. The generation remains attached so callers can distinguish a stale graph from an observation for a different generation.

func (*Cache) MarkUnavailable

func (cache *Cache) MarkUnavailable(detail string)

MarkUnavailable fails closed when the watcher can no longer observe the registered trees. It is not equivalent to fresh content.

func (*Cache) Store

func (cache *Cache) Store(status Status)

Store replaces the observation after a complete inventory check or a successful publication.

func (*Cache) StoreIfUnverified

func (cache *Cache) StoreIfUnverified(status Status) bool

StoreIfUnverified publishes a background verification result only while no watcher event or successful rebuild has superseded it. This prevents a scan started at server setup from turning an already observed change back into fresh.

type Monitor

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

Monitor invalidates a freshness cache from filesystem notifications. It never hashes on the notification path; the next full rebuild creates the next attestation, while graph_status remains a bounded cache read.

func NewMonitor

func NewMonitor(
	ctx context.Context,
	repositories []workspace.Repository,
	cache *Cache,
) (*Monitor, error)

NewMonitor starts watching the registered repositories. The watcher's one initial directory walk happens at setup, outside graph_status; subsequent status calls only read the supplied cache.

func NewRegistryMonitor

func NewRegistryMonitor(
	ctx context.Context,
	source config.RepositoriesFile,
	registryPath string,
	attestationRoot string,
	cache *Cache,
) (*Monitor, error)

NewRegistryMonitor resolves the configured repositories once and then watches their runtime roots. Registry and Git inspection belongs at server setup, never in a graph_status call.

func (*Monitor) Close

func (monitor *Monitor) Close()

Close stops the monitor and waits until it no longer owns filesystem watches. It is safe to call on a nil monitor.

type Record

type Record struct {
	Version    int    `json:"version"`
	Generation uint64 `json:"generation"`
	Digest     string `json:"digest"`
}

type Status

type Status struct {
	Generation uint64 `json:"generation"`
	State      string `json:"state"`
	Detail     string `json:"detail,omitempty"`
}

func Check

func Check(ctx context.Context, root string, generation uint64, repositories []workspace.Repository) Status

Jump to

Keyboard shortcuts

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