Templates

A run template's file format and header fields, the eight shipped templates and their purposes, where operator templates live, override and reset, and what validation refuses.

A template is the graph a run executes: model nodes, builtins and the cords between them. This page says what the code does; file:line citations are in parentheses. The nodes themselves are on nodes.

01the template file#

A template is one YAML file with a template: header beside the patch document, which is inline. The patch document is version, nodes and cords. See nodes. The file is read strictly: an unknown key is an error, and a file with more than one YAML document is refused.

The header is a Declaration:

A ticket template is any template that closes tickets and has a required tickets input (TicketTemplate). It is read from the declaration, never from the name. A ticket template launches one previewed run per ticket.

02shipped templates#

03where templates live#

The eight above are embedded in smith (internal/harness/*.yaml). Smith's code registers some input templates as well. They are read-only, and saving a template under their name is refused. Which ones they are is not checked here.

An operator's templates live at <library_root>/templates/<name>.yaml (TemplatesDir, Library.Dir at 385-390).

04a saved copy of a shipped template or role#

A saved copy of a shipped template, or a role folder that overrides a built-in role, stands in one of three states. Settings shows the state beside it, with a reset back to the shipped one (templates: Library.List; roles: Role.Shadow, set by find in internal/contextsource/persona/persona.go).

"Shipped changed since" is a stored hash. Saving a copy of a shipped template writes a marker beside it, <templates dir>/.<name>.shipped, and saving a role writes <role folder>/.shipped. Each holds the sha256 of the shipped version at that save (ShippedRevision, BuiltInRevision). The copy is flagged when that hash differs from today's shipped one. Reset removes the marker with the copy, and the marker is never listed as a template. A copy saved before markers existed, or edited by hand without a save through smith, has no marker, so it reads edited and never edited: shipped changed since. A role saved through the settings page is trimmed and its kit rewritten, so it can read edited while its words are unchanged.

A reset of a library template from settings is POST /api/desk/settings/template-reset, the operator's own press. A role resets through POST /api/desk/role with reset, which removes the role's folder.

05validation#

ValidateTemplate is the one validator. Library load, propose and save all call it. It refuses a template when:

06propose_template#

propose_template takes a name, a one-line purpose and the whole template file. The desk validates it and puts a template card in the conversation. The card shows the graph, each node's role, model and profile, what each node can touch, the validator's problems, and a diff against the template it varies: the header's base, else the template of the same name. Nothing is written. Only the operator's save to library on a valid card adds it, and the desk tells the conductor what they chose. Once saved, draft_launch can carry it. See launch.