Skip to content

safe-bash: provide virtual /dev/null semantics for injected filesystems #700

Description

@kamilio

Safe-bash should provide /dev/null semantics across arbitrary injected filesystems, rather than requiring each product adapter to rediscover them.

Our persistent agent filesystem stores every supplied path as ordinary data. A model ran a missing command with 2>/dev/null; safe-bash forwarded that destination to storage, leaving a real 39-byte /dev/null file containing shell: line 3: find: command not found\n. Later ls -l /dev/null; cat /dev/null displayed the file and old diagnostic. This is a real product reproduction, not an expectation that the host OS null device is available.

Published-artifact audit: safe-bash/safe-fs 0.1.496 exports have no virtual-device filesystem helper; /dev/null occurrences in safe-bash concern diff/patch filename conventions, not general filesystem I/O. We currently intercept the canonical path in our adapter, but this is generic shell behavior that belongs upstream.

Please add a bounded device overlay (in safe-fs if that is the right abstraction), installed by safe-bash around an injected filesystem, with consistent behavior for redirection and command filesystem access (cat, stat, cp, tee, etc.):

  • /dev/null always exists; reads return EOF, normal and append writes discard all bytes without persistence or whole-input buffering. Streaming drains respect cancellation and close the producer.
  • Canonical absolute/relative paths resolve consistently. Exclusive creation fails EEXIST; device-as-directory/descendant access fails ENOTDIR; unlink/rename/replacement cannot turn the reserved device into an ordinary file.
  • Define stat and directory-listing behavior (including /dev), and how the device is represented if FileStat currently only supports file/directory/symlink.
  • Never forward null-device mutations to the backing store, consume its file quota, or delete an existing historical backing row. Any masked historical record remains the application's explicit cleanup responsibility.
  • Public supported API only; exercise an injected persistent adapter and actual workerd, including a large canceled stream and a backing-store spy proving no persistent writes.

A redirection-only special case is insufficient: normal commands also invoke the filesystem directly. Product prompt listings may bypass the shell; our application must still hide historical /dev/null rows there until deliberately cleaned up. We will retain our temporary local behavior until a published upstream implementation is verified.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions