Skip to content

RUNTIME-005: Binary file write mode ('wb') not supported — no byte array type #170

Description

@Masterplanner25

Summary

builtin_write_file in io.py always opens files with encoding='utf-8' — there is no binary write mode. Scripts that need to write binary data (compiled bytecode, image files, protocol buffers) cannot do so via std:fs.

Additionally, there is no byte array type in Nodus. Binary data from subprocess.stdout is a string (decoded), and there is no way to construct or manipulate raw byte sequences from within a script.

Impact

This is a Stage 3 bootstrap gap: to write a Nodus compiler in Nodus itself, the compiler must be able to write compiled bytecode files. Without binary write and a byte array type, this is not possible.

Fix direction (v5)

  1. Add write_file_bytes(path, bytes_list) builtin that opens with 'wb' mode and writes a list of integers (0–255) as bytes
  2. Add read_file_bytes(path) that reads a file in binary mode and returns a list of integers
  3. Consider a Bytes value type for more ergonomic binary handling

As a stopgap, std:subprocess can write binary files by invoking system tools, but that's a workaround, not a solution.

Affected versions

v4.0.0 (current when filed). Noted in Runtime Readiness Audit bootstrap table as MISSING.

Activity

  1. added this to the v5.0 milestone on Jun 8, 2026
  2. Masterplanner25 commented on Aug 17, 2026

    @Masterplanner25
    OwnerAuthor

    Triage 2026-08-17 (against v5.0.2). Still reproduces — there is no binary write path:

    $ nodus run b1.nd
    Key error: Missing module export: write_bytes
    

    std:fs exposes no write_bytes, and there is still no byte-array type.
    Unchanged through 5.0.2.

  3. removed this from the v5.0 milestone on Aug 25, 2026
  4. Masterplanner25 commented on Aug 30, 2026

    @Masterplanner25
    OwnerAuthor

    Re-verified 2026-08-30 against 5.7.1 dev source — still valid, as part of a sweep over the 2026-06-07 audit batch.

    No write_file_bytes / read_file_bytes builtin exists, and there is still no byte type. Every "wb" open in the tree is internal Python — bytecode_cache.py, snapshots.py, registry_client.py, subprocess_module.py — and none is reachable from .nd.

    Still the bootstrap gap this describes: examples/expr_compiler.nd is a lexer/parser/evaluator already written in Nodus, and it cannot write its output.

    Cross-reference for whoever picks this up: #173, the other named blocker on the same axis, has moved — throughput measured ~477K instr/sec after #522, roughly double the figure still in that issue's title. This one has not moved at all.

  5. added a commit that references this issue on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions