FMT-3: Actions and guards
A finding of FMT-3 means that an action or a guard of the machine isn’t one that smllm knows, or that its params are wrong. The rules page says what the rule checks.
Messages
<file>:<line>: error: <path>: unknown action `<name>`. Write an action as {type, params}. Only setRef can be a bare name (FMT-3)
<file>:<line>: error: <path>.type: unknown action type `<type>` (expected one of: prompt, command, setRef) (FMT-3)
<file>:<line>: error: <path>: a prompt needs exactly one of: text, file (FMT-3)
<file>:<line>: error: <path>: prompt file <file>: <error>. The path is relative to the file that gives it (FMT-3)
<file>:<line>: error: <path>: setRef runs only in a transition's actions under `on`. Entry, exit, and always have no event to read the ref param from (FMT-3)
<file>:<line>: error: <path>: a guard is a map {type, params}, not a name. Guard types: command { run }, visits { state, atLeast } (FMT-3)
<file>:<line>: error: <path>.type: unknown guard type `<type>` (expected one of: command, visits) (FMT-3)
<file>:<line>: error: <path>: visits counts unknown state <state> (FMT-3)
<file>:<line>: warning: <path>: visits atLeast 0 is always true (FMT-3)
Cause
smllm validate lists a warning only with --warnings.
Each message has its own cause:
- An action is a bare name other than
setRef. - An action’s
typeis a value other thanprompt,command, andsetRef. - A prompt’s params give both
textandfile, or neither. - smllm can’t read the file that a prompt names. smllm reads the path from the folder of the file that gives it, which is the machine file, or the config for
[idle] on-enter. - A
setRefaction is underentry,exit, oralways. Only a transition underonhas an event that carries the ref param. - A guard is a name, not a map.
- A guard’s
typeis a value other thancommandandvisits. - A
visitsguard counts a state that the machine doesn’t have. - A
visitsguard hasatLeast: 0, which every instance passes.
Fix
Make the change that the message names:
- Write the action as a map with
typeandparams. - Set
typetoprompt,command, orsetRef. - Give the prompt exactly one of
textandfile. - Correct the path, or create the file. The path is relative to the folder of the file that gives it: the machine file, or the config for
[idle] on-enter. - Move
setRefto the actions of a transition underon. - Write the guard as a map with
typeandparams. - Set
typetocommandorvisits. - Name a state of the machine in
state. - Set
atLeastto 1 or more, or remove the guard.
Example
This machine gives a prompt file with a path that starts at the project, not at the machine file:
.smllm/prompts/triage.md
Reproduce the bug, then fire `reproduced`.
.smllm/fix.smllm.yaml
id: fix
initial: TRIAGE
meta:
smllm: 1
states:
TRIAGE:
entry:
type: prompt
params:
file: .smllm/prompts/triage.md
on:
reproduced: DONE
DONE:
type: final
smllm validate reports the prompt file:
$ smllm validate .smllm/fix.smllm.yaml
.smllm/fix.smllm.yaml:7: error: states.TRIAGE.entry: prompt file .smllm/prompts/triage.md: no such file. The path is relative to the file that gives it (FMT-3)
1 error, 0 warnings, 0 info
[exit 1]
The fixed machine gives the path from the folder of the machine file:
.smllm/fix.smllm.yaml
id: fix
initial: TRIAGE
meta:
smllm: 1
states:
TRIAGE:
entry:
type: prompt
params:
file: prompts/triage.md
on:
reproduced: DONE
DONE:
type: final
smllm validate reports no finding:
$ smllm validate .smllm/fix.smllm.yaml
0 errors, 0 warnings, 0 info