feat(dsl): standard library — movement modifiers (p7-s5) - #103
Merged
Conversation
Translates §8.9 into bundled DSL source: the `any_shape`/`common_*_shape` hierarchy §8.9.1.2 prints as DSL, the seven §8.9.19–§8.9.25 enums, and the seventeen modifiers that tune a movement action. With this the whole §8 standard library is declared. Every modifier carries §8.9.1.1's four common parameters — `at`, `movement_mode`, `track`, `shape` — on the strength of "The following parameters are common to all domain model movement modifiers". Five usage signatures omit the `<standard-movement-parameters>` placeholder the other twelve include; the general statement is the normative one, and accepting a parameter the standard permits beats rejecting a valid scenario. The modifiers are actor-associated, which §7.3.12.3 states outright: its example of an actor-associated modifier is `modifier vehicle.keep_lane()`, annotated "keep_lane() is defined in the domain model (see §8.9.16)". Each one goes on the most general actor that can run the actions it tunes — `movable_object`, which owns `move()` and parents both `vehicle` and `person`, or `vehicle` for the lane-related pair §7.3.12.3 places there by name. Association turns out to be what makes the chapter declarable at all. An unassociated `modifier lane` collides head-on with §8.12.10's `struct lane`, and an unassociated `modifier speed` shadows `stdtypes::speed` so thoroughly that `speed_range: range of speed` stops naming a physical type. Under the qualified names neither problem arises. A test pins this so the declarations are not later "simplified" back into a collision. Three modifiers must nonetheless be unassociated. §8.8 declares ACTIONS `movable_object.change_speed`, `movable_object.keep_speed` and `vehicle.change_lane`; §8.9 declares MODIFIERS of the same names for the same actors. A qualified behavior name identifies exactly one declaration (§7.2.2.2.5), so the language cannot hold both. §7.3.12.3's unassociated form is the only spelling that exists and does not collide. The defect is in the standard, not in the translation, and it is recorded in the worksheet, the coverage matrix and a test. 43f's forward-looking guard fired on this, exactly as intended, and is updated rather than deleted: it now pins that an action and a modifier may share a simple name, and points at the collision test for the case they cannot. Second facet added to #100 while probing this chapter: a modifier application inside a `with:` block is not validated at all — a nonsense modifier name is accepted silently. That is the larger half of the gap, since the `with:` block is where the domain model expects nearly every movement modifier to be applied. §8.9 is the surface that fix should be tested against, and p8-s3 (#46) needs it first. 1285 gtest (+7), 184 pytest. The library still checks with zero diagnostics of any severity. Refs #43
8 tasks
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.
Slice 43g of #43, and the last of the library. §8.9 as bundled DSL source: the
any_shape/common_*_shapehierarchy, the seven §8.9.19–§8.9.25 enums, andthe 17 movement modifiers.
With this the whole §8 standard library is declared. Only the CLI and
bindings slice (43i) remains before #43 closes.
The common parameters
Every modifier carries §8.9.1.1's four:
at,movement_mode,track,shape— on the strength of "The following parameters are common to all domain model
movement modifiers."
Five usage signatures (
keep_position,keep_speed,keep_lane,physical_movement,avoid_collisions) omit the<standard-movement-parameters>placeholder the other twelve include. Thegeneral statement is the normative one and the signatures illustrate a typical
call, so all seventeen get them — and over-accepting is the safer error, since
the alternative rejects a scenario the standard permits.
The modifiers are actor-associated, and §7.3 says so
§7.3.12.3's example of an actor-associated modifier is:
The language reference is telling us how this chapter is declared. Each modifier
goes on the most general actor that can execute the movement actions it tunes:
movable_object, which ownsmove()and parents bothvehicleandperson,or
vehiclefor the lane-related pair §7.3.12.3 places there by name.Association is not decoration — it is what makes the chapter declarable. An
unassociated
modifier lanecollides head-on with §8.12.10'sstruct lane, andan unassociated
modifier speedshadowsstdtypes::speedso thoroughly thatspeed_range: range of speedstops naming a physical type. Undervehicle.laneandmovable_object.speedneither problem arises.AssociationIsWhatMakesTheChapterDeclarablepins this, so the declarations arenot later "simplified" back into a collision.
Three modifiers where the standard collides with itself
§8.8 declares actions
movable_object.change_speed,movable_object.keep_speedandvehicle.change_lane. §8.9 declaresmodifiers of the same names for the same actors. A qualified behavior name
identifies exactly one declaration (§7.2.2.2.5), so the language cannot hold
both.
§7.3.12.3's unassociated form is the only spelling that exists in the language
and does not collide, so those three take it. The defect is in the standard
rather than in the translation; it is recorded in the worksheet, in the coverage
matrix, and in
ThreeModifiersAreUnassociatedBecauseTheStandardCollides.43f's forward-looking guard fired on exactly this, which is what it was for. It
is updated rather than deleted: it now pins that an action and a modifier may
share a simple name, and points at the collision test for the case they cannot.
Reported, not fixed — second facet of #100
Probing this chapter found that a modifier application inside a
with:blockis not validated at all:
check_modifier_applicationruns for a scenario-member application but not forthe ones collected in a
withblock. That is the larger half of #100, since thewith:block is where the domain model expects nearly every movement modifierto be applied. Added as a comment there with the §7.3.12.2 scoping rule that
also explains the original symptom.
p8-s3 (#46) needs #100 fixed first, and §8.9 is the surface to test it
against — which is the useful thing this slice hands the next one.
Tests
dsl_stdlib_test.cpp, +7 cases: the shape hierarchy and what eachcompute()returns; the seven enums; all four common parameters on all seventeen
modifiers; the actor association; the three-way collision; the scalar/range
pairs as separate fields with the range one actually a range type; and the
collision guard.
1285 gtest (+7), 184 pytest.
TheBundledLibraryChecksCleanstill assertszero diagnostics of any severity across the now-complete library.
Docs:
osc-dsl-coverage.md,frontends/dsl/README.md, the new worksheet, and anote in the worksheet README that §8.9 is the chapter where the
strip-the-examples trick does not help, because its examples are inline.
Refs #43