Repository navigation
ghidra: decode EMAC load displacement after the extension word - #771
Draft
Leomayoral wants to merge 1587 commits into
Draft
Leomayoral wants to merge 1587 commits into
Leomayoral wants to merge 1587 commits into
Conversation
…e needs (agreed 2026-12-01) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… contract on fakes; lifecycle names (PackageMemory, PackageCode, TracedSeam, OperationReport, package module) Nothing real implements quiet yet, so take-down is unchanged for every package; the wait/retain path is covered by fakes only. runtime.dko.json differs from base only by constant-pool reshuffling (verified against a fresh base build). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st) guard) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ase 0 facts and limits as findings 182 and 183 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t v4 and tables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tables and descriptors, devices [limits], ports facts (needs the v4 commit; does not build alone) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ommit) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fixtures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tooling and test updates Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emplates (Cargo workspace entries) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Em-approved) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l rows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phase 2 of extensibility: the plan and the guidance that describe the table read verb, row claims, [[service.uses]] and the fit pre-check. Builds alone (docs only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Table read verb, columns and table_capacity; ledger/admission: the old fit admission is deleted, reload and live fit are pre-checked, [[service.uses]] claims. Also the platform tables, device data, ports rules and SDK contract that these read. Does not build alone: services and tests follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Machine type and param rows come from the rows table; MISSING rows; list-getter hook; MACH_OWNER removed. Not buildable alone (needs the runtime commit before it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FX param and send rows through the table, with measured row claims from module:check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shared key table, sticky waves, Tick part; each service answers queries through the table read verb. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Patchkit reads service uses and measured row claims; module-check, nx and device tools updated; test-support fakes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unit tests over fakes, assembly tests for the fit pre-check and rows, scenarios for lfo and shortcuts, and in-memory row fakes. Each fact sits at the lowest level that can see it; a deleted lfo image_table test is replaced by the table read verb tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ved) Generated from the Phase 2 sources: dko objects, SDK catalogue and log kinds, port bindings, boot-effects snapshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the service Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…age strings; MISSING rows vacated) The DN2 page rows' name and title go back to the stock row's strings at a service stop (pagerows::forget_strings; they are not table rows yet, see extensibility.md section 14). A held MISSING machine row is vacated by the table on a service stop. Re-holding MISSING rows on restart is a Phase 3 follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dule templates keep their own types Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad them in set_rows_info and size the test tables to w::WORDS The readers of rows_info take its words through a raw pointer. The machines tests built tables of 96 and 112 words while w::WORDS is 120, so words past the end came from the heap: zero on macOS, other bytes on Linux (BadDesc in place_tables, or a refused add_at in the CI run). set_rows_info now pads a shorter table with zeros and the machines tests use w::WORDS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test: controller contract suite; pinned RPC surface and snapshot format checks
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…_modules Restore iterates the .dkp module section in place instead of copying it into an 8-entry set, so a module that can't load gets a visible warning with the refusal reason instead of being dropped. The SDK gains dk_project_modules(slot, start, out, max) and dk_project_summary reports module_total; project service 0.13.7. The project-user fixture reads a 12-module project across pages on the device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(project): restore every module a project lists; no cap of 8
…it module_ui by concept
Pure moves for Part A step 3: loader/records.rs becomes package/records/{resident_cells,
provider_cells}.rs and module_ui.rs a module_ui/ folder (enrollment, registry, request,
completion, tick). No logic change: runtime and system package objects byte-identical
(objdiff), no test lost (ledger). runtime-areas.json maps records/** to module-load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s-folder refactor(runtime): move the record cells into package/records; split module_ui
unload_body becomes Loader::release_record (same steps, same order); the refused-load frees in load.rs and the seam's package_free use the smaller free_unstarted, sharing free_block. The busy-retry path is unchanged. Runtime object identical; the package differs only in load_inner, package_free, the package_stop closure and free_block. Boot snapshots unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e annotations (ElekLabs#979) Composable profiling of the SHARC fast tier. The profile model, dkprof, module:cost and the workbench know no emulator series; emulator-only data is an optional, namespaced producer contribution that consumers ignore when absent. - Engine: `FastEngine::tier_report()` returns plain data per root (built, refused with reason, or untried; calls, insns, declines by kind with reasons, exits by pc and kind). The `cov run` log line is built from it (`cov_run_line`), one source. `set_cov(bool)` (also on `FastTier`) switches the counters per engine; the glue's coverage-note flag is thread-local and each engine sets it on entry to a call, so a second engine no longer disables the first one's notes. - Schema: `dk.profile/1` gains optional `annotations` `{cpu, addr, series, fields}`. A field is any JSON value (whole counts stay exact integers); a row of an unreadable shape is skipped and recorded in `loss`, never failing the profile. Absent means none. - Series (docs/INSTRUMENTATION.md): `emu.sharc.tier` (per root), `emu.sharc.tier.decline` (per root and entry-requirement failure class), `emu.sharc.tier.exit` (per exit pc and kind). - Adapter: `tierAnnotations` in packages/sharc-rig-kit/src/tier-annotations.ts, plain data in and out. The rig has no fast tier yet, so only a fixture feeds it. - dkprof: a generic renderer, one table per annotation series present (rows by address, capped by `--top`); no series names in dkprof or workbench-core. The tier module and the report's `tier` field are removed. Tests: TierReport mapping; per-engine coverage switch; `cov run` line equals the slot counters; annotations round trip with exact u64; unknown series and odd field types parse with known parts unchanged; a profile without annotations gives an unchanged Report; generic series rendering; adapter fields. dkprof wasm rebuilt and read a profile with and without annotations. Checks: `mise run test:changed` passed after a format fix (an unrelated about-board timing test flaked once under load, passed on rerun). Device proof `emulator-sharc-tests,gate-smoke,gate-pins` passed (87 ok, 0 failed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Gate `mise run test:all` passed (240 host tasks ok, device halves ok, 0 failed, 0 retried). Selected: emulator-sharc-tests sharc-semantics.device.test.ts: test-device--dn2; emulator-reply-tests reply-inflight.device.test.ts: test-device--dt2; gate-device-smoke: device (17 halves). Skipped: test:subset: skipped, selected by affected and left to the full tier (mise run test:all -- --all-affected or test:full): 217 device halves and conformance tasks of 49 projects: core/digikit-menu-memory-tests 2, core/digikit-menu 2, core/dynfx 2, core/fx 1, core/input 2, core/introblank 2, core/plusdrive-write 4, core/runtime-boot-tests 9, core/runtime-capacity-tests 4, core/runtime-diag-tests 12, core/runtime-entry-tests 2, core/runtime-ext-facts-tests 4, 37 more projects --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…lock ModuleRecord (24 B: reg, magic, block, bytes, ui offset, rec), ModuleIndex (REC_CEIL slots; enroll publishes last, release returns the block) and RecordBlock (layout [image | bss | pad | record | ui part]) in package/records/. The ui part (Enrollment, 2,074 B) is reserved only for modules importing dk_workbench_register, read from the import table at place time; Registry.modules is gone. Fit and the host tools count record_bytes. A magic word and invariant checks guard stale records. Fields that outlive the block (outcome, reasons, processor jobs, selection row) stay fixed until the image-less record. Package bss 74,421 -> 57,797; text +988. Boot snapshot: +32 B per module block (approved). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
refactor(runtime): module records live in each module's arena block
…owner A selected module refused at boot gets an image-less record (record only, created in one pass after the boot loop so no holes form), holding its outcome and reason (refusal 26 B). Fields read after take-down (sel_of_rec, log_name, processor jobs) and provider outcomes stay in fixed columns, each with the reason in its owner. Loader tables move to a HeaderTables owner. The capacity test reads the refused count from the boot report times the generated record size. Boot snapshot: the errors scenarios gain the two 64-byte image-less records (approved); normal boots unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tier (ElekLabs#984) ## Problem The SHARC engine aliases a direct low DM address byte by byte: when the first byte is absent at an address it reads `SW_ALIAS_BASE + address` (0x4801xxxx). The fast tier's flat access aliased per page only, so every access to page 0x2001 above the loader image end (0x2001ab7c, module state of loaded modules) left the kernel. The per-page decode-watch guard also left the kernel on any store to a watched page, even when the store overlapped no decoded unit. ## Design The checks branch to cold blocks placed after the kernel body (`fast/lower/flat_access.rs`), so the hot path adds no operation. The alias block takes the alias page when the raw first byte is absent and the address is below the alias base, then repeats the bitmap, watch and exact decode-unit tests there. A store on a decode-watched page stays in the kernel unless it overlaps a decoded unit (`CTX_FLAT_DEC`; the same rule as `Mem::note_watched_n`). The wasm flat-table check (`check_window`) knows the decode table. ## Why it is exact The cold blocks apply the same address decision, watch test and decode-unit overlap test as the interpreter's `Mem` path, only inside the kernel. A case the blocks do not cover still exits as before. The parity columns below are PCM, DSP state and ColdFire state against main at the same length. ## Tests `flat_access_check.mjs` (the wasm flat-table check) and the fast-tier unit tests cover the alias page and the decode-watch overlap rule. Parity "=" in every measured cell. ## Measurement `sharc_cells`, A = main, B = branch, each label with its own core, lengths 20 and 24 s, parity "=" everywhere: | cell (fixture) | B/A host insns | | --- | --- | | DN2 trig1-hold (stock) | 1.0005 | | DT2 dt2-sample-trig (stock) | 1.0005 | | mw-d, ASCEND | 0.7716 | | mw-b, Pluck x4 | 0.9323 | | mw-bc | 0.9440 | | mw-e | 0.9916 | The mw-* fixtures predate runtime 0.17 and ElekLabs#969 (heap-only memory). **Not measured on runtime 0.17.** The mw-mod key sequence does not engage the modules on fresh 0.17 fixtures (they load, but never run). I tried to drive ASCEND and Pluck without panel keys through `wb profile calibrate run --emu` and it is blocked on 0.17: the node host cannot install the module services, so the install deletes `services/fx.dks` as unused, Pluck is refused with `unknown-hash` for the machines service, and ASCEND fails to load with result -48. ASCEND has no `calibration.toml`, and its target-test needs a panel-prepared project. So there are no 0.17 exit counts for sites `mem_addr.rs@287` and `@330`, and no 0.17 A/B. The only counts read on 0.17 come from the stock hold-note case, where each site shows 2 to 3 exits over the whole run: near zero. Whether today's modules reach the aliased tail is therefore open, and the gain above applies to the old fixtures. Until it is measured, treat this as an exactness and robustness fix (accesses to a half-backed page and the decode-watch guard stay in the kernel and match the interpreter), with a gain for code that keeps state there. **Stock cost: +0.05%** (1.0005 on both stock cells), accepted. Probable cause: the new cold blocks sit after the kernel body, which shifts code layout and slightly enlarges each kernel; no operation is added to the hot path. ## Review follow-up tests Each compares the kernel store (plus the interpreter store as fallback after an exit) with the interpreter alone on memory, present/dirty bits, overlay (undo log `touched`) and code/decode watch notes, on the interpreter and native backends (`sharc/src/fast/lower/mod.rs`): - `flat_store_on_a_decode_watched_page_leaves_only_on_a_decoded_unit`: replaces the `dec_gen`/`code_gen` assertion that could not fail; adds odd 2- and 4-byte stores that cross a decoded unit (the `u0`, `u0+1`, `u1` selection, `flat_access.rs`). - `flat_store_through_the_alias_tail_on_a_decode_watched_page`: cold alias path then `flat_watched_store`, same cases through the 0x2001 alias tail. - `flat_store_on_a_code_watched_page_always_leaves`: WATCH_CODE natively, plain and alias tail, inside and outside the span, and with a decode watch on the page too. - `flat_access_follows_the_alias_of_a_partly_backed_page`: now also checks present/dirty bits and the overlay, and runs a conditional store through `Miss::Cold` with the condition true and false. All 9 `flat_` tests pass. Nits: `flat_alias` takes a `Site` struct (no clippy allow), `DEC_WORDS` is private, findings line 1436 now lists three bases. **Wide accesses.** 40/48-bit and long-word accesses never reach the flat path: `Width::from_fields` returns None for them (`mem_addr.rs:46-53`) and the 3a/3b/3d/4b forms refuse (`mem_addr.rs:323,345,371`, `mem_imm.rs:85-87`). Only widths 1, 2 and 4 call `flat_access` (`mem_addr.rs:150`, `mod.rs:1430,1436`); callret uses 4. ## Gate - `mise run test:changed`: unit and static tasks passed (33 tasks); rig preflight: 19 halves, 0 problems. - Device proof, as printed (`test-device--dn2`, `smoke`, `pins` on `emulator-sharc-tests`, `gate-smoke`, `gate-pins`): 87 ok, 0 failed, 3114 s. - At merge the gate also runs one other-device half (`emulator-reply-tests:test-device--dt2`) and the smoke set; `test:all` is left for the merge queue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Gate `mise run test:all`: pass (exit 0). - selected: emulator-sharc-tests sharc-semantics.device.test.ts: test-device--dn2; emulator-reply-tests reply-inflight.device.test.ts: test-device--dt2; gate-device-smoke: device (17 halves); conformance: none selected - skipped: test:subset left to the full tier: 217 device halves and conformance tasks of 49 projects (core/digikit-menu-memory-tests 2, core/digikit-menu 2, core/dynfx 2, core/fx 1, core/input 2, core/introblank 2, core/plusdrive-write 4, core/runtime-boot-tests 9, ... 37 more projects) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…-complete refactor(runtime): records for modules refused at boot; HeaderTables owner
Adds the 2026-12-05 evidence refresh, two root causes (SHARC where it isn't needed, graph edges wider than the code), the agreed order (7a) and the SHARC link replay spike (7b). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
usb-bulk and usb-bulk-audio records now match their code. system-package-restart, crash-capture, bootscreen-safe, bootscreen-fault and debug-observers load no module with a DSP part and assert no audio or DSP state, so they drop the coupled SHARC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The selection code now returns why each device test was chosen (owner, record, imports, hub, area, ports, named) as data, and what it left out (narrowed halves, dropped files). The device command writes it as selection.json in its trace dir; the printed lines are unchanged. - selection-record.mjs builds the record (halves with rule and trigger, skipped with reason, changed, dropped, lane, commit, base, level); full-tier runs record their scope only. - gate-history --selection joins the record with slot wait and run time at read time and prints device-half minutes by rule plus the plan's headline numbers; older runs show as unrecorded. - trace-rows.mjs is the one reader of slots-trace.json and nx-profile.json. - The per-test reporter keeps the first error message of a failed test and writes a suite-error record for hook and collection failures, whose tests Vitest marks skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bootscreen-safe failed under dsp zero with 'empty startup requires a reusable coupled session' (packages/test-support/src/session.ts:331 needs dsp 'sharc'). bootscreen-fault's halt error text also differs under zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skippedHalves returns each skipped id with its reason and ranHalves gives the halves that run, so selection-record.mjs only reshapes. A failed selection.json write prints one line and the gate carries on. errorText cuts at 600 characters without splitting a surrogate pair. The device-literals baseline takes the selection-record test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tem 7) Records the SHARC link record spike (host commands land at wall-time points; the CF waits on the SHARC in only 15-16% of frame time, yet zero mode runs 2-5x faster per test), the five tests moved to zero DSP, and item 7 as agreed with c0 and db: device keys hash emulator semantics, with an equivalence check on the SHARC implementation crates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The graph edges only decide what `nx affected` marks; device targets already depend on the patchkit, daemon and image producers and key on their inputs, and the gate picks device halves by ownership. - module-dependencies: a project with device or conformance targets no longer gets implicit edges to digi-control, patchkit and devices (about 60 projects each). The record-module, conformance and nested-project edges stay. - core/runtime: replace the dkrt-svc-* glob by the five service crates its Cargo dev-dependencies compile (rt, fx, lfo, rows, machines). The projects: inputs of rust-tests and test-assembly keep the glob, so the cache keys do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Targets that run through nx affected need a real project edge to each project whose output they read; dependsOn alone does not mark them affected. - module-dependencies: a project with test-dsp or test-dsp-conformance keeps the patchkit and devices edges (the patchkit binary, the dsp fingerprint, devices/cycle-factors.json). Device and conformance device targets stay without them; digi-control stays dropped. - core/runtime: restore the dkrt-svc-* glob, since test-assembly consumes every service pack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(tools): record gate selections, cache-safe edges and five tests on zero DSP
Under load the gate's --explain run could exit nonzero after printing its affected line; the plan was written without the ownership step's test:subset lines, so two replays of an unchanged tree differed (reported by digitakt2-e1). A failed sample now writes no plan, is listed as FAILED, and the run exits 1 after finishing the other samples. The nx affected --explain file moves to the worktree's dist/, so lanes replaying the same sample no longer overwrite each other's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(nx): test-plans fails a sample whose gate explain failed
…ce-images patchkit:cli, every module pack and pack-aliases, patchkit:device-bytes and patchkit:device-images were cache: false, so every gate run in every worktree rebuilt them (0% hit over 7 days). They are cached on declared inputs now. - cli: adds COMPILE_SOURCE.patchkit, Cargo.toml, Cargo.lock, .cargo, the rust pin, rustc version, profile and flag variables (shared rustEnvInputs with the hermetic rust-tests); outputs are the binary and the patchkit test keys. - pack and pack-aliases: inputs were already complete; only the flag changes. - device-bytes: adds the module manifests. - device-images: adds devices, ports, ports/fw, the manifests, and the stock image bytes through firmware-hash.mjs --syx --overrides (new flag, images only). Checked: second run hits, restored outputs are byte-identical, a one-line input edit misses and the revert hits again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each missing input meant a stale cache hit and a false pass. - device-images hashes the module files the loader opens beyond module.toml (payload bodies, registry index_table, system package), derived from the manifests by loaderFiles; firmware-hash.mjs --module-files - pack and pack-aliases take ports/*.toml, ports/fw and the environment overrides (PATCHKIT_MODULES refuses reuse), through firmware-hash.mjs - patchkit:cli hashes CF_NATIVE_DIR and the kernels.rs it names - docs/TESTING.md: drop the stale "uncached" sentence, describe the inputs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
perf(nx): cache the patchkit CLI, module packs and device images
This branch has not been deployed
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.
MAC and MSAC with a
(d16,Ay)load consumed four bytes and read the EMAC extension word as the displacement. The SLEIGH change consumes the extension word before the signed displacement, so all four word/long load constructors consume six bytes. The firmware oracle tolerates the known mismatch in older saved listings and requires the live decoder to agree. The slow integration test now calls the current oracle API.Fixes #430.
Verification
The focused tests compile the repository's SLEIGH language and cover positive and negative displacements, all four constructors, the next instruction boundary, and the three unaffected addressing modes. Fourteen tests passed. Two full-image oracle tests skipped because their saved Ghidra disassembly and cross-reference databases were unavailable. Ruff and the diff checks passed.
A separate check decoded the actual instruction bytes from stock firmware with the freshly compiled language. In all three images the decoder read
mac.wwith displacement+4from A1 and resumed at the following four-bytemac.l.0x400d94460x400d944c0x400db2ce0x400db2d40x400d92e20x400d92e8Both affected Nx targets passed. The complete merge gate stopped in
test_ports_are_currentbecause the DT2 1.17 Ghidra database and source dump manifest were unavailable. The expansion object target passed on retry with the installed m68k cross compiler. After the gate, the stock Digitone II 1.12 simulator cold-booted to ready, saved its snapshot and processed 4,745 audio frames with zero missing blocks. This PR remains in draft pending the complete gate.