Skip to content

Detector: report the window burst, not the session total, for THRASH and RAPID_SCROLL - #53

Open
Orpheus-agent wants to merge 1 commit into
mainfrom
orpheus/daily-improve-20261008-72
Open

Orpheus-agent wants to merge 1 commit into
mainfrom
orpheus/daily-improve-20261008-72

Conversation

@Orpheus-agent

Copy link
Copy Markdown
Collaborator

What this fixes

THRASH and RAPID_SCROLL are "N in windowMs" rules, so they are sliding-window counts. Both fired on a window but reported the length of the whole (session, element) bucket in their summary and severity, so a long calm session with one late burst claimed every event landed inside the window.

Concretely, with five INPUT_CHANGE events in a 2s burst and five more calm changes later on the same field, the detector emitted:

  • before: summary: "10 input changes within 4000ms", severity: 1.0
  • after: summary: "5 input changes within 4000ms", severity: 0.5

The summary is what the friction dashboard and the intervention diagnostic show the customer, and the severity feeds the dispatcher's confidence, which sets how prominently an intervention renders - so both were inflated by events the rule never saw in a window. RAPID_SCROLL's summary had the same defect (N scroll events in 2000ms with N = the whole session).

RAGE_CLICK already had this fixed; the comment in detectRageClicks states the principle: "unrelated earlier clicks must not inflate the severity or the claim about how many clicks occurred in this window." This change extracts that scan into a shared maxInWindow helper and uses it in all three rules.

Detection is unchanged

A window holding >= min events exists iff the same min events fit inside one window, so the thresholds are untouched. RAGE_CLICK is refactored onto the shared helper with no behaviour change; its existing sliding-window tests still pass.

Verification

  • pnpm test - 277 passed (3 new: THRASH windowed summary + severity, a burst late in a long calm session, and RAPID_SCROLL)
  • pnpm typecheck, pnpm lint - clean
  • pnpm sdk:build / sdk:build:min / demo:build - public/demo/demo.js rebuilt (the demo bundles the detector); bundles match the CI freshness check
  • pnpm demo:verify - real guided demo acceptance passes on desktop and mobile

Opened by Orpheus-agent for review; not merged.

…and RAPID_SCROLL

A rule whose threshold is "N in windowMs" is a sliding-window count, so the
number it reports - and the severity derived from it - must be the count it
actually saw inside one window. RAGE_CLICK was already fixed to do this;
THRASH and RAPID_SCROLL still reported the length of the whole (session,
element) bucket.

Concretely: a session with five input changes in a 2s burst and five more calm
changes later produced a THRASH summary of "10 input changes within 4000ms" and
severity 1.0, when the rule fired on the five-change burst. That copy is what
the friction dashboard and the intervention diagnostic show the customer, and
the severity feeds the dispatcher's confidence, which sets how prominently the
intervention renders - so both were inflated by events the rule never saw in a
window. RAPID_SCROLL had the same defect in its summary.

Fix: extract the RAGE_CLICK sliding-window scan into `maxInWindow` and use it in
all three rules, so the reported count and severity are the windowed burst.
Detection thresholds are unchanged: a window holding >= min events exists iff
the same min events fit inside one window. RAGE_CLICK is refactored onto the
shared helper with no behaviour change; its existing tests still pass.

Verified: 277 tests pass (3 new - THRASH windowed summary+severity, a burst
late in a long calm session, and RAPID_SCROLL), plus typecheck, lint, SDK
bundle freshness and the real guided demo acceptance (desktop + mobile).
public/demo/demo.js is rebuilt because the demo bundles the detector.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant