corpus

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package corpus implements the internal benchmark corpus: a curated, capability-tagged set of closed beads worth tracking over time.

The corpus is intentionally curation-driven (no auto-promotion). Three files describe it:

  • <root>/corpus.yaml — append-only top-level index, one entry per promoted bead. Required fields: bead_id, promoted, promoted_by, and exactly one of {capability, failure_mode}.
  • <root>/corpus/<bead-id>.yaml — per-bead detail (project_root, base and known-good revisions, difficulty, prompt_kind, notes).
  • <root>/corpus/capabilities.yaml — controlled vocabulary of capability + failure_mode tags. Every tag referenced by the index must appear here.

Validate loads all three files and cross-checks them; the returned errors point at the file + entry that is malformed.

Index

Constants

This section is empty.

Variables

View Source
var ValidDifficulties = []string{"easy", "medium", "hard"}

ValidDifficulties enumerates accepted difficulty buckets.

View Source
var ValidPromptKinds = []string{
	"implement-with-spec",
	"port-by-analogy",
	"debug-and-fix",
	"review",
}

ValidPromptKinds enumerates accepted prompt kinds.

Functions

func CapabilitiesPath

func CapabilitiesPath(root string) string

CapabilitiesPath returns the conventional capabilities vocabulary path.

func DetailDir

func DetailDir(root string) string

DetailDir returns the conventional per-bead detail directory.

func IndexPath

func IndexPath(root string) string

IndexPath returns the conventional index path under root.

func Promote

func Promote(root string, req PromoteRequest) error

Promote appends the request to corpus.yaml and writes the per-bead detail file. Both writes are atomic (write temp + rename). If the post-write Validate() fails, Promote rolls both files back to their pre-call state and returns the validation error.

Promote refuses if the bead is already in corpus.yaml — the caller should also gate on "open in beads.jsonl" / "no closing commit" before invoking.

func Validate

func Validate(root string) error

Validate loads and cross-validates the corpus rooted at root.

func ValidateLoaded

func ValidateLoaded(l *Loaded) error

ValidateLoaded cross-validates an already-loaded corpus. The error returned is a single error joining every problem found, so callers see all failures at once.

Types

type Capabilities

type Capabilities struct {
	Version int   `yaml:"version"`
	Tags    []Tag `yaml:"tags"`
}

Capabilities is the YAML envelope for capabilities.yaml.

type Detail

type Detail struct {
	BeadID       string `yaml:"bead_id"`
	ProjectRoot  string `yaml:"project_root"`
	BaseRev      string `yaml:"base_rev"`
	KnownGoodRev string `yaml:"known_good_rev"`
	Captured     string `yaml:"captured"`
	Capability   string `yaml:"capability,omitempty"`
	FailureMode  string `yaml:"failure_mode,omitempty"`
	Difficulty   string `yaml:"difficulty"`
	PromptKind   string `yaml:"prompt_kind"`
	Notes        string `yaml:"notes"`
}

Detail is the per-bead detail YAML stored at corpus/<bead-id>.yaml.

type Index

type Index struct {
	Version int          `yaml:"version"`
	Beads   []IndexEntry `yaml:"beads"`
}

Index is the YAML envelope for corpus.yaml.

type IndexEntry

type IndexEntry struct {
	BeadID      string `yaml:"id"`
	Capability  string `yaml:"capability,omitempty"`
	FailureMode string `yaml:"failure_mode,omitempty"`
	Promoted    string `yaml:"promoted"`
	PromotedBy  string `yaml:"promoted_by"`
}

IndexEntry is one line of corpus.yaml (top-level index).

type Loaded

type Loaded struct {
	Root         string
	Index        Index
	Capabilities Capabilities
	Details      map[string]Detail // keyed by bead_id
	DetailFiles  map[string]string // bead_id → file path on disk
}

Loaded is the result of Load — the three files plus their resolved root.

func Load

func Load(root string) (*Loaded, error)

Load reads and parses all three files. It does NOT cross-validate; call Validate (or call ValidateLoaded) for that. Missing files return an error wrapping os.ErrNotExist so callers can distinguish "no corpus yet" from a malformed corpus.

func (*Loaded) HasBead

func (l *Loaded) HasBead(id string) bool

HasBead reports whether the given bead_id is already promoted.

func (*Loaded) SortedBeadIDs

func (l *Loaded) SortedBeadIDs() []string

SortedBeadIDs returns the bead ids declared in the index, sorted.

type PromoteRequest

type PromoteRequest struct {
	BeadID       string
	ProjectRoot  string
	BaseRev      string
	KnownGoodRev string
	Captured     string // YYYY-MM-DD
	Promoted     string // YYYY-MM-DD; defaults to Captured
	PromotedBy   string
	Capability   string
	FailureMode  string
	Difficulty   string
	PromptKind   string
	Notes        string
}

PromoteRequest captures the fields needed to add one bead to the corpus. Exactly one of Capability or FailureMode must be set.

type Tag

type Tag struct {
	ID          string `yaml:"id"`
	Area        string `yaml:"area"`
	Kind        string `yaml:"kind"` // "capability" or "failure_mode"
	Description string `yaml:"description"`
}

Tag is one capability-vocabulary entry in capabilities.yaml.

Jump to

Keyboard shortcuts

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