Skip to content

Fail closed when Grok STT words is not a JSON array - #149

Open
jmjava wants to merge 2 commits into
mainfrom
cursor/grok-stt-words-list-2ccd
Open

Fail closed when Grok STT words is not a JSON array#149
jmjava wants to merge 2 commits into
mainfrom
cursor/grok-stt-words-list-2ccd

Conversation

@jmjava

@jmjava jmjava commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Problem

_grok_stt treated parsed.get("words") or [] as a list and skipped any
non-dict item. A string words field was iterated character-by-character, and
a scalar/list item inside words/segments silently dropped that token. Whisper
word indices and wait_word then pointed at the wrong spoken times.

This is the leftover from PR #146 (_stt_json_number on start/end did not
cover the list shape).

Fix

  • Present words / segments must be JSON arrays.
  • Each item must be a JSON object (words[i] / segments[i]).
  • Missing or null words still becomes [] (no word-level timestamps).
  • Empty segments: [] still synthesizes a segment from words (or duration).

Tests

  • test_grok_stt_string_words_raises
  • test_grok_stt_non_object_word_raises
  • test_grok_stt_object_segments_raises
  • test_grok_stt_missing_words_still_ok

Local: ruff check src/ tests/ green; pytest tests/ -v --tb=short 825 passed, 1 skipped;
docgen benchmark meets src/docgen/benchmark_data/baseline.json (no --update-baseline).

Out of scope

Open in Web Open in Cursor 

A string words field iterated characters and wrote empty timing.json.
Non-object items were skipped, shifting token indices. Require arrays of
objects; missing words still means no word stream.

Co-authored-by: jmjava <jmjava@gmail.com>
@jmjava
jmjava marked this pull request as ready for review September 8, 2026 01:19
Co-authored-by: jmjava <jmjava@gmail.com>
@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Stopping this loop. This is another sibling fail-closed type check, not product progress. Do not reopen. Do not mint #150.

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.

2 participants