Skip to main content

Module preset_source

Module preset_source 

Source
Expand description

Preset source abstraction — extensible pluggable loaders for hat-collection presets authored in formats other than Ralph’s native YAML.

This module defines the PresetSource trait and ships two built-in implementations:

  • YamlPresetSource — the canonical Ralph single-file YAML shape.
  • TomlPresetSource — imports multi-file TOML presets authored for the @mobrienv/autoloop runtime (directory containing autoloops.toml + topology.toml + roles/*.md
    • optional harness.md).

New preset shapes plug in by implementing PresetSource::detect + PresetSource::load and registering with PresetRegistry.

All impls produce a serde_yaml::Value that can be consumed by the existing hat-overlay merging pipeline in ralph-cli, so downstream code does not need to know which preset format was on disk.

§Autoloop → Ralph mapping

AutoloopRalph
[[role]] idhats.<id> key
[[role]] prompt_file (read from disk)hats.<id>.instructions
[[role]] emitshats.<id>.publishes
[handoff] <event> = [role, ...] (inverted)hats.<role>.triggers list
topology.completionevent_loop.completion_promise
autoloops.toml event_loop.completion_eventevent_loop.completion_promise (fallback)
autoloops.toml event_loop.required_eventsevent_loop.required_events
autoloops.toml event_loop.max_iterationsevent_loop.max_iterations
handoff["loop.start"] (first target’s role id)event_loop.starting_event = "loop.start"
harness.md (whole file)appended to core.guardrails

Fields Ralph has but autoloop lacks (backend, cli, core.specs_dir, etc.) stay unset — the overlay only populates hats/events/event_loop slots, and the caller’s ralph.yml supplies the rest exactly as it does for builtin presets.

Structs§

PresetRegistry
Ordered registry of PresetSource impls.
TomlPresetSource
YamlPresetSource

Enums§

PresetSourceError
Error returned by a PresetSource::load implementation.

Traits§

PresetSource
Pluggable loader for a preset shape.