File, JSON, and output primitives for ports

fs.writeBytesAtSync(path, offset, bytes): bool overwrites an existing regular file starting at the given byte offset without truncating the prefix or suffix. fs.writeBytesAt(path, offset, bytes): Future<bool> performs the same operation asynchronously. Offset accepts integer types, including long for files beyond 2 GiB. Writing beyond EOF extends the file with a zero-filled gap. An empty write succeeds for an existing regular file. Neither variant creates missing files. Invalid ranges and open/write/close failures return false; failed writes can be partial. These calls do not promise transactionality or durable disk flushes.

json.valid(text): bool validates one complete JSON document without throwing for malformed input. json.parse<T>(text) rejects malformed syntax and trailing content with a catchable error. Number grammar, escape sequences, and UTF-16 surrogate pairs and raw UTF-8 are checked. Integers must fit signed 64-bit storage and floats must be finite; escaped NUL is rejected because Rad strings are NUL-terminated. Whitespace surrounding the one document is accepted.

json.parse<Map>(text) reads an object whose keys aren’t known in advance: a string member is its text, any other member is its JSON (nested objects/arrays, escaped strings, shortest round-trip float text), suitable for parsing again. m.keys() returns the object’s keys; arrays, scalars and null parse to an empty map. Use json.from(value) to serialize typed Rad values.

sys.write(value) and sys.print(value) are aliases for sys.output.write(value): they write without appending a newline. Use sys.output.flush() when immediate visibility is required; use sys.output(value) to include a newline.