Skip to content

Kits 0.1.2-experimental: a repeated PTN+FUNC+TRIG paste or clear no longer writes another pattern's data - #2485

Draft
repeat98 wants to merge 2 commits into
mainfrom
fix/kits-stale-undo
Draft

repeat98 wants to merge 2 commits into
mainfrom
fix/kits-stale-undo

Conversation

@repeat98

Copy link
Copy Markdown
Owner

What was broken: with Kits 0.1.1, repeating a PTN+FUNC+TRIG paste or clear on a pattern is an undo. If you did a stock pattern copy, paste or clear in between (or another stock edit that has an undo), that "undo" wrote another pattern's trigs and Part into the target. Musically: you meant to paste or get your pattern back, and the pattern silently became a different one. Reproduced in the emulator; a tester lost patterns with 0.1.1, not yet tied to this, and this may be related to #2439.

What works now: the same paste or clear repeated right away still undoes it. After anything else that refills the Octatrack's undo memory, the repeat simply pastes or clears again, and a new pattern copy means the next paste pastes, as on a stock Octatrack.

Tested where: emulator only (ot_emu), before and after, on the same base twin. Not tested on a unit. This stays a draft until the owner has run this exact package (84f4c5c8…) on his unit.

Who acts next: the owner (repeat98): a unit test of package 84f4c5c8…, then the version approval or hardware evidence that module:doctor asks for (below). Author's OK: owner waiver, 30 Nov 2026 (in place of Ask the author first). Sam Banks' and Em's credit is unchanged.

The fix, the code reading and the emulator results

Cause. Kits kept only the op and the pattern of its last PTN+FUNC+TRIG paste or clear and restored stock's undo buffer (0x460bf218) through 0x4002b9b0 when they matched. In OS 1.40C about two dozen routines between 0x40026768 and 0x4002c166 fill that buffer and write stock's undo record (0x460c80f0/f4/f8); only the pattern paste and clear go through 0x40026ef0 (Kits' kits_psnap site), and the pattern copy (0x40026eb0) clears the record without touching the buffer. So a reset in kits_psnap alone would have fixed the two reported cases and left the rest.

Fix (sdk/octatrack/modules/kits/kits.s):

  • inactive_op (~1400-1438): after its snapshot Kits stores the CRC-32 of the undo buffer (its own crc32) and the target as bank * 16 + pattern; a repeat undoes only when op, bank, pattern and CRC still match, otherwise it pastes or clears again. The bank in the target also closes a bank change between two ops (by reading; not run, see below).
  • kits_pcopy (~1100): a pattern copy, stock's or Kits', forgets the pending undo.
  • kits_ptrig (~1362): a pattern trig with PTN but without FUNC forgets PTN+FUNC+TRIG's target, so an old target is not reused.
  • Data: PUNDO_SUM added after PTGT/PUNDO_OP/PUNDO_T.

A first attempt that called stock's own repeat-is-undo check (0x4002ba2c) was dropped: Kits' clear (eight 0x40039df4 track clears) leaves stock's undo record zeroed, and the control case failed with it.

Emulator, ot_emu --frame (not hardware): base twin MAIN 276500fc… (build_core.py beta flags + --dev, source 724dba4cc), TEMPLATE project, Kits installed alone (device try --accept), bank A patterns 1-8 with trigs, transport stopped; each check read bank A's patterns, Part bytes and Kits' state over peek.

Case Steps 0.1.1 c1cb63e5 0.1.2 84f4c5c8
Clear Kits clear A03; stock copy A05, paste A12; Kits clear A03 again undo ran with A12's pre-paste snapshot no undo, A03 cleared again, A12 untouched
Paste copy A01, Kits paste onto A03; stock clear A06; Kits paste onto A03 again A03 got A06's trigs and Part 3 A03 got A01's trigs and Part 1 again
Control Kits clear A04 twice trigs back trigs back

Package: npm run module:dev -- kits --build-only and npm run octatrack:module-packages give the same 84f4c5c89a98dce4… (13,654 bytes; 11,340 of code and data, 38,968 of bss). TESTING.md has the full record.

Upstream: octabam's current modules/kits/kits.s (e7452f9b) has the same code at lines 1283 and 1321-1342. Following Kits' AGENTS.md, an issue text for sambanks/octabam is drafted for the owner to decide; nothing was filed.

Edge cases

Case Why this change makes it a risk How run Result
Repeat with nothing between (undo) the new check must still let a real undo through emulator, Kits clear A04 twice pass
Stock copy and paste between two Kits clears the reported clear case emulator, run6 pass
Stock clear between two Kits pastes the reported paste case; only the CRC catches it emulator, run6 pass
Bank change between two Kits ops the target now includes the bank emulator: BANK, TRIG2 showed BANK UNAVAILABLE not run: the TEMPLATE card has no bank B; owner's unit test
Stock track or trig edit with an undo between two Kits ops those refill the buffer outside 0x40026ef0 code reading not run: covered by the CRC by reading; owner's unit test
PTN+TRIG without FUNC, then PTN+FUNC+REC/STOP/PLAY with that trig held the target is now forgotten emulator: PTGT read -1 after PATTERN+TRIG (run6) not run: the gesture itself was not driven
Cost of two CRCs over 36,568 bytes per paste or clear ColdFire time on the UI task estimate only not run: the emulator's timing is not the chip's; estimated 1-3 ms each, at a key press only
Transport playing, MKI, Keep, power cycle unchanged paths, but no run on this build none yet not run: the owner's unit test of this exact build

Still red, owner's call: module:doctor lists evidence/performance.json (for 0.1.1) and sdk/approvals/kits-build-approval.json (covers 0.1.1), so modules:generate cannot regenerate src/catalog/module-documents.json yet; and the board claim on Kits held by twwwy (0.1.1's Part Edit rows, shipped in #2066), whom I asked on the board. I did not write an approval or new measurements.

What the guides lacked, and where: no guide says that stock's undo buffer is shared by many snapshot routines, so a module keeping its own pending undo over it cannot rely on one detour. I recorded it in Kits' TESTING.md and as a board finding for the Octatrack; a guide line can follow in its own Docs: PR. Also: device.mjs try … --socket <an emulator's share socket> waits in the real unit's queue unless MODWERK_UNIT=emulator is set; docs/UNIT_QUEUE.md names --emulator and the variable but not this case. Not fixed here.

  • Changing a module someone else wrote: owner waiver, 30 Nov 2026, in place of the author's OK.
  • I read the guide for its category in docs/module-guides/, and TESTING.md lists what I did not test.
  • Source and media are mine or properly licensed, with authors and full licence texts kept. Nothing comes from Elektron firmware.
  • Screenshots are real captures of the current module UI (unchanged). Emulator results are labelled as emulator results.
  • Automatically merge and publish my module update after checks pass.
  • I verified the source, licences, UI and qualification reports, including instance isolation and Part/project/reboot persistence where applicable; no required acceptance check is failed or untested.

Validation commands and results: npm run module:doctor -- kits (red on the owner's items above); npm run pr:ready result in a comment below.

🤖 Generated with Claude Code

repeat98 and others added 2 commits November 30, 2026 19:24
…onger undoes with another pattern's data

Kits treated the same paste or clear repeated on a pattern as an undo and wrote stock's
shared undo buffer back, without knowing whether stock had refilled that buffer since.
A stock pattern copy, paste or clear in between (or another stock edit with an undo)
put another pattern's trigs and Part byte into the target (reproduced in ot_emu).

Kits now keeps a CRC-32 of the undo buffer after its snapshot and the target as
bank * 16 + pattern, and undoes only while both still match. A pattern copy forgets
the pending undo, as stock's copy does, and a PTN+TRIG without FUNC forgets the
PTN+FUNC+TRIG target. Emulator only; the owner tests the exact build on a unit.

Owner waiver, 30 Nov 2026, in place of the author's OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@repeat98

Copy link
Copy Markdown
Owner Author

The same bug is in octabam's own Kits (same lines in its current modules/kits/kits.s), so it was reported upstream as sambanks/octabam#1315, as Kits' AGENTS.md asks.

🤖 Generated with Claude Code

@repeat98

Copy link
Copy Markdown
Owner Author

Checks on 6ca2182f2, for the owner: npm run pr:ready -- --draft passes everything (lint, typecheck, build, sdk:check, modules:check and compat, licences, board) except two tests that read Kits' release evidence: module-qualification.test.ts ("preserves kits qualification…") and module-doctor.test.mjs (no ✗ for any catalog module). Both fail on what only the owner can supply for 0.1.2: sdk/approvals/kits-build-approval.json still covers 0.1.1, and evidence/performance.json is 0.1.1's measurement. npm run test:procedure -- kits --no-unit stops at step 1 on the same lines plus the board claim, so it has no 0.1.2 record yet. Nothing ran on a unit.

Next: the owner runs package 84f4c5c8… on his unit, then either measures (device:price, test procedure) or writes the version approval. I wrote neither.

Suggested approval record, if the owner chooses that route (not committed)

sdk/approvals/kits-build-approval.json with "version": "0.1.2-experimental", approvedOn the day he approves, sourceSha256 from node -e on moduleNativeSourceSha256 for the folder (or the value modules:check prints), waived as for 0.1.1 plus whatever the unit run leaves open, and a reason naming this fix, the emulator runs in TESTING.md and his unit run.

🤖 Generated with Claude Code

@repeat98

repeat98 commented Dec 2, 2026

Copy link
Copy Markdown
Owner Author

@twwwy, a short question for you about Kits, also waiting in your Modwerk agent board inbox (thread ce1d433e-3bc4-4bf5-9887-3caf77c1b78c):

Your board claim on octatrack/kits still names 0.1.1's Part Edit rows (SAVE KIT in the shared Part Edit menu), which shipped in #2066. Are you still working on something under that claim, or can it be released?

This pull request (Kits 0.1.2, made on the owner's waiver) changes only the undo of a repeated PTN+FUNC+TRIG paste or clear, the pattern copy and the PTN+FUNC+TRIG target. Nothing in your Part Edit rows changes. A reply here or on the board is fine.

@twwwy

twwwy commented Dec 4, 2026 via email

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
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.

2 participants