mirror of
https://github.com/ruvnet/RuView
synced 2026-08-06 19:51:43 +00:00
fix(homecore-automation): start engine + implement time/run-mode/choose/template (ADR-161 A3-A7)
A3 (HIGH): homecore-server constructed AutomationEngine then dropped it immediately while the doc claimed automation was active. Now .start()s the engine into a long-lived binding (event loop + timer task). A4 (HIGH): Trigger::Time was hard-coded false with no timer. Added a 1 Hz wall-clock timer task that fires time: automations when local HH:MM:SS matches 'at' (HH:MM or HH:MM:SS); matches_sync(Time)=false is now correct + documented. A5 (HIGH): RunMode was documented as AtomicBool-enforced but every trigger spawned unbounded parallel. Each automation now carries a running AtomicBool; Single/IgnoreFirst skip re-entrant triggers, Parallel fires every time. (Bounded Queued/Restart/max → ACCEPTED-FUTURE, honestly stated in the doc.) A6 (HIGH): Action::Choose discarded choices and always ran default. Now deserialises each branch's conditions, evaluates them, and runs the first matching branch; default only if none match. A7 (MEDIUM): template: conditions were always false in the engine path (EvalContext built with template_env: None). The engine now builds a TemplateEnvironment over the state machine and threads it into every EvalContext (event loop, timer, Choose). Tests (fail on old source): - engine_behaviors::time_trigger_fires_via_timer_path (A4) - engine_behaviors::single_mode_does_not_double_fire_on_rapid_triggers (A5; old fired 2x) - engine_behaviors::parallel_mode_does_fire_concurrently (A5) - action::choose_runs_matching_branch_not_default (A6; old ran default) - engine_behaviors::template_condition_evaluates_true_in_engine (A7; old always false) engine.rs kept <500 lines; behavioral tests moved to tests/engine_behaviors.rs. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -150,7 +150,12 @@ impl Trigger {
|
||||
true
|
||||
}
|
||||
Trigger::Time { .. } => {
|
||||
// Time triggers are evaluated by the engine's timer task, not here.
|
||||
// Time triggers are wall-clock based and have no state-change
|
||||
// context to match here. They are evaluated by the engine's
|
||||
// 1 Hz timer task (`AutomationEngine::start_timer`, HC-WS-04 /
|
||||
// ADR-161), which compares the trigger's `at` against the local
|
||||
// wall-clock second. `matches_sync` therefore returns false for
|
||||
// `Time` on the state-change path by design.
|
||||
false
|
||||
}
|
||||
Trigger::Event { event_type } => {
|
||||
|
||||
Reference in New Issue
Block a user