← Back to Pull requests

feat(wordlist): novice-readiness Phase 7 — one word-list parser everywhere, Search needs a list, normalize keeps letters #87

Merged
apassuello merged 20 files (1274 lines) on Oct 25, 2026 15:06 UTC
View on GitHub
apassuello apassuello commented on Oct 25, 2026 13:22 UTC
Author

Novice-readiness Phase 7: word lists and CLI. This implements spec §4 items 1–3 (docs/superpowers/specs/2026-10-23-novice-readiness-design.md, now 0.2.14) as plan Tasks 7.1–7.7 pin them, plus 7.8–7.8c for the review fixes.

What changes for a user

  • Accented words fold to A–Z everywhere a list is read (§4 item 1, L11): CAFÉ → CAFE, NAÏVE → NAIVE, fullwidth CAT → CAT. A word that still holds a non-A–Z letter after the fold (STRAßE, ÆON, BJØRN, Greek) is skipped with reason not letters only. One parser now serves the solver (fill, pattern, resume), the upload preview, theme-word matching, Verify, Clean and the Lists panel (backend/core/wordlist_reader.py). Before this, Verify and Clean had their own split(";") loops, so they disagreed with what Autofill would place, and the Lists panel showed NAÏVE,40 as one word.

  • A word-list cache written before the fold is never served (CACHE_VERSION = 2). Such a cache falls back to the text list with a warning until build-cache is re-run.

  • Search needs a word list (§4 item 2, SR4): with none ticked, Search is disabled and shows Select at least one word list, and Enter sends nothing. POST /api/pattern and /api/pattern/with-progress answer an explicit wordlists: [] with 400 NO_WORDLIST, so the CLI's built-in demo list can't be reached from the API either. An absent key still means ["comprehensive"].

  • normalize's default rule keeps letters only (§4 item 3): Hello, World! → HELLOWORLD, naïve → NAIVE, Straße → STRASSE, no letters → "". The named rules are unchanged.
  • Owner rulings recorded in the spec (2026-10-25)

  • 0.2.12: Q10 option (a), NO_WORDLIST on the pattern routes; §8 PD-L7 ruled as written.

  • 0.2.13: normalize uppercases with str.upper(), so ß → SS. This deliberately differs from the word-list parser, which skips ß.

  • 0.2.14: the Lists panel's edits identify a word by the folded word the list shows (Greptile P1 on this PR); an add keeps that line and never uppercases ß into SS.
  • Behaviour changes worth knowing

  • 6 lines of data/wordlists/themed/foreign_words.txt no longer load (CŒUR, SŒUR, ŒIL, ŒUVRE, ŒUFS, SŒURS): Œ has no NFKD decomposition, the same class as Æ/Ø. No other tracked list loads a different word (measured in Task 7.1).

  • WordListManager.load raises on a list it can't read whole, as before; Verify and Clean keep their skip-and-continue.

  • cleanup_old_states' DST fix came from #86 and is not part of this diff.
  • Verification

    Each gate was run alone and in sequence, all rc 0: pytest, pytest -m slow, bash scripts/docs-check.sh and bash scripts/check-guards.sh --full-tree at df8db43; npx vitest run and npm run build at 8fd21e5 (nothing after it touches src/). After the rebase onto main, docs-check and check-guards --full-tree pass again, and the pre-push hook re-runs pytest and vitest on this tree. After 7.8–7.8c, at 7c31489, each alone, all rc 0 / no failures: pytest (2333 passed), pytest -m slow (90 passed), docs-check, check-guards; nothing after 8fd21e5 touches src/. Every task's test was written first and failed at its own assertions, and a reverting mutation was checked. Evidence is in the per-task reports.

    Browser check (Chrome, servers from this branch): Search enabled by default; unticking the last list disables it and shows the hint; Enter sends no request; re-ticking sends POST /api/pattern/with-progress and shows results. Over HTTP: [] → 400 NO_WORDLIST on both routes, unknown name → 400 UNKNOWN_WORDLIST, absent key → results.

    Issues

    Closes #51: its remaining items were Verify/Clean's loaders and WordListManager, and all three now read through WordList.parse_line. The list edits follow (spec 0.2.14): add_words and remove_words identify a line by the folded word the list shows (line_key in backend/core/wordlist_reader.py), so removing CAFE removes a stored CAFÉ;50, adding APPLE to a file holding apple,50 keeps one line, an add no longer rewrites a skipped STRAßE as a valid STRASSE, and it keeps the valid line when a malformed one (GRAPE;abc) shares its word.

    Issue 57: items 1–3 (L11, SR4, CLI-normalize) are settled here. Item 4 (TH4, theme placements) is not part of this PR, so 57 stays open.

    Not changed (recorded, not filed)

  • /fill/with-progress, verify-words, clean and resume still accept wordlists: []. /fill/with-progress then runs the CLI with no list, so Autofill searches the demo list. Only the API can reach this: the Autofill panel disables Start with the same hint. Owner default: unchanged.

  • fill's explicit theme entries (theme_entries_dict) place letters unfolded.

  • list_states' displayed age has the same one-hour DST error #86 fixed in cleanup.
  • Diff: 1274 lines (+1171 / -103) across 20 files Reviewer: apassuello Review duration: 104m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.86) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.86 · 1274 lines diff across 20 files
    0.86
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 4 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    83%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    5 items
    greptile-apps[bot] greptile-apps[bot] commented on Oct 25, 2026 13:26 UTC
    Bot

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=87650754"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/apacorp/github/apassuello/crossword-helper/-/pull/87"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2>

    [High impact] The PR appears safe to merge; the previous removal issue is fixed and no new blocking issues were found.

    <h3>Summary</h3>

    The PR makes word-list reads agree, requires a selected list for Search, and changes the default normalize rule to keep folded letters.

  • Every word-list reader now uses the solver's folded A–Z rules.

  • Pattern Search stops when no word list is selected.

  • Default normalization now keeps letters and drops punctuation.
  • <!-- greptile_confidence_score:5 -->

    <sub>Reviews (2) · Last reviewed commit: "fix(wordlists): an add keeps the line th..." · Reviewed by Greptile</sub>

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 25, 2026 13:26 UTC
    Code Review
    backend/data/wordlist_manager.py:1
    @@ -76,13 +80,7 @@ def load(self, name: str) -> List[str]:
             if not filepath.exists():
                 raise FileNotFoundError(f"Wordlist '{name}' not found at {filepath}")
     
    -        words = []
    -        with open(filepath, "r", encoding="utf-8") as f:
    -            for line in f:
    -                line = line.strip()
    -                # Skip comments and empty lines
    -                if line and not line.startswith("#"):
    -                    words.append(line.split(";", 1)[0].strip().upper())
    +        words = read_wordlist_words_ordered(filepath, strict=True)

    <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> Returned words cannot be removed

    load() now returns CAFE for a stored CAFÉ;50, but remove_words() still compares the requested word against the original spelling before ;. An API client that reads the list and sends {"remove_words": ["CAFE"]} gets a successful response, yet the word remains. The same mismatch affects comma-scored lines.

    Make removal use the shared parser and canonical spelling while keeping untouched lines as written.

    <a href="https://app.greptile.com/ide/claude-code?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20backend%2Fdata%2Fwordlist_manager.py%0ALine%3A%2083%0A%0AComment%3A%0AReturned%20words%20cannot%20be%20removed%0A%0A%60load%28%29%60%20now%20returns%20%60CAFE%60%20for%20a%20stored%20%60CAF%C3%89%3B50%60%2C%20but%20%60remove_words%28%29%60%20still%20compares%20the%20requested%20word%20against%20the%20original%20spelling%20before%20%60%3B%60.%20An%20API%20client%20that%20reads%20the%20list%20and%20sends%20%60%7B%22remove_words%22%3A%20%5B%22CAFE%22%5D%7D%60%20gets%20a%20successful%20response%2C%20yet%20the%20word%20remains.%20The%20same%20mismatch%20affects%20comma-scored%20lines.%0A%0AMake%20removal%20use%20the%20shared%20parser%20and%20canonical%20spelling%20while%20keeping%20untouched%20lines%20as%20written.%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=apassuello%2Fcrossword-helper&pr=87&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaudeDark.svg?v=7"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=7"><img alt="Fix in Claude Code" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=7"></picture></a>

    apassuello apassuello commented on Oct 25, 2026 14:58 UTC
    Author

    @greptile

    apassuello apassuello commented on code on Oct 25, 2026 14:59 UTC
    Code Review
    backend/data/wordlist_manager.py:1
    @@ -76,13 +80,7 @@ def load(self, name: str) -> List[str]:
             if not filepath.exists():
                 raise FileNotFoundError(f"Wordlist '{name}' not found at {filepath}")
     
    -        words = []
    -        with open(filepath, "r", encoding="utf-8") as f:
    -            for line in f:
    -                line = line.strip()
    -                # Skip comments and empty lines
    -                if line and not line.startswith("#"):
    -                    words.append(line.split(";", 1)[0].strip().upper())
    +        words = read_wordlist_words_ordered(filepath, strict=True)

    Valid, fixed in 4d6ff89 (spec 0.2.14, 68dbb7c). add_words and remove_words now identify a line by line_key (backend/core/wordlist_reader.py): WordList.canonical_word of the word parse_line returns, the same rule load reads with. Removing CAFE drops a stored CAFÉ;50, GRAPE drops grape,40, and a removal drops every stored line with that key. add_words had the same raw key, so adding CAFE beside CAFÉ;50 (or APPLE beside apple,50) wrote a second line that load hid. It now keeps one line, the one the list shows. Lines that a removal does not touch stay as written.

    While testing, an add's rewrite also turned a skipped STRAßE into a valid STRASSE ("ß".upper() is "SS"). Fixed in 68b6115: a line whose key uppercasing would change is written as given. And review found that "keep the first" could keep a line the parser rejects (GRAPE;abc) over a later valid GRAPE;40, dropping GRAPE on an unrelated add. Fixed in 7c31489: the kept line is the first one parse_line accepts.

    Tests: TestEditsKeyOnTheFoldedWord in backend/tests/unit/test_wordlist_manager_shared_parser.py, red against the old key before each fix.

    Reviewers
    Assignees
    apassuello apassuello
    Labels
    risk: low confidence: 83.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 85.5% (HIGH) · Higher = larger blast radius
    85.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 83.2% · Lower = rushed or shallow review
    83.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.4% · Safe to merge
    14.4%