Skip to content

Test Suite 5 — Threshold set commands & release follows trigger

mchristegh edited this page Jul 10, 2026 · 1 revision
Harness function suite5() in test-scripts/test-harness.js
Checks 22 (the # column below reconciles)
Kind Synchronous

Proves the runtime threshold machinery: the release-follows-trigger rule, the symmetric wrong-side guards in both directions, boolean-mode overrides, the blank-config parsing regressions, and the inverted-configured-pair sanitization guard.

Baseline config (applies unless a scenario says otherwise): plain numeric node — mean aggregation, Above-mode, quorum and staleness disabled, Emit aggregate on change only checked, heartbeat off, persistence off; thresholds per scenario.

Traceability convention: the Check column is the harness's literal PASS/FAIL string — a failing line in the test output can be searched in this document verbatim. This document moves with the harness: a new, renamed, or removed check lands here in the same change.


5.1 Release-follows-trigger free move

Config: no hysteresis (trigger 60, release 60). One reading of 45, then settrigger 40.

# Check Protects
1 no-hysteresis settrigger 40 applies (release-follows-trigger) With no distinct release, settrigger moves freely — it can never self-invalidate
2 set-command re-evaluates in place (45 >= 40 triggers immediately) Set-commands take effect immediately, not on the next reading
3 release FOLLOWED the trigger (39 < 40 releases) The effective release tracked the moved trigger dynamically

5.2 Symmetric wrong-side guards

Config: hysteresis pair (trigger 60, release 55).

# Check Protects
4 non-numeric settrigger rejected with attempted value Invalid values are observable rejections (triggerSet carries the attempt)
5 wrong-side settrigger (50 < release 55) rejected With a distinct release, settrigger is guarded — an inverted pair would flap outputs 1/2
6 wrong-side setrelease (75 > trigger 60) rejected The mirror guard on setrelease, against the effective trigger
7 ordered pair move down (setrelease first) applies both The documented pair-move ordering works: move in the direction that keeps the pair valid at each step

5.3 Below-mode mirror

Config: Below-mode (trigger 5, release 8).

# Check Protects
8 below-mode wrong-side settrigger (10 > release 8) rejected The guard's inequality flips correctly with the trigger direction
9 below-mode valid settrigger 6 applies …without over-rejecting valid values

5.4 Boolean-mode overrides

Config: boolean node, All trigger rule, Same as trigger release.

# Check Protects
10 boolean atleastn without count rejected The atleastn preset requires its count (msg.settriggern)
11 atleastn(2) override: 1 true does not trigger A preset override replaces the configured rule (All would not have triggered either here — the next row discriminates)
12 atleastn(2) override: 2 true triggers 2-of-3 true fires under the override where the configured All rule would not — the override is live
13 boolean fraction release override (1/3 < 0.34 releases) A numeric fraction is a valid release override, compared strictly

5.5 Blank-config parsing regressions

Fresh nodes configured with blank threshold fields (the Number("") === 0 hazard).

# Check Protects
14 blank release: trigger still fires at the trigger value Blank release doesn't disturb the trigger side
15 blank release behaves as same-as-trigger (59 < 60 releases; a phantom 0 would never release) Blank must mean same-as-trigger — the phantom-zero bug would latch forever
16 blank trigger never triggers (null, not a phantom 0) Blank trigger is unset, not a threshold of zero

5.6 Inverted configured pair: constructor sanitization

Nodes constructed with the release on the wrong side of the trigger.

# Check Protects
17 valid configured pair does not warn The guard has no false positives
18 inverted pair (above-mode) warns exactly once A configuration defect gets the node's single legitimate node.warn
19 sanitized pair triggers normally (55 >= 50) Sanitization preserves the trigger side untouched
20 sanitized pair does NOT flap (52 stays latched; unsanitized release 63 would fire here) The discriminating check: the exact flapping failure the guard exists to prevent
21 sanitized release follows trigger (49 < 50 releases) The ignored release falls back to release-follows-trigger, not to nothing
22 inverted pair (below-mode) warns too The guard mirrors with the trigger direction

Clone this wiki locally