You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Self-Hosting Phase 2] Port Field and Physics DSL Lowering to Flow #682
Progress: #707 already moved the first Field DSL parsing primitives into Flow. #710 now starts the Physics DSL side with native directive classification, simplified field grammar validation, Vec2 recognition, and the exact currently-shipped field stride/offset arithmetic. This does not satisfy the lowering issue yet: remaining work is native spatial allocation/indexing and boundary expansion, differential/Laplacian desugaring, and physics rule/constraint lowering. I am keeping the regex/source-assembly host boundary in Python until those transformations can consume native AST/data rather than re-parsing strings in Flow.
After merged #710, the next AST-independent Physics DSL slice is now concrete from compile_physics_to_flow:
Rule rewriting primitives: name += expr -> name = name + expr; name *= expr -> name = name * (expr).
Constraint projection rewriting: position.x/y and velocity.x/y -> flattened SoA scalar names.
clamp( -> clamp_f64( substitution.
Vec2 constant splitting (Vec2(x, y) -> <name>_x, <name>_y) can follow as another deterministic helper.
These can move to native Flow without yet porting the PhysicsWorld Python object graph or code-generation assembly. The broader world/entity/rule regex parser and complete generated-code emission remain later #682 work.
Implemented the next rewrite slice in src/flow/physics_dsl.py: statement-bounded compound assignment lowering (+=, -=, *=, /=), projection flattening for position/velocity x/y, and clamp -> clamp_f64 in both rules and constraints. Added regressions in tests/unit/test_physics_dsl.py. Full suite: 1814 passed, 4 skipped.
Additional parity fix: generated update loops now load and store scalar entity fields (their accessors were previously emitted but unused), so scalar rules such as compile to valid executable Flow. Added regression coverage. Full suite remains 1814 passed, 4 skipped.
Correction: generated update loops now load and store scalar entity fields (their accessors were previously emitted but unused), so scalar rules such as mass *= damping compile to valid executable Flow. Added regression coverage. Full suite remains 1814 passed, 4 skipped.
Correctness follow-up: tightened vector-rule recognition so only the exact canonical gravity/friction/forward-motion forms use specialized lowering. Other position/velocity operations now go through component expansion, so position -= velocity * dt preserves subtraction instead of being miscompiled as addition. Focused physics/shader/dynamics tests: 41 passed.
Implemented the documented pairwise collision interaction lowering. An interaction with distance(a, b) guard, normalize(b.position - a.position), and dot(a.velocity - b.velocity, normal) now generates an executable a<b SoA pass with equal-and-opposite velocity impulses and is invoked by the update loop. Unsupported interaction shapes fail explicitly. Physics/shader/dynamics/field focused checks: 48 passed.
Validation follow-up: the interaction block-boundary parser fix prevents later constraints/interactions from being swallowed into an earlier block. The generated canonical collision pass now parses through Flow and C generation. Full suite: 1815 passed, 4 skipped.
End-to-end validation: the module EXAMPLE_DSL now parses into 3 rules and 4 independent constraints, compiles to generated Flow, and passes the Flow parser plus C generator. The canonical interaction fixture also passes that pipeline. Full suite: 1815 passed, 4 skipped.
Physics DSL: only the lexical and layout primitives are in Flow (compiler/src/physics_dsl.flow, tests/lang/test_physics_dsl_port.flow). The Python lowering (compile_physics_to_flow) had no caller outside its own tests and was deleted in Port the remaining Python commands and tools to Flow #1064, so there is no longer anything to port.
Remaining: decide whether a physics DSL front end is wanted. If not, this can close; if so, it is a new feature and should get its own issue.
Closing as obsolete. The Field DSL and dynamics lowering are native in Flow, and the retired Python physics lowering had no caller outside its tests. A future physics DSL front end would be a new feature with a separate issue.
Activity
godofecht commentedon Aug 22, 2026
Progress: #707 already moved the first Field DSL parsing primitives into Flow. #710 now starts the Physics DSL side with native directive classification, simplified field grammar validation, Vec2 recognition, and the exact currently-shipped field stride/offset arithmetic. This does not satisfy the lowering issue yet: remaining work is native spatial allocation/indexing and boundary expansion, differential/Laplacian desugaring, and physics rule/constraint lowering. I am keeping the regex/source-assembly host boundary in Python until those transformations can consume native AST/data rather than re-parsing strings in Flow.
godofecht commentedon Aug 22, 2026
After merged #710, the next AST-independent Physics DSL slice is now concrete from
compile_physics_to_flow:name += expr->name = name + expr;name *= expr->name = name * (expr).position.x/yandvelocity.x/y-> flattened SoA scalar names.clamp(->clamp_f64(substitution.Vec2(x, y)-><name>_x,<name>_y) can follow as another deterministic helper.These can move to native Flow without yet porting the
PhysicsWorldPython object graph or code-generation assembly. The broader world/entity/rule regex parser and complete generated-code emission remain later #682 work.godofecht commentedon Sep 16, 2026
Implemented the next rewrite slice in src/flow/physics_dsl.py: statement-bounded compound assignment lowering (+=, -=, *=, /=), projection flattening for position/velocity x/y, and clamp -> clamp_f64 in both rules and constraints. Added regressions in tests/unit/test_physics_dsl.py. Full suite: 1814 passed, 4 skipped.
godofecht commentedon Sep 16, 2026
Follow-up generator correctness fix: compile_physics_to_flow no longer silently drops valid rule statements. Added component-wise expansion for non-hard-coded Vec2 scale/translation rules and preserves scalar/generated Flow statements. Regression coverage includes damping plus constraint projection/clamp lowering. Full suite: 1814 passed, 4 skipped.
godofecht commentedon Sep 16, 2026
Additional parity fix: generated update loops now load and store scalar entity fields (their accessors were previously emitted but unused), so scalar rules such as compile to valid executable Flow. Added regression coverage. Full suite remains 1814 passed, 4 skipped.
godofecht commentedon Sep 16, 2026
Correction: generated update loops now load and store scalar entity fields (their accessors were previously emitted but unused), so scalar rules such as mass *= damping compile to valid executable Flow. Added regression coverage. Full suite remains 1814 passed, 4 skipped.
godofecht commentedon Sep 16, 2026
Correctness follow-up: tightened vector-rule recognition so only the exact canonical gravity/friction/forward-motion forms use specialized lowering. Other position/velocity operations now go through component expansion, so position -= velocity * dt preserves subtraction instead of being miscompiled as addition. Focused physics/shader/dynamics tests: 41 passed.
godofecht commentedon Sep 16, 2026
Implemented the documented pairwise collision interaction lowering. An interaction with distance(a, b) guard, normalize(b.position - a.position), and dot(a.velocity - b.velocity, normal) now generates an executable a<b SoA pass with equal-and-opposite velocity impulses and is invoked by the update loop. Unsupported interaction shapes fail explicitly. Physics/shader/dynamics/field focused checks: 48 passed.
godofecht commentedon Sep 16, 2026
Validation follow-up: the interaction block-boundary parser fix prevents later constraints/interactions from being swallowed into an earlier block. The generated canonical collision pass now parses through Flow and C generation. Full suite: 1815 passed, 4 skipped.
godofecht commentedon Sep 16, 2026
End-to-end validation: the module EXAMPLE_DSL now parses into 3 rules and 4 independent constraints, compiles to generated Flow, and passes the Flow parser plus C generator. The canonical interaction fixture also passes that pipeline. Full suite: 1815 passed, 4 skipped.
godofecht commentedon Sep 16, 2026
Added native executable coverage for the bundled field DSL core import path. The bootstrap compiler emits, compiles, and runs tests/lang/test_field_dsl_core.flow successfully; focused native field/pattern tests pass.
selfhost: port Field DSL expansion to Flow (#682)
selfhost: port Field DSL expansion to Flow (#682)
godofecht commentedon Sep 30, 2026
State on main (ee5048d):
compiler/src/field_dsl.flow,field_dsl_core.flow), Python expander retired, gatecompiler/scripts/parity_field_dsl.sh../flow run examples/evolution/heat_diffusion.flowexits 0.compiler/src/physics_dsl.flow,tests/lang/test_physics_dsl_port.flow). The Python lowering (compile_physics_to_flow) had no caller outside its own tests and was deleted in Port the remaining Python commands and tools to Flow #1064, so there is no longer anything to port.Remaining: decide whether a physics DSL front end is wanted. If not, this can close; if so, it is a new feature and should get its own issue.
godofecht commentedon Oct 2, 2026
Closing as obsolete. The Field DSL and dynamics lowering are native in Flow, and the retired Python physics lowering had no caller outside its tests. A future physics DSL front end would be a new feature with a separate issue.