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."

An observed plan change routes to nothing because the milestone briefs are this step's product.

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 omits that metadata without stopping 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"

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

A re-entered build keeps an existing run-scoped bin/gate, including a non-executable one the baseline must report. Both branches overwrite project_gate_present because command steps retain stale outputs.

build
[[patterns.prepare_project_gate.steps]]
name = "probe_project_gate"
title = "Check For Project Gate Command"
type = "command"
run = 'run_state="$(dirname "$(dirname "$project_gate_present")")"; mkdir -p "$run_state/state"; if test -e "$run_state/bin/gate"; then printf yes > "$project_gate_present"; else printf no > "$project_gate_present"; fi'
outputs = [
  { name = "project_gate_present", path = "state/project-gate-present.txt", values = ["yes", "no"], scope = "run" },
]

[[patterns.prepare_project_gate.steps]]
if = { project_gate_present = "yes" }
else = "author_project_gate"

[[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 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.author_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 milestones

This outer for re-enumerates milestones/, so a milestone review can add a later iteration.

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

[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"

[[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

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."