Skip to content

feat: zero lists and domain overrides - #28

Open
kajaaz wants to merge 1 commit into
fix/redef-no-in-placefrom
feat/zero-lists-domain-overrides
Open

kajaaz wants to merge 1 commit into
fix/redef-no-in-placefrom
feat/zero-lists-domain-overrides

Conversation

@kajaaz

@kajaaz kajaaz commented Nov 12, 2026

Copy link
Copy Markdown

The plan

This PR is 2 of 8. Together they let Ledger fuzz its device apps on an Absolution state model, with libFuzzer and with KLEE, through one harness.

Absolution (this repo)        Ledger SDK              Ledger apps
1 A1 build fixes
2 A2 model tuning  <- this PR
3 A3 KLEE driver
  tag v1.2.0 -------------->  4 S1 LedgerHarness ---> 6, 7, 8: one PR per app
                              5 S2 KLEE lane
# PR Adds
1 A1, #27 build fixes: a rebuild no longer recompiles unchanged sources, release builds keep the invariant check, a parser leak
2 A2, this PR model tuning in the same run: zero lists, domain overrides, --no-post-check, harness-only sources
3 A3 --symbolic klee: a KLEE driver on the fuzzer's input layout, so a KLEE test replays on the fuzzer
4 S1 SDK: an app lists its APDU commands in a manifest, and the SDK builds its fuzzers, seeds and tests on Absolution v1.2.0
5 S2 SDK: an opt-in KLEE lane on the same harness, seeded from the fuzz corpus
6 to 8 apps three apps move their fuzzers to the SDK harness

A1 to A3 are stacked and released together as v1.2.0. The SDK and app PRs are in internal Ledger repositories.

This PR is the second step, stacked on A1 (#27): its base is the A1 branch, so the diff shows only this step. The SDK harness (step 4) passes these options for every app.

What

Tune the discovered model in the same run, without exporting, editing and re-importing a .zon:

Option CMake Effect
-Z, --zero-symbols ZERO_SYMBOLS matched globals get one all-zero value; unmatched selectors are reported
--lenient-zero-symbols LENIENT_ZERO_SYMBOLS same, for shared lists; unmatched selectors are silent
-O, --domain-overrides DOMAIN_OVERRIDES <global>.<field> = values ..., top or enum T; unmatched lines are fatal
--no-post-check NO_POST_CHECK no check_invariant() assertion after the harness
EXTRA_SOURCES harness-side C files, linked and never sampled

A selector is a global name, or name@path to pick one by source path. The order is --invariant, then zero lists, then overrides. Editing any of these files regenerates the driver.

Why

The Ledger SDK harness keeps most app state at zero (every input starts from boot) and narrows a few enums and flags. With only .zon import/export, each app had to commit a machine-local model and re-export it after every source change.

Changes

  • src/Tuning.zig (new): parsing and applying both file kinds, with tests.
  • src/main.zig, src/root.zig, src/Parser.zig (C enum collection), src/cgen/emit.zig (--no-post-check).
  • cmake/AbsolutionFuzzer.cmake, cmake/RunAbsolution.cmake: the new arguments.
  • USAGE.md: "Zero lists and domain overrides".

Tests

zig build test, zig build -Doptimize=ReleaseFast and zig run scripts/integration.zig pass.

@kajaaz
kajaaz requested a review from 0pendev as a code owner November 12, 2026 16:33
@kajaaz
kajaaz changed the base branch from main to fix/redef-no-in-place November 12, 2026 16:33
@kajaaz
kajaaz added this pull request to stack #29 November 12, 2026 16:33
@kajaaz kajaaz changed the title Feat/zero lists domain overrides feat: zero lists and domain overrides Nov 13, 2026
Comment thread src/main.zig
if (opts.seed) |seed_path| try seed.writeSeed(io, seed_path, needed_bytes);
}

fn readAll(gpa: std.mem.Allocator, io: std.Io, arena: std.mem.Allocator, path: []const u8) ![]const u8 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this helper? We have nothing in the stdlib for that?

Comment thread USAGE.md

### Zero lists and domain overrides

Most projects only need a few tweaks on top of the discovered model. Instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss this.
I do agree but the interest of forcing the first generation is that you have an absolute expression of all invariants 🤔

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