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

Đang mở
#417 4 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Mola-maker đang làm issue này rồi.

Từ ngày 8/11/2026.

  • #492 của @YidaWeng — đang mở

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, rust
Lĩnh vực
api, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?
Ngôn ngữ chính
Rust
Star
2.1k
Fork
110
Merge trung bình
23 giờ 52 phút
Pull request đã merge (30 ngày)
138

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Ephemeral-AI-Lab/layerfs

Tất cả issue của Ephemeral-AI-Lab/layerfs

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.