Skip to content

Add the kuna decompiler backend (+ kuna SLEIGH type aliases) - #2

Merged
mahaloz merged 1 commit into
mainfrom
feat/kuna-backend
Jun 29, 2026
Merged

mahaloz merged 1 commit into
mainfrom
feat/kuna-backend

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a kuna decompiler backend so the benchmark can score the standalone kuna Rust decompiler (a line-faithful port of Ghidra's decompiler) alongside angr / ghidra / ida / binja.

decbench/decompilers/raw/kuna_raw.py (registered kuna)

Unlike the other raw backends (which import a native Python module), kuna ships as a standalone CLI, so this backend shells out to it — like the dockerized backends — driving kuna's whole-binary entrypoint:

kuna decompile-all <binary> --json

which loads + analyzes the binary once and decompiles every function (the load-once contract ghidra/angr satisfy by reusing one program/JVM/process). It reuses the shared common helpers verbatim (ELF-file-space addressing, CRT/PLT skip-filter, source-name narrowing, gotos/bools metadata, atomic progress-pickle), parses kuna's per-function {name, address, code, variables} into the standard DecompilationResult, and is located via $KUNA_BIN or kuna on $PATH.

type_match TYPE_MAP: kuna SLEIGH type aliases

kuna spells the integer core types int4/int8/uint4/… (sized in bytes, like the existing undefinedN). Added these to TYPE_MAP so they normalize to the DWARF base-type names — exactly the way angr's undefinedN and IDA's __intN are already aliased. Without it kuna's type_match is unfairly ~0.

Validation

decbench evaluate <bin> -d kuna runs all three metrics end-to-end on real Joern/gcc:

metric score (on a -g sample)
GED (structure) 0.00 (perfect — lower is better)
type_match 0.85 mean
byte_match 0.19 mean (recompiles)

Registry: kuna appears in list_registered(), is_available() true when the CLI is found.

Notes

  • Surgical: only decompilers/raw/kuna_raw.py (new), decompilers/raw/__init__.py (registration), and metrics/type_match.py (the TYPE_MAP aliases) — no other working-tree changes touched.
  • The kuna CLI side (kuna decompile-all --json) is a separate PR in the kuna repo.
  • ⚠️ The type_match metric content-caches per decompiler output; if you've already cached kuna results from before the TYPE_MAP change, re-run with DECBENCH_NO_CACHE=1 (or clear the cache) so the new aliases take effect. Fresh kuna runs are unaffected.

🤖 Generated with Claude Code

https://claude.ai/code/session_019rQxQo7u2SGf7osJEjf3rK

Adds a kuna decompiler backend (`decbench/decompilers/raw/kuna_raw.py`,
registered as `kuna`) that drives the standalone kuna Rust CLI's whole-binary
entrypoint `kuna decompile-all --json` — one process per binary, loading +
analyzing once and decompiling every function (the same load-once contract the
ghidra/angr raw backends satisfy). It reuses the shared `common` helpers for
ELF-file-space addressing, CRT/PLT skip-filtering, source-name narrowing,
gotos/bools metadata, and the atomic progress-pickle, and parses kuna's
per-function `{name,address,code,variables}` into the standard
`DecompilationResult`. The CLI is located via `$KUNA_BIN` or `kuna` on `$PATH`.

`type_match`: alias kuna's SLEIGH core-type spellings (`int4`/`int8`/`uint4`…,
sized in bytes like the existing `undefinedN`) into `TYPE_MAP`, so kuna's
recovered types normalize to the DWARF base-type names — the same way angr's
`undefinedN` and IDA's `__intN` are aliased. Without it kuna's type_match is
unfairly ~0.

Validated end-to-end via `decbench evaluate <bin> -d kuna` (GED + type_match +
byte_match all run on real Joern/gcc; type_match 0.85 mean on a -g sample).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019rQxQo7u2SGf7osJEjf3rK
@mahaloz
mahaloz marked this pull request as ready for review June 29, 2026 15:39
@mahaloz
mahaloz merged commit cc9ff3f into main Jun 29, 2026
@mahaloz
mahaloz deleted the feat/kuna-backend branch July 22, 2026 21:45
mahaloz added a commit that referenced this pull request Nov 4, 2026
External eval-kit submission from Nemesis, ingested as the `psalms` column
(version refine6t). Their decompiled output is withheld from every published
payload at their request (`private_artifacts`, as for Ventris); their scores
are measured and ranked exactly like every other column.

Ingest was clean against the current manifest: no drift, 249 of the 250
sample-set functions submitted (the one miss is a Betaflight O2 firmware
function), nothing dropped. Scored with the metric code behind the published
numbers (GED cache v4, type_match v17, byte_match v7), so the column is
comparable with the rest of the board.

sample-set, #2 of 16 by Union:

    Union      144/250  57.6%   (codex 59.6%, claude-code 56.8%)
    Structure  131/246  53.3%
    Types       37/236  15.7%
    Recompile   14/158   8.9%
    Errors       0/249   0.0%

Verified before publishing:
  - every other column's ged/type_match/byte_match overlay entry and checkpoint
    leaf is unchanged, and no GED slice was lost (7515 slices, 0 pending);
  - the finalize coverage guard held at 770 -> 770 binaries and
    96,103 -> 96,103 function rows; `--audit` reports no SILENT-DROP, and the
    four psalms gaps are the no-source-CFG slices every sample-set column has;
  - with psalms removed, aggregates.json and dataset.json match the deployed
    site exactly apart from generated_at;
  - the View page keeps all 539 samples, the same 100/100/100/239 mix and the
    same 536 entries carrying source; 25 easy/medium/hard picks re-tiered,
    because tiers use cross-decompiler GED agreement;
  - 242 View entries carry psalms scores with the body withheld, no psalms
    output appears anywhere in site/, and the Pages privacy check passes;
  - the HuggingFace dataset is unaffected (the column is excluded there).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKPMDEpdQyVL57JXxHw
mahaloz added a commit that referenced this pull request Nov 4, 2026
* Add Nemesis's Psalms as a private sample-set column

Nemesis submitted the sample-set eval kit for their Psalms decompiler on the
condition that their decompiled output is not republished. Handled exactly
like Ventris: the column is scored and ranked like any other, its code is
withheld from every site payload (the View page shows the "private" notice),
and it is excluded from the HuggingFace dataset.

- decompilers.toml / site.toml / external.py: register `psalms` as a
  closed-source, sample-set-only external column with `private_artifacts`.
- `layout.EXCLUDED_DECOMPILERS` gains `psalms`, and `publish_dataset.py
  --exclude-decompiler` now adds to those defaults instead of replacing them.
  The recorded live invocation (`--exclude-decompiler ventris
  --exclude-decompiler retdec`) would otherwise have published the psalms
  column; `--no-exclusions` stays the only way to disable the defaults.
- `psalms` joins the GED promotion defaults in reeval_ged.py and ingest.py.

[AUTOMATED] authored end-to-end by Claude Code at the maintainer's request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKPMDEpdQyVL57JXxHw

* [AUTOMATED] Promote codex@gpt-6-astra's GED by default

`reeval_ged.py` promotes CANONICAL_DECOMPILERS plus the ids named in
DECBENCH_REEVAL_DECOMPILERS. The versioned `codex@gpt-6-astra` column was in
neither by default, so a GED refresh scoped to a new column dropped all 257 of
its published slices from ged_new.json. Add it to CANONICAL_DECOMPILERS and to
ingest's printed defaults, with a test that every ingest default is promoted.

[AUTOMATED] authored end-to-end by Claude Code at the maintainer's request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKPMDEpdQyVL57JXxHw

* [AUTOMATED] site: snapshot GED on Rust Joern

Freeze the scoreboard as published on 2026-10-09 before Psalms joins the
sample set. Adding Psalms moves no previously published number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKPMDEpdQyVL57JXxHw

* [AUTOMATED] site: add Nemesis Psalms sample-set results

External eval-kit submission from Nemesis, ingested as the `psalms` column
(version refine6t). Their decompiled output is withheld from every published
payload at their request (`private_artifacts`, as for Ventris); their scores
are measured and ranked exactly like every other column.

Ingest was clean against the current manifest: no drift, 249 of the 250
sample-set functions submitted (the one miss is a Betaflight O2 firmware
function), nothing dropped. Scored with the metric code behind the published
numbers (GED cache v4, type_match v17, byte_match v7), so the column is
comparable with the rest of the board.

sample-set, #2 of 16 by Union:

    Union      144/250  57.6%   (codex 59.6%, claude-code 56.8%)
    Structure  131/246  53.3%
    Types       37/236  15.7%
    Recompile   14/158   8.9%
    Errors       0/249   0.0%

Verified before publishing:
  - every other column's ged/type_match/byte_match overlay entry and checkpoint
    leaf is unchanged, and no GED slice was lost (7515 slices, 0 pending);
  - the finalize coverage guard held at 770 -> 770 binaries and
    96,103 -> 96,103 function rows; `--audit` reports no SILENT-DROP, and the
    four psalms gaps are the no-source-CFG slices every sample-set column has;
  - with psalms removed, aggregates.json and dataset.json match the deployed
    site exactly apart from generated_at;
  - the View page keeps all 539 samples, the same 100/100/100/239 mix and the
    same 536 entries carrying source; 25 easy/medium/hard picks re-tiered,
    because tiers use cross-decompiler GED agreement;
  - 242 View entries carry psalms scores with the body withheld, no psalms
    output appears anywhere in site/, and the Pages privacy check passes;
  - the HuggingFace dataset is unaffected (the column is excluded there).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKPMDEpdQyVL57JXxHw

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant