Repository navigation
Detector: fire REPEAT_SEARCH at its declared minimum - #52
Open
Orpheus-agent wants to merge 1 commit into
Open
Orpheus-agent wants to merge 1 commit into
Orpheus-agent wants to merge 1 commit into
Conversation
detectRepeatSearch used `arr.length > rule.minRepeats`, so with the default
`minRepeats: 2` a query had to be searched three times before REPEAT_SEARCH
fired. Every other count rule in the detector fires at its declared minimum
(`minPastes`, `minToggles`, `minDismisses`, `minRetries`…), and the
REPEAT_SEARCH copy ("Same query? Try a different phrasing or a filter") is
written for the smallest possible repeat. A user who searched the same thing
twice therefore produced no detection at all - nothing on the friction
dashboard, no intervention. Fire at `>= minRepeats` and pin it with a
regression test.
The guided demo bundles the production detector client-side, so
public/demo/demo.js is rebuilt from the same source to keep the checked-in
bundle in sync (CI's stale-bundle check enforces this).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
detectRepeatSearchfired one search past its declared minimum:With
minRepeats: 2, a query had to be searched three times beforeREPEAT_SEARCHwas produced. Every other count rule insrc/lib/struggle/detect.tsfires at its declared minimum —minPastes: 2fires on the 2nd paste,minToggles: 3on the 3rd toggle,minDismisses: 2/minRetries: 2on the 2nd, and so on. This was the only rule using>rather than>=/< … continue.Why it matters
The smallest possible repeat — a user running the same query twice — is exactly the case the
REPEAT_SEARCHintervention copy is written for ("Same query? Try a different phrasing or a filter."). Because the rule never fired on it, that user produced no detection at all: nothing on the friction dashboard and no dispatched intervention.Change
Fire at
>= minRepeats:A regression test (
tests/struggle.test.ts,detectStruggles - repeat search) pins the behaviour: it fails on the current code (expected +0 to be 1) and passes with the fix. It also asserts the rule does not fire for two different queries, and still emits a single detection per (session, element, type).public/demo/demo.jsis rebuilt from the same source because the guided demo bundles the production detector client-side; CI's stale-bundle check enforces that the checked-in bundle matches a fresh build.Verification
pnpm typecheck— cleanpnpm lint— cleanpnpm test— 277 passed (274 baseline + 3 new); the new "fires on the second identical search" test was confirmed to fail against the pre-fix codepnpm sdk:build/sdk:build:min/demo:build— SDK bundles unchanged;demo.jsrebuilt and deterministic across two buildspnpm sdk:verify,pnpm demo:verify(real Chromium, desktop + mobile) — passpnpm build— production build succeedsOpened for review by Orpheus-agent; not auto-merged.