Skip to content

Fix: Model:Cycles base, a runtime module never patches over the base's own sites - #2277

Closed
npp1993 wants to merge 2 commits into
repeat98:mainfrom
npp1993:claude/mc-held-sites
Closed

npp1993 wants to merge 2 commits into
repeat98:mainfrom
npp1993:claude/mc-held-sites

Conversation

@npp1993

@npp1993 npp1993 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

What this fixes: on the Model:Cycles base, a module loaded over USB could patch over the base's own code. Its runtime glue allowed every stock address, so a module site overlapping one of the base's sites would replace the base's code with bytes the loader took for stock. Musically nothing changes until the base is rebuilt: nobody loads modules onto a Model:Cycles today (its base is unreleased, beta downloads only).

Who must act: someone with the Model:Cycles OS 1.13 file (@repeat98 or the Model:Cycles' developer) runs npm run machine:base -- model-cycles --stock <OS> --write and records the new identity; I don't have the OS file here. Not run on a unit.

This is the Analog Rytm MKII's fix from @repeat98's review of #1934, brought to the Model:Cycles:

  • scripts/machine-base.py writes held-sites.h beside a staged runtime.c, holding the core's and base.json's sites as address ranges. These are the same lines as on base/analog-rytm-mkii-next (commit 4fd9e10), copied byte for byte so the two branches merge cleanly. They also bring base-next's version lines, which do nothing on main (no base.json there has a top-level version).
  • sdk/machines/model-cycles/elekloader/base/runtime.c: patchable refuses any module site that touches a held range. The paused() guard is now max < 2u * TASKS with a _Static_assert(2u * TASKS <= RUNTIME_PAUSED). The old 2*TASKS+1 was harmless with the Model:Cycles' 12 tasks; with the Rytm's 16 it refused every switch with sites.
Tests and evidence
  • sdk/tests/test_machine_base.py::test_a_model_cycles_runtime_module_never_patches_over_the_base: the staged ranges equal the pinned package 646706ff's 8 sites exactly. The real runtime.c built on the host refuses every site, its last byte and a run-in, and allows the gaps between them. 33 tests pass.
  • npm run check passed on 6be9e7c (the two review edits after it touch only a test skip and a comment).
  • An independent review found nothing blocking: the span count is 1 + 1 + 2·11 = 24, a dev base's header covers its extra site, and no CI check compares base sources with the recorded package. Its smaller points are in.
  • Not tested: a module with sites on a Model:Cycles unit. The recorded base predates this change until it is rebuilt.

What the guides lacked: nothing kept a runtime module off a machine base's own sites. The Octatrack has its event list, but the elemod machines had no equivalent. sdk/machines/model-cycles/LINK.md now says so.

🤖 Generated with Claude Code

npp1993 and others added 2 commits November 26, 2026 11:25
…s own sites (held-sites.h from machine:base), and the paused guard sized to 2 x TASKS (from the Rytm's review on repeat98#1934)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompiler, the host stand-in named

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Nov 26, 2026
@repeat98

Copy link
Copy Markdown
Owner

Thanks, this is the right fix, and it matches the Rytm's lines exactly. Model:Cycles base changes go on one cumulative draft, so I've started base/model-cycles-next from your two commits, credited to you: #2319. I'm closing this one in its favour. The rebuild with the OS file is mine and happens there.

Please send the next Model:Cycles base change to that branch: cut from it, merge main in, and check it with npm run pr:ready -- --base-branch base/model-cycles-next.

@repeat98 repeat98 closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants