Add RSVP speech scoring and failure safeguards - #131
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds position-aware scoring for RSVP automatic speech responses, including multilingual transcript normalization and token-to-target alignment, and introduces safeguards so technical speech failures are treated as invalid (not incorrectly scored) while preserving existing non-speech modes.
Changes:
- Add Unicode- and language-profile-based speech transcript normalization (English/Persian/Arabic) and deterministic token alignment.
- Implement RSVP speech scoring with policy controls (word order, repetition, self-correction) and rich diagnostics.
- Add runtime lifecycle safeguards (cleanup on skip/failure, provider language mapping from condition language) and trial validity gating for QUEST consumption.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| threshold.js | Updates RSVP-reading block instructions and records/acts on RSVP speech preparation success. |
| components/trialRoutines.js | Uses RSVP speech validity rules to decide QUEST validity and whether to consume target word sets. |
| components/rsvpReading.js | Closes active RSVP speech resources when skipping due to bad tracking. |
| components/instructions.js | Adds instruction text helpers for automatic speech RSVP reading. |
| components/rsvpSpeech/rsvpSpeechRuntime.ts | Renames language mapping to condition language; adds close-tracking to avoid controller lifecycle races; improves cleanup on failures. |
| components/rsvpSpeech/rsvpSpeechValidity.ts | Introduces explicit validity/consumption rules for automatic speech trials (pre/post exposure failures, missing registrations). |
| components/rsvpSpeech/rsvpSpeechScoring.ts | Adds RSVP speech scoring pipeline (normalize → align → classify → score) with diagnostics and policy enforcement. |
| components/speech/textNormalization.ts | Implements language profiles and Unicode-aware normalization/tokenization with join-control handling. |
| components/speech/tokenAlignment.ts | Implements monotonic, position-aware alignment with special handling for Persian join/split patterns and diagnostics. |
| tests/tokenAlignment.test.ts | Adds alignment behavior tests (ordering, duplicates, Persian join/split, merged tokens). |
| tests/textNormalization.test.ts | Adds normalization/tokenization tests across English/Persian/Arabic scripts and punctuation cases. |
| tests/rsvpSpeechScoring.test.ts | Adds scoring/policy tests and multilingual edge cases, including Persian-specific behavior. |
| tests/rsvpSpeechValidity.test.ts | Adds validity matrix tests for runtime failure states vs QUEST consumption. |
| tests/rsvpSpeechRuntime.test.ts | Updates runtime tests for renamed language resolver and adds lifecycle/cleanup tests. |
| tests/lifetime.test.ts | Updates global mocks to include RSVP speech runtime state. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+4629
to
+4645
| let rsvpReadingBlockInstructs = | ||
| initialInstructions + | ||
| (automaticSpeechOnly | ||
| ? instructionsText.rsvpReadingAutomaticSpeechBegin( | ||
| L, | ||
| responseType.current, | ||
| totalTrials, | ||
| ) | ||
| : instructionsText.initialByThresholdParameter["timing"]( | ||
| L, | ||
| responseType.current, | ||
| totalTrials, | ||
| )); | ||
| if (automaticSpeechModes.length > 0 && !automaticSpeechOnly) { | ||
| rsvpReadingBlockInstructs += | ||
| instructionsText.rsvpReadingAutomaticSpeechResponse(L); | ||
| } |
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.
Summary
Testing