skip to content

The pattern gallery

An annotated tour of the shipped corpus: what each pattern is for, how it is built, and the lines a fork of it would edit.

The seven bundled patterns under config/patterns/: build, map, merge, milestone, sprint, troubleshoot, and until. A project-local .gantry/<plan>/patterns/<name>.toml overrides a global-mirror patterns/<name>.toml, which overrides the same-named bundled pattern.

build carries default = true, so gantry <plan> selects it. map and until declare --map <source> and --until <goal.md>. --pattern <name|file.toml> selects a discovery name or TOML file path; entry parameters bind positionally or through --param <name> <value>.

Build family — build.toml, milestone.toml, sprint.toml

build.toml includes milestone.toml, troubleshoot.toml, and merge.toml; milestone.toml includes sprint.toml, troubleshoot.toml, and merge.toml. The composed closure shares one definition namespace. All three build-family files declare an entry; only build declares plan_source as declared_plan_source, which binds the plain-build argument. milestone and sprint remain selectable with --pattern.

build.toml

For: the default milestone build. until calls build for each gap plan.

Structure: plan_milestones uses write-milestones to write milestones/ and plan_scope; write_about writes about.md and a failed session routes to nothing. plan_scope routes work to prepare_project_gate and none to stop_no_milestones. probe_project_gate checks for a run-scoped bin/gate; author_project_gate writes it when absent, then project_baseline gates it. build_milestones re-enumerates milestones/, calls build_milestone for each brief, and skips ledger-complete milestones. build_milestone calls milestone, then gates project_gate; one troubleshoot pass and repaired_milestone_boundary_gate handle red. project_final_gate repeats the run-scoped gate after the for; its red route has the same repair sequence. The stops cover none or absent plan_scope and a red run-scoped gate at the baseline, milestone boundary, or final boundary.

To fork: change plan_milestones's write-milestones prompt, author_project_gate's write-project-gate prompt, the build_milestones fail or body, or the write_handover on_stop hook.

milestone.toml

For: one milestone. build_milestone calls it once per brief.

Structure: brief_environment uses write-environment; a failed session routes to nothing. plan_sprints uses write-sprints to write sprints/. probe_gate checks for bin/gate, and author_gate writes invocation-scoped gate_script when absent; baseline gates it before run_sprints calls sprint for each task brief. milestone_review uses diff = "iteration-start", so it reviews the enclosing build iteration. complete gates reviewer edits and repairs one red result through troubleshoot; blocked stops.

To fork: override execute_prompt, review_prompt, or troubleshoot_prompt; rewrite milestone_review's EXTRA_JUDGMENT; or omit baseline and its router. probe_gate routes an absent bin/gate to author_gate, which writes gate_script.

sprint.toml

For: one gated task. milestone calls it from run_sprints; it includes troubleshoot.toml for red-gate repair, plan-change review, and write_handover.

Structure: executor_blocked routes through examine_executor_blocked and troubleshoot before stopping. build_gate routes red to recover_build and green to review_and_commit; a red recovery_gate routes troubleshoot_verdict to retry or handover. retry_sprint tail-calls sprint with restore = "iteration-start". review_and_commit reviews the iteration; complete gates reviewer edits, retry uses check_attempt_ceiling, and blocked writes a handover before stopping. A red review-edit gate repairs forward or restores the boundary before re-gating. The shared plan-change route cannot recurse. A green task returns to the enclosing for, which records it complete. attempt_ceiling defaults to unbounded; build passes 2.

troubleshoot.toml

For: shared troubleshoot infrastructure. build, milestone, sprint, map, and merge include it; troubleshoot is also selectable by name.

Structure: troubleshoot is one troubleshoot-stage agent step with troubleshoot_prompt, declared_gate_command, protected_check, and position; it declares troubleshoot_verdict, troubleshoot_revert, troubleshoot_note, and handover_document. review_plan_change runs review-plan-change; accepted routes to nothing, and rejected writes plan_change_rejected_handover_document before stopping. write_handover is the shared on_stop hook and writes engine_stop_handover_document.

To fork: change troubleshoot's default parameters, examine_plan_change_rejected's literal troubleshoot prompt, or write_handover.

merge.toml

For: finish-time merge repair. The engine invokes merge for conflicted, residue, or gate-red.

Structure: read_merge_state routes conflicted to resolve_conflicted_merge, residue to adjudicate_merge_residue, and gate-red to repair_merge_gate_red. A failed residue adjudication receives one retry. A red merge gate calls troubleshoot; retry returns to the engine, while handover or troubleshoot_revert = "revert" stops.

To fork: change the merge parameters or the resolve-merge and adjudicate-merge prompts.

map.toml

For: a roster of independent tasks. [[header.cli_flags]] binds it to --map <source>; two consecutive failed tasks stop the run.

Structure: write_roster uses write-map-roster to write filename-ordered task files under state/roster/; each has +++-delimited TOML front matter with gate and a prose prompt body. check_roster writes roster_check and roster_complaint; no routes to map_with_complaint, which retries a failed rewritten roster without a ceiling. run_tasks is a for with fail = "continue" over map_task: build_task, task_gate, one repair on red, repaired_gate, then record_done or record_failed. Those commands write verdict files below the map_task invocation root, although their scope = "run" outputs declare run-root paths. check_streak counts .failed among the last two filename-sorted verdict files. map has no run-scoped gate.

To fork: change check_streak's tail -n 2 or -ge 2, the repair route, either roster-check command, or run_tasks's fail = "continue".

until.toml

For: work until an acceptance check goes green, the gap planner reports no actionable work, or a cycle ceiling stops the run. [[header.cli_flags]] binds it to --until <goal.md>. It includes build.toml for each gap plan.

Structure: probe_check tests whether the check path, defaulting to bin/goal-check, is executable; absence routes to the read-only write-goal-check agent. run_check captures gap_report; failure routes to decide_cycle and success completes until_loop. max_cycles = "unbounded" writes continue; a non-negative ceiling stops after that many completed build cycles, and another value is invalid. plan_the_gap uses write-gap-plan with check protected; work routes to run_cycle and none stops. build_the_plan calls build with gap_plan and the protected check, and next_cycle tail-calls until_loop with next_completed_cycles.

To fork: change check's default, the write-goal-check or write-gap-plan prompt, or run_cycle's pattern = "build".

docs/patterns/gallery.md in the Gantry repository, rendered as it stands