-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterion_v1.ebnf
More file actions
228 lines (164 loc) · 8.54 KB
/
iterion_v1.ebnf
File metadata and controls
228 lines (164 loc) · 8.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
(* ============================================================
Grammaire EBNF — iterion DSL V1
============================================================
Convention :
- MAJUSCULES = terminaux / tokens
- minuscules = non-terminaux
- (* ... *) = commentaire
- { x } = 0..N répétitions
- [ x ] = optionnel
- ( x | y ) = alternative
- "..." = littéral
============================================================ *)
(* ---- Fichier source ---- *)
file = { top_level_decl } ;
top_level_decl = vars_decl
| prompt_decl
| schema_decl
| agent_decl
| judge_decl
| router_decl
| human_decl
| tool_node_decl
| workflow_decl
| comment ;
(* ---- Commentaires ---- *)
(* Les commentaires commencent par ## et s'étendent jusqu'à la fin de la ligne.
Ils sont autorisés partout où un top_level_decl ou un edge est attendu. *)
comment = "##" REST_OF_LINE ;
(* ---- Variables globales (top-level) ---- *)
vars_decl = "vars" ":" NEWLINE INDENT { var_field } DEDENT ;
var_field = IDENT ":" type_expr [ "=" literal ] NEWLINE ;
(* ---- Prompts ---- *)
prompt_decl = "prompt" IDENT ":" NEWLINE INDENT prompt_body DEDENT ;
prompt_body = { PROMPT_TEXT_LINE } ;
(* Un PROMPT_TEXT_LINE est toute ligne indentée sous le prompt.
Peut contenir des interpolations {{...}} qui seront résolues à l'exécution. *)
(* ---- Schemas ---- *)
schema_decl = "schema" IDENT ":" NEWLINE INDENT { schema_field } DEDENT ;
schema_field = IDENT ":" field_type [ enum_constraint ] NEWLINE ;
field_type = "string" | "bool" | "int" | "float" | "json" | "string[]" ;
enum_constraint = "[" "enum" ":" STRING_LIT { "," STRING_LIT } "]" ;
(* ---- Nœuds : agent ---- *)
agent_decl = "agent" IDENT ":" NEWLINE INDENT { agent_prop } DEDENT ;
agent_prop = "model" ":" STRING_LIT NEWLINE
| "input" ":" IDENT NEWLINE
| "output" ":" IDENT NEWLINE
| "publish" ":" IDENT NEWLINE
| "system" ":" IDENT NEWLINE
| "user" ":" IDENT NEWLINE
| "session" ":" session_mode NEWLINE
| "tools" ":" tool_list NEWLINE
| "tool_max_steps" ":" INT_LIT NEWLINE
| "delegate" ":" STRING_LIT NEWLINE
| "reasoning_effort" ":" reasoning_effort_value NEWLINE
| "await" ":" await_mode NEWLINE ;
session_mode = "fresh" | "inherit" | "fork" | "artifacts_only" ;
reasoning_effort_value = "low" | "medium" | "high" | "extra_high" ;
tool_list = "[" tool_ref { "," tool_ref } "]" ;
tool_ref = IDENT { "." IDENT } ;
(* ---- Nœuds : judge ---- *)
(* Identique à agent mais avec le mot-clé "judge".
Sémantiquement, un judge n'appelle pas de tools et produit un verdict. *)
judge_decl = "judge" IDENT ":" NEWLINE INDENT { judge_prop } DEDENT ;
judge_prop = "model" ":" STRING_LIT NEWLINE
| "input" ":" IDENT NEWLINE
| "output" ":" IDENT NEWLINE
| "publish" ":" IDENT NEWLINE
| "system" ":" IDENT NEWLINE
| "user" ":" IDENT NEWLINE
| "session" ":" session_mode NEWLINE
| "tools" ":" tool_list NEWLINE
| "tool_max_steps" ":" INT_LIT NEWLINE
| "delegate" ":" STRING_LIT NEWLINE
| "reasoning_effort" ":" reasoning_effort_value NEWLINE
| "await" ":" await_mode NEWLINE ;
(* ---- Nœuds : router ---- *)
router_decl = "router" IDENT ":" NEWLINE INDENT { router_prop } DEDENT ;
router_prop = "mode" ":" router_mode NEWLINE ;
router_mode = "fan_out_all" | "condition" | "round_robin" ;
(* Note: routers do not support "await" — they are fan-out sources, not
convergence targets. Only agent, judge, human, and tool nodes can
be convergence points. *)
(* ---- Await (convergence strategy) ---- *)
(* When a node receives inputs from multiple parallel branches,
await controls how it waits for them.
wait_all: wait for all incoming branches (default for convergence points)
best_effort: proceed when possible, tolerate branch failures *)
await_mode = "wait_all" | "best_effort" ;
(* ---- Nœuds : human ---- *)
human_decl = "human" IDENT ":" NEWLINE INDENT { human_prop } DEDENT ;
human_prop = "input" ":" IDENT NEWLINE
| "output" ":" IDENT NEWLINE
| "publish" ":" IDENT NEWLINE
| "instructions" ":" IDENT NEWLINE
| "mode" ":" human_mode NEWLINE
| "model" ":" STRING_LIT NEWLINE
| "system" ":" IDENT NEWLINE
| "min_answers" ":" INT_LIT NEWLINE
| "await" ":" await_mode NEWLINE ;
human_mode = "pause_until_answers" | "auto_answer" | "auto_or_pause" ;
(* pause_until_answers : always pauses for human input (default).
auto_answer : LLM generates answers — never pauses. Requires model + output.
auto_or_pause : LLM decides whether to pause or auto-answer via a
needs_human_input boolean. Requires model + output. *)
(* ---- Nœuds : tool (exécution directe) ---- *)
tool_node_decl = "tool" IDENT ":" NEWLINE INDENT { tool_node_prop } DEDENT ;
tool_node_prop = "command" ":" STRING_LIT NEWLINE
| "output" ":" IDENT NEWLINE
| "await" ":" await_mode NEWLINE ;
(* ---- Nœuds terminaux ---- *)
(* "done" et "fail" ne sont pas déclarés ; ils sont des identifiants réservés
utilisables comme cible d'une edge dans le workflow. *)
(* ---- Workflow ---- *)
workflow_decl = "workflow" IDENT ":" NEWLINE INDENT
[ workflow_vars ]
workflow_entry
[ workflow_budget ]
{ edge | comment }
DEDENT ;
workflow_vars = "vars" ":" NEWLINE INDENT { var_field } DEDENT ;
workflow_entry = "entry" ":" IDENT NEWLINE ;
workflow_budget = "budget" ":" NEWLINE INDENT { budget_prop } DEDENT ;
budget_prop = "max_parallel_branches" ":" INT_LIT NEWLINE
| "max_duration" ":" STRING_LIT NEWLINE
| "max_cost_usd" ":" NUMBER_LIT NEWLINE
| "max_tokens" ":" INT_LIT NEWLINE
| "max_iterations" ":" INT_LIT NEWLINE ;
(* ---- Edges (dans workflow) ---- *)
edge = IDENT "->" IDENT [ when_clause ] [ loop_clause ] [ with_block ] NEWLINE ;
when_clause = "when" [ "not" ] IDENT ;
loop_clause = "as" IDENT "(" INT_LIT ")" ;
with_block = "with" "{" NEWLINE { with_mapping } "}" ;
with_mapping = IDENT ":" STRING_LIT NEWLINE ;
(* ---- Expressions de template ---- *)
(* À l'intérieur de STRING_LIT dans les with_blocks et prompt_body,
les interpolations suivantes sont reconnues : *)
template_expr = "{{" template_ref "}}" ;
template_ref = "vars" "." IDENT
| "input" "." IDENT
| "outputs" "." IDENT [ "." IDENT ]
| "artifacts" "." IDENT ;
(* ---- Types ---- *)
type_expr = "string" | "bool" | "int" | "float" | "json" | "string[]" ;
literal = STRING_LIT | INT_LIT | FLOAT_LIT | BOOL_LIT ;
(* ---- Tokens terminaux ---- *)
IDENT = LETTER { LETTER | DIGIT | "_" } ;
STRING_LIT = '"' { CHAR } '"' ;
INT_LIT = DIGIT { DIGIT } ;
FLOAT_LIT = DIGIT { DIGIT } "." DIGIT { DIGIT } ;
NUMBER_LIT = INT_LIT | FLOAT_LIT ;
BOOL_LIT = "true" | "false" ;
LETTER = "a".."z" | "A".."Z" | "_" ;
DIGIT = "0".."9" ;
CHAR = (* tout caractère sauf '"' non-échappé *) ;
PROMPT_TEXT_LINE = (* ligne indentée quelconque, potentiellement avec {{...}} *) ;
REST_OF_LINE = (* tout jusqu'au NEWLINE *) ;
NEWLINE = "\n" ;
(* ---- Indentation ---- *)
(* Le langage utilise l'indentation significative (style YAML/Python).
INDENT et DEDENT sont des tokens virtuels émis par le lexer
lorsque le niveau d'indentation augmente ou diminue.
La convention est 2 espaces par niveau. *)
INDENT = (* augmentation du niveau d'indentation *) ;
DEDENT = (* diminution du niveau d'indentation *) ;