Skip to content

Migrate scrabble module to Conductor#792

Draft
Shrey5132 wants to merge 2 commits into
source-academy:conductor-migrationfrom
Shrey5132:feat/migrate-scrabble
Draft

Migrate scrabble module to Conductor#792
Shrey5132 wants to merge 2 commits into
source-academy:conductor-migrationfrom
Shrey5132:feat/migrate-scrabble

Conversation

@Shrey5132

Copy link
Copy Markdown

Description

Fixes #782

Migrates the scrabble module to be Conductor-ready. scrabble has no tab/visualization component, so this is scoped entirely to src/bundles/scrabble/.

Unlike repeat/binary_tree/midi, scrabble exports four static word/letter lists, not functions - there's nothing for the usual exportedNames/@moduleMethod closure path to wrap. index.ts is now a BaseModulePlugin subclass that pushes all four exports in an initialise() override, wrapped via DataType.OPAQUE (opaque_make(value, true)) rather than DataType.ARRAY.

DataType.ARRAY was the other option, but IDataHandler.array_make has no bulk constructor - it fills with a single init value, so populating it requires one array_set call per element. scrabble_words is 172,820 entries; scrabble_letters (nested arrays of single-character strings) would be closer to 1.9M calls. No module anywhere in this migration has used array_make for real data yet. opaque_make is a single call regardless of the underlying value's size, same pattern rune uses for its whole Rune object.

functions.ts is untouched - it's pure data derivation (map/filter over the word list), nothing conductor-specific about it.

Tradeoff worth flagging

Opaque values are only "manipulated by modules," not natively indexable by Source/Python code, so direct indexing like scrabble_words[12] will no longer work once this ships. Happy to add accessor functions (e.g. scrabble_word_at) as a follow-up if that's needed, but held off since it wasn't clear that's wanted and it's easy to add later without touching the OPAQUE plumbing.

Unrelated bug fixed along the way

The existing scrabble_words matches snapshot / scrabble_letters matches snapshot tests hung vitest indefinitely - confirmed via bisection against repeat's suite (clean, 1.2s) and this module's new test in isolation via .only (clean, 2.76s). Snapshotting a 172,820-entry array (and the nested scrabble_letters) produced a 2.1M-line .snap file that vitest's serializer choked on. Dropped those two tests and deleted the stale snapshot file; the existing index spot-checks (scrabble_words[12], scrabble_letters[100000]) already cover the full arrays cheaply, and the _tiny variants (~1,728 entries) still get proper snapshots (regenerated, 2 written).

Testing

  • yarn workspace @sourceacademy/bundle-scrabble run tsc - passes
  • yarn workspace @sourceacademy/bundle-scrabble run lint - passes
  • yarn workspace @sourceacademy/bundle-scrabble run test - 5/5 passing, against @sourceacademy/modules-testplugin's TestDataHandler
  • yarn workspace @sourceacademy/bundle-scrabble run build - produces build/bundles/scrabble.js

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

scrabble exports four static word/letter lists rather than functions,
so there's nothing for the usual exportedNames/@moduleMethod closure
path to wrap. Exposes them via DataType.OPAQUE (opaque_make in an
initialise() override) instead of DataType.ARRAY, since array_make has
no bulk constructor and the full word list is 172,820 entries.

Also drops the two full-array snapshot tests (scrabble_words/
scrabble_letters) - snapshotting 172,820 entries produced a
multi-million-line .snap file that hung vitest's serializer. The
existing index spot-checks already cover the full arrays; only the
~1,728-entry _tiny variants are snapshotted now.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the scrabble bundle to export a ScrabbleModulePlugin extending BaseModulePlugin instead of directly exporting the word lists. The word lists are now exposed as opaque values asynchronously during initialization. Additionally, snapshot tests for the full-sized word lists were removed to prevent test runner hangs, and a new test was added to verify the plugin's initialization behavior. Feedback is provided to optimize the initialization performance by executing the asynchronous opaque_make calls concurrently using Promise.all instead of sequentially.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/bundles/scrabble/src/index.ts
@Shrey5132 Shrey5132 marked this pull request as draft July 13, 2026 22:46
The four exports are independent, so awaiting them one at a time added
needless latency. Addresses gemini-code-assist review comment on source-academy#792.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Shrey5132 Shrey5132 requested a review from Akshay-2007-1 July 13, 2026 22:56
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