fix: a condition leg is reported once it is held, so a working leg cannot read nan

A finite trigger_time() only says the edge was accepted; the mode is Capturing
until the post window fills. Every field the report prints is read from
display_snapshot(), whose stamps span x = 0 only once the event is Held, so
reporting on the latch alone raced the capture: leg 2 printed
`measured=nan at0=nan ... mode=1` on one run and the documented
`at0=-0.500907 earlier=-0.498185 mode=2` on the next. The report now waits for
Held under the same poll budget, and says `latched but never held` when it runs
out -- a different defect from `no latch`, so the line names which.

The readings are corrected against three consecutive leg-2 runs and one leg-3
run: `t0` is a rebased stream stamp and varies every run, so it was never an
assertion; `hits=` likewise tracks the arm phase (12 at one arm, 11 at another).
The mode ordinals were wrong -- `mode=2` is `Held`, not `Capturing`. Shapes 2
and 3 are now measured rather than read from the arm code; shape 1 still is not.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Martino FerrariandClaude Opus 4.6 committed 2026-10-08 11:34:30 +02:00
1 parent 90d5d0e2d2
commit c8f10f59dc
2 files changed
+40 -12

No files matched your search

+8 -2
View File
@@ -8975,9 +8975,15 @@ gboolean condition_probe_report(gpointer user) {
App* a = static_cast<App*>(user);
if (a->window == nullptr) return G_SOURCE_REMOVE;
const double t0 = a->model->trigger_time();
if (!std::isfinite(t0) || t0 <= 0.0) {
// A finite `t0` only says the edge was *accepted*: the mode is `Capturing` until the post
// window fills. Every field below is read from `display_snapshot()`, whose stamps span x = 0
// only once the event is `Held`, so reporting on the latch alone races the capture and
// prints `nan` for a leg that is working. Both waits share the one poll budget.
if (!std::isfinite(t0) || t0 <= 0.0 || a->model->display_mode() != DisplayMode::Held) {
if (++g_condition.waited < 200) return G_SOURCE_CONTINUE;
std::fprintf(stderr, "[condition-probe] no latch after %d polls\n", g_condition.waited);
const bool latched = std::isfinite(t0) && t0 > 0.0;
std::fprintf(stderr, "[condition-probe] %s after %d polls\n",
latched ? "latched but never held" : "no latch", g_condition.waited);
std::fflush(stderr);
return G_SOURCE_REMOVE;
}