hats

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 10 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentFetcher

type ContentFetcher interface {
	GetFileContents(ctx context.Context, installationID int64, repo, path string) ([]byte, error)
}

ContentFetcher is the subset of the github client this package needs. Defined here to avoid a direct dependency on the github package.

type FetchFunc

type FetchFunc func() ([]byte, error)

FetchFunc returns the raw bytes of hats.md or an error.

func GitHubFetchFunc

func GitHubFetchFunc(ctx context.Context, f ContentFetcher, installationID int64, repo, path string) FetchFunc

GitHubFetchFunc wires a ContentFetcher into a FetchFunc for a given repo and path. Each call to the returned FetchFunc issues one GetFileContents call — the caller owns retry/timeout policy.

The context is captured at construction time; pass a long-lived context (typically context.Background() or a shutdown-tied context). A request-scoped context would apply its cancellation or deadline to every future refresh.

type Hat

type Hat struct {
	Name                   string
	WhenToPick             string
	RetrievalLabels        []string
	RetrievalBoostKeywords []string
	Posture                Posture
	Phase1Asks             string
	// AnchorIssueNumbers collects every `#NNN` reference that appears in the
	// Anchors paragraph, including PR numbers cited in parentheticals. Issue
	// and PR numbers share a namespace on GitHub, so downstream consumers can
	// treat these uniformly — but they are not a curated subset of issues.
	AnchorIssueNumbers []int
}

Hat is one class entry in the taxonomy.

type Loader

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

Loader caches a parsed Taxonomy with a TTL and returns stale results if a fetch fails after TTL expiry.

func NewLoader

func NewLoader(f FetchFunc, ttl time.Duration) *Loader

NewLoader returns a Loader that fetches via f and caches for ttl.

func (*Loader) Get

func (l *Loader) Get() (Taxonomy, error)

Get returns the current taxonomy, refreshing if the cache is expired. On fetch error, returns the stale cached taxonomy if one exists; otherwise returns the fetch error.

The returned Taxonomy is a shallow copy of the cached value — Hats and their inner slices share backing storage with the cache, so callers must treat the result as read-only. Mutating any slice will corrupt future cache reads.

func (*Loader) Invalidate

func (l *Loader) Invalidate()

Invalidate forces the next Get() to re-fetch.

type Posture

type Posture string

Posture is one of the reasoning postures declared in hats.md.

const (
	PostureCausalHypothesis  Posture = "causal-hypothesis"
	PostureWorkaroundMenu    Posture = "ambiguous-workaround-menu"
	PostureCausalNarrative   Posture = "internal-regression"
	PostureDemandGating      Posture = "demand-gating-needed"
	PostureConfigDependent   Posture = "config-dependent"
	PostureBlockedOnUpstream Posture = "blocked-on-upstream"
)

type Taxonomy

type Taxonomy struct {
	Preamble string
	Hats     []Hat
}

Taxonomy is the parsed content of a hats.md file.

func Parse

func Parse(data []byte) (Taxonomy, error)

Parse converts hats.md content into a Taxonomy.

func (Taxonomy) Find

func (t Taxonomy) Find(name string) *Hat

Find returns the hat with the given name, or nil.

Jump to

Keyboard shortcuts

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