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

オープン
#417 コメント 4 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Mola-maker がすでに取り組んでいます。

2026年11月8日 から。

  • #492 @YidaWeng による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, rust
領域
api, backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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?
主要言語
Rust
スター
2.1k
フォーク
110
平均マージ
23時間 52分
マージ済み PR(30日)
138

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Ephemeral-AI-Lab/layerfs のほかの issue

Ephemeral-AI-Lab/layerfs の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。