recipestore

package
v0.1.5 Latest Latest
Warning

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

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

Documentation

Overview

Package recipestore provides a content-addressed store for recipe/configuration snapshots. Each unique configuration is stored once, keyed by its SHA-256 hash. Preference entries emit only the hash, keeping the JSONL lean while enabling full config lookup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(cfg *RecipeSnapshot) string

Hash returns the content-addressed key for a RecipeSnapshot.

Name is excluded — it is a display label, not a behavioral setting. Version is included because it determines which Runner implementation executes the recipe, so identical fields under different schema versions produce different behavior.

Format: cfg_v{version}_{sha256hex}

Types

type ConstraintsConfig

type ConstraintsConfig struct {
	MaxSteps int    `json:"max_steps,omitempty"`
	Timeout  string `json:"timeout,omitempty"`
}

ConstraintsConfig captures constraint settings relevant to preference comparison.

type ContextConfig

type ContextConfig struct {
	MaxHistoryTurns  int     `json:"max_history_turns,omitempty"`
	Strategy         string  `json:"strategy,omitempty"`
	CompactThreshold float64 `json:"compact_threshold,omitempty"`
	TaskMode         string  `json:"task_mode,omitempty"`
}

ContextConfig captures conversation history management settings.

type ModelParamsConfig

type ModelParamsConfig struct {
	Temperature *float64 `json:"temperature,omitempty"`
	MaxTokens   *int     `json:"max_tokens,omitempty"`
	Seed        *int64   `json:"seed,omitempty"`
}

ModelParamsConfig captures sampling parameters relevant to preference comparison.

type ModelProfileConfig

type ModelProfileConfig struct {
	ContextBudget  int    `json:"context_budget,omitempty"`
	ToolFormat     string `json:"tool_format,omitempty"`
	SystemRole     *bool  `json:"system_role,omitempty"`
	MidConvoSystem *bool  `json:"mid_convo_system,omitempty"`
}

ModelProfileConfig captures capability overrides for a model.

type OutputRuleConfig

type OutputRuleConfig struct {
	MaxLines          int    `json:"max_lines,omitempty"`
	MaxTokens         int    `json:"max_tokens,omitempty"`
	Truncation        string `json:"truncation,omitempty"`
	TruncationMessage string `json:"truncation_message,omitempty"`
}

OutputRuleConfig captures deterministic output processing for a tool.

type RecipeSnapshot

type RecipeSnapshot struct {
	Version             int                           `json:"version,omitempty"`
	Name                string                        `json:"name"`
	SystemPrompt        string                        `json:"system_prompt,omitempty"`
	ToolGuidance        map[string]string             `json:"tool_guidance,omitempty"`
	Tools               []string                      `json:"tools,omitempty"`
	BashPrefixes        []string                      `json:"bash_prefixes,omitempty"`
	ToolDescriptions    map[string]string             `json:"tool_descriptions,omitempty"`
	Constraints         *ConstraintsConfig            `json:"constraints,omitempty"`
	ModelParams         *ModelParamsConfig            `json:"model_params,omitempty"`
	Context             *ContextConfig                `json:"context,omitempty"`
	SystemReminders     []SystemReminderConfig        `json:"system_reminders,omitempty"`
	OutputProcessing    map[string]OutputRuleConfig   `json:"output_processing,omitempty"`
	SummarizationPrompt string                        `json:"summarization_prompt,omitempty"`
	ModelProfiles       map[string]ModelProfileConfig `json:"model_profiles,omitempty"`
}

RecipeSnapshot captures the active recipe/configuration at the time of a preference recording. It mirrors the fields relevant for comparing experimental setups.

Name and Version are stored for display and diagnostics but excluded from the content-addressed hash — they are metadata about the recipe, not settings that affect model behavior.

type Store

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

Store is a content-addressed store for RecipeSnapshot values. It is safe for concurrent use.

func New

func New(path string) *Store

New creates a Store backed by the given file path. If the file does not exist, the store starts empty.

func (*Store) Get

func (s *Store) Get(hash string) *RecipeSnapshot

Get retrieves a RecipeSnapshot by its hash. Returns nil if not found.

func (*Store) HashesForName

func (s *Store) HashesForName(name string) []string

HashesForName returns all hashes whose snapshot has the given recipe name.

func (*Store) List

func (s *Store) List() map[string]*RecipeSnapshot

List returns a copy of all stored snapshots keyed by hash.

func (*Store) Put

func (s *Store) Put(cfg *RecipeSnapshot) string

Put stores a RecipeSnapshot and returns its hash. If the snapshot already exists (same hash), it is not re-written to disk.

type SystemReminderConfig

type SystemReminderConfig struct {
	Name    string `json:"name"`
	Trigger string `json:"trigger,omitempty"`
	Content string `json:"content,omitempty"`
}

SystemReminderConfig captures a conditional mid-conversation injection.

Jump to

Keyboard shortcuts

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