Graph templates and Agentic Recipes
Agentic Recipes are a top-level MechaHarness concept: concrete, reusable
agent-control patterns hosts tile into larger graphs. The substrate is
always :class:~mechaharness.graph_templates.base.GraphTemplate — parameterized
subgraph factories with soft points, registry merge, and provenance stamps.
There is no second recipe executor or type system.
Clients instantiate a template/recipe, bind soft points, and may keep the
resulting concrete :class:~mechaharness.graph.ExecutionGraph in their own
repository. MechaHarness validates and executes those graphs without taking
ownership of client-specific realizations.
Normative requirements: Reusable graph recipes and typed decision plane.
Surface |
Value |
|---|---|
Package |
|
Concept |
Agentic Recipe (catalog id) |
Substrate |
|
Stability |
evolving |
Config hook |
|
Catalog
First-wave candidates (existing templates; promote/document as recipes with owning user stories):
Catalog id |
Module |
Owning story |
Purpose |
|---|---|---|---|
|
|
Plan → parallel branches → reduce |
|
|
|
Produce → verify → bounded repair |
|
|
|
Isolated reviewers; retain disagreement |
|
|
|
Diagnose → repair env → recheck |
|
initialize_preflight |
|
|
Linkage → capability → checkpoint → ready |
|
|
Batched typed decisions + escalate |
|
|
|
Visible classify → permit → backoff → escalate |
|
|
|
Produce → isolated critique → bounded refine |
|
|
|
Scenario → isolated review → deterministic safety score |
|
|
|
Expandable tools → inference / tool_call rounds |
|
|
|
Frontier guidance → instruction plan → audited gate |
|
|
|
Oneshot vs list; refine; pre/item/post acceptance |
|
|
|
Collect → freeze → decide → QA → deterministic → gate |
|
|
|
Read-only evidence inventory ( |
|
|
|
Freeze inventory into typed |
|
|
|
Ordered ChangePlan slices from a contract |
|
|
|
Scoped slice apply with diff + hashes |
|
|
|
Host-observed VerificationReport |
|
|
|
Evidence-linked Diagnosis |
|
|
|
Deterministic retry / stop / yield gate |
|
|
|
Host DevelopmentOutcome gate |
|
|
|
Fair A/B trial records (no auto-winner) |
|
|
|
Product tile: discovery → … → accept |
Composition helpers: GraphTemplateParams.instance_key (namespaced ids),
GraphTemplate.tile (embed under a parent node). Story:
fangore_recipe_namespace_tile.
Node components (sub-node elements inside a graph node): Node components.
Soft points
Each template declares SoftPoints (tools, providers, prompts, models,
budgets, persistence, policies, runner kinds, task state). Bindings go in
GraphTemplateParams.soft_bindings (plus inputs / branch_payloads /
acceptance / stop_contract where applicable). Soft-point names SHOULD
describe the human decision being bound. Templates MUST NOT embed client
product policy or durable application state.
Instantiated graphs are stamped with template_name, template_version, and
template_status for provenance and deprecation detection. Optimize tiling
code for human readability of how recipes compose into the final graph.
Versions, promotion, and evolution allowlist
GraphTemplateRegistry stores every registered version of a catalog id.
register activates a template (legacy replace-by-name); add_version stores
an immutable candidate that stays inactive until promote(name, version)
moves the active pointer. rollback(name) restores the previous target, and
get(name, version=...) reads any stored version. Hosts own eval results and
promotion policy; the registry owns only the reversible pointer.
SoftPoint.evolvable (default False) is the declared evolution allowlist:
an optimizer may rewrite only evolvable soft points, enforced by
GraphTemplate.assert_evolution_allowed. Graph topology, grants, and stop
contracts are hard structure.
Promotion surfaces (host orientation)
Intent |
API |
|---|---|
Catalog pointer + held-out gate + host opinion |
|
Catalog pointer + held-out gate only |
|
Ungated pointer move (advanced / migration) |
|
Offline research candidate |
|
Soft instruction → hard rule |
|
Prefer promote_recipe for product hosts: it applies
MechaHarnessConfig.get_recipe_promotion_policy() then the held-out gate.
promote remains an ungated pointer move for hosts that run their own gate.
Campaigns use get_evolution_campaign_hooks() (no-op defaults); pass them as hooks and promote_recipe calls on_promotion after a successful move. Typed-port search is registry.search_compatible(...). The same
held-out gate guards ResearchLab.promote.
Recipe comparison (do not merge)
Catalog id |
Control story |
|---|---|
|
Produce → critique → refine loop with evolvable soft points |
|
Isolated multi-reviewer context (adversarial optional) |
|
Oracle / verify then repair until stop |
|
Produce → isolated review → deterministic score (measure-only) |
|
Bounded decision surfaces with policy / shadow / telemetry |
|
Read-only workspace evidence → typed inventory |
|
Freeze priors → typed ChangeContract |
|
Contract → ordered ChangePlan slices |
|
Approved slice → scoped writes → ChangeExecution |
|
ChangeExecution + contract → host VerificationReport |
|
VerificationReport → typed Diagnosis + next experiment |
|
Diagnosis → StrategyRevision disposition (retry/stop/yield) |
|
Host gates → DevelopmentOutcome (completed/needs_guidance/failed) |
|
Trial record assemble/validate for A/B/C/D arms |
|
Product composition (discovery → … → accept) |
These are distinct Agentic Recipes on the same GraphTemplate substrate.
Typed ports and candidate search
A template may declare io_contract (a TemplateIOContract of typed input and
output ports). search_compatible_recipes(registry, required_inputs, required_outputs) returns the catalog ids whose ports fit; it never builds a
graph, and recipes without an io_contract are not candidates. Hosts
can bound optimizer candidates with recipe_evolution.propose_candidates, which
emits soft-binding dicts only and validates them against the registry and the
evolvable allowlist.
Usage sketch
from mechaharness.graph_templates import (
GraphTemplateParams,
default_graph_templates,
)
registry = default_graph_templates()
template = registry.get("fan_out_aggregate")
assert template is not None
graph = template.instantiate(
GraphTemplateParams(
goal="survey sources",
branch_payloads=[{"index": 0}, {"index": 1}],
acceptance=["all_branches_ok"],
soft_bindings={"fan_in_budget": 4},
)
)
assert graph.template_name == "fan_out_aggregate"
# Bind runners for plan/branch/reduce kinds via Config, then:
# LinkageResolver → GraphExecutor.run(graph)
Ownership / incubation
See Inspiration requirements map and
req 19 in dev-blog-inspiration.
Generic skeletons and Agentic Recipes live here; host-specific workflows
incubate in the client until promotion extracts a reusable recipe.
Every shipped recipe needs ≥1 owning user story that names the catalog id in
its implementation text.
Recipe reference pages
- Audited infer-accept (
audited_infer_accept) - Bounded retry (
bounded_retry) - Template: change_decomposition
- Template: change_execution
- Template: change_verification
- Template: contract_extraction
- Conversational tool loop (
conversational_tool_loop) - Typed decision plane (
decision_plane) - Template: development_acceptance
- Template: environment_repair
- Template: failure_diagnosis
- Template: fan_out_aggregate
- Template: gastronomic_comparison
- Template: gastronomic_guided_development
- Guided coding (
guided_coding) - Template: independent_review
- Instruction todo plan (
instruction_todo_plan) - Template: produce_critique_refine
- Template: safety_eval
- Template: strategy_revision
- Template: verify_repair
- Template: workspace_discovery