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

Aperta
#417 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Mola-maker ci sta già lavorando.

Dal 8/11/2026.

  • #492 di @YidaWeng — aperta

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, rust
Ambito
api, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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?
Lingua principale
Rust
Stelle
2.1k
Fork
110
Merge medio
23h 52m
PR unite (30g)
138

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Ephemeral-AI-Lab/layerfs

Tutte le issue di Ephemeral-AI-Lab/layerfs

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.