Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/2026-11-29-catalog-folder-only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- The vendored folder now holds only the module catalog: the last two kit files, their lock pins and the builder fingerprint's kit fields are gone, as nothing reads them since base 0.8.4.
- The builder's random-set test fills the Octatrack bases again instead of skipping them silently.
2 changes: 1 addition & 1 deletion scripts/change-scope.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function nativeChange(change, machine) {
const common = /^sdk\/(build|runtime)\//.test(path)
if (machine === 'octatrack') return common || /^sdk\/octatrack\/modules\//.test(path) || /^sdk\/octabam\/(platform|tools|dsp|licenses)\//.test(path)
|| /^sdk\/(?:machines\/octatrack|firmware_codec)\//.test(path) || /^public\/octatrack-modules\//.test(path)
|| ['sdk/tests/test_base_bound.py', 'vendor/elekloader/kit/kit.json', 'scripts/test-base-bound.sh', 'scripts/mirror-octatrack-modules.mjs'].includes(path)
|| ['sdk/tests/test_base_bound.py', 'scripts/test-base-bound.sh', 'scripts/mirror-octatrack-modules.mjs'].includes(path)
|| path === 'sdk/catalog.json' || /^src\/engine\/assets\/(?!elemod\/)/.test(path)
|| /^scripts\/(build-module-packages\.py|build-utility-packages\.py|build-usb-audio-packages\.py|build-modules-isolated\.sh|import-module-build\.mjs|module-source\.mjs)$/.test(path)
return common || new RegExp(`^sdk\\/(${ELEMOD}|elemod|machines)\\/`).test(path) || /^vendor\/elekloader\/(catalog\/|elekloader\.lock\.json$|upstream-catalog\.json$)/.test(path) || /^sdk\/imports\/elekloader-[^/]+\.json$/.test(path)
Expand Down
2 changes: 1 addition & 1 deletion scripts/change-scope.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('release export reproduction', () => {
expect([...files].filter(path => !scope(change(path)).elemod)).toEqual([])
})
it.each(['sdk/machines/octatrack/base-binding.json', 'sdk/machines/octatrack/module-adapters/base_bound.py',
'public/octatrack-modules/cc-map/test.mwrm', 'sdk/tests/test_base_bound.py', 'vendor/elekloader/kit/kit.json'])(
'public/octatrack-modules/cc-map/test.mwrm', 'sdk/tests/test_base_bound.py'])(
'runs the pinned Octatrack rebuild for %s', path => expect(scope(change(path)).modules).toBe(true))
it('reproduces a changed committed Elemod export', () => {
expect(scope(change('sdk/imports/packages/demo/demo-1.0.0-os1.54.elemod')).elemod).toBe(true)
Expand Down
12 changes: 6 additions & 6 deletions scripts/elekloader-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { tmpdir } from 'node:os'
import { basename, dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { parseCatalog, sourceUrl } from '../src/engine/elektron/builder-catalog.ts'
import { KIT_FILES, UPSTREAM_CATALOG, assembleCatalog, isCatalogRecord, type CatalogFile, type Lock } from './elekloader-vendor.ts'
import { UPSTREAM_CATALOG, assembleCatalog, isCatalogRecord, type CatalogFile, type Lock } from './elekloader-vendor.ts'

export { mergeCatalogOverlay } from './elekloader-vendor.ts'

Expand Down Expand Up @@ -67,9 +67,9 @@ export function verifyCatalogFolder(folder: string) {
if (bad.length) throw new Error(folder + ' is not its catalog:\n' + bad.join('\n'))
}

/** The lock: the kept kit files and the upstream catalog's text, by sha256. */
export function catalogLock(kitDir: string, upstreamText: string, revision: string, previous: Lock): Lock {
return { ...previous, kit: { ...previous.kit, files: Object.fromEntries([...KIT_FILES].sort().map(path => [path, sha(readFileSync(join(kitDir, path)))])) }, catalog: { revision, sha256: sha(new TextEncoder().encode(upstreamText)), cores: (JSON.parse(upstreamText) as CatalogFile).cores.length, mods: (JSON.parse(upstreamText) as CatalogFile).mods.length } }
/** The lock: the upstream catalog's text, by sha256. */
export function catalogLock(upstreamText: string, revision: string, previous: Lock): Lock {
return { ...previous, catalog: { revision, sha256: sha(new TextEncoder().encode(upstreamText)), cores: (JSON.parse(upstreamText) as CatalogFile).cores.length, mods: (JSON.parse(upstreamText) as CatalogFile).mods.length } }
}

/** A catalog cut to Modwerk's library: the mods `listed(machine, id)` names, with the mods they require on the same
Expand Down Expand Up @@ -179,7 +179,7 @@ async function main(root: string, argv: string[]) {
}
const from = paths.find(p => p.toLowerCase().endsWith('.json'))
if ((!paths.length && !overlayPath) || paths.length !== (from ? 1 : 0) || (library && !from)) throw new Error(usage)
const vendor = resolve(root, 'vendor/elekloader'), kitDir = join(vendor, 'kit'), catalogDir = join(vendor, 'catalog')
const vendor = resolve(root, 'vendor/elekloader'), catalogDir = join(vendor, 'catalog')
const scratch = mkdtempSync(join(tmpdir(), 'modwerk-elekloader-')), notes: string[] = []
const catalogNext = join(scratch, 'catalog')
let keepScratch = false
Expand Down Expand Up @@ -226,7 +226,7 @@ async function main(root: string, argv: string[]) {
const named = new Set([...newCatalog.cores, ...newCatalog.mods].map(p => p.file))
for (const name of readdirSync(catalogNext)) if (name !== 'catalog.json' && !named.has(name)) rmSync(join(catalogNext, name))
verifyCatalogFolder(catalogNext)
const lock = JSON.stringify(catalogLock(kitDir, upstreamText, upstream.revision, lockBefore), null, 1) + '\n'
const lock = JSON.stringify(catalogLock(upstreamText, upstream.revision, lockBefore), null, 1) + '\n'

// Keep every affected file, the regenerated distribution notices included: a later error must not leave a new
// catalog beside an old lock, or a partly regenerated set of notices.
Expand Down
33 changes: 8 additions & 25 deletions scripts/elekloader-vendor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// The catalog the site's builder serves (vendor/elekloader/catalog) and what is left of the vendored kit (KIT_FILES).
// The lock (vendor/elekloader/elekloader.lock.json) pins those files and the upstream catalog, upstream-catalog.json. Each
// The catalog the site's builder serves (vendor/elekloader/catalog).
// The lock (vendor/elekloader/elekloader.lock.json) pins the upstream catalog, upstream-catalog.json. Each
// Modwerk-built mod's pins live in its own import record, sdk/imports/elekloader-*.json, so two module PRs never edit
// one shared file. The served catalog/catalog.json is both together: generated by npm ci (prepare) and npm run check,
// never committed. Verifies every pinned file offline, refuses a catalog package that jumps or calls to an odd address
Expand All @@ -20,19 +20,8 @@ export const ELEKLOADER_SITE = 'elekloader/'
export const UPSTREAM_CATALOG = 'vendor/elekloader/upstream-catalog.json', SITE_CATALOG = 'vendor/elekloader/catalog/catalog.json'
/** A module's own catalog pins (a repository path), as `npm run elekloader:update -- --overlay` takes them. */
export const isCatalogRecord = (path: string) => /^sdk\/imports\/elekloader-[a-z0-9][a-z0-9.-]*\.json$/.test(path)
export type Lock = { schema: number; kind: string; kit: { version: string; protocol: number; files: Record<string, string> }; catalog: { revision: string; sha256: string; cores?: number; mods?: number } }
export type Lock = { schema: number; kind: string; catalog: { revision: string; sha256: string; cores?: number; mods?: number } }

/** The two files kept in vendor/elekloader/kit until the Octatrack base's build tools are Modwerk's own: kit.json,
* whose commit pins the upstream checkout those Python tools run (npm run upstream:tools), and src/codec/aplib.ts, a
* re-export of Modwerk's packer that sdk/machines/octatrack/elekloader/test_recipe.py runs. Nothing else is there:
* the site's builder is src/engine/elektron (builder.ts). */
export const KIT_FILES = ['kit.json', 'src/codec/aplib.ts'] as const
export const KIT_REPLACEMENTS: Readonly<Record<string, string>> = { 'src/codec/aplib.ts': 'src/engine/elektron/codec/pack.ts' }
/** What the kept codec file holds: the re-export, relative to vendor/elekloader/kit/<path>. */
export const replacementText = (path: string, from = '../'.repeat(path.split('/').length + 2) + KIT_REPLACEMENTS[path]) =>
'// SPDX-License-Identifier: GPL-3.0-or-later\n'
+ '// Modwerk replaces this kit file with its own implementation (vendor/elekloader/README.md, "Replaced kit files").\n'
+ `export * from '${from}'\n`
/** The kit's notice as Modwerk ships it, after a note on what it covers now. */
export function kitNotice(notice: string) {
return 'Modwerk\'s firmware builder (src/engine/elektron) is Modwerk\'s own implementation of the package and firmware '
Expand Down Expand Up @@ -105,18 +94,12 @@ const names = async (folder: string) => (await walk(folder)).map(path => relativ

/** Throws when any vendored byte differs from the lock; -> the lock, the catalog, and the site assets as [path, bytes]. */
export async function readVendoredElekloader(root: string): Promise<{ lock: Lock; catalog: Catalog; assets: [string, Buffer][] }> {
const folder = resolve(root, 'vendor/elekloader'), kit = resolve(folder, 'kit'), dir = resolve(folder, 'catalog')
const folder = resolve(root, 'vendor/elekloader'), dir = resolve(folder, 'catalog')
const lock = JSON.parse(await readFile(resolve(folder, 'elekloader.lock.json'), 'utf8')) as Lock
if (lock.schema !== 1 || lock.kind !== 'elekloader-kit-lock' || !lock.kit?.files || !lock.catalog?.sha256) throw new Error('Invalid elekloader lock file')
if (lock.schema !== 1 || lock.kind !== 'elekloader-kit-lock' || !lock.catalog?.sha256) throw new Error('Invalid elekloader lock file')
const top = (await readdir(folder)).sort().join(',')
if (top !== 'README.md,catalog,elekloader.lock.json,kit,upstream-catalog.json') throw new Error('vendor/elekloader holds only README.md, catalog/, elekloader.lock.json, kit/ and upstream-catalog.json: ' + top)
if (top !== 'README.md,catalog,elekloader.lock.json,upstream-catalog.json') throw new Error('vendor/elekloader holds only README.md, catalog/, elekloader.lock.json and upstream-catalog.json: ' + top)
const bad: string[] = []
const kitFiles = await names(kit)
if (kitFiles.join() !== [...KIT_FILES].sort().join()) bad.push('vendor/elekloader/kit holds only ' + KIT_FILES.join(' and ') + ': ' + kitFiles.join(', '))
if (Object.keys(lock.kit.files).sort().join() !== [...KIT_FILES].sort().join()) bad.push('the lock pins only ' + KIT_FILES.join(' and ') + ' of the kit')
for (const path of kitFiles) if (lock.kit.files[path] !== sha(await readFile(resolve(kit, path)))) bad.push('kit file changed: ' + path)
for (const path of Object.keys(KIT_REPLACEMENTS))
if (await readFile(resolve(kit, path), 'utf8').catch(() => '') !== replacementText(path)) bad.push('kept kit file is not the re-export of ' + KIT_REPLACEMENTS[path] + ': ' + path)
const site = siteCatalog(root), raw = Buffer.from(site.text)
if (sha(Buffer.from(site.upstream)) !== lock.catalog.sha256) bad.push('upstream-catalog.json is not the one the lock pins')
if (!(await readFile(resolve(dir, 'catalog.json')).catch(() => Buffer.alloc(0))).equals(raw)) bad.push('catalog/catalog.json is not the upstream catalog plus the module records: run npm run prepare')
Expand Down Expand Up @@ -168,6 +151,6 @@ export function elekloaderSite(root: string): Plugin {

if (process.argv[1] === fileURLToPath(import.meta.url) && process.argv.includes('--write')) writeSiteCatalog(resolve(dirname(fileURLToPath(import.meta.url)), '..'))
else if (process.argv[1] === fileURLToPath(import.meta.url)) {
const { lock, catalog, assets } = await readVendoredElekloader(resolve(dirname(fileURLToPath(import.meta.url)), '..'))
console.log('Vendored catalog ' + catalog.revision.slice(0, 7) + ' (' + catalog.cores.length + ' cores, ' + catalog.mods.length + ' mods): ' + assets.length + ' site assets, and the kit pin ' + lock.kit.version + ', as the lock pins.')
const { catalog, assets } = await readVendoredElekloader(resolve(dirname(fileURLToPath(import.meta.url)), '..'))
console.log('Vendored catalog ' + catalog.revision.slice(0, 7) + ' (' + catalog.cores.length + ' cores, ' + catalog.mods.length + ' mods): ' + assets.length + ' site assets, as the lock pins.')
}
2 changes: 1 addition & 1 deletion scripts/firmware-build-manifest.d.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type FirmwareBuildManifest = {
format: 'modwerk-firmware-builder-v1'
inputsSha256: string
elekloader: { version: string; commit: string; protocol: number; catalogSha256: string }
elekloader: { catalogSha256: string }
}
export function sha256(bytes: Uint8Array | string): string
export function readFirmwareBuildManifest(root: string): Promise<FirmwareBuildManifest>
3 changes: 1 addition & 2 deletions scripts/firmware-build-manifest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ export async function readFirmwareBuildManifest(root) {
}
for (const path of ['src/engine', 'src/catalog', 'src/config', 'vendor/elekloader']) await walk(path)
for (const path of ['sdk/catalog.json', 'src/community/modules.ts', 'src/community/module-changelogs.json', 'package-lock.json']) files[path] = sha256(await readFile(resolve(root, path)))
const kit = JSON.parse(await readFile(resolve(root, 'vendor/elekloader/kit/kit.json'), 'utf8'))
return {
format: 'modwerk-firmware-builder-v1',
inputsSha256: sha256(JSON.stringify(Object.fromEntries(Object.entries(files).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)))),
elekloader: { version: kit.version, commit: kit.commit, protocol: kit.protocol, catalogSha256: files['vendor/elekloader/catalog/catalog.json'] },
elekloader: { catalogSha256: files['vendor/elekloader/catalog/catalog.json'] },
}
}
3 changes: 1 addition & 2 deletions scripts/firmware-download.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ describe('local firmware release verification', () => {

it('fingerprints input bytes, independent of filesystem enumeration order', async () => {
const folder = await mkdtemp(join(tmpdir(), 'modwerk-manifest-test-')); cleanup.push(folder)
for (const dir of ['src/engine', 'src/catalog', 'src/config', 'vendor/elekloader/kit', 'vendor/elekloader/catalog', 'src/community', 'sdk']) await mkdir(join(folder, dir), { recursive: true })
for (const dir of ['src/engine', 'src/catalog', 'src/config', 'vendor/elekloader/catalog', 'src/community', 'sdk']) await mkdir(join(folder, dir), { recursive: true })
for (const name of ['sdk/catalog.json', 'src/community/modules.ts', 'src/community/module-changelogs.json', 'package-lock.json', 'vendor/elekloader/catalog/catalog.json']) await writeFile(join(folder, name), '{}')
await writeFile(join(folder, 'vendor/elekloader/kit/kit.json'), JSON.stringify({ version: '1', commit: 'a', protocol: 1 }))
await writeFile(join(folder, 'src/engine/a.ts'), 'one')
const before = await readFirmwareBuildManifest(folder)
await writeFile(join(folder, 'src/engine/ignored.test.ts'), 'test only')
Expand Down
17 changes: 7 additions & 10 deletions sdk/machines/octatrack/elekloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ byte parity do not establish safe boot, logger retention, cache handling,
audio or physical reboot persistence. Keep private candidates out of release
until those results and owner review are recorded.

Use Node 24, the reviewed GNU `m68k-elf` toolchain, a clean Elekloader checkout
at `vendor/elekloader/kit/kit.json`'s commit (`npm run upstream:tools` keeps one
in `~/.cache/modwerk-upstream/elekloader`) and your original OT OS 1.40C.
The checkout runs with Modwerk's own firmware codec: a script puts it on `sys.path` only through
`firmware_codec.use_elekloader()` ([`sdk/firmware_codec`](../../../firmware_codec/__init__.py)), which serves the
section format, the `.syx` transport and the ColdFire decoder in place of the checkout's `codec/` and `isa/`
(`sdk/tests/test_firmware_codec.py` checks every script).
Use Node 24, the reviewed GNU `m68k-elf` toolchain and your original OT OS 1.40C.
The scripts run Modwerk's own firmware builder (`sdk/firmware_builder`) and codec, which they load only through
`firmware_codec.use_elekloader()` ([`sdk/firmware_codec`](../../../firmware_codec/__init__.py));
`sdk/tests/test_firmware_codec.py` checks every script.
Both output directories below must be new and outside every Git checkout:

```sh
Expand Down Expand Up @@ -136,9 +133,9 @@ module packages (`npm run octatrack:module-packages -- --base-only`) so every ba
checks the remaining published files against their manifest hashes without
rebuilding or deleting them. Use the full generator for a separately qualified
module update; existing standalone recipes may name earlier source/tool inputs.
The cave/table declarations also pin the generator source, and they and the standalone recipes pin the Elekloader
checkout's files the build runs and Modwerk's codec in place of its `codec/` and `isa/` (`firmware_codec.inputs()`),
so a kit update or a codec edit (`vendor/elekloader/kit/kit.json`) needs the same refresh in its own pull request:
The cave/table declarations also pin the generator source, and they and the standalone recipes pin the builder's and
the codec's files the build runs (`firmware_codec.inputs()`), so a builder or codec edit needs the same refresh in its
own pull request:
CI has no firmware and cannot see it, and until then the builds refuse with "does not name the exact source inputs"
(kit 0.7.0, 22 October 2026). Refresh a generator-only pin only after rebuilding
the affected packages and proving every published byte unchanged; never replace a pin merely to make a check pass.
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/test_own_builder_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def _octatrack_bases(tmp):
"import { join } from 'node:path'; import { pathToFileURL } from 'node:url';"
"const [root, stockPath, jobs] = process.argv.slice(1);"
"const imp = p => import(pathToFileURL(join(root, p)).href);"
"const formats = await imp('vendor/elekloader/kit/src/formats.ts');"
"const formats = await imp('src/engine/elektron/firmware-formats.ts');"
"const { recoverStockDsp } = await imp('src/engine/stock-dsp.ts');"
"const { fillBase } = await imp('src/engine/elekloader/octatrack-base.ts');"
"const [parsed, device] = await formats.load(new Uint8Array(readFileSync(stockPath)));"
Expand Down
3 changes: 1 addition & 2 deletions src/engine/elekloader/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// The builder's replies as elekloader's kit types them (vendor/elekloader/kit/src/kit/protocol.ts), under the names
// Modwerk's pages use.
// The builder's replies, under the names Modwerk's pages use.
export type {
Device as BuilderDevice, Stock as BuilderStock, Mod as BuilderMod, Added as BuilderAdded, Check as BuilderCheck,
VersionField as BuilderVersion, Output as BuilderFile, Log as BuilderLog, BuildResult as BuilderResult,
Expand Down
13 changes: 5 additions & 8 deletions vendor/elekloader/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Vendored catalog

The site's firmware builder is Modwerk's own (`src/engine/elektron/builder.ts`: the worker, the linker, both OS file
families, module storage and the catalog). This folder holds what it serves and what is left to replace:
families, module storage and the catalog). This folder holds what it serves:

| Path | What |
| --- | --- |
| `upstream-catalog.json` | the cores and mods Modwerk offers from upstream releases, cut to the library |
| `catalog/` | the pinned packages and `catalog.json`: `upstream-catalog.json` plus every module record `sdk/imports/elekloader-*.json`, generated by `npm ci` (`prepare`) and `npm run check`, never committed |
| `elekloader.lock.json` | the lock: `upstream-catalog.json` and the two kit files below by SHA-256 |
| `kit/kit.json` | the commit pin of the upstream checkout the Octatrack base's Python build tools still run (`npm run upstream:tools`) |
| `kit/src/codec/aplib.ts` | a re-export of Modwerk's packer that `sdk/machines/octatrack/elekloader/test_recipe.py` runs |
| `elekloader.lock.json` | the lock: `upstream-catalog.json` by SHA-256 |

The two kit files go when the Octatrack base's build tools are Modwerk's own. `npm run elekloader:check` (part of
`npm run elekloader:check` (part of
`npm run check`) checks the lock, that `catalog/catalog.json` is the upstream catalog plus every module record, every
pinned file, and refuses a package whose `jsr` or `jmp` to an absolute address has an odd target
(`src/engine/elektron/odd-jumps.ts`): a real unit stops there with an address error, while the emulators run on. The
Expand All @@ -36,6 +34,5 @@ Update by pull request, owner reviewed:

## Replaced kit files

Every kit file is now Modwerk's own code under `src/engine/elektron` and the kit's own copies are gone. One path
stays as a one-line re-export, `kit/src/codec/aplib.ts` of `src/engine/elektron/codec/pack.ts`, because the Octatrack
base's `test_recipe.py` runs it there and changing that file gives the base a new identity.
Every kit file is Modwerk's own code under `src/engine/elektron` (the browser) and `sdk/firmware_builder` (the base
tools); no kit file is left here.
Loading
Loading