From d850f16a3a881d3b1a3a141e868b5ef37624f0cb Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 19 Oct 2026 16:43:48 +0200 Subject: [PATCH] cultnet-ts/content: cut the nil pre-checks the array header read already refuses A nil manifest, chunks slot or chunk element reaches the array header read, which refuses it with the same field name; the three pre-checks were equivalent mutants in the Stryker sweep. Co-Authored-By: Claude Opus 5.5 --- packages/cultnet-ts/src/content.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cultnet-ts/src/content.ts b/packages/cultnet-ts/src/content.ts index ee501551..7e9ba6ba 100644 --- a/packages/cultnet-ts/src/content.ts +++ b/packages/cultnet-ts/src/content.ts @@ -230,7 +230,6 @@ class Reader { export function decodeManifest(bytes: Uint8Array): CultMeshCdnArtifactManifest { checkPayloadDepth(bytes, "CDN artifact manifest"); const reader = new Reader(bytes); - if (reader.nil()) wrongType("manifest"); // A slot the array does not reach keeps the property initialiser; a slot past the tenth is skipped. Trailing bytes are not read. const count = reader.array("manifest"); let index = 0; @@ -243,7 +242,7 @@ export function decodeManifest(bytes: Uint8Array): CultMeshCdnArtifactManifest { sizeBytes: slot(() => reader.integer("sizeBytes"), 0), mimeType: slot(() => reader.string("mimeType"), "application/octet-stream"), createdAtUtc: slot(() => reader.string("createdAtUtc"), ""), - chunks: slot(() => Array.from({ length: reader.nil() ? wrongType("chunks") : reader.array("chunks") }, () => readChunkRef(reader)), []), + chunks: slot(() => Array.from({ length: reader.array("chunks") }, () => readChunkRef(reader)), []), tags: slot(() => reader.nil() ? null : Array.from({ length: reader.array("tags") }, () => reader.string("tags")), []), metadata: slot(() => reader.nil() ? null : Array.from({ length: reader.map("metadata") }, () => [reader.string("metadata") ?? wrongType("metadata"), reader.string("metadata")] as const), []), @@ -254,7 +253,6 @@ export function decodeManifest(bytes: Uint8Array): CultMeshCdnArtifactManifest { } function readChunkRef(reader: Reader): CultMeshCdnChunkRef { - if (reader.nil()) wrongType("chunks"); const count = reader.array("chunks"); let index = 0; const slot = (read: () => T, initial: T): T => index++ < count ? read() : initial;