fix: a clock glitch is bridged and a channel is known by name, so a capture keeps its t0
Two defects behind one report ("a trigger during a capture overrides the first,
and the hold-off does not apply"); the second is also what made a spike in one
channel look like the acquisition resetting.
The trigger engine keyed its invalidation on the trigger channel's *index*, which
every rebuild of the channel list renumbers -- enabling a signal that sorts before
it is enough. Any rebuild therefore abandoned an open capture and set no hold-off,
so the next edge inside the post window became t0. It keys on the channel's name
now, which changes only when the source genuinely does.
A packet whose stamps jump more than 256 packet spans ahead is now rejected as a
fault and *bridged* at the declared cadence, instead of poisoning the monotonic
mark (which pinned every later packet flat at the glitched value) and condemning
the next good packet. Only four consecutive failures abandon the declared time
signal, and that fallback no longer wipes the rings: the arrival clock is anchored
to continue from the monotonic mark, so the history is still on one timeline --
the wipe is what made one glitching packet look like the stream restarting from 0.
The declared unit is resolved before those checks, since they weigh the stamps
against a cadence in seconds.
Guards: UDPSCOPE_PROBE_TRIGRENUM_MS prints t0_held=1 through the real widgets,
and the mock's --time-glitch-at/--time-glitch-by injects the clock fault.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
4003084648
commit
f179fbbb44
13 files changed
+406
-96
No files matched your search
@@ -36,6 +36,36 @@ Part of [CLAUDE.md](../../CLAUDE.md). These are rules that cost a defect to lear
|
||||
length. The LOD min/max pyramid still preserves the extremes *of what is stored*; a spike
|
||||
narrower than a group is now filtered away rather than aliased, which is the correct
|
||||
trade and is why the status line's `rate` field is worth reading.
|
||||
- **One bad packet is bridged; only a run of them changes the time source.** The stream-time
|
||||
checks in `build_stamps()` reject three things: stamps that are not finite, a packet with no
|
||||
span at all, and a packet whose stamps do not advance past the previous packet's last. A
|
||||
fourth was added because a real device's clock glitches: a packet whose stamps jump **more
|
||||
than 256 packet spans** ahead is a fault, not a gap, and must be rejected — letting it
|
||||
through poisons `last_stamp_`, and the monotonic clamp (`max(stamps[k] - epoch,
|
||||
last_stamp_)`) then pins every later packet flat at the glitched value, so the whole stream
|
||||
freezes at one x and never recovers. A rejected packet is **bridged**: its stamps are
|
||||
replaced by a continuation of the accepted timeline at the declared cadence, so neither the
|
||||
monotonic mark nor `last_stream_anchor_` is poisoned and the next good packet is accepted
|
||||
normally. Believing the glitch instead is what condemned the *next*, perfectly good packet
|
||||
(it now sits below the poisoned anchor, so it fails the advance test) and threw the whole
|
||||
stream onto the arrival clock. Only **four consecutive** rejected packets abandon the
|
||||
declared time signal, because that is what a signal which is not a time base at all looks
|
||||
like; a first packet with nothing to bridge from still falls back immediately. The unit
|
||||
scale ('ns', 'us', 'ms') is therefore resolved **before** these checks rather than after:
|
||||
they weigh the stamps against a cadence in seconds, and on a 'ns' stream an unscaled
|
||||
comparison is off by 1e9, so every packet would read as an implausible jump. The guard is
|
||||
`tools/mock_udpstreamer.py --time-glitch-at`/`--time-glitch-by` (see
|
||||
[verification.md](verification.md)).
|
||||
- **The arrival-clock fallback does not drop history.** `arrival_epoch_` is derived from
|
||||
`last_stamp_`, so the arrival clock *continues* from the monotonic mark and the two
|
||||
timelines share a zero by construction — the recorded stamps are therefore still on one
|
||||
timeline and are kept. The fallback used to call `reset_live_history_locked()` on the
|
||||
reasoning that the old stamps belonged to a dead clock; they do not, and that wipe is what
|
||||
made a single glitching packet look like "the live stream restarted from 0 with no action
|
||||
from the user". The continuity is also what makes a rebase of `TriggerEngine` unnecessary:
|
||||
the engine holds four absolute stamps (`holdoff_until_s_`, `pending_start_s_`,
|
||||
`last_trigger_s_`, `last_t_s_`) and they stay valid across the change. Anything that makes
|
||||
the clock *discontinuous* breaks that and has to reset them.
|
||||
- **The trigger sees the stored (filtered) signal, not the wire signal.** `engine.process()`
|
||||
is fed the averaged value, inside the `if` that pushes it. An edge found on a sample that
|
||||
is not in the buffer would be cut from data that does not contain it.
|
||||
|
||||
Reference in new issue
Block a user