mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 14:46:43 +02:00
fix(spiral-db): add test suite and fix critical bugs
Add comprehensive test suite (174 tests) covering encoding, schema, image, database CRUD, and PNG round-trip. Fix critical bugs: - PNG compression: replace non-functional zlibCompress with pako.deflate - PNG import: add CRC validation, support all filter types (Sub/Up/Avg/Paeth) - Input validation: validate records against schema before insert - Index overflow: dynamic dataStartRing prevents index/data ring overlap - Image expansion: expand before writes instead of after to prevent OOB - update() read bug: search index from end to find latest entry, not deleted one - String encoding: enforce 511-byte max length - Index ring count: use 6 bits (2 pixels) instead of 3 bits for >7 ring support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3f5c17adbc
commit
d4d08cc68b
9 changed files with 2227 additions and 163 deletions
|
|
@ -185,6 +185,11 @@ export function decodeBool(stream: BitStream): boolean {
|
|||
export function encodeString(stream: BitStream, value: string, compress = false): void {
|
||||
const bytes = new TextEncoder().encode(value);
|
||||
|
||||
// 9-bit length field can hold max 511 bytes
|
||||
if (bytes.length > 511) {
|
||||
throw new Error(`String too long: ${bytes.length} bytes (max 511)`);
|
||||
}
|
||||
|
||||
if (compress && bytes.length > 20) {
|
||||
const compressed = pako.deflate(bytes);
|
||||
if (compressed.length < bytes.length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue