/// Protocol terminal targets and the labels the graph uses for them. /// /// Mirrors `web/src/protocol.js` (`SUCCESS_END`, `FAILURE_END`, /// `isTerminal`, `resolveTarget`) and the label helpers in `web/src/graph.js`. /// Pure Dart: no Flutter imports and no layout or rendering decisions. library; /// The explicit success terminal (`Protocol.SUCCESS_END`). const String successEnd = '#success'; /// The explicit failure terminal (`Protocol.FAILURE_END`). const String failureEnd = '#failure'; /// True only for the two explicit terminal targets. /// /// A bare `#` is not itself terminal; [resolveTarget] turns it into one using /// the outcome, exactly as the server and the web client do. bool isTerminalTarget(String? target) => target == successEnd || target == failureEnd; /// Mirrors `Protocol.resolveTarget`: a bare `#` is the outcome's terminal. /// /// Every other value is preserved verbatim, including an empty or unknown /// stage key. A missing target stays null rather than becoming a terminal, so /// a blank edge cannot fabricate a visit or a terminal node. String? resolveTarget(String? outcome, String? target) { if (target != '#') return target; return outcome == 'error' ? failureEnd : successEnd; } /// A graph node title: a stage keeps its key, a terminal reads Success/Failure. String nodeDisplayLabel(String? key) { if (key == successEnd) return 'Success'; if (key == failureEnd) return 'Failure'; return key ?? ''; } /// The TUI-mirroring label: terminal targets are all caps. String nodeLabel(String? key) { if (key == successEnd) return 'SUCCESS'; if (key == failureEnd) return 'FAILURE'; return key ?? ''; }