Repository navigation
Example Loops
📖 loopsmith's documentation lives at bitphill.github.io/loopsmith → This wiki mirrors it so existing links keep working.
← Wiki home · Rendered viewer with search
Fifteen worked loop configurations that ship with loopsmith, plus a frozen 0.3-era corpus in config/examples/legacy/. They are simultaneously the primary teaching material, the fixture set for the integration tests, and the example library compiled into the web UI. Editing one of these files touches all three roles, so this module has more invariants around it than its extension (.yaml, .md) suggests.
An example is a complete, runnable LoopConfig written around one lesson — how a gate is built out of scripts rather than opinions, how human_checkpoint stops an irreversible action, how evolution.baseline fences self-modification. The header comment at the top of each .yaml states that lesson explicitly and is the first thing to read:
# Draft and send cold outreach — behind a human checkpoint, with an opt-out.
# ...
# Two decisions carry the weight:
# 1. `human_checkpoint` covers sending. ...
These are the most-copied files in the repository. That is also why they are the strictest: three test suites and two CI steps exist purely to stop them drifting from the shape the tool actually has.
Each loop is authored once, as <name>.yaml. The <name>.md beside it is generated from it and must never be hand-edited:
loopsmith loop convert config/examples/research-loop.yaml # prints the Markdown twin
./tools/sync-examples.sh # regenerate all twins + sync the crate copies
./tools/sync-examples.sh --check # fail if anything is stale (what CI runs)The two formats are the same model in two grammars — YAML keys on one side, ## Section / ### item / - field: value bullets on the other. loopsmith-core's render_md and parse_md are inverses, and runtime/crates/loopsmith-core/tests/md_roundtrip.rs enforces it from both directions:
-
every_example_config_survives_a_markdown_round_trip— load the.yaml, render, re-parse, require an identicalLoopConfig. -
every_shipped_md_example_means_the_same_as_its_yaml_twin— load both files on disk and compare. This is the test that catches a hand-edited.md.
Both comparisons normalise by trimming trailing whitespace inside strings: a YAML folded scalar (>) ends in a newline that a Markdown bullet cannot carry, and that is the only difference the Markdown grammar is allowed to introduce.
Two spellings of the same field coexist across the library and both normalise to the same model. Older examples use the isolated: true shorthand on a node; container-refactor-loop and self-tuning-loop use the explicit form:
isolation:
mode: worktree # or: none | container (+ network: bool)The rendered .md always shows the explicit form, which is why write appears as isolation: mode: worktree in blogger-loop.md but as isolated: true in blogger-loop.yaml.
Every 1.0 example has the same four top-level sections — intent, execution, safety, and optionally evolution — plus name, version, description, environment, and features.
intent — what the loop is for, in terms a person can check.
-
background:key/value/notetriples. These are the knobs a copier edits —categories,daily_cap,test_command,prevalence_rule. Values that must be replaced say so in thenote("Replace.Any good ideais not a segment and returns nothing usable"). -
prerequisites: the manual work that must precede automation. See below. -
goals: named,depends_on-ordered, with apriority. -
success: usually a singletarget: overall,mode: percentage,threshold: 1.0entry meaning "every blocking check passes".
execution — how the work gets done.
-
graph.nodes:id,role(researcher,builder,judge,adversary),instruction,depends_on,goals,stage,tier,weight,isolation.graph.join.strategy,graph.concurrency(mode: auto,cap,min_marginal_gain), andgraph.container_imagewhere containers are used. -
providers: the same three-provider cascade in nearly every example —ollama(cheap, local),claude(standard,claude_code),openai(strong,curl+requires_env: [OPENAI_API_KEY]) — withcascademapping tiers to ordered provider lists andenforce_judge_independence: true. -
phases.items+phases.dependency: named stages with aguideline, wired asresearch -> draft -> revise. Nodestagevalues must match a phase name. -
default_skills,skills,memory,triggers.
safety — what must not happen, and when to stop.
-
checks: the gate. Each has atarget(a goal name oroverall),mode: objective | subjective, astatement, and adetectorof typefile_exists,regex_match,threshold,script, orjudge. -
gates.stop(max_iterations,max_cost_usd,max_wall_clock_seconds,no_progress_iterations,stop_on_overall_success), and incontainer-refactor-loopalsogates.entryandgates.rollback. -
limits.global: proserules,forbidden_paths,forbidden_commands,max_seconds,human_checkpoint. -
recoveryper failure class,alerts,protected.components.
evolution — present and enabled: true in exactly one example (self-tuning-loop), with baseline, max_regression, allowed_kinds, require_sandbox, require_approval, keep_rollback.
Every shipped example fails loopsmith loop validate with exactly one error, and that is load-bearing, not a bug:
$ loopsmith loop validate config/examples/research-loop.yaml
error intent.prerequisites: 2 step(s) not marked done: …check_pre_execution in runtime/crates/loopsmith-core/src/validate.rs:267 emits that error while any prerequisites entry has done: false, and warns when the list is empty at all. Every example ships with all of its steps false because an example config describes a job nobody has done yet. A copier does the job by hand, ticks the steps with what they actually did, and only then can the loop run.
CI turns this into the cheapest regression signal in the project: the "Every example refuses for exactly one reason" step (.github/workflows/ci.yml:103) validates all 30 example files and fails if any produces more than one error or any warning at all. A schema change that breaks a config shows up there immediately.
These are not enforced by the schema, but breaking one in a new example makes it teach the wrong thing:
-
The judge sits on a different provider from the writer.
enforce_judge_independence: trueeverywhere,judgenodes pinned toprovider: openai/tier: strong.container-refactor-loopcarries a second provider family purely so a judge has somewhere to run — with one provider, judge independence refuses every judgment and nothing can pass. -
Objective and subjective checks are mixed, and the objective ones carry the weight.
blogger-loopis the clearest case: "sounds human" is decomposed into threethresholddetectors (sentence_length_variance,stock_transitions_per_500w,hedging_density) plus ajudge, and all four are blocking. -
Irreversible actions go behind
human_checkpoint, not behind a sterninstruction. Publishing, sending, paying, deploying, adopting a proposed config value. -
Anti-self-grading checks.
account-watch-loopscores last run's predictions in its first phase, before making new ones, and enforces it withno-retroactive-predictions(ascriptdetector over timestamps). -
features.self_evolution: falsein every example butself-tuning-loop.
| Example | The lesson it carries |
|---|---|
research-loop |
Smallest example whose checks are all deterministic. Cited brief, adversary node, source_floor. |
refactor-loop |
The test suite as the gate; editing a test to make it pass is a blocking failure. |
container-refactor-loop |
Wide parallelism done safely: three builder nodes in one wait_for_all wave, each isolation: mode: container over its own worktree, gates.entry requiring a clean tree, gates.rollback on a red suite. |
self-tuning-loop |
The fence around self-evolution — evolution.baseline measured from real manual runs, max_regression: 0.05, allowed_kinds that deliberately exclude validation_change, and protected.components a proposal may never touch. |
landing-page-loop |
A strong gate for a design task: npm run build exits zero, Lighthouse ≥ 90/95, page weight < 500KB, every CTA resolves. Taste is one judge among many, not the verdict. |
blogger-loop |
Gating "reads like a person wrote it" by measuring the mechanical tells and putting the taste judgment on another provider. |
idea-radar-loop |
Ideas that trace to dated verbatim complaints, with a numeric pain_threshold and an honest competitor check. |
trend-radar-loop |
A rise_definition as a number (2× the trailing 7-day average), every trend carrying the post IDs it came from. |
account-watch-loop |
Predictions written with timestamps and scored by a later run; unfalsifiable predictions count as misses. |
traffic-loop |
Measuring referred sessions from an analytics export rather than posts made, with per-venue rules as constraints. |
sales-leads-loop |
Lawful collection: permitted_sources / forbidden_sources, and lawful-basis-recorded as a blocking check. |
cold-outreach-loop |
The most constrained example. The loop drafts and queues; a human releases. suppression-honoured and opt-out-present are blocking. |
marketing-automation-loop |
Claims sourced to the product's own site, one post per platform per day, publishing behind a checkpoint. |
viral-game-loop |
Decomposing an ungateable word ("viral") into four checkable ones: builds, runs headless, time-to-first-play, cold playtest. |
x402-agent-loop |
An agent that spends money, with two documented postures (supervised as shipped; autonomous by removing one human_checkpoint line) behind a funded float, a merchant allowlist, and max_cost_usd. |
wiki/Examples.md carries this table for users, plus a "which one to start from" section. Keep the two in step when adding an example.
Thirteen 0.3-shaped copies of the examples that predate 1.0 (everything except container-refactor-loop and self-tuning-loop). They are not documentation, and nothing links to them. They exist so runtime/crates/loopsmith-core/tests/legacy_corpus.rs can assert three things:
-
every_legacy_example_migrates_to_the_one_beside_it— loading the 0.3 file and the 1.0 file of the same name must produce identicalLoopConfigs. That is a stronger claim than "the old file still parses": it says the relocation table puts every key exactly where the 1.0 file puts it by hand, checked against thirteen configs someone actually wrote. -
the_legacy_corpus_is_actually_legacy— each corpus entry must still trip at least one relocation, or it proves nothing. -
no_shipped_example_still_uses_a_03_key— the inverse for the files outsidelegacy/. A shipped example needing the relocation table would print a deprecation notice to someone who just installed the tool.
Don't migrate a legacy/ file. Don't add a 0.3 key to a shipped one.
graph TD
Y["config/examples/<name>.yaml<br/>(the only hand-edited copy)"]
MD["<name>.md twin"]
CRATE["loopsmith-web/templates/<br/>examples/<name>.yaml"]
EMB["EMBEDDED const<br/>(include_str!)"]
API["GET /api/examples<br/>GET /api/examples/{id}"]
TESTS["md_roundtrip · legacy_corpus<br/>cli stress harness"]
Y -->|loop convert| MD
Y -->|cp| CRATE
CRATE --> EMB
EMB --> API
Y -.->|"repo override,<br/>no rebuild"| API
Y --> TESTS
MD --> TESTS
Both derived copies are produced by tools/sync-examples.sh, and both have a test that fails when it has not been run.
The crate copy exists for a specific reason documented in runtime/crates/loopsmith-web/src/examples.rs: include_str! cannot reach above the package root, and config/ is excluded from the published tarball. An example served from config/ works in a checkout and 404s for everyone who installed from crates.io, npm, pip, or brew.
At runtime the web UI resolves examples from three sources, first to claim an id winning:
-
~/.loopsmith/examples/*.yaml— the user's own (origin: "user") -
config/examples/*.yamlrelative to the working directory (origin: "repo") — live edits in a checkout appear without a rebuild - the compiled-in copies (
origin: "embedded")
examples::list() builds one ExampleCard per id, and none of its fields are hand-written metadata: name, blurb, goals, validations, judge_validations, nodes, providers, trigger, max_iterations, max_cost_usd are all parsed out of the config itself, so a card cannot disagree with the loop it describes. judge_validations is surfaced deliberately — a loop judged entirely by models is a loop whose gate is an opinion. An example that fails to parse is dropped rather than shown as a card that errors on click.
runtime/crates/loopsmith-cli/tests/stress.rs runs every example through the real binary:
-
every_example_completes_an_iteration_and_leaves_a_consistent_record— one capped iteration with satisfiable detectors; asserts the ledger opened, recorded why it stopped, that the run log and ledger agree line for line, and that one iteration left exactly one summary. -
every_example_survives_a_run_where_nothing_passes— no stubs, no artifacts, no metrics; the run must exit non-zero and writeStopGateTriggeredto the ledger rather than panic.
tests/harness/mod.rs is what makes a shipped example runnable, and reading it explains several things about the configs:
-
unblock()flips everyprerequisites.donetotrue— otherwise nothing would validate. -
deterministic_providers()rewrites each provider toprintfwhile preserving provider ids, becauseenforce_judge_independencecompares ids; renaming them would silently disable the check the examples are demonstrating. -
stub_scripts()generates a stub for everyscripts/…detector a config names. The examples reference 29 distinct script detectors between them and the repository ships none of them.scripts/check-suppression.sh,scripts/check-timestamps.sh,scripts/word-count.shand the rest are contracts a copier implements — an example is deliberately not a turnkey program. -
satisfy_files()/satisfy_metrics()write the artifacts andmetrics.jsonkeys the detectors name. The stub artifact body carries a URL and apost_id:line because that is what the shippedregex_matchdetectors look for.
research-loop.yaml and refactor-loop.yaml additionally serve as named fixtures in tests/surface.rs, tests/opt_in.rs, and tests/grammar.rs. Changing either one can move assertions in those files.
- Author
config/examples/<name>.yamlonly. Lead with a header comment stating the one lesson. Pointprerequisitesat real manual work and leave every stepdone: false. - Give the gate at least one objective detector per goal, and put any judge on a provider the builder does not use.
-
cd runtime && cargo build --release --bin loopsmith, then./tools/sync-examples.sh. This regenerates the.md, copies the YAML intoruntime/crates/loopsmith-web/templates/examples/, and removes orphans in both directions. -
Add an
include_str!entry toEMBEDDEDinruntime/crates/loopsmith-web/src/examples.rs. The sync script copies the file but does not touch that array;embedded_examples_match_the_source_of_truthcomparesEMBEDDED.len()against the YAML count on disk and fails if you forget. - Add a row to
wiki/Examples.md, and to "Which one to start from" if it is the best example of something. -
cargo test --workspaceandloopsmith loop validateon both files — exactly one error, zero warnings.
Things that will bite:
- Several test and CI thresholds are floors tied to the current library size:
seen -ge 30in CI (15 YAML + 15 Markdown),checked >= 15inno_shipped_example_still_uses_a_03_key,checked >= 13over the legacy corpus. Adding examples is free; removing one means updating the floor deliberately. - Every
.mdneeds a.yamltwin and vice versa — an orphan in either direction is a failure (sync-examples.sh --check, andevery_shipped_md_example_means_the_same_as_its_yaml_twin). - A
regex_matchdetector can only name an artifact that one of the same config'sfile_existsdetectors registers, under its full path or its stem. Anything else has nothing to match and fails closed for the life of the loop. - The module doc comment at the top of
examples.rsstill says "Thirteen working loops ship inside the binary" while fifteen are inEMBEDDED. Fix it next time you add one.
Generated by gitnexus wiki from bitphill/loopsmith. Do not edit by hand — regenerated on each run.
Documentation site · Code wiki · Repository
- Architecture
- CLI Command Surface
- The command surface
- Concepts
- Distribution & Installers
- Evolution & Perturbation
- Example Loops
- The example loops
- Execution Graph & Concurrency Planning
- Gating & Success Criteria
- Loop Configuration Schema
- Loop Execution Engine
- Markdown/YAML Config Interchange
- MCP Server
- Memory & Episode Store
- Migration 0.3 → 1.0
- Other
- Permissions & Sandboxing
- Platform Utilities
- Project Documentation
- Provider Integration
- Scheduling & Triggers
- Skills System