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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
//! The engine seam (ADR-0002): `EngineFactory` / `EngineSession`, step-kind routing,
//! and capability hooks (`step_kinds`, `doctor`).
//!
//! Both traits are **sync + dyn** (ADR-0006) and used as `Box<dyn …>`. Adding an
//! engine is a new crate implementing both traits plus one registry line in
//! `proef-cli` — with **zero changes to this crate** (the structural acceptance
//! test for M6).
//!
//! # Example: a minimal engine
//!
//! ```
//! use proef_core::cancel::CancellationToken;
//! use proef_core::engine::{
//! DoctorCheck, DoctorResult, EngineFactory, EngineSession, ScenarioCtx, StepKindSpec,
//! };
//! use proef_core::error::EngineError;
//! use proef_core::event::EventSink;
//! use proef_core::step::{BatchResult, StepBatch};
//! use proef_core::world::World;
//!
//! struct NullEngine;
//! struct NullSession;
//!
//! impl EngineFactory for NullEngine {
//! fn id(&self) -> &'static str {
//! "null"
//! }
//! fn step_kinds(&self) -> &'static [StepKindSpec] {
//! const KINDS: &[StepKindSpec] = &[StepKindSpec {
//! prefix: "null",
//! schema: "true",
//! validate: None,
//! fragments: None,
//! options: None,
//! }];
//! KINDS
//! }
//! fn doctor(&self) -> Vec<DoctorCheck> {
//! Vec::new()
//! }
//! fn open(&self, _ctx: &ScenarioCtx) -> Result<Box<dyn EngineSession>, EngineError> {
//! Ok(Box::new(NullSession))
//! }
//! }
//!
//! impl EngineSession for NullSession {
//! fn run_batch(
//! &mut self,
//! batch: &StepBatch,
//! _world: &mut World,
//! _events: &EventSink,
//! _cancel: &CancellationToken,
//! ) -> BatchResult {
//! BatchResult { steps: Vec::with_capacity(batch.steps.len()), error: None }
//! }
//! fn finish(&mut self) -> Result<(), EngineError> {
//! Ok(())
//! }
//! }
//!
//! let factory: Box<dyn EngineFactory> = Box::new(NullEngine);
//! assert_eq!(factory.id(), "null");
//! ```
use Arc;
use crateCancellationToken;
use crateEngineError;
use crateEventSink;
use crate;
use crateWorld;
/// Identifies an engine (`hurl`, …). A macro step's kind names the
/// engine that executes it (ADR-0002 routing).
;
/// An engine's claim on a pack step kind: the key prefix (`hurl`; other
/// prefixes reserved — ADR-0002 errata) plus the
/// JSON-Schema fragment describing that step's payload, merged into `proef schema`
/// output (TECH-SPEC §6), and an optional static payload validator used by pack
/// validation pass 7 (probe-instantiation parse — TECH-SPEC §4.1).
/// An engine-contributed static payload validator (pack validation pass 7).
pub type PayloadValidator = fn ;
/// How the core bounds one raw option's value (ADR-0007 budgets).
/// What a raw option key means to the core's budget and double-declaration
/// rules — the engine's vocabulary translated into the core's policy.
/// An engine-contributed recogniser: a raw option key (the text left of the
/// `:` in an `[Options]` line) → what the core's rules should make of it.
///
/// The seam that keeps option *spellings* out of `proef-core`. The fragment
/// half of this rule already crossed the seam — an engine maps its own AST to
/// [`ScannedFragment::declared_options`] — while the inline half matched
/// `"retry-interval:"` as a literal in core, so one rule lived at two
/// altitudes and a second engine would have got its fragments linted and its
/// inline blocks not.
///
/// `None` = the kind has no raw options the core bounds.
pub type OptionRecogniser = fn ;
/// An engine-contributed reader for one fragment file's whole text (ADR-0018).
pub type FragmentScanner = fn ;
/// One fragment file as its claiming engine read it.
/// What a step kind needs to own a fragment file format: the extension that
/// identifies one and the parser that reads it. Source discovery asks the
/// registry for the extension rather than naming a file type itself, so adding
/// an engine never teaches the CLI a new one (ADR-0002).
/// One entry of a fragment file, as the claiming engine's own parser sees it.
///
/// Engine-agnostic by construction: `proef-core` never learns a hurl type, and
/// a future engine fills the same shape from its own AST. Everything here is
/// *read* from the entry — nothing is declared separately and nothing can
/// therefore drift from the file.
/// The option families a pack step and a fragment can *both* declare, spelled as
/// the pack spells them.
///
/// This is the vocabulary [`ScannedFragment::declared_options`] must use: the
/// double-declaration rule works by string equality against the keys a step
/// writes in YAML, so an engine reporting hurl's own spelling (`retry-interval`,
/// say) would match nothing and the clash would go quiet — which is exactly the
/// silent last-wins `proef::pack::option_declared_twice` exists to refuse.
/// Engines fold their spellings into these (hurl's `retry-interval` is `retry`:
/// one policy, and a step's `retry:` sets both).
///
/// Kept in step with `MacroStep::declared_options`, which derives the other half
/// of the same comparison.
pub const OPTION_FAMILIES: & = &;
/// A fragment file the claiming engine's parser could not read (1-based
/// line/column **within that file**).
///
/// Distinct from [`PayloadProbeError`] despite the same shape: that one is
/// positioned inside a pack's payload block and gets mapped onto the pack
/// file, this one already points at a real file of its own.
/// A syntax problem found while probe-validating a step payload
/// (1-based line/column **within the payload text**; the pack loader maps it
/// onto the pack file).
/// Outcome of one environment check contributed by an engine.
/// Severity of a [`DoctorResult`].
/// One named environment check (native libraries, tool availability, …) surfaced
/// through `proef doctor` (ADR-0002 capability hook).
/// Per-scenario context handed to [`EngineFactory::open`]. Fields grow additively
/// as milestones land (artifact dirs, config, …).
/// Every engine variable a scenario must inject as a secret, paired with its
/// value — [`ScenarioCtx::secret_bindings`] joined against
/// [`ScenarioCtx::secrets`]. **The one place that join is written.**
///
/// It lives in core, not in each engine, because it is easy to get subtly
/// wrong: inject under the *secret* name rather than the *variable* name and a
/// renamed binding (ADR-0018) resolves to nothing, so the request goes out with
/// an unresolved `{{…}}` and fails far from the cause.
///
/// It yields borrows on purpose. Returning an owned variable→value map would put
/// a second copy of every secret value in memory for each scenario; ADR-0005
/// keeps values in exactly one place, the run-level `secrets` map.
///
/// A binding whose secret is absent is skipped — the CLI already refuses a run
/// whose secrets it cannot resolve, so that is defence in depth, not a path.
/// Batch-level HTTP defaults (per-entry `[Options]` in artifacts override them
/// — clone-then-override, verified TECH-SPEC §5).
/// A scenario's emitted artifact, shared with the engine that executes it.
/// Compiled-in engine entry point: identity, capability discovery, and session
/// opening (ADR-0002). Registered in `proef-cli`'s registry, one line per engine.
/// A live per-scenario engine session (ADR-0002). Only a session runs batches —
/// lifecycle is enforced by this ownership shape, not typestate.