Repository navigation
Declare the navigation graph with a Kotlin DSL (no codegen) - #18
Merged
Merged
Conversation
rinekri
force-pushed
the
codex/way-dsl-dual-support
branch
from
November 8, 2026 21:24
d4979ad to
15a3089
Compare
rinekri
force-pushed
the
codex/way-dsl-dual-support
branch
from
November 8, 2026 22:33
15a3089 to
15851f9
Compare
ru.kode.way.dsl.Graph declares a graph in Kotlin as an alternative to .dot files. It ships as a separate artifact, ru.kode:way-dsl (module :way-dsl, same targets as :way, api dependency on :way). It implements the runtime Schema and NodeBuilder, so it works on every platform of :way and mixes with generated schemas. Supported: flows, parameterized screens and flows, included graphs (the counterpart of type = schema), and a parallel root whose regions are included graphs. A finished child flow is reported with ChildFlowFinishedEvent. Tests cover graph validation, payloads and navigation parity with graphs generated from equivalent .dot files.
Bring the Kotlin DSL to parity with .dot codegen: - typed flow, parallel and include parameters (parameterizedFlow<P, R>, parameterizedParallel<P, R>, typed target(payload) and factories); a nullable root is built with null when started without a payload - history(id) and deepHistory(id) nodes with a HistoryTarget, with the placement rules of the .dot parser - parallel flows anywhere, regions may be local flows and parallels - an included graph may have several parents in one region; Schema.targets returns every path, target(payload, via) picks one Validation mirrors Parser.kt. GraphTest covers each feature and its errors, DslParityTest runs each against a generated counterpart.
rinekri
force-pushed
the
codex/way-dsl-dual-support
branch
from
November 9, 2026 10:02
15851f9 to
fe2ab52
Compare
This was referenced Nov 9, 2026
rinekri
marked this pull request as ready for review
November 9, 2026 11:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ru.kode.way.dsl.Graphdeclares a navigation graph in Kotlin, as an alternative to.dotfiles and the Gradle plugin. AGraphgives the runtime aSchemaand aNodeBuilder, just as generated code does. That meansNavigationService, extension points andway-composework the same with either one, and DSL and generated schemas can include each other.It ships as a separate artifact,
ru.kode:way-dsl(module:way-dsl, packageru.kode.way.dsl), with the same targets as:way: JVM, Android and iOS. It depends onru.kode:wayviaapi, so one dependency is enough:implementation("ru.kode:way-dsl:<version>")Nothing in
:wayhad to become public for it; it uses only the existing public API.Usage
Supported:
flow<R>,parameterizedFlow<P, R>,parallel<R>,parameterizedParallel<P, R>,parameterizedScreen<P>.include(id, OtherGraph.root)takes the payload and result types of the included root.Any?reaches user code.Pworks as in codegen (NullPayload; a nullable root starts withnull).event.childFlowResult(AppGraph.login).history(id)anddeepHistory(id), with the same placement rules asParser.kt. Their target is the runtimeHistoryTarget, and they need no factory.Schema.targetsreturns every path, andtarget(payload, via = parent)is the counterpart of the generated<id>Via<Parent>.Parser.kt:Not supported, compared with
.dot:AbsoluteTarget);Schema.regionByName);A DSL target under a parallel starts at its closest flow, not at the flow above the parallel; both resolve to the same node.
The README has a new "Kotlin DSL" section, and the CHANGELOG has an
Unreleasedentry.:way-dsl:jvmTestis added to the CI task list, and:way-dslto the release workflow's test and publish steps. No version bump.Testing
GraphTest(13 tests) covers:MissingPayloadExceptionand missing factories;DslParityTest(6 tests) runs the same event sequences on generated graphs (dsl-parity-*.dotinway-dsl/src/commonTest/way) and on equivalent DSL graphs. The active path, alive paths and node payloads must be identical after every step. It covers:nulland a non-null root payload;:way(TestNodeBuilder,TestFlowNode, ...) are copied intoway-dsl/src/commonTest, because KMP has no test fixtures../gradlew spotlessCheck;./gradlew build, excluding the sixiosSimulatorArm64Test/iosX64Testtasks, since no simulator runtime is installed on the machine used.Codegen bugs found on master (not fixed here)
historynode under aparallelFlowis generated as a region and the builder crashes on entering the parallel. The parity fixture leaves it out on the.dotside. The DSL excludes history nodes from regions, and a DSL-only check covers a deep history of a parallel restoring nested regions.