Skip to content

feat: action conflicts, override by event & bulk actions (§7.5) (#51) - #85

Merged
JArmandoAnaya merged 1 commit into
mainfrom
feat/p5-s4-action-conflict-bulk
Aug 1, 2026
Merged

JArmandoAnaya merged 1 commit into
mainfrom
feat/p5-s4-action-conflict-bulk

Conversation

@JArmandoAnaya

Copy link
Copy Markdown
Contributor

Completes what ADR-0005 deferred and p5-s4 only partly delivered.

Which actions conflict

ir::ActionDomain + control_domains() are Annex A Table 10 and §7.4.1.1
written down once. control_domains takes an Action, not a kind string,
because §7.4.1.2 makes the classification settings-dependent:

LaneChangeActions, SpeedAction, LaneOffsetAction may be used to set a state,
if used with the step dynamic option. In this particular use case, these
actions do not assign a control strategy as the changes are enacted
instantaneously.

Behavior change: a Step-shaped SpeedAction fired while a ramp is running
no longer overrides it. It writes the speed and completes; the ramp — never in
conflict with it — resumes from its own schedule on the next step. The engine
reports this the first time it happens on an entity, citing §7.4.1.2: writing a
value a control strategy erases one step later is rarely the authored intent,
and §7.5.2.2 asks implementations to warn about unintended behavior rather than
reject a valid file. In Init, where nothing else runs, nothing is reported.

Two tests asserted the old rule and were rewritten. One now uses a shaped
action — the actual conflict case — so supersession stays covered; the other
asserts the new Step behavior and the diagnostic.

Override by event (§7.5.2.1)

This was missing entirely: a stopped event marked its element Complete and left
the engine still driving the entity from an action the storyboard had forgotten.

Scheduler::step gains an optional StopCallback. stop_cascade calls it for
every action still in an event's running set, in document order, before marking
the element Complete. The scheduler owns element state and knows nothing about
entities; only the engine knows a given action held a longitudinal controller or
a trajectory follower, so Engine::stop_action releases exactly the domains
that action owned and leaves the entity where the release found it.

Never-ending actions end this way too — §7.5.3 says every ending but the regular
one applies to them, and now that is true in practice.

The existing step overloads are unchanged and pass a no-op.

Bulk actions (§7.5.4, §8.3.3.3)

ir::Action gains bulk_group(). The XML frontend already lowers a private
action once per actor of its ManeuverGroup; it now stamps those instances with a
shared id from a per-document counter, so the ids depend on document order alone.

One instance per actor means completion needed no new code: the instances
share an Event, and an Event already ends only when all of its actions have
(§8.3.3.1) — exactly §8.3.3.3's join. The id is load-bearing for one rule:

If any of the corresponding instances of Entity sparks a conflict ... all its
instances of Entity are supposed to fall back to default behavior
simultaneously.

retire_bulk_siblings walks the entity table (a std::map, so entity-id order
on every platform) and retires every owner in the group. Retiring is itself a
supersession and superseding propagates to the group, so one guard breaks the
recursion.

Surface

No C ABI or bindings change — scheduler.h is a core header, not a stability
commitment. ir::Action grows one std::size_t, set while a scenario is built
and never during execution.

Tests and docs

11 new gtest cases (899 → 910) in action_conflict_test.cpp (domain
classification, override-by-event including a never-ending action, bulk override
/ bulk stop / bit-identity) and xml_storyboard_test.cpp (shared group ids).
ADR-0025; the storyboard guide gains an action-conflict section with the domain
table; the §7.5 coverage row flips to landed.

Local: 910/910 gtest, 164/164 pytest, detmath guard, coverage-matrix checker and
clang-format green.

Closes #51

Completes what ADR-0005 deferred and p5-s4 only partly delivered.

Which actions conflict is now Annex A Table 10 written down once, in
ir::ActionDomain + control_domains(). It takes an Action, not a kind,
because §7.4.1.2 makes the classification settings-dependent: an action
'used with the step dynamic option ... does not assign a control strategy
as the changes are enacted instantaneously'. So a Step-shaped SpeedAction
no longer overrides a running ramp — it writes the speed and completes,
and the ramp resumes on the next step. That is a behavior change; it is
reported when it happens mid-run, because a value something else erases a
step later is rarely the authored intent, and §7.5.2.2 asks implementations
to warn rather than reject. Two tests that asserted the old rule were
rewritten, one of them onto a shaped action — the real conflict case.

Override by event (§7.5.2.1) was missing entirely: a stopped event marked
its element Complete and left the engine driving the entity from an action
the storyboard had forgotten. The scheduler now reports every action a
stopTransition ends, in document order, and the engine releases exactly the
domains that action held. Never-ending actions end this way too (§7.5.3).

Bulk actions (§7.5.4, §8.3.3.3): instances of one authored private action
share an ir::Action::bulk_group. Completion needed no code — the instances
share an Event, and an Event already ends only when all its actions have,
which is §8.3.3.3's join. The id is load-bearing for one rule: a conflict
on any actor retires every instance, so they fall back together.

Scheduler::step gains a StopCallback overload; the existing ones pass a
no-op. No C ABI or bindings change.

11 new gtest cases (910) in action_conflict_test.cpp and
xml_storyboard_test.cpp, ADR-0025, the storyboard guide and the coverage
row.

Closes #51
@JArmandoAnaya
JArmandoAnaya merged commit ce7752b into main Aug 1, 2026
9 checks passed
@JArmandoAnaya
JArmandoAnaya deleted the feat/p5-s4-action-conflict-bulk branch August 1, 2026 15:00
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.

[p5-s4] Action conflict resolution, continuous actions & bulk actor semantics (§7.5)

1 participant