Repository navigation
Improvement: every Octatrack hook has a user or a reason in unused-hooks.json - #1602
Merged
Merged
Conversation
…s or contributes to unless unused-hooks.json says why, and on a stale line there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 was wrong or hard: Nothing checked that the Octatrack's hooks in
sdk/machines/octatrack/events.jsonare used. A hook that no module, draft, adapter or test binds to is base code nothing exercises. Nobody could see which ones those were, and a new hook could land with no user and no stated reason.What this changes:
sdk/machines/octatrack/hook_coverage.pycollects every declaration that binds a handler to a hook:subscribe({"event", "fn"}orHOOK:FN:ORDER),contribute({"to", "data"}) andraiseentries. It reads them from module and draftruntime.jsonfiles,module-adapters/machine-ports.json, the package rows insrc/engine/assets/octatrack-module-packages.json, and the same entries written in Python (dict(event=…, fn=…),build.py --subscribe HOOK:…,--raise HOOK) in the base's build, the adapters, module tools and tests. The Python is parsed withast. A hook named only in prose, a comment, an index lookup, a C or assembly symbol, or the base's own raise does not count, because none of those binds a handler.--listprints each hook's users.sdk/machines/octatrack/unused-hooks.jsonholds one line per hook that has no user yet, each with a one-line reason. The check fails on a hook with no user and no line, on a line whose hook has a user now, on a line that names no hook, on a hook listed twice, and on a reason that is empty, more than one line or over 200 characters.sdk/tests/test_hook_coverage.pyruns the check against the repository and unit-tests it on temporary trees.sdk:checkpicks up everysdk/tests/test*.py, sonpm run checkand CI run it with nothing else changed.docs/module-guides/README.md, "Propose a hook" step 1 now says a new hook needs a user, or a line inunused-hooks.jsonsaying why it waits.dsp-sites.jsonis left out on purpose. Each of its sites already names the module whose manifest declares it, anddsp_sites.py --checkrefuses a site that no manifest declares, so a second list would repeat that check.changelog/2026-11-16-hook-coverage.md.What it flags today (all 15 are seeded in
unused-hooks.json):ot_midi_generatorstest_midi_generators.c). VECTOR MIDI contributed to it in VECTOR 0.3.0 (VECTOR 0.3.0-experimental: VECTOR MIDI, phrases on the Octatrack's MIDI tracks #1339) and was taken out again in 0.3.1 (VECTOR 0.3.1-experimental: VECTOR again, sample tracks only; the MIDI generator becomes its own module #1342) to become its own module, which is still pending.ev_banks_load,ev_banks_loaded,ev_bank_load,ev_bank_loaded,ev_project_new,ev_bank_write,ev_bank_written,ev_project_store,ev_project_stored,ev_project_reload,ev_project_reloaded,ev_part_savedev_part_clearev_modules_readyThe other 37 each have at least one declared user. The list matches the plain-text survey count, so no base-internal or test user was missed for these 15.
How I checked it:
python3 -m unittestonsdk/tests/test_hook_coverage.py: 6 tests OK. One test runs the real repository; five run fixture trees covering declarations against prose, a reason, stale and unknown lines, one-line reasons and duplicate keys.python3 -B sdk/machines/octatrack/hook_coverage.py --listruns in about 2 s.vitestonsrc/catalog/module-guides.test.tsandsrc/catalog/docs-links.test.ts, afternpm run prepare: passed.npm run licenses:check,npm run machines:check, and the changelog and document-size checks (checkChangelog,checkDocs): passed.npm run check,pr:readyand the whole SDK suite, which are left to CI here because the machine is shared with other jobs.--raise ev_voice_bindintest_runtime_loader.py) still counts as a use. That only matters for a hook whose sole "user" is such a test, and no hook is in that position today.What the guides lacked or got wrong, and where I fixed it: "Propose a hook" in
docs/module-guides/README.mddid not say that a hook needs a user. It does now.HOOKS.mdis generated byevents.py, so I left it alone.🤖 Generated with Claude Code