Unrendered Handlebars block helpers strip safety flags from destructive commands (gt reaper purge has always run live)
Summary
gt's wisp renderer substitutes simple {{var}} placeholders but leaves Handlebars block helpers ({{#if}}, {{#each}}, {{else}}, {{/if}}) verbatim in the step body that an agent then reads as its instructions.
Where a block helper wraps a safety flag on a destructive command, the flag silently disappears and the agent is handed either literal template syntax inside the command, or a command whose behaviour has quietly changed.
Concrete instance: gt reaper purge has always run live
internal/formula/formulas/mol-dog-reaper.formula.toml wraps --dry-run in a block helper in four places:
gt reaper reap ... {{#if dry_run}}--dry-run{{/if}} --json
gt reaper purge ... {{#if dry_run}}--dry-run{{/if}} --json
gt reaper auto-close ... {{#if dry_run}}--dry-run{{/if}} --json
gt convoy check {{#if dry_run}}# dry_run set: run 'gt convoy list' and report instead of closing{{/if}}[vars.dry_run] defaults to "". Since the helper never renders:
gt reaper purgehas run live on every dispatch since the formula existed.- Setting
dry_run="true"changes nothing. The rehearsal the formula documents has never been reachable — it is a documented safety control that silently does nothing. - The agent receives a purge command with
{{#if dry_run}}sitting in it, and must either pass that as an argument or guess whether a safety flag was intended.
The gt convoy check case is the worst of the four, because the whole rehearsal instruction is inside the block. Unrendered, the default behaviour is "close every convoy whose tracked issues are complete and notify subscribers" — a state-changing operation behind a verb that reads as a read-only probe.
Observed in production
On 2026-09-30 a dog was dispatched mol-dog-reaper, reached the purge step and ran it live. It did not delete anything only because there were no purge candidates at that moment. Nothing in the system flagged the missing flag.
A related detail worth recording: we tried to warn the dog mid-run, but gt nudge waits for the target to be idle before delivering, so the warning landed after the molecule had already run. A stop message cannot reach a busy agent.
Scope
This is not limited to the reaper. Both templating dialects are in use across the formula set, and an audit that greps only for {{# misses half of it:
| Dialect | Opener | Seen in |
|---|---|---|
| Handlebars | {{#if}} {{#each}} |
the mol-* formulas |
Go text/template |
{{if .x}} {{range .x}} {{end}} |
design, code-review, mol-plan-review, mol-prd-review (all type = "convoy" — these appear to be rendered correctly by the legs runner and are not the problem) |
A greppable check covering both:
grep -rnE '\{\{(#|if |range|with |else|end)' internal/formula/formulas/*.tomlThe hazard is a dialect mismatch — Go block syntax in a body the Handlebars path renders, or a Handlebars helper that no path renders — not either dialect as such. mol-dep-propagate (no type, so Handlebars-rendered) contains a Go {{range dependent}} block inside a gt mail send heredoc, where dependent is not a declared var at all.
A second, quieter failure mode in the same family: an undeclared simple var renders to nothing with no visual cue whatsoever. mol-dog-doctor carried gt escalate -s CRITICAL "Dolt: server unreachable on port {{port}}" with no port in its [vars].
Candidate fixes
Three options, and the choice is yours — I have no view on which fits the codebase best:
- Render block helpers. Fixes the instance; the renderer then supports what the formulas already assume.
- Fail loudly. Refuse to hand a wisp to an agent if any unrendered
{{ }}remains in the body. This catches the whole class, including undeclared vars, and is probably the smallest change with the widest coverage. - Invert the polarity of
gt reaper purge— require--executeto delete, default to rehearsal. This is worth doing regardless of the renderer, because it removes the class rather than an instance: with--dry-run, every kind of text damage (unrendered helper, truncation, a dropped continuation line, an agent paraphrasing) points toward deletion. With--execute, all of it degrades to a no-op.
PR
A workaround for the immediate instance is at #4908 — it replaces the four block helpers with a simple {{dry_run_flag}} var that the renderer does substitute. Default "" = live, so behaviour is unchanged; it makes the rehearsal reachable for the first time. It deliberately does not attempt any of the three fixes above.
Source: gastownhall/gastown