Files
2026-05-27 23:29:53 +01:00

2.0 KiB

Storage — Spec Delta (storage-set-partial)

ADDED Requirements

STORAGE-PARTIAL-WRITE-01 — setPartial is part of the abstract surface

AbstractStorage MUST declare abstract setPartial(key: string, offset: number, bytes: Uint8Array, signal?: AbortSignal): Promise<void>. Every concrete subclass MUST provide an implementation. A protected defaultSetPartial helper MUST exist as the read-modify-write reference fallback.

Verified by: src/abstract/abstract.spec-conformance.test.ts (STORAGE-PARTIAL-WRITE-01).

STORAGE-PARTIAL-WRITE-02 — sparse extension semantics

When setPartial(key, offset, bytes) is called on a non-existent key or on an existing object shorter than offset + bytes.byteLength, the storage object MUST be created/extended to length max(currentLength, offset + bytes.byteLength). Bytes in the gap [currentLength, offset) MUST be zero (0x00) on subsequent reads.

Verified by: src/abstract/abstract.spec-conformance.test.ts (STORAGE-PARTIAL-WRITE-02).

STORAGE-PARTIAL-WRITE-03 — overlap is in-place overwrite

When setPartial(key, offset, bytes) is called on a key whose existing object overlaps the written range, bytes within [offset, offset + bytes.byteLength) MUST be overwritten with bytes. Bytes outside that range MUST be preserved exactly.

Verified by: src/abstract/abstract.spec-conformance.test.ts (STORAGE-PARTIAL-WRITE-03).

STORAGE-PARTIAL-WRITE-04 — capabilities are explicit

AbstractStorage MUST expose a readonly capabilities property of shape { partialReads: boolean; partialWrites: boolean; nativeStreams: boolean; atomicWrites: boolean; contentAddressable: boolean }. Defaults MUST be all false. Subclasses MUST override per native support. MemoryStorage.capabilities.partialWrites MUST be true.

Verified by: src/abstract/abstract.spec-conformance.test.ts (STORAGE-PARTIAL-WRITE-04); src/memory/memory.spec-conformance.test.ts (STORAGE-PARTIAL-WRITE-04).