Skip to content

feat(esp32): fail fast on a disk too small for a cold ESP32 build - #1767

Merged
zackees merged 3 commits into
mainfrom
agent/esp32-disk-preflight
Oct 28, 2026
Merged

zackees merged 3 commits into
mainfrom
agent/esp32-disk-preflight

Conversation

@zackees

@zackees zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member

What this is

Gives a client's agent a way to fix a machine that needs root (a wedged graphics
driver, a package that will not repair) without blanket root. Every
escalation is a Telegram approval the human taps, and every attempt is logged.

The sudoers entry grants exactly one command to one user:

<agent-user> ALL=(root) NOPASSWD: /usr/local/libexec/hermes-consent-exec

No argument wildcards. The root helper refuses unless the exact argv was
approved by the configured Telegram user, inside the TTL, once; it writes one
JSON line per attempt (allowed and denied) to /var/log/hermes-consent.log
(0600 root). The fragment is validated with visudo -cf and swapped in
atomically; /etc/sudoers is never edited.

What state it leaves the machine in

  • /usr/local/libexec/hermes-consent-exec (root:root 0755)
  • /etc/hermes-consent/config.json (root:root 0644) — approver id + TTL
  • /etc/sudoers.d/90-hermes-consent (root:root 0440) — the single rule
  • /var/lib/hermes-consent (0700) and /var/log/hermes-consent.log (0600)
  • ~<agent>/.hermes/consent/ (0700) — request/approval records

--uninstall removes the rule, helper and config and keeps the audit log.

Three targets

Target Delivery Verified by
Ubuntu 24.04 installer bosn run --task e2e-ubuntu
Arch Linux the same installer, unchanged (pacman, no apt) bosn run --task e2e-arch
NixOS flake attribute replaces the installer — security.sudo.extraRules, /etc config, tmpfiles nix build .#checks.x86_64-linux.consent-sudo (VM test)

How it was tested

  • Ubuntu 24.04 container: 44 assertions, 0 failed, 0 skipped.
  • Arch Linux container: 43 assertions, 0 failed, 1 skipped (/etc/sudoers.d is
    0750 there, so the unprivileged phase cannot stat the fragment; the root audit
    phase verifies its content and mode — the skip prints that reason).
  • NixOS VM test (runNixOSTest, real boot, /dev/kvm): passed all subtests.

The suite proves, from real command output: sudo -n true fails before install
and still fails after; sudo -n /usr/bin/id and /bin/sh are refused; an
unapproved id, a wrong-Telegram-user approval, an expired approval, a replayed
approval and tampered argv are all refused with distinct reason codes; one
correct approval runs the exact argv as root (id -u → 0) exactly once; the
audit log has one allowed line and every denied line; uninstall leaves sudo
still requiring a password.

The container Dockerfiles grant the unprivileged test user only the
installer (so the suite can prove the before/after state); everything else still
demands a password. That is harness-only and commented as such.

Limitation (also in the skill and README)

This stops prompt injection and silent escalation. It does not stop a fully
compromised gateway process: the approval record is written by a user-level
process running as the same user as the agent, so a process that can call
approve can mint one. Only splitting the approval and execution across
privilege domains would close that; this design deliberately does not attempt it.

Flagged deviation

bosn run --task e2e-all runs the full assertion set on the default (Ubuntu)
stack plus the repo's skill gate. A single container cannot host the Arch
container, so Arch remains its own task — the task comment says so rather than
pretending otherwise.

fbuild could measure free disk space and never did: `volume_facts` had no
caller outside platform/, so a full disk surfaced as a raw ENOSPC from
whichever subprocess wrote next, with no statement of the path or the
shortfall (#1750).

Before package resolution the ESP32 build now measures every root it
writes and turns a shortfall into one actionable error naming the path,
free vs required bytes, the shortfall, and the largest reclaimable caches
under the cache root. A healthy build logs a single info line.

The check is measurement only: reclaiming caches stays an explicit,
budgeted step, because #1341 showed a mid-build eviction can delete a warm
esptool install. Builds that only free space (--clean, --clean-all) skip
the check. FBUILD_MIN_DISK_BYTES overrides the cache requirement and 0
disables the check.

Refs #1750
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The ban_std_pathbuf dylint denies naming std::path::PathBuf in new code, so
DiskRoot/RootSpace store fbuild_core::path::NormalizedPath instead. Std-only
free-space probing still takes &Path.
ban_unrooted_tempdir denies std::env::temp_dir() in production code: fbuild's
scratch tree is <cache root>/tmp, so the pre-flight measures that instead of
$TMPDIR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant