Skip to content

Improvement: every Octatrack hook has a user or a reason in unused-hooks.json - #1602

Merged
repeat98 merged 1 commit into
mainfrom
improvement/octatrack-hook-coverage
Nov 16, 2026
Merged

repeat98 merged 1 commit into
mainfrom
improvement/octatrack-hook-coverage

Conversation

@repeat98

Copy link
Copy Markdown
Owner
  • What was wrong or hard: Nothing checked that the Octatrack's hooks in sdk/machines/octatrack/events.json are 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.py collects every declaration that binds a handler to a hook: subscribe ({"event", "fn"} or HOOK:FN:ORDER), contribute ({"to", "data"}) and raise entries. It reads them from module and draft runtime.json files, module-adapters/machine-ports.json, the package rows in src/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 with ast. 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. --list prints each hook's users.
    • sdk/machines/octatrack/unused-hooks.json holds 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.py runs the check against the repository and unit-tests it on temporary trees. sdk:check picks up every sdk/tests/test*.py, so npm run check and CI run it with nothing else changed.
    • In docs/module-guides/README.md, "Propose a hook" step 1 now says a new hook needs a user, or a line in unused-hooks.json saying why it waits.
    • dsp-sites.json is left out on purpose. Each of its sites already names the module whose manifest declares it, and dsp_sites.py --check refuses a site that no manifest declares, so a second list would repeat that check.
    • Changelog: changelog/2026-11-16-hook-coverage.md.
  • What it flags today (all 15 are seeded in unused-hooks.json):

    hook reason
    ot_midi_generators Base table since Improvement: MIDI generators on the Octatrack's MIDI tracks (base table) #775, and its reader is host-tested (test_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_saved Added in Improvement: Octatrack base hooks for project, bank and Part loads and saves, and a base up to 1.5 MiB #1564 for MIDI Scenes and Kits, which keep data per project, bank and Part. First module pending.
    ev_part_clear Same as above. Improvement: Octatrack base hooks for project, bank and Part loads and saves, and a base up to 1.5 MiB #1564 also lists it as not yet reached on a unit.
    ev_modules_ready Added in Improvement: Octatrack base hooks for project, bank and Part loads and saves, and a base up to 1.5 MiB #1564. The base raises it when the installed modules change, so that a module may read its file from the card. First module pending.

    The 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 unittest on sdk/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 --list runs in about 2 s.
    • vitest on src/catalog/module-guides.test.ts and src/catalog/docs-links.test.ts, after npm run prepare: passed.
    • npm run licenses:check, npm run machines:check, and the changelog and document-size checks (checkChangelog, checkDocs): passed.
    • Not run: the full npm run check, pr:ready and the whole SDK suite, which are left to CI here because the machine is shared with other jobs.
    • Known limit: a test that expects a refusal (for example --raise ev_voice_bind in test_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.md did not say that a hook needs a user. It does now. HOOKS.md is generated by events.py, so I left it alone.

🤖 Generated with Claude Code

…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>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 16, 2026
@repeat98
repeat98 merged commit 6daa214 into main Nov 16, 2026
13 checks passed
@repeat98
repeat98 deleted the improvement/octatrack-hook-coverage branch November 25, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant