Repository navigation
selfhost: dynamics DSL and flow-block lowering on flowc, Python expanders retired (#681) - #999
Merged
Merged
Conversation
godofecht
force-pushed
the
port/dynamics-dsl-flowc
branch
2 times, most recently
from
September 29, 2026 06:33
1f7351f to
c65ad26
Compare
godofecht
force-pushed
the
port/dynamics-dsl-flowc
branch
from
September 29, 2026 06:52
c65ad26 to
e44dec7
Compare
…wc source read FLOWC_EXPAND_ONLY now takes the stages to run (field, dynamics, flow, or 1 for all). dynamics_dsl and flow_blocks are new leaf frontend modules; their expanders are stubs until the ports land.
compiler/src/flow_blocks.flow is src/flow/flow_blocks.py plus the flow grammar from parser.py: the Python lexer's token rules and column arithmetic, the flow body grammar, the expression grammar the flow items use, pipeline stages, every validation in its original order, and the lowering to Name_new/_init/_derivs/_step/_default_dt/_outputs/_check. The lowering is emitted as Flow source in place of the block, one declaration per line with ';' between statements, padded to the block's line count so later lines keep their numbers. tests/lang/test_time_blocks.flow and test_hybrid_events.flow now build and pass on flowc.
compiler/src/dynamics_dsl.flow is now the whole of expand_dynamics_dsl
from src/flow/dynamics_dsl.py, with the two corrections from
_dynamics_dsl_fixes.py applied (raw dsys validation, setup injected on its
own line). Detection, represent extraction, every dsys / horizon / sense /
ga evolve / closed / analyze / wfc field / couple / guide form, dynamics { }
blocks, code generation and injection. Output is byte-identical to the
Python, including its quirks and its ValueError, IndexError and KeyError
text. Floats are formatted from the exact binary value (%.17g and repr),
so no variadic C call is involved.
compiler/scripts/parity_dynamics_dsl.sh holds flowc to 94 fixtures whose goldens were recorded from the Python expander at 7527ab37 (27 expansions, 67 errors, including the nine tracked programs that use the DSL), checks that every other tracked .flow passes through untouched, diffs live against the Python at any revision with --python, and builds and runs examples/dynamics/ga_dsys_syntax.flow on flowc with python stubbed out. The end-to-end run skips flowc's bundle typecheck until #988 is fixed.
compiler/scripts/parity_flow_blocks.sh parses the Python lowering and flowc's expansion with the Python parser at a git revision and requires equal declaration trees, and equal diagnostics (message, line, column, hint). 107 fixtures (21 expansions, 86 errors) carry goldens recorded from the Python at 7527ab37, two run fixtures carry the Python host's program output, and bouncing_ball_evolves builds with ./flow compile on flowc with python stubbed out. The flowc typechecker accepts flow_panic, the intrinsic an always/never block lowers to.
dynamics_dsl.py and flow_blocks.py now call flowc's FLOWC_EXPAND_ONLY mode (dynamics, flow) through the runner field_dsl.py already had, and _dynamics_dsl_fixes.py is gone. Parser.parse lowers flow blocks by asking flowc for the expanded source, then attaches each FlowDecl and its recognition manifest to the lowered struct for tooling. field_dsl.py asks for the field stage alone, now that FLOWC_EXPAND_ONLY=1 runs every stage. The dynamics tests assert on the expansion instead of the removed Python program objects; the byte-level check is parity_dynamics_dsl.sh. flow-driver bundles programs that use the dynamics DSL, which adds stdlib imports. parser.py comments lose their em dashes (the prose hook lints whole staged files).
…fter parse The word 'flow' followed by a name and a brace inside a comment sent the compiler's own modules through flowc. The cheap check now looks at line starts, as the other DSL checks do, and a flow block it misses is lowered by flowc once the parse sees a FlowDecl.
FLOWC_EXPAND_ONLY=1 now runs every stage, so flow blocks and the dynamics DSL counted as passthrough failures.
The run_*.out goldens were matched by the *.out ignore rule, so a clean checkout had none and parity_flow_blocks.sh failed both run fixtures. Recorded with --write-golden 7527ab37 and unignored.
The Python parser now hands flow-block expansion to flowc. On a clean
runner the first such fuzz input built flowc_bootstrap with cc inside the
5 second per-input limit and was reported as a hang (repro 'flow Osc {').
With flowc built first the input is a clean parse error.
Every roundtrip step transpiles main.flow on the Python host. With the dynamics DSL and flow-block modules a step went from about 17s to 23s and the whole run from 15 to over 20 minutes, so the 20 minute timeout killed it twice during compile_module driver.
#971 changed a comment in docs/vision/examples/pendulum.flow from verify_examples.py to verify_examples.sh. The ex_ fixture must match its source byte for byte.
godofecht
force-pushed
the
port/dynamics-dsl-flowc
branch
from
September 29, 2026 07:10
e44dec7 to
da0cc45
Compare
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
With #999 on main, flowc expands dyn. blocks, so the server indexes dynamics files the way it compiles them.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
With #999 on main, flowc expands dyn. blocks, so the server indexes dynamics files the way it compiles them.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
With #999 on main, flowc expands dyn. blocks, so the server indexes dynamics files the way it compiles them.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
With #999 on main, flowc expands dyn. blocks, so the server indexes dynamics files the way it compiles them.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
With #999 on main, flowc expands dyn. blocks, so the server indexes dynamics files the way it compiles them.
This was referenced Sep 29, 2026
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.
Fixes #681
What
The dynamics DSL and
flowblocks (evolves,when ... reaches,every,solver,always/never,recognize,connect, nested flows,|>flow stages) now expand inside flowc. Programs that use them compile on the flowc host with no Python.compiler/src/flow_blocks.flow(new, about 5,600 lines) issrc/flow/flow_blocks.pyplus the flow grammar fromparser.py. It follows the Python lexer's token rules and column arithmetic, parses the flow body and the expressions in it, runs every validation in the original order, and lowers each flow to the same struct andName_new/_init/_derivs/_step/_default_dt/_outputs/_checkfunctions. It writes them as Flow source in place of the block: one declaration per line,;between statements, padded to the block's line count so later lines keep their numbers.compiler/src/dynamics_dsl.flowis now the whole ofdynamics_dsl.pywith the_dynamics_dsl_fixes.pycorrections applied. The output is byte-identical to the Python expander.flowc_expand_stages_in_placeinresolve.flow, used bymain.flow,driver.flowand all bundle passes).FLOWC_EXPAND_ONLYtakesfield,dynamics,flow, or1for all.!(a < b)was emitted as!a < b), andflow_panicis an intrinsic, accepted by the typechecker.dynamics_dsl.pyandflow_blocks.pyare thin bridges to flowc, and_dynamics_dsl_fixes.pyis deleted.Parser.parseasks flowc for the lowered source and keeps eachFlowDecland its recognition manifest on the lowered struct for tooling. Net Python insrc/flow: 143 lines added, 3,565 removed.This branch builds on #956 (Field DSL port, still open) and carries its commits minus its bootstrap regeneration. Merge #956 first; the regenerated C here is from the combined tree.
Parity
compiler/scripts/parity_flow_blocks.sh --python 7527ab37:The Python lowering produced AST, so the gate compares parsed results. The Python parser at the given revision lowers the original source and parses flowc's expansion, and the two declaration lists must be equal (positions and
has_selfaside). Diagnostics must match the Python text: message, line, column and hint. 107 fixtures (21 expansions, 86 errors) carry goldens recorded from the Python. Two run fixtures carry the Python host's program output, andtests/lang/test_time_blocks.flowandtest_hybrid_events.flownow pass on flowc. Separately, 36 of the 38 flow examples that build on both hosts print the same output.rc_rl_rlcdiffers because of #993, andchemostatis identical but slower than the 10 s limit at -O1.compiler/scripts/parity_dynamics_dsl.sh --python 7527ab37:The dynamics e2e sets
FLOWC_TYPECHECK=0because of #988.parity_field_dsl.shstill passes (21 fixtures, 2007 files untouched); it now asks for the field stage alone.Bootstrap
Regenerated last, in its own commit, per AGENTS.md from the Python host emit. Fixed point OK.
bootstrap_from_c.sh --verify,self_host_full.sh(three generations byte-identical) androundtrip.shpass. Bootstrap suite (tests/lang, FLOWC_IN/FLOWC_OUT, cc -Itests/lang): 121 pass, 17 fail, against 119/19 on main. The two new passes are the flow-block tests and nothing regressed. Python unit suite: 1798 passed, 4 skipped.Not changed
docs/project/python-in-flow.md,docs/vision/north-star.mdanddocs/AI_FLOW_HANDBOOK.mdstill name the Python modules. The commit hook rejects those files for dashes that were already there, so they are left for a separate pass.Gaps found: #988 (bundle typecheck and unexported stdlib functions), #992 (println of an f64 struct field), #993 (print takes a type from another function's parameter).