zarr-metadata 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,17 +8,31 @@
8
8
  *
9
9
  * - the `regular` chunk grid's `chunk_shape` has one length per dimension
10
10
  * of `shape`;
11
+ * - the `rectilinear` chunk grid's `chunk_shapes` has one entry per
12
+ * dimension, and each explicit chunk list (integers and `[size, count]`
13
+ * run-length pairs) sums exactly to that dimension's length (the
14
+ * bare-integer uniform shorthand carries no sum constraint, like the
15
+ * regular grid);
11
16
  * - a `transpose` codec's `order` is a permutation of `0..n-1`, with one
12
17
  * entry per array dimension;
13
18
  * - a `sharding_indexed` codec's inner `chunk_shape` matches the array's
14
- * dimensionality and evenly divides the shape of the chunk it shards
15
- * (the regular grid's chunk at the top level, the parent shard's inner
16
- * chunk when sharding nests);
19
+ * dimensionality and evenly divides every chunk it shards — the grid's
20
+ * chunk at the top level (each distinct per-dimension size, for
21
+ * rectilinear grids), the parent shard's inner chunk when sharding
22
+ * nests;
17
23
  * - `fill_value` has a JSON shape permitted for the named core data type
18
24
  * (booleans for `bool`, ranged integers for the int types, numbers /
19
25
  * the "NaN"-family sentinels / width-checked "0x…" strings for the
20
26
  * float types, two-element arrays for the complex types).
21
27
  *
28
+ * Dimensional context is THREADED through codec pipelines rather than
29
+ * assumed constant (mirroring zarr-python's chunk-spec threading): a valid
30
+ * `transpose` permutes the per-dimension chunk sizes for the codecs after
31
+ * it, and any codec this layer cannot reason about — `reshape` may change
32
+ * a chunk's rank, and unknown codecs may do anything — invalidates the
33
+ * dimensional context for the rest of the pipeline instead of letting
34
+ * stale array-level facts produce false verdicts.
35
+ *
22
36
  * Unrecognized names are skipped everywhere — the extension name space is
23
37
  * open, and a rule that guessed would lie. This layer has no counterpart
24
38
  * in the Python reference implementation (which stops at structure), so it
@@ -1 +1 @@
1
- {"version":3,"file":"semantics.d.ts","sourceRoot":"","sources":["../src/semantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAoB,MAAM,aAAa,CAAC;AAqLvE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAoClE"}
1
+ {"version":3,"file":"semantics.d.ts","sourceRoot":"","sources":["../src/semantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAoB,MAAM,aAAa,CAAC;AA6OvE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAqFlE"}
package/dist/semantics.js CHANGED
@@ -8,17 +8,31 @@
8
8
  *
9
9
  * - the `regular` chunk grid's `chunk_shape` has one length per dimension
10
10
  * of `shape`;
11
+ * - the `rectilinear` chunk grid's `chunk_shapes` has one entry per
12
+ * dimension, and each explicit chunk list (integers and `[size, count]`
13
+ * run-length pairs) sums exactly to that dimension's length (the
14
+ * bare-integer uniform shorthand carries no sum constraint, like the
15
+ * regular grid);
11
16
  * - a `transpose` codec's `order` is a permutation of `0..n-1`, with one
12
17
  * entry per array dimension;
13
18
  * - a `sharding_indexed` codec's inner `chunk_shape` matches the array's
14
- * dimensionality and evenly divides the shape of the chunk it shards
15
- * (the regular grid's chunk at the top level, the parent shard's inner
16
- * chunk when sharding nests);
19
+ * dimensionality and evenly divides every chunk it shards — the grid's
20
+ * chunk at the top level (each distinct per-dimension size, for
21
+ * rectilinear grids), the parent shard's inner chunk when sharding
22
+ * nests;
17
23
  * - `fill_value` has a JSON shape permitted for the named core data type
18
24
  * (booleans for `bool`, ranged integers for the int types, numbers /
19
25
  * the "NaN"-family sentinels / width-checked "0x…" strings for the
20
26
  * float types, two-element arrays for the complex types).
21
27
  *
28
+ * Dimensional context is THREADED through codec pipelines rather than
29
+ * assumed constant (mirroring zarr-python's chunk-spec threading): a valid
30
+ * `transpose` permutes the per-dimension chunk sizes for the codecs after
31
+ * it, and any codec this layer cannot reason about — `reshape` may change
32
+ * a chunk's rank, and unknown codecs may do anything — invalidates the
33
+ * dimensional context for the rest of the pipeline instead of letting
34
+ * stale array-level facts produce false verdicts.
35
+ *
22
36
  * Unrecognized names are skipped everywhere — the extension name space is
23
37
  * open, and a rule that guessed would lie. This layer has no counterpart
24
38
  * in the Python reference implementation (which stops at structure), so it
@@ -122,22 +136,39 @@ function isPermutation(order) {
122
136
  }
123
137
  /**
124
138
  * Walk one codec pipeline. `dims` is the array dimensionality at this point
125
- * (undefined when unknowable); `outerChunkShape` is the shape of the chunk
126
- * this pipeline encodes — what a sharding codec's inner chunks must divide.
139
+ * (undefined when unknowable); `outerChunkSizes` holds the distinct chunk
140
+ * lengths per dimension this pipeline may encode — what a sharding codec's
141
+ * inner chunks must divide. A regular grid contributes one size per
142
+ * dimension; a rectilinear grid may contribute several.
127
143
  */
128
- function pipelineIssues(pipeline, path, dims, outerChunkShape) {
144
+ function pipelineIssues(pipeline, path, initialDims, initialChunkSizes) {
129
145
  const issues = [];
146
+ // The dimensional context THREADS through the pipeline: transpose permutes
147
+ // it, and anything this layer cannot reason about invalidates it for the
148
+ // remaining codecs.
149
+ let dims = initialDims;
150
+ let chunkSizes = initialChunkSizes;
151
+ const dropContext = () => {
152
+ dims = undefined;
153
+ chunkSizes = undefined;
154
+ };
130
155
  pipeline.forEach((entry, index) => {
131
156
  const parts = fieldParts(entry);
132
- if (parts === undefined)
157
+ if (parts === undefined) {
158
+ dropContext(); // structurally invalid entry: no further reasoning
133
159
  return;
160
+ }
134
161
  const { name, configuration } = parts;
135
162
  if (name === "transpose") {
136
163
  const order = configuration?.["order"];
137
- if (!isIntArray(order))
138
- return; // shape errors are the schema layer's
164
+ if (!isIntArray(order)) {
165
+ dropContext(); // shape errors are the schema layer's
166
+ return;
167
+ }
139
168
  const orderPath = [...path, index, "configuration", "order"];
169
+ let sound = true;
140
170
  if (!isPermutation(order)) {
171
+ sound = false;
141
172
  issues.push({
142
173
  path: orderPath,
143
174
  message: `expected a permutation of the integers 0..${order.length - 1}`,
@@ -145,17 +176,30 @@ function pipelineIssues(pipeline, path, dims, outerChunkShape) {
145
176
  });
146
177
  }
147
178
  if (dims !== undefined && order.length !== dims) {
179
+ sound = false;
148
180
  issues.push({
149
181
  path: orderPath,
150
182
  message: `expected one entry per array dimension (${dims})`,
151
183
  kind: "invalid_value",
152
184
  });
153
185
  }
186
+ if (!sound) {
187
+ dropContext();
188
+ }
189
+ else if (chunkSizes !== undefined) {
190
+ const sizes = chunkSizes;
191
+ chunkSizes =
192
+ order.length === sizes.length
193
+ ? order.map((axis) => sizes[axis])
194
+ : undefined;
195
+ }
154
196
  }
155
197
  else if (name === "sharding_indexed") {
156
198
  const chunkShape = configuration?.["chunk_shape"];
157
- if (!isIntArray(chunkShape))
199
+ if (!isIntArray(chunkShape)) {
200
+ dropContext();
158
201
  return;
202
+ }
159
203
  const chunkShapePath = [...path, index, "configuration", "chunk_shape"];
160
204
  if (dims !== undefined && chunkShape.length !== dims) {
161
205
  issues.push({
@@ -164,22 +208,44 @@ function pipelineIssues(pipeline, path, dims, outerChunkShape) {
164
208
  kind: "invalid_value",
165
209
  });
166
210
  }
167
- else if (outerChunkShape !== undefined &&
168
- chunkShape.length === outerChunkShape.length &&
169
- chunkShape.every((length) => length > 0) &&
170
- outerChunkShape.some((outer, axis) => outer % chunkShape[axis] !== 0)) {
171
- issues.push({
172
- path: chunkShapePath,
173
- message: `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(outerChunkShape)}`,
174
- kind: "invalid_value",
211
+ else if (chunkSizes !== undefined &&
212
+ chunkShape.length === chunkSizes.length &&
213
+ chunkShape.every((length) => length > 0)) {
214
+ let violation;
215
+ chunkSizes.forEach((sizes, axis) => {
216
+ if (violation !== undefined)
217
+ return;
218
+ const bad = sizes.find((size) => size % chunkShape[axis] !== 0);
219
+ if (bad !== undefined)
220
+ violation = { axis, size: bad };
175
221
  });
222
+ if (violation !== undefined) {
223
+ const { axis, size } = violation;
224
+ const sizesNow = chunkSizes;
225
+ const uniform = sizesNow.every((sizes) => sizes.length === 1);
226
+ issues.push({
227
+ path: chunkShapePath,
228
+ message: uniform
229
+ ? `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(sizesNow.map((sizes) => sizes[0]))}`
230
+ : `expected ${JSON.stringify(chunkShape)} to evenly divide every chunk size of the grid (dimension ${axis} has chunk size ${size})`,
231
+ kind: "invalid_value",
232
+ });
233
+ }
176
234
  }
177
235
  const inner = configuration?.["codecs"];
178
236
  if (Array.isArray(inner)) {
179
- issues.push(...pipelineIssues(inner, [...path, index, "configuration", "codecs"], dims, chunkShape));
237
+ issues.push(...pipelineIssues(inner, [...path, index, "configuration", "codecs"], chunkShape.length, chunkShape.map((length) => [length])));
180
238
  }
181
239
  // index_codecs encode the shard index, whose shape differs from the
182
- // array's — no dimensional context applies there.
240
+ // array's — no dimensional context applies there. After the
241
+ // array -> bytes boundary the dimensional context is spent.
242
+ dropContext();
243
+ }
244
+ else {
245
+ // A codec this layer cannot reason about (reshape may change a
246
+ // chunk's rank; unknown codecs may do anything): stale array-level
247
+ // facts must not judge the codecs after it.
248
+ dropContext();
183
249
  }
184
250
  });
185
251
  return issues;
@@ -197,18 +263,72 @@ export function validateArraySemanticsV3(value) {
197
263
  const shape = isIntArray(value["shape"]) ? value["shape"] : undefined;
198
264
  const dims = shape?.length;
199
265
  const grid = fieldParts(value["chunk_grid"]);
200
- let chunkShape;
266
+ let chunkSizes;
201
267
  if (grid?.name === "regular") {
202
268
  const configured = grid.configuration?.["chunk_shape"];
203
269
  if (isIntArray(configured)) {
204
- chunkShape = configured;
205
270
  if (dims !== undefined && configured.length !== dims) {
206
271
  issues.push({
207
272
  path: ["chunk_grid", "configuration", "chunk_shape"],
208
273
  message: `expected one length per dimension of shape (${dims})`,
209
274
  kind: "invalid_value",
210
275
  });
211
- chunkShape = undefined; // wrong arity: unusable as division context
276
+ // wrong arity: unusable as division context
277
+ }
278
+ else {
279
+ chunkSizes = configured.map((length) => [length]);
280
+ }
281
+ }
282
+ }
283
+ else if (grid?.name === "rectilinear") {
284
+ const specs = grid.configuration?.["chunk_shapes"];
285
+ if (Array.isArray(specs)) {
286
+ if (dims !== undefined && specs.length !== dims) {
287
+ issues.push({
288
+ path: ["chunk_grid", "configuration", "chunk_shapes"],
289
+ message: `expected one entry per dimension of shape (${dims})`,
290
+ kind: "invalid_value",
291
+ });
292
+ }
293
+ else {
294
+ const perDim = specs.map((spec, dim) => {
295
+ // Bare integer: uniform shorthand, no sum constraint (edge chunks
296
+ // are permitted, as with the regular grid).
297
+ if (Number.isInteger(spec))
298
+ return spec > 0 ? [spec] : undefined;
299
+ if (!Array.isArray(spec))
300
+ return undefined; // registry schema's problem
301
+ const sizes = new Set();
302
+ let total = 0;
303
+ for (const entry of spec) {
304
+ if (Number.isInteger(entry)) {
305
+ sizes.add(entry);
306
+ total += entry;
307
+ }
308
+ else if (Array.isArray(entry) &&
309
+ entry.length === 2 &&
310
+ Number.isInteger(entry[0]) &&
311
+ Number.isInteger(entry[1])) {
312
+ sizes.add(entry[0]);
313
+ total += entry[0] * entry[1];
314
+ }
315
+ else {
316
+ return undefined; // malformed entry: registry schema's problem
317
+ }
318
+ }
319
+ const extent = shape?.[dim];
320
+ if (extent !== undefined && total !== extent) {
321
+ issues.push({
322
+ path: ["chunk_grid", "configuration", "chunk_shapes", dim],
323
+ message: `expected chunk sizes summing to ${extent} along dimension ${dim}, got ${total}`,
324
+ kind: "invalid_value",
325
+ });
326
+ }
327
+ return [...sizes];
328
+ });
329
+ if (perDim.every((sizes) => sizes !== undefined)) {
330
+ chunkSizes = perDim;
331
+ }
212
332
  }
213
333
  }
214
334
  }
@@ -221,7 +341,7 @@ export function validateArraySemanticsV3(value) {
221
341
  }
222
342
  const codecs = value["codecs"];
223
343
  if (Array.isArray(codecs)) {
224
- issues.push(...pipelineIssues(codecs, ["codecs"], dims, chunkShape));
344
+ issues.push(...pipelineIssues(codecs, ["codecs"], dims, chunkSizes));
225
345
  }
226
346
  return treeOf(issues);
227
347
  }
@@ -1 +1 @@
1
- {"version":3,"file":"semantics.js","sourceRoot":"","sources":["../src/semantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,MAAM,EAAoC,MAAM,aAAa,CAAC;AAIvE,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtF,MAAM,KAAK,GAAY,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC1C,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,SAAS,UAAU,CACjB,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;IAChF,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC9D,MAAM,aAAa,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC;QAC7C,OAAO;YACL,IAAI,EAAE,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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarr-metadata",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Spec-defined metadata types and validators for Zarr v2 and v3.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/semantics.ts CHANGED
@@ -8,17 +8,31 @@
8
8
  *
9
9
  * - the `regular` chunk grid's `chunk_shape` has one length per dimension
10
10
  * of `shape`;
11
+ * - the `rectilinear` chunk grid's `chunk_shapes` has one entry per
12
+ * dimension, and each explicit chunk list (integers and `[size, count]`
13
+ * run-length pairs) sums exactly to that dimension's length (the
14
+ * bare-integer uniform shorthand carries no sum constraint, like the
15
+ * regular grid);
11
16
  * - a `transpose` codec's `order` is a permutation of `0..n-1`, with one
12
17
  * entry per array dimension;
13
18
  * - a `sharding_indexed` codec's inner `chunk_shape` matches the array's
14
- * dimensionality and evenly divides the shape of the chunk it shards
15
- * (the regular grid's chunk at the top level, the parent shard's inner
16
- * chunk when sharding nests);
19
+ * dimensionality and evenly divides every chunk it shards — the grid's
20
+ * chunk at the top level (each distinct per-dimension size, for
21
+ * rectilinear grids), the parent shard's inner chunk when sharding
22
+ * nests;
17
23
  * - `fill_value` has a JSON shape permitted for the named core data type
18
24
  * (booleans for `bool`, ranged integers for the int types, numbers /
19
25
  * the "NaN"-family sentinels / width-checked "0x…" strings for the
20
26
  * float types, two-element arrays for the complex types).
21
27
  *
28
+ * Dimensional context is THREADED through codec pipelines rather than
29
+ * assumed constant (mirroring zarr-python's chunk-spec threading): a valid
30
+ * `transpose` permutes the per-dimension chunk sizes for the codecs after
31
+ * it, and any codec this layer cannot reason about — `reshape` may change
32
+ * a chunk's rank, and unknown codecs may do anything — invalidates the
33
+ * dimensional context for the rest of the pipeline instead of letting
34
+ * stale array-level facts produce false verdicts.
35
+ *
22
36
  * Unrecognized names are skipped everywhere — the extension name space is
23
37
  * open, and a rule that guessed would lie. This layer has no counterpart
24
38
  * in the Python reference implementation (which stops at structure), so it
@@ -140,25 +154,44 @@ function isPermutation(order: number[]): boolean {
140
154
 
141
155
  /**
142
156
  * Walk one codec pipeline. `dims` is the array dimensionality at this point
143
- * (undefined when unknowable); `outerChunkShape` is the shape of the chunk
144
- * this pipeline encodes — what a sharding codec's inner chunks must divide.
157
+ * (undefined when unknowable); `outerChunkSizes` holds the distinct chunk
158
+ * lengths per dimension this pipeline may encode — what a sharding codec's
159
+ * inner chunks must divide. A regular grid contributes one size per
160
+ * dimension; a rectilinear grid may contribute several.
145
161
  */
146
162
  function pipelineIssues(
147
163
  pipeline: unknown[],
148
164
  path: Path,
149
- dims: number | undefined,
150
- outerChunkShape: number[] | undefined,
165
+ initialDims: number | undefined,
166
+ initialChunkSizes: number[][] | undefined,
151
167
  ): PathedIssue[] {
152
168
  const issues: PathedIssue[] = [];
169
+ // The dimensional context THREADS through the pipeline: transpose permutes
170
+ // it, and anything this layer cannot reason about invalidates it for the
171
+ // remaining codecs.
172
+ let dims = initialDims;
173
+ let chunkSizes = initialChunkSizes;
174
+ const dropContext = (): void => {
175
+ dims = undefined;
176
+ chunkSizes = undefined;
177
+ };
153
178
  pipeline.forEach((entry, index) => {
154
179
  const parts = fieldParts(entry);
155
- if (parts === undefined) return;
180
+ if (parts === undefined) {
181
+ dropContext(); // structurally invalid entry: no further reasoning
182
+ return;
183
+ }
156
184
  const { name, configuration } = parts;
157
185
  if (name === "transpose") {
158
186
  const order = configuration?.["order"];
159
- if (!isIntArray(order)) return; // shape errors are the schema layer's
187
+ if (!isIntArray(order)) {
188
+ dropContext(); // shape errors are the schema layer's
189
+ return;
190
+ }
160
191
  const orderPath = [...path, index, "configuration", "order"];
192
+ let sound = true;
161
193
  if (!isPermutation(order)) {
194
+ sound = false;
162
195
  issues.push({
163
196
  path: orderPath,
164
197
  message: `expected a permutation of the integers 0..${order.length - 1}`,
@@ -166,15 +199,28 @@ function pipelineIssues(
166
199
  });
167
200
  }
168
201
  if (dims !== undefined && order.length !== dims) {
202
+ sound = false;
169
203
  issues.push({
170
204
  path: orderPath,
171
205
  message: `expected one entry per array dimension (${dims})`,
172
206
  kind: "invalid_value",
173
207
  });
174
208
  }
209
+ if (!sound) {
210
+ dropContext();
211
+ } else if (chunkSizes !== undefined) {
212
+ const sizes = chunkSizes;
213
+ chunkSizes =
214
+ order.length === sizes.length
215
+ ? order.map((axis) => sizes[axis] as number[])
216
+ : undefined;
217
+ }
175
218
  } else if (name === "sharding_indexed") {
176
219
  const chunkShape = configuration?.["chunk_shape"];
177
- if (!isIntArray(chunkShape)) return;
220
+ if (!isIntArray(chunkShape)) {
221
+ dropContext();
222
+ return;
223
+ }
178
224
  const chunkShapePath = [...path, index, "configuration", "chunk_shape"];
179
225
  if (dims !== undefined && chunkShape.length !== dims) {
180
226
  issues.push({
@@ -183,25 +229,49 @@ function pipelineIssues(
183
229
  kind: "invalid_value",
184
230
  });
185
231
  } else if (
186
- outerChunkShape !== undefined &&
187
- chunkShape.length === outerChunkShape.length &&
188
- chunkShape.every((length) => length > 0) &&
189
- outerChunkShape.some((outer, axis) => outer % (chunkShape[axis] as number) !== 0)
232
+ chunkSizes !== undefined &&
233
+ chunkShape.length === chunkSizes.length &&
234
+ chunkShape.every((length) => length > 0)
190
235
  ) {
191
- issues.push({
192
- path: chunkShapePath,
193
- message: `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(outerChunkShape)}`,
194
- kind: "invalid_value",
236
+ let violation: { axis: number; size: number } | undefined;
237
+ chunkSizes.forEach((sizes, axis) => {
238
+ if (violation !== undefined) return;
239
+ const bad = sizes.find((size) => size % (chunkShape[axis] as number) !== 0);
240
+ if (bad !== undefined) violation = { axis, size: bad };
195
241
  });
242
+ if (violation !== undefined) {
243
+ const { axis, size } = violation;
244
+ const sizesNow = chunkSizes;
245
+ const uniform = sizesNow.every((sizes) => sizes.length === 1);
246
+ issues.push({
247
+ path: chunkShapePath,
248
+ message: uniform
249
+ ? `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(sizesNow.map((sizes) => sizes[0]))}`
250
+ : `expected ${JSON.stringify(chunkShape)} to evenly divide every chunk size of the grid (dimension ${axis} has chunk size ${size})`,
251
+ kind: "invalid_value",
252
+ });
253
+ }
196
254
  }
197
255
  const inner = configuration?.["codecs"];
198
256
  if (Array.isArray(inner)) {
199
257
  issues.push(
200
- ...pipelineIssues(inner, [...path, index, "configuration", "codecs"], dims, chunkShape),
258
+ ...pipelineIssues(
259
+ inner,
260
+ [...path, index, "configuration", "codecs"],
261
+ chunkShape.length,
262
+ chunkShape.map((length) => [length]),
263
+ ),
201
264
  );
202
265
  }
203
266
  // index_codecs encode the shard index, whose shape differs from the
204
- // array's — no dimensional context applies there.
267
+ // array's — no dimensional context applies there. After the
268
+ // array -> bytes boundary the dimensional context is spent.
269
+ dropContext();
270
+ } else {
271
+ // A codec this layer cannot reason about (reshape may change a
272
+ // chunk's rank; unknown codecs may do anything): stale array-level
273
+ // facts must not judge the codecs after it.
274
+ dropContext();
205
275
  }
206
276
  });
207
277
  return issues;
@@ -220,18 +290,67 @@ export function validateArraySemanticsV3(value: unknown): ErrorTree {
220
290
  const dims = shape?.length;
221
291
 
222
292
  const grid = fieldParts(value["chunk_grid"]);
223
- let chunkShape: number[] | undefined;
293
+ let chunkSizes: number[][] | undefined;
224
294
  if (grid?.name === "regular") {
225
295
  const configured = grid.configuration?.["chunk_shape"];
226
296
  if (isIntArray(configured)) {
227
- chunkShape = configured;
228
297
  if (dims !== undefined && configured.length !== dims) {
229
298
  issues.push({
230
299
  path: ["chunk_grid", "configuration", "chunk_shape"],
231
300
  message: `expected one length per dimension of shape (${dims})`,
232
301
  kind: "invalid_value",
233
302
  });
234
- chunkShape = undefined; // wrong arity: unusable as division context
303
+ // wrong arity: unusable as division context
304
+ } else {
305
+ chunkSizes = configured.map((length) => [length]);
306
+ }
307
+ }
308
+ } else if (grid?.name === "rectilinear") {
309
+ const specs = grid.configuration?.["chunk_shapes"];
310
+ if (Array.isArray(specs)) {
311
+ if (dims !== undefined && specs.length !== dims) {
312
+ issues.push({
313
+ path: ["chunk_grid", "configuration", "chunk_shapes"],
314
+ message: `expected one entry per dimension of shape (${dims})`,
315
+ kind: "invalid_value",
316
+ });
317
+ } else {
318
+ const perDim: (number[] | undefined)[] = specs.map((spec, dim) => {
319
+ // Bare integer: uniform shorthand, no sum constraint (edge chunks
320
+ // are permitted, as with the regular grid).
321
+ if (Number.isInteger(spec)) return spec as number > 0 ? [spec as number] : undefined;
322
+ if (!Array.isArray(spec)) return undefined; // registry schema's problem
323
+ const sizes = new Set<number>();
324
+ let total = 0;
325
+ for (const entry of spec) {
326
+ if (Number.isInteger(entry)) {
327
+ sizes.add(entry as number);
328
+ total += entry as number;
329
+ } else if (
330
+ Array.isArray(entry) &&
331
+ entry.length === 2 &&
332
+ Number.isInteger(entry[0]) &&
333
+ Number.isInteger(entry[1])
334
+ ) {
335
+ sizes.add(entry[0] as number);
336
+ total += (entry[0] as number) * (entry[1] as number);
337
+ } else {
338
+ return undefined; // malformed entry: registry schema's problem
339
+ }
340
+ }
341
+ const extent = shape?.[dim];
342
+ if (extent !== undefined && total !== extent) {
343
+ issues.push({
344
+ path: ["chunk_grid", "configuration", "chunk_shapes", dim],
345
+ message: `expected chunk sizes summing to ${extent} along dimension ${dim}, got ${total}`,
346
+ kind: "invalid_value",
347
+ });
348
+ }
349
+ return [...sizes];
350
+ });
351
+ if (perDim.every((sizes) => sizes !== undefined)) {
352
+ chunkSizes = perDim as number[][];
353
+ }
235
354
  }
236
355
  }
237
356
  }
@@ -246,7 +365,7 @@ export function validateArraySemanticsV3(value: unknown): ErrorTree {
246
365
 
247
366
  const codecs = value["codecs"];
248
367
  if (Array.isArray(codecs)) {
249
- issues.push(...pipelineIssues(codecs, ["codecs"], dims, chunkShape));
368
+ issues.push(...pipelineIssues(codecs, ["codecs"], dims, chunkSizes));
250
369
  }
251
370
  return treeOf(issues);
252
371
  }