Skip to content

feat(cli): replace the xgenext2fs spawn with @deroll/genext2fs - #517

Draft
tuler wants to merge 1 commit into
claude/replace-xgenext2fs-cartesi-machine-rhhnskfrom
claude/replace-xgenext2fs-rhhnsk
Draft

feat(cli): replace the xgenext2fs spawn with @deroll/genext2fs#517
tuler wants to merge 1 commit into
claude/replace-xgenext2fs-cartesi-machine-rhhnskfrom
claude/replace-xgenext2fs-rhhnsk

Conversation

@tuler

@tuler tuler commented Aug 17, 2026

Copy link
Copy Markdown
Member

Contributes to #72.

Important

Stacked on #509 — that is this PR's base branch, so the diff shown here is only the ext2 change. Retarget to prerelease/v2-alpha once #509 merges.

That issue asks for the external programs the CLI drives to stop being spawned binaries, and notes that "instead of spawning binaries another possibility is to build NodeJS bindings to native code components". #509 does the emulator; this one does the ext2 generator.

Program Before After
xgenext2fs execa, falling back to docker run in the SDK image @deroll/genext2fs

Docker is still needed to build the root drive from a Dockerfile (riscv64 via QEMU), for squashfs drives (mksquashfs), and for the services run brings up.

What changed

src/exec/genext2fs.tsempty, fromDirectory and fromTar call createImage/tarToExt2 instead of spawning. The bindings get the same block size, faketime and readjustment settings the old command lines used, so drive contents are unchanged. Paths are resolved against the destination directory, since there is no subprocess cwd to lean on anymore, and the diagnostics the tool writes to stderr are forwarded to the same reporter as before.

version() is now a synchronous lookup of the vendored xgenext2fs version rather than a --version subprocess. requiredVersion stays, so the test still guards that the vendored version is one the CLI supports.

The builders drop the sdkImage argument they only passed to genext2fsbuildEmpty loses the parameter entirely, the others still need it for mksquashfs.

Testing

  • The version test moved from tests/integration/exec/ to tests/unit/exec/, since building a drive no longer needs Docker. It grew along the way: it now builds an empty drive and asserts its size, builds one from a directory, asserts the "too few blocks" failure still surfaces, and asserts two builds of the same input are byte identical (the reproducibility that faketime buys).
  • tests/integration/builder/empty.test.ts no longer pulls the SDK image.
  • 169 unit tests pass on this branch (164 from feat(cli): replace the cartesi-machine spawn with @cartesi/machine #509 plus 5 here).

Note on the dependency

This is a personal-scope package, unlike @cartesi/machine in #509. @deroll/cm@cartesi/machine was already planned and has landed; @deroll/genext2fs is newer than that comment and is not named in the plan, so whether it also moves under @cartesi/* is an open question.

Worth a look from whoever owns licensing: it is GPL-2.0-only, inherited from xgenext2fs which it compiles in, while the CLI is Apache-2.0. @cartesi/machine is Apache-2.0, so this applies only to the ext2 dependency.


Generated by Claude Code

@changeset-bot

changeset-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 590525b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@socket-security

socket-security Bot commented Aug 17, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​deroll/​genext2fs@​0.2.0-alpha.0741001008670

View full report

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 95.17% (🎯 0%) 5061 / 5318
🔵 Statements 95.17% 5061 / 5318
🔵 Functions 90% 144 / 160
🔵 Branches 0% 0 / 0
📁 File Coverage (20 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 86.61% 🟢 86.61% 🟡 66.67% 🔴 0% 75-77, 79, 109-111, 168-177
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/tar.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/builder.ts 🟢 99.79% 🟢 99.79% 🟢 100% 🔴 0% 228
apps/cli/src/compose/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/node.ts 🟢 99.24% 🟢 99.24% 🟢 100% 🔴 0% 106
apps/cli/src/config.ts 🟢 94.32% 🟢 94.32% 🟢 95.24% 🔴 0% 75-76, 251, 260, 269, 363, ...
apps/cli/src/contracts.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...rc/errors/ForkChainValidationError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...c/errors/UnsupportedForkChainError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...c/exec/cartesi-machine-stored-hash.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/exec/cartesi-machine.ts 🔴 16.9% 🔴 16.9% 🔴 50% 🔴 0% 43-45, 54-109
apps/cli/src/exec/genext2fs.ts 🟢 90.91% 🟢 90.91% 🟢 100% 🔴 0% 31-35
apps/cli/src/exec/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/exec/mksquashfs.ts 🟢 91.53% 🟢 91.53% 🟢 100% 🔴 0% 70-74
apps/cli/src/exec/util.ts 🟢 85.11% 🟢 85.11% 🟡 66.67% 🔴 0% 24-28, 68-69
apps/cli/src/images.ts 🔴 16.13% 🔴 16.13% 🔴 0% 🔴 0% 20-21, 27-30, 39-41, 45-49,...
apps/cli/src/machine.ts 🟢 86.52% 🟢 86.52% 🟢 84.62% 🔴 0% 22-23, 187, 275, 290, 293, ...

Build ext2 drives through the @deroll/genext2fs N-API bindings, instead of
spawning xgenext2fs (falling back to running it inside the SDK docker image).

The bindings are given the same block size, faketime and readjustment settings
the command line used, so drives stay byte identical. Since building a drive no
longer needs docker, the version test moves from the integration suite to the
unit one, where it also covers building images and their reproducibility.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UTEd5g3mF849BATTstssR3
@tuler
tuler force-pushed the claude/replace-xgenext2fs-rhhnsk branch from d02ec21 to 590525b Compare August 17, 2026 21:11
@brunomenezes brunomenezes moved this to 🧑‍💻 In Progress in Rollups Tooling Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo
Status: 🧑‍💻 In Progress

Development

Successfully merging this pull request may close these issues.

3 participants