Commit 7e597f7
authored
graph: spec v0.4 fan-out runtime (proposal 0005 PU side) — phase 3 (#16)
* graph: spec v0.4 fan-out runtime (proposal 0005 PU side) — phase 3
Implements pipeline-utilities §9: parallel fan-out of compiled
subgraphs with bounded concurrency, two error policies, configurable
empty-input behavior, and per-instance middleware composition. Lands
all 8 target conformance fixtures (pipeline-utilities 017-023 +
graph-engine 017-observer-fan-out-index).
Engine:
- fan_out.py: FanOutNode (a third Node sibling alongside FunctionNode
and SubgraphNode), FanOutConfig dataclass, per-instance projection
helpers, concurrency-bounded execution via asyncio.gather +
Semaphore, fan-in merge for fail_fast and collect policies,
on_empty raise/noop handling.
- errors.py: FanOutCountModeAmbiguous, FanOutFieldNotList compile
errors; FanOutEmpty, FanOutInvalidCount, FanOutInvalidConcurrency
runtime errors. The runtime trio subclasses NodeException so they
surface as graph-engine §4 node_exception with an additional
fan_out_category attribute (matching fixture 023's expected
shape).
- observer.py: _InvocationContext gains fan_out_index; new
descend_into_fan_out_instance helper stamps the index onto the
child context so inner-node events fire with it populated.
- compiled.py: _step_fan_out_node — wraps the whole fan-out as one
parent dispatch (per §9.6) with started/completed events around
the chain; _dispatch_started/_completed propagate fan_out_index
from context onto every NodeEvent.
- builder.py: GraphBuilder.add_fan_out_node with full §9 compile-
time validation (mode mutual-exclusion, items_field list-typed
check, declared-field references for collect_field, target_field,
count_field, errors_field, inputs, extra_outputs).
Conformance harness:
- adapter.py: fan_out node directive translation; new test seam
directives update_pure, update_from_field, flaky_by_index (both
fail_count_per_idx and fail_when_idx shapes), flaky_instance_only;
_TracingFanOutNode for execution-order trace recording.
- test_pipeline_utilities.py: instance_middleware threading via a
new fan_out_instance_middleware kwarg on build_graph; cases-
fixture handling now merges shared subgraph blocks into each
case so 018-019, 021-023 see them; supports state_field_read and
queue_chunk callable resolvers for count + concurrency.
- test_conformance.py: removed fan_out from
_UNSUPPORTED_NODE_DIRECTIVES so graph-engine fixture 017 runs.
Unit tests (test_fan_out.py): 19 tests covering items_field
projection, count modes (literal int + state-reading callable),
count + concurrency callables resolved exactly once at entry, inputs
mapping projection, concurrency limit enforcement, fail_fast
recoverable_state contract, collect errors_field shape, on_empty
raise/noop, count_field write, extra_outputs merge,
instance_middleware retry composition, fan-in determinism under
nondeterministic completion timing, four compile-error checks
(count_mode_ambiguous both/neither, field_not_list,
inputs/extra_outputs undeclared field references).
Total tests: 276 passing, 0 skipped.
* test: document fixture-global counter limitation in flaky test seams
The PR review thread suggested keying flaky_by_index and
flaky_instance_only by id(state) for per-instance counters. Tried
that; broke fixture 021. Root cause: instance-level retry (021)
constructs a fresh subgraph state on each retry, so id(state) resets
per retry attempt — the per-instance counter starts over and retry
exhausts.
True per-instance semantics need an identifier stable across both
node-level retry (state stable, id works) AND instance-level retry
(state changes, id doesn't work). A state-field key would work but
the field name is fixture-specific (item for 020, input for 021).
Reverting to a fixture-global counter and documenting the limitation
in the docstring + an inline comment, so a future fixture exercising
the gap surfaces a real failure rather than silently miscounting.
The existing fixtures (019 collect, 020 node-level retry, 021
instance-level retry) align with the global counter at runtime —
not because the semantics are correct, but because the timing
happens to land the failure on the right call.1 parent 89f5277 commit 7e597f7
10 files changed
Lines changed: 1886 additions & 29 deletions
File tree
- src/openarmature/graph
- tests
- conformance
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
54 | 67 | | |
55 | 68 | | |
56 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
79 | 84 | | |
80 | 85 | | |
81 | 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 | + | |
82 | 237 | | |
83 | 238 | | |
84 | 239 | | |
| |||
195 | 350 | | |
196 | 351 | | |
197 | 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
260 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
261 | 270 | | |
262 | 271 | | |
263 | 272 | | |
| |||
457 | 466 | | |
458 | 467 | | |
459 | 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 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
460 | 525 | | |
461 | 526 | | |
462 | 527 | | |
| |||
479 | 544 | | |
480 | 545 | | |
481 | 546 | | |
| 547 | + | |
482 | 548 | | |
483 | 549 | | |
484 | 550 | | |
| |||
506 | 572 | | |
507 | 573 | | |
508 | 574 | | |
| 575 | + | |
509 | 576 | | |
510 | 577 | | |
0 commit comments