Remove the Timestamp kind
The Timestamp kind was a residual from an early research reference. It was byte-identical to String everywhere (length-prefixed UTF-8) and its only distinguishing behavior was a hand-rolled non-strict RFC 3339 check that the docs admitted was incomplete (Feb 31 passes, seconds range unchecked, no leap seconds). JSON-level timestamp validation is jsonschema's job (format: date-time on the validate_json path), not alktype's. Removes the AlkTypeKind::Timestamp variant, its to_bast_str/from_bast_str mapping, the builder's Schema::timestamp() constructor, the validate_timestamp/is_rfc3339_timestamp validator arms, and the materializer/reader/engine timestamp arms. Updates the meta-schema primitive enum (14 -> 13), the spec docs (bast-format.md, schema-layer.md, builder.md, validation.md, overview.md, data-access.md, README.md), and the kind-count references (19 -> 18). Verification: cargo test --release (407 pass), cargo clippy --all-targets -- -D warnings (clean), cargo doc --no-deps (clean), cargo build --target wasm32-unknown-unknown --release (clean).
This commit is contained in:
1 parent
62ed009281
commit
510553d800
17 files changed
+38
-225
No files matched your search
@@ -16,7 +16,7 @@ format definition; the engine is generic.
|
||||
|----------|--------|-------------|
|
||||
| [overview.md](overview.md) | accepted | Crate purpose, "schema is the format" principle, dependencies, consumers, scope boundaries |
|
||||
| [`bast-format.md`](bast-format.md) | accepted | **Normative BAST format specification.** Meta-schema, TypeRef, TypeDef shapes (Struct/Union/Enum/FieldDef), examples, validation model. The format the engine consumes. |
|
||||
| [schema-layer.md](schema-layer.md) | accepted | The BAST parser (`src/bast.rs`) — the typed tree (`BastDoc`/`BastDef`/`BastType`/…) every engine module walks, the 19 BAST kinds, the `AlkTypeKind` enum, and the foundational annotation types. |
|
||||
| [schema-layer.md](schema-layer.md) | accepted | The BAST parser (`src/bast.rs`) — the typed tree (`BastDoc`/`BastDef`/`BastType`/…) every engine module walks, the 18 BAST kinds, the `AlkTypeKind` enum, and the foundational annotation types. |
|
||||
| [layout-engine.md](layout-engine.md) | draft | Offset computation, the two layout modes (packed sequential vs aligned static), alignment, endianness, variable-length handling |
|
||||
| [data-access.md](data-access.md) | draft | Read/write functions, TUnion dispatch, field paths, zero-copy access, length-prefix reading |
|
||||
| [validation.md](validation.md) | accepted | The two-validator model (BAST-native for `validate_bytes`, standard `jsonschema` for `validate_json`), `AlkTypeError`, load-time vs access-time validation, `AlkTypeEngine` as the compiled form of a BAST document (ADR-010, ADR-VAL-SPLIT). |
|
||||
|
||||
@@ -140,7 +140,7 @@ These are different validators for different inputs.
|
||||
"int8", "int16", "int32", "int64",
|
||||
"uint8", "uint16", "uint32", "uint64",
|
||||
"float32", "float64",
|
||||
"bool", "string", "bytes", "timestamp"
|
||||
"bool", "string", "bytes"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -309,7 +309,7 @@ are convenient for one-off nested types.
|
||||
|
||||
### Primitives
|
||||
|
||||
The 14 primitive `kind` strings map to the unchanged `AlkTypeKind`
|
||||
The 13 primitive `kind` strings map to the unchanged `AlkTypeKind`
|
||||
variants (D-BAST-002 — lowercase strings, PascalCase enum variants):
|
||||
|
||||
| BAST kind | `AlkTypeKind` | Rust type | Size | Category |
|
||||
@@ -327,7 +327,6 @@ variants (D-BAST-002 — lowercase strings, PascalCase enum variants):
|
||||
| `bool` | `Boolean` | `bool` (`0x00`=false, `0x01`=true) | 1 | fixed |
|
||||
| `string` | `String` | length-prefixed UTF-8 | variable | variable |
|
||||
| `bytes` | `Bytes` | length-prefixed raw bytes | variable | variable |
|
||||
| `timestamp` | `Timestamp` | length-prefixed RFC 3339 string | variable | variable |
|
||||
|
||||
`int64`/`uint64` are alktype additions (not in TypeBox's `typedef.ts`),
|
||||
required by SFTP `offset: u64` and metatensor `data_offsets`. JSON
|
||||
@@ -457,7 +456,7 @@ override). In little-endian mode, `u32::from_le_bytes`; in big-endian
|
||||
mode, `u32::from_be_bytes`. Ensures SFTP consumers (big-endian) have
|
||||
consistent byte order for field values and length prefixes.
|
||||
|
||||
Applies to all variable-length types: `string`, `bytes`, `timestamp`,
|
||||
Applies to all variable-length types: `string`, `bytes`,
|
||||
`record`, and arrays of variable-length elements.
|
||||
|
||||
## Endianness
|
||||
@@ -541,7 +540,6 @@ BAST type tree that checks exactly these:
|
||||
| Float finiteness (Float32/64) | `validate_float` with `as_f64().is_finite()` |
|
||||
| String `maxLength` (byte length) | `check_string` reads the field-level `maxLength` |
|
||||
| Bytes `maxLength` (array length) | `check_bytes` accepts the `Value::Array` form (the materializer emits bytes as an array of u8) |
|
||||
| RFC 3339 timestamp shape | `validate_timestamp` — same non-strict check as v0.1.0 |
|
||||
| Enum index bounds | `validate_enum` checks `idx < values.len()` — **fixes the v0.1.0 dead constraint** |
|
||||
| Union variant dispatch | `validate_union` reads `__discriminator`, looks up the variant, recurses via `validate_typeref` |
|
||||
| Struct fields | `validate_struct` walks `fields`, requires each declared field present, recurses |
|
||||
|
||||
@@ -33,7 +33,7 @@ constructor used (D-BAST-008):
|
||||
|
||||
The builder covers:
|
||||
|
||||
- All 19 BAST kinds (binary-layout schemas) — see
|
||||
- All 18 BAST kinds (binary-layout schemas) — see
|
||||
[schema-layer.md](schema-layer.md) for the kinds and
|
||||
[`bast-format.md`](bast-format.md) for the format.
|
||||
- All standard JSON Schema keywords needed for operation payload
|
||||
@@ -113,7 +113,7 @@ constraints; `.build()` produces `Value`.
|
||||
#### BAST kind constructors
|
||||
|
||||
One constructor per `AlkTypeKind` variant (see [schema-layer.md](schema-layer.md)
|
||||
§"The 19 BAST Kinds"):
|
||||
§"The 18 BAST Kinds"):
|
||||
|
||||
```rust
|
||||
impl Schema {
|
||||
@@ -135,7 +135,6 @@ impl Schema {
|
||||
// Variable-length kinds
|
||||
pub fn string() -> Self;
|
||||
pub fn bytes() -> Self;
|
||||
pub fn timestamp() -> Self;
|
||||
// Composite kinds
|
||||
pub fn struct_() -> Self; // fields added via .field()
|
||||
pub fn union_(disc: Discriminator) -> Self; // variants via .mapping()
|
||||
@@ -150,7 +149,7 @@ Composite constructors produce the BAST object form.
|
||||
|
||||
**`enum_of`** produces a BAST enum TypeDef (`{ "kind": "enum", "values":
|
||||
[...] }`); declaration order is the index order — see
|
||||
[schema-layer.md](schema-layer.md) §"The 19 BAST Kinds"):
|
||||
[schema-layer.md](schema-layer.md) §"The 18 BAST Kinds"):
|
||||
|
||||
```rust
|
||||
Schema::enum_of(&["read", "write", "execute"]).build()
|
||||
|
||||
@@ -100,7 +100,7 @@ impl SequentialReader {
|
||||
```
|
||||
|
||||
`read_field`/`write_field` on `AlkTypeEngine` work for the fixed-size
|
||||
primitive kinds and the length-prefixed `String`/`Bytes`/`Timestamp`
|
||||
primitive kinds and the length-prefixed `String`/`Bytes`
|
||||
fields. Composite kinds (`Struct`, `Union`, `Array`, `Record`) return a
|
||||
`FieldValue` carrying a layout descriptor (byte range, variant start,
|
||||
or array stride) for the consumer to recurse on — see §"FieldValue" above.
|
||||
|
||||
@@ -27,8 +27,8 @@ three capabilities:
|
||||
3. **Validation** — two validators for two input types:
|
||||
- `validate_bytes(&[u8])` uses the BAST-native validator (a recursive
|
||||
walker over the BAST type tree) to check the value-domain
|
||||
constraints the materializer doesn't (integer ranges, `maxLength`,
|
||||
timestamp shape, enum index bounds, union variant constraints).
|
||||
constraints the materializer doesn't (integer ranges, `maxLength`,
|
||||
enum index bounds, union variant constraints).
|
||||
- `validate_json(&Value)` uses a standard `jsonschema::Validator`
|
||||
compiled from a consumer-provided JSON Schema (BAST is not involved
|
||||
— BAST describes bytes, not JSON shape).
|
||||
@@ -194,7 +194,7 @@ and [ADR-BAST](decisions/bast-bast-format.md).
|
||||
## Architecture (component pointers)
|
||||
|
||||
- **[schema-layer.md](schema-layer.md)** — the BAST parser (the typed
|
||||
surface every engine module walks), the 19 BAST kinds, the
|
||||
surface every engine module walks), the 18 BAST kinds, the
|
||||
`AlkTypeKind` enum, and the foundational annotation types.
|
||||
- **[`bast-format.md`](bast-format.md)** — the normative BAST format
|
||||
specification (meta-schema, TypeRef, examples, validation model).
|
||||
|
||||
@@ -18,7 +18,7 @@ validation model). This document describes the *implementation* — the
|
||||
typed parser in `src/bast.rs` and the foundational `AlkTypeKind` enum
|
||||
in `src/schema.rs` — and points at the format spec for shape details.
|
||||
|
||||
## The 19 BAST Kinds
|
||||
## The 18 BAST Kinds
|
||||
|
||||
BAST uses lowercase `kind` strings (`"uint32"`, `"struct"`, `"union"`,
|
||||
etc.). The engine represents them as the `AlkTypeKind` Rust enum — one
|
||||
@@ -41,7 +41,6 @@ comparison at every field access.
|
||||
| `bool` | `Boolean` | `bool` (`0x00`=false, `0x01`=true) | 1 | fixed |
|
||||
| `string` | `String` | length-prefixed UTF-8 | variable | variable |
|
||||
| `bytes` | `Bytes` | length-prefixed raw bytes | variable | variable |
|
||||
| `timestamp` | `Timestamp` | length-prefixed RFC 3339 string | variable | variable |
|
||||
| `struct` | `Struct` | record of fields | sum of field sizes | composite |
|
||||
| `union` | `Union` | tagged union | discriminator + variant | composite |
|
||||
| `array` | `Array` | repeated element | count × element size | composite |
|
||||
@@ -63,7 +62,7 @@ pub enum AlkTypeKind {
|
||||
Uint8, Uint16, Uint32, Uint64,
|
||||
Float32, Float64,
|
||||
Boolean, Enum,
|
||||
String, Bytes, Timestamp,
|
||||
String, Bytes,
|
||||
Struct, Union, Array, Record,
|
||||
}
|
||||
```
|
||||
@@ -78,7 +77,7 @@ The enum carries the kind's binary-layout metadata as inherent methods:
|
||||
| `natural_alignment(self)` | `usize` | 1 for u8/i8/bool, 2 for u16/i16, 4 for u32/i32/f32/enum, 8 for u64/i64/f64, 4 for variable-length (the u32 length prefix), 1 for struct/union/array |
|
||||
| `is_fixed_size(self)` | `bool` | True for the 12 fixed-size primitive kinds |
|
||||
| `is_composite(self)` | `bool` | True for Struct, Union, Array, Record |
|
||||
| `is_variable_length(self)` | `bool` | True for String, Bytes, Timestamp, Record |
|
||||
| `is_variable_length(self)` | `bool` | True for String, Bytes, Record |
|
||||
| `needs_endian(self)` | `bool` | True for kinds whose read/write takes an `Endian` parameter |
|
||||
|
||||
`AlkTypeKind` implements `Display`, backed by `to_bast_str` so the
|
||||
|
||||
@@ -48,7 +48,6 @@ tree ([`crate::bast::BastDoc`]/[`BastType`]) that checks exactly these:
|
||||
| Float finiteness (Float32/64) | `validate_float` with `as_f64().is_finite()` |
|
||||
| String `maxLength` (byte length) | `check_string` reads the field-level `maxLength` |
|
||||
| Bytes `maxLength` (array length) | `check_bytes` accepts the `Value::Array` form (the materializer emits bytes as an array of u8) |
|
||||
| RFC 3339 timestamp shape | `validate_timestamp` — non-strict check (matching v0.1.0) |
|
||||
| Enum index bounds | `validate_enum` checks `idx < values.len()` — **fixes the v0.1.0 dead constraint** |
|
||||
| Union variant dispatch | `validate_union` reads `__discriminator`, looks up the variant, recurses via `validate_typeref` |
|
||||
| Struct fields | `validate_struct` walks `fields`, requires each declared field present, recurses |
|
||||
|
||||
Reference in new issue
Block a user