mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
- RemoteExecutionEnv: a Durable ExecutionEnv on another machine whose results match NodeExecutionEnv there; Connection to the pi-env daemon - packages/env/daemon: the Rust daemon for Linux, macOS, Android and Windows, following Node and libuv semantics - env.yml runs Durable's env tests, the daemon's checks and pi-env's conformance and differential tests on Linux, macOS and Windows
3 KiB
3 KiB
Semantics
The reference is Durable's NodeExecutionEnv (packages/durable/src/env/node.ts) on the remote machine. Durable's
env conformance suite and client/test/differential.test.ts check each rule below.
Split of work
| Concern | Where |
|---|---|
Path resolution: ~ (remote home), file://, relative to cwd |
client, POSIX rules |
| Abort checkpoints of each method | client, as NodeExecutionEnv |
Error code mapping (ENOENT → not_found, ...) |
client, as NodeExecutionEnv's toFileError |
readTextFile decoding (byte-order mark kept, like readFile(path, "utf8")) |
client |
| Line reader | client, positional reads and Durable's StreamDecoder |
| Timeout validation, result precedence (callback error, timeout, abort, spill failure, exit code) | client |
| System calls, processes, spill files, line scans | daemon |
| Command output decoding: per stream, WHATWG UTF-8, only a leading byte-order mark dropped | daemon (encoding_rs) |
Rules the standard libraries do not follow
- Recursive
mkdir: an existing directory is fine, an existing file fails withEEXIST, a file in the way of a parent fails withENOTDIR. Writes create missing parents this way. rm: a missing path fails unlessforce; a directory withoutrecursivefails withERR_FS_EISDIR(FileErrorcodeunknown).mkdtemp:mkdtemp(3)of<tmpdir>/<prefix>XXXXXX; the prefix is joined with POSIXpath.join, so../xworks.tmpdir:TMPDIR,TMP,TEMP, then/tmp(Termux:$PREFIX/tmp), trailing slash removed.listDir: names in byte order, like libuv'sscandir; fails if any entry cannot be lstat'ed.openDirReaderkeeps directory order and skips entries removed meanwhile.openBinaryReader: nonblocking open; directories fail withis_directory, other non-regular files withinvalid;noFollowrefuses a final symbolic link (O_NOFOLLOW).readBinaryFilereturns aBuffer, reader reads a plainUint8Array, as Node does.
Commands
- A string runs through the shell: a configured
shellPaththat does not exist fails withshell_unavailable; otherwise/bin/bash,which bash, thensh, with-c. An argv array runs its program directly. - The working directory must exist (
spawn_error). - Environment: with
inheritEnv(default), the daemon's environment, thenshellEnv, thenenv; without it, onlyenv. - Each command gets a new session (process group), default signal dispositions and an empty signal mask. Timeout,
abort and
cleanup()kill the group withSIGKILL. - After the process exits, output is still collected until both pipes end, or 100 ms pass without output.
- An abort settles as
aborted;cleanup()kills without aborting, so the command settles with exit code 137. - A process killed by a signal reports
128 + signal. - Spill: once the output crosses
spill.afterBytesorspill.afterLines(counted over raw chunks in arrival order, as Node counts), the complete raw output goes topi-output-<uuid>.login a freshtmp-directory.