Skip to content

feat: several named graph inputs - #16

Merged
psyinf merged 1 commit into
mainfrom
feature/named-graph-inputs
Sep 19, 2026
Merged

psyinf merged 1 commit into
mainfrom
feature/named-graph-inputs

Conversation

@psyinf

@psyinf psyinf commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Implements TODO item "Several named graph inputs". Stacked on #15 — merge that first; this PR then retargets to main.

What

A graph can read named inputs, mirroring GraphOutputs:

DslFilterGraph<GraphInputs, Match> matcher(R"dsl(
    in.orders -> ParseOrder -> order
    in.quotes -> ParseQuote -> quote
    (order, quote) -> Match -> out
)dsl",
    GraphInputs::of<Order, Quote>("orders", "quotes")); // optional

matcher.push("quotes", Quote{...});                                       // one run, one input
matcher.filter(GraphInputs{}.set("orders", order).set("quotes", quote));  // one run, several inputs

Semantics

  • One push / filter is one run. Inputs not fed are empty, exactly like dropped paths: readers are skipped, merges see holes. No new rules for merges or outputs.
  • GraphInputs::of<Types...>(keys...) declares input types, checked at construction like any edge. Declared-but-unread and read-but-undeclared inputs are diagnostics.
  • Without a declaration, an input is typed by its first reader (diagnostics say so: the graph input 'in.orders' (typed by its reader 'ParseOrder')).
  • Feeding an unknown key throws std::out_of_range; a mistyped value throws std::invalid_argument.
  • in with GraphInputs, or in.<key> with a plain input type, is a diagnostic. DslFilterGraph<In, Out> with a plain type is unchanged.

Also

  • .<key> on anything other than in/out (e.g. msg.x) is now a diagnostic; it used to be silently ignored.
  • dsl::GraphProgram::inputs lists the inputs a program reads; validateDslGraph(text, inputTypes) overload.
  • Internally, edge types live in a small EdgeTypes helper, and GraphPlan::run takes one value per input.

Docs / tests

README ("Several named inputs"), EXAMPLE.md section 5 + textPipeline demo 4b, CHANGELOG, TODO (item removed, rest renumbered). New GraphInputsTests.cpp (11 cases, incl. nesting a named-input graph as a stage) plus parser-agreement cases. All 107 tests pass (MSVC debug, ASan).

Base automatically changed from feature/named-merge-slots to main September 19, 2026 19:41
A graph can read named inputs, `in.<key>`, with the new GraphInputs as
its input type, mirroring GraphOutputs. push(key, value) runs the graph
fed through one input; filter(GraphInputs) feeds several in one run.
Inputs not fed in a run are empty, like dropped paths, so merges and
outputs need no new rules.

GraphInputs::of<Types...>(keys...) declares the input types, checked
when the graph is built; an undeclared input takes the type of its
first reader. Unknown keys and mistyped values throw when fed. A
`.<key>` on anything but in/out is now a diagnostic instead of being
ignored.

Implements TODO item 2 (now item 1 after the previous removal).
@psyinf
psyinf force-pushed the feature/named-graph-inputs branch from be213b8 to ff42094 Compare September 19, 2026 19:42
@psyinf
psyinf merged commit a07f90e into main Sep 19, 2026
3 checks passed
@psyinf
psyinf deleted the feature/named-graph-inputs branch September 19, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant