skip to content

The build pattern

The default milestone build: decompose a plan into ordered milestone briefs, then build each brief. What a flagless `gantry <plan>` runs, and what `until` calls to build one cycle's plan.

build — the default milestone build

The for body is build_milestone, which calls milestone and then re-runs the run-scoped gate; milestone is never the loop body itself.

build
[header]
pattern_language_compatibility = "3"
entry = "build"
include = ["milestone.toml", "troubleshoot.toml", "merge.toml"]
merge = "merge"
on_stop = "write_handover"
default = true
description = """
The default milestone build: decompose a plan into ordered milestone briefs, then build each brief.
What a flagless `gantry <plan>` runs, and what `until` calls to build one cycle's plan.
"""

include composes milestone.toml, and through it sprint.toml, into one definition namespace: milestone and the write_handover stop hook this file names are both declared there.

build
[patterns.build]

[[patterns.build.parameters]]
name = "plan_source"
kind = "path"
default = "plan.md"
declared_plan_source = true
description = "The plan prose the milestone planner reads, and the run's identity."

[[patterns.build.parameters]]
name = "protected_check"
kind = "path"
default = ".gantry/no-protected-check"
description = "An optional record-path check an enclosing recursive goal run freezes."

[[patterns.build.parameters]]
name = "attempt_ceiling"
kind = "text"
default = "2"
description = "The ordinary build attempt ceiling passed to each sprint task."

[[patterns.build.parameters]]
name = "troubleshoot_prompt"
kind = "prompt-id"
default = "troubleshoot"
description = "The troubleshoot pass's prompt, passed through the milestone and run-scoped gate repair paths."

[[patterns.build.parameters]]
name = "merge_attempt_ceiling"
kind = "text"
default = "2"
description = "The finish-time merge repair ceiling passed to the bundled merge pattern."

The ordered milestone briefs the for below iterates, plus whether the plan holds any work at all. Writing those files is this step's product rather than an edit to plan files someone else owns, so an observed plan change routes to nothing, the engine-provided identity pattern.

build
[[patterns.build.steps]]
name = "plan_milestones"
title = "Decompose Plan Into Milestone Briefs"
type = "agent"
stage = "plan"
prompt = "write-milestones"
inputs = ["{{plan_source}}"]
protected = ["{{protected_check}}"]
on_plan_change = "nothing"
outputs = [
  { name = "milestones", path = "milestones/" },
  { name = "plan_scope", path = "state/plan-scope.txt", values = ["work", "none"] },
]

about.md names the run and describes it, and carries a title and blurb per task; a failed session routes to nothing, so an absent one costs decoration and not the run.

build
[[patterns.build.steps]]
name = "write_about"
title = "Write Run About Card"
type = "agent"
stage = "support"
prompt = "write-about"
inputs = ["{{plan_source}}", "{{milestones}}"]
read_only = true
outputs = [
  { name = "about_card", path = "about.md" },
]

[[patterns.build.steps]]
if = { write_about = "failed" }
then = "nothing"

A plan with nothing to build stops here, rather than falling through an empty for and reporting success.

build
[[patterns.build.steps]]
if = "plan_scope"
then = { work = "prepare_project_gate", none = "stop_no_milestones" }
else = "stop_plan_scope_absent"

The gate for the whole build. scope = "run" because every other output resolves under its own invocation's state root, and this gate is reused after every milestone.

build
[[patterns.prepare_project_gate.steps]]
name = "author_project_gate"
title = "Write Project Gate Command"
type = "agent"
stage = "gate-build"
prompt = "write-project-gate"
inputs = ["{{plan_source}}"]
read_only = true
outputs = [
  { name = "project_gate", path = "bin/gate", scope = "run" },
]

The gate proved before any milestone changes the tree.

build
[[patterns.prepare_project_gate.steps]]
name = "project_baseline"
title = "Testing"
type = "gate"
command = "{{project_gate}}"

[[patterns.prepare_project_gate.steps]]
if = { project_baseline = "red" }
then = "stop_project_baseline_red"
else = "build_milestones"

The milestones

The outer of the two nested fors; milestone.toml holds the inner one. The list is re-enumerated before every iteration, so a brief the milestone reviewer inserted is built too; done-ness comes from the ledger, so a finished milestone is not rebuilt. fail is left at its default, so one failed milestone stops the run.

build
[[patterns.build_milestones.steps]]
name = "milestones"
type = "for"
list = { directory = "{{milestones}}" }
body = "build_milestone"

{{task}} is the path of the brief file this iteration resolved to.

build
[patterns.build_milestones.steps.parameters]
plan_source = "{{task}}"
protected_check = "{{protected_check}}"
attempt_ceiling = "{{attempt_ceiling}}"
troubleshoot_prompt = "{{troubleshoot_prompt}}"

[[patterns.build_milestones.steps]]
name = "project_final_gate"
title = "Testing"
type = "gate"
command = "{{project_gate}}"

[[patterns.build_milestones.steps]]
if = { project_final_gate = "red" }
then = "repair_project_final_gate"

Each iteration calls milestone, then runs project_gate before the enclosing for records the milestone done.

build
[[patterns.build_milestone.parameters]]
name = "plan_source"
kind = "path"
description = "The milestone brief passed to the milestone body."

[[patterns.build_milestone.parameters]]
name = "protected_check"
kind = "path"
description = "An optional record-path check an enclosing recursive goal run freezes."

[[patterns.build_milestone.parameters]]
name = "attempt_ceiling"
kind = "text"
description = "The attempt ceiling passed to each sprint task."

[[patterns.build_milestone.parameters]]
name = "troubleshoot_prompt"
kind = "prompt-id"
description = "The troubleshoot pass's prompt, passed to the milestone and to run-scoped gate repair."

[[patterns.build_milestone.steps]]
name = "milestone_body"
type = "call"
pattern = "milestone"

[patterns.build_milestone.steps.parameters]
plan_source = "{{plan_source}}"
protected_check = "{{protected_check}}"
attempt_ceiling = "{{attempt_ceiling}}"
troubleshoot_prompt = "{{troubleshoot_prompt}}"

[[patterns.build_milestone.steps]]
name = "milestone_boundary_gate"
title = "Testing"
type = "gate"
command = "{{project_gate}}"

[[patterns.build_milestone.steps]]
if = { milestone_boundary_gate = "red" }
then = "repair_milestone_boundary_gate"

[[patterns.repair_milestone_boundary_gate.steps]]
name = "milestone_boundary_gate_recovery"
type = "call"
pattern = "troubleshoot"

[patterns.repair_milestone_boundary_gate.steps.parameters]
troubleshoot_prompt = "{{troubleshoot_prompt}}"
declared_gate_command = "{{project_gate}}"
protected_check = "{{protected_check}}"
position = """
Every task in this milestone passed the milestone declared gate, the milestone review already ran,
and the milestone review edits were gated. The run-scoped gate is red because of this milestone's
work or its interaction with earlier work. `retry` does not exist at this position: repair the
run-scoped gate failure or write the handover document.
"""

[[patterns.repair_milestone_boundary_gate.steps]]
name = "repaired_milestone_boundary_gate"
title = "Testing"
type = "gate"
command = "{{project_gate}}"

[[patterns.repair_milestone_boundary_gate.steps]]
if = { repaired_milestone_boundary_gate = "red" }
then = "stop_repaired_milestone_boundary_gate"

[[patterns.stop_repaired_milestone_boundary_gate.steps]]
type = "stop"
note = "The run-scoped gate is red after a milestone body completed."

[[patterns.repair_project_final_gate.steps]]
name = "project_final_gate_recovery"
type = "call"
pattern = "troubleshoot"

[patterns.repair_project_final_gate.steps.parameters]
troubleshoot_prompt = "{{troubleshoot_prompt}}"
declared_gate_command = "{{project_gate}}"
protected_check = "{{protected_check}}"
position = """
Every milestone is built and gated. This is the last run gate, and nothing runs after it but the
merge. No active task brief exists here: read the run's `plan.md` and `milestones/` under its
orchestration directory, `.gantry/<run>/` in the worktree. `retry` does not exist at this position: repair the run-scoped gate failure or write the
handover document.
"""

[[patterns.repair_project_final_gate.steps]]
name = "repaired_project_final_gate"
title = "Testing"
type = "gate"
command = "{{project_gate}}"

[[patterns.repair_project_final_gate.steps]]
if = { repaired_project_final_gate = "red" }
then = "stop_repaired_project_final_gate"

[[patterns.stop_repaired_project_final_gate.steps]]
type = "stop"
note = "The run-scoped gate is red after all milestone bodies completed."

The endings

Falling off the end of build_milestones, after project_final_gate is green, is the successful ending and declares no step.

build
[[patterns.stop_project_baseline_red.steps]]
type = "stop"
note = "The run-scoped gate is red on the clean baseline, so no milestone may build on it."

[[patterns.stop_no_milestones.steps]]
type = "stop"
note = "The milestone planner reported no actionable work in the plan; its own account is at state/plan-scope.txt and the plan it read is the run's declared plan source."

[[patterns.stop_plan_scope_absent.steps]]
type = "stop"
note = "The milestone planner did not write state/plan-scope.txt, so the build cannot tell whether there is work to run."