Fix: regional trigger threshold proximity for lt/lte operators#3656
Fix: regional trigger threshold proximity for lt/lte operators#3656FayezBast wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes
Confidence Score: 4/5Safe to merge — the bug fix is logically correct, watching windows are mutually exclusive from the active check, and the new tests cover the previously broken paths. The operator-aware band logic is correct for all four comparison operators and for negative thresholds. The only gap is that tests/regional-snapshot.test.mjs — the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[evaluateTriggers] --> B{resolveMetric}
B -- null --> C[dormant]
B -- value --> D{evaluateThreshold}
D -- true --> E[active]
D -- false --> F{isCloseToThreshold}
F --> G{operator?}
G -- gt/gte --> H["value < target AND value >= target - band"]
G -- lt/lte --> I["value > target AND value <= target + band"]
G -- delta_gt/delta_lt --> J[false]
G -- default --> J
H -- true --> K[watching]
I -- true --> K
H -- false --> C
I -- false --> C
J --> C
style E fill:#f44,color:#fff
style K fill:#fa0,color:#000
style C fill:#888,color:#fff
Reviews (1): Last reviewed commit: "Fix: regional trigger threshold proximit..." | Re-trigger Greptile |
| it('keeps gt/gte watching semantics for positive thresholds', () => { | ||
| assert.equal(isCloseToThreshold(0.85, { operator: 'gte', value: 1.0 }), true); | ||
| assert.equal(isCloseToThreshold(1.0, { operator: 'gte', value: 1.0 }), false); | ||
| }); |
There was a problem hiding this comment.
The
gt operator is never tested against a positive threshold in isolation — only gte is used in the "keeps gt/gte watching semantics" test, and gt with a negative target is exercised in the negative-threshold test. Since gt and gte share the same switch branch this is low risk, but a single positive-gt assertion would close the gap and guard against any future divergence between the two cases.
| it('keeps gt/gte watching semantics for positive thresholds', () => { | |
| assert.equal(isCloseToThreshold(0.85, { operator: 'gte', value: 1.0 }), true); | |
| assert.equal(isCloseToThreshold(1.0, { operator: 'gte', value: 1.0 }), false); | |
| }); | |
| it('keeps gt/gte watching semantics for positive thresholds', () => { | |
| assert.equal(isCloseToThreshold(0.85, { operator: 'gte', value: 1.0 }), true); | |
| assert.equal(isCloseToThreshold(1.0, { operator: 'gte', value: 1.0 }), false); | |
| assert.equal(isCloseToThreshold(0.85, { operator: 'gt', value: 1.0 }), true); | |
| assert.equal(isCloseToThreshold(1.0, { operator: 'gt', value: 1.0 }), false); | |
| }); |
Summary
Fixes regional trigger threshold proximity detection for
lt/lteoperators. The previous helper only worked correctly for upward thresholds (gt/gte), which could hide near-breach regional intelligence triggers that move downward toward a threshold.Adds focused regression coverage for
lt,lte,gte, negative thresholds, and dormantdelta_*operators.Type of change
Affected areas
Checklist
npm run typecheck)