JS SDK: no way to read a binary file back (fs.read refuses it as Binary)

Abierto
#417 4 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@Mola-maker ya está trabajando en esto.

Desde el 8/11/2026.

  • #492 de @YidaWeng — abierto

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, rust
Área
api, backend

Línea de trabajo

Read the existing fs.read implementation and read_range in layerfs-content, then follow the path through layerfs-store-service/src/read/reads.rs to the layerfs-api handler. The issue leaves the public API shape, byte cap, and whether the method should exist undecided, so those owner decisions must be settled before implementation. Done means a decision and, if approved, a bounded binary read with a Linux SDK test.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

integration new feature

Split from #413. Writes are fixed by #416; this issue is about reading.

Problem

The JS SDK can write a binary file but cannot read it back. fs.read reads text in windows (at most 2000 lines / 48 KiB per call) and refuses a file with NUL or invalid UTF-8 as Binary. No other SDK call returns a file's raw bytes. fs.stat gives only its size.

This means a binary file round-trip through the fs surface is impossible. For example, the Magpie LayerFS plugin (magpie-community/plugins#318) has to skip binary files on checkout and list them as not materialized.

Decision needed (owner)

Whether to add a byte read to the public SDK, and in what shape. It would be a new public method, and once released it has to be kept.

A possible shape (not decided)

fs.read_bytes(ref, path, offset = 0, length?) → { bytes: Buffer, size, hasMore }:

  • One bounded range per call, capped like fs.read's window. A whole-file read would hold a large file in memory.
  • Reads at the same immutable snapshot as fs.read (a Branch, Commit or Layer), so paging through a file is consistent.
  • NotFile / IsDirectory / NoSuchPath refusals as for fs.read. An offset past the end returns empty bytes with hasMore: false.
  • Built on the existing read_range in layerfs-content, through layerfs-store-service/src/read/reads.rs and a small layerfs-api handler. No storage format change.
  • The binding already returns SdkValue::Bytes as a Buffer, and the dsh port's encoding carries Buffer. So no binding or port change is expected.
  • Rough size: +45 to +65 production lines (mostly core), plus a Linux SDK test.

Questions for the decision

  1. A new method, or an option on fs.read (for example encoding: "bytes")? fs.read is line-based, so a separate method seems cleaner.
  2. The per-call cap: the same 48 KiB as fs.read, or larger, since bytes need no line scanning?
  3. Is it needed at all, or should binary access go through a mounted Workspace (workspace.mount + exec) instead?
Lenguaje dominante
Rust
Estrellas
2.1k
Forks
110
Merge medio
23 h 52 min
PR fusionados (30 d)
138

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Ephemeral-AI-Lab/layerfs

Todos los issues de Ephemeral-AI-Lab/layerfs

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.