staleness

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: AGPL-3.0 Imports: 9 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 staleness decides whether a section's content is withheld: verified older than its doc_type threshold AND making claims that rot (code paths, symbols). The advisory-vs-guarded split is deliberate — "function X at Y:Z" claims actively mislead when stale, plain learnings don't.

Index

Constants

This section is empty.

Variables

View Source
var ErrGuarded = errors.New("section requires verification")

ErrGuarded signals the caller must pass force_read or verify-then-mark before reading.

Functions

func ExtractVerifyHints

func ExtractVerifyHints(content string, max int) []string

ExtractVerifyHints returns up to `max` unique matched code paths for a verification hint.

func MentionsCodePath

func MentionsCodePath(content string) bool

MentionsCodePath reports whether content references a code path likely to rot.

func Preview

func Preview(content string, max int) string

Preview returns a short preview of content for refused sections (default 200 chars).

Types

type CheckResult

type CheckResult struct {
	Stale         bool // verified_at is older than threshold (advisory)
	Guarded       bool // Stale AND mentions code path — server should refuse content
	ThresholdDays int
	Age           time.Duration
}

CheckResult describes what to do with a section relative to staleness.

func Check

func Check(ctx context.Context, store *ThresholdStore, section models.Section, docType string) (CheckResult, error)

Check evaluates whether a section is guarded. NULL verified_at is treated as verified at creation (migration backfills legacy rows; model default handles new).

type ThresholdStore

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

ThresholdStore loads and caches staleness thresholds (5-min TTL to avoid a DB hit per search).

func NewThresholdStore

func NewThresholdStore(db *gorm.DB) *ThresholdStore

NewThresholdStore returns a threshold cache backed by `db`.

func (*ThresholdStore) All added in v1.1.1

func (s *ThresholdStore) All(ctx context.Context) (map[string]int, error)

All returns a fresh copy of every doc_type -> day threshold, reusing the same cache and refresh as DaysFor. The copy keeps callers from mutating the cache.

func (*ThresholdStore) DaysFor

func (s *ThresholdStore) DaysFor(ctx context.Context, docType string) (int, error)

DaysFor returns the day threshold for a doc_type, falling back to the reference threshold. Cached.

func (*ThresholdStore) Invalidate

func (s *ThresholdStore) Invalidate()

Invalidate forces a reload on the next lookup (for admin tools that change thresholds).

Jump to

Keyboard shortcuts

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