Automattic / Automattic/kandelo

Track real stat block metadata across filesystem backends

Open
#928 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
31
Forks
15
Avg merge
11h 7m
Merged PRs (30d)
80

Description

## Problem

Kandelo ABI 39 stops `WasmStat` after the timestamps. Guest musl has trailing
`st_rdev`, `st_blksize`, and `st_blocks` fields, but the kernel does not provide
those values. The current `statx` path also substitutes a fixed 4096-byte I/O
size and `ceil(st_size / 512)` for the block count.

That is not enough for POSIX/XSI behavior. `st_blksize` is the preferred I/O
size for the object, while `st_blocks` is the number of blocks actually
allocated. SharedFS supports sparse holes, so a one-byte write near 1 MiB does
not allocate 1 MiB of data blocks. Reporting logical length as allocated space
would make a platform bug look fixed and can mislead tools that inspect sparse
files.

This came out of the #769 cleanup. Commits e56cde47 and 2c3d702 should not be
replayed as written because their regression requires the incorrect
logical-size result.

## Required platform design

- Carry `rdev`, preferred I/O block size, and allocated-block metadata through
the normal filesystem and host path.
- Use native `fs.Stats` values for Node-backed files.
- Count the real allocated data and indirection blocks for SharedFS, including
sparse files and truncation.
- Define and document an honest browser/OPFS policy. If the browser cannot
expose physical allocation, track Kandelo-owned allocation metadata or state
the virtual-filesystem boundary explicitly; do not present logical length as
host allocation.
- Keep `stat`, `lstat`, `fstat`, `fstatat`, and `statx` consistent for wasm32
and wasm64, including synthetic kernel objects and devices.
- Cover empty, dense, sparse, direct, indirect, truncate, open-unlinked, and
hard-linked files in Node and Chromium.

## ABI and artifacts

Treat this as ABI-changing. Extending or versioning the stat metadata requires
an `ABI_VERSION` bump, an atomic snapshot and generated-binding update, and a
full ABI audit. Rebuild statically linked package artifacts and ABI-bound VFS
images so old libc code is not presented as if it received the new fields.

The narrow libc hardening that zero-initializes fields the current ABI does not
supply can land separately. That prevents stack garbage from leaking today,
but it deliberately does not claim this issue is fixed.

Contributor guide

No contributing guide indexed for this repository

Research direction

Trace the stat, statx, filesystem, and host paths for wasm32 and wasm64, then inspect ABI_VERSION, generated bindings, and ABI-bound artifacts. Use the required Node and Chromium scenario matrix as the validation plan. Done means consistent real metadata across all stat variants and backends, an explicit browser allocation policy, an ABI audit and version update, and rebuilt artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript, wasm
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.