Break the alknet-typedef architecture specs into atomic, dependency-ordered implementation tasks covering crate init, error types, schema layer, data access, both layout modes (aligned static + packed sequential), TUnion dispatch, jsonschema custom keyword validators, TypedefEngine integration, comprehensive tests, and a final review checkpoint. Validated: 12 tasks, 0 cycles, 7 parallel generations.
5.5 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level |
|---|---|---|---|---|---|---|---|
| typedef/crate-init | Initialize alknet-typedef crate with Cargo.toml, dependencies, and module skeleton | pending | moderate | low | project | implementation |
Description
Initialize the alknet-typedef crate from scratch. This is a greenfield crate — the
binary struct engine that takes a JSON Schema with TypeDef:* custom keywords and
produces an offset map, read/write functions, and validation. The schema is the format
definition; the engine is generic.
Per ADR-095,
the crate depends on jsonschema (v0.46.5, Draft 2020-12) for validation and
serde_json (with preserve_order) for schema parsing. No tokio, no platform deps.
Compiles to wasm32-unknown-unknown.
Crate setup
Create crates/alknet-typedef/ with:
Cargo.toml— package metadata, dependenciessrc/lib.rs— crate root with module declarations and re-exports- Module skeleton files for:
src/error.rs—TypedefErrorenum (ADR-098)src/schema.rs— TypeDef kind detection, annotation parsing,$refnormalization,Endianenum (ADR-097)src/data_access.rs— primitive read/write functions for all 17 TypeDef kindssrc/offset_map.rs— aligned staticOffsetMapcomputation (ADR-096 Mode 2)src/layout_builder.rs— packed sequentialLayoutBuilder(ADR-096 Mode 1, write side)src/sequential_reader.rs— packed sequentialSequentialReader(ADR-096 Mode 1, read side)src/tunion.rs— TUnion discriminator dispatch (byte-offset and field-name, ADR-097 §4)src/validation.rs— custom keyword validators for all 17TypeDef:*kindssrc/engine.rs—TypedefEnginestruct combining layout + validator
Dependencies
Per the architecture spec (overview.md):
| Crate | Purpose |
|---|---|
jsonschema 0.46 |
Validation engine, custom keyword support (workspace path: ../../jsonschema) |
serde_json (preserve_order) |
Schema parsing; field order is load-bearing for binary layouts |
No other dependencies. No tokio, no platform deps.
Workspace Cargo.toml
Add crates/alknet-typedef to the workspace members list in the root Cargo.toml.
Module skeleton
// src/lib.rs
//! alknet-typedef: The binary struct engine.
//!
//! Takes a JSON Schema with `TypeDef:*` custom keywords and produces
//! an offset map, read/write functions, and validation — all driven
//! by the schema. The schema is the format definition; the engine is
//! generic.
//!
//! ## Architecture
//!
//! - **Schema layer** ([`schema`]): TypeDef kind detection, annotation
//! parsing, `$ref` normalization, endianness.
//! - **Layout engine** ([`offset_map`], [`layout_builder`],
//! [`sequential_reader`]): Two layout modes — aligned static for
//! mmap-friendly formats, packed sequential for protocol wire formats.
//! - **Data access** ([`data_access`]): Typed read/write at computed
//! offsets, zero-copy for fixed-size types.
//! - **TUnion dispatch** ([`tunion`]): Byte-offset and field-name
//! discriminator dispatch.
//! - **Validation** ([`validation`]): Custom keyword validators for all
//! 17 `TypeDef:*` kinds, delegated to the `jsonschema` crate.
//! - **Engine** ([`engine`]): `TypedefEngine` — the compiled form of a
//! schema, combining layout and validation.
pub mod data_access;
pub mod engine;
pub mod error;
pub mod layout_builder;
pub mod offset_map;
pub mod schema;
pub mod sequential_reader;
pub mod tunion;
pub mod validation;
// Re-exports (filled in by subsequent tasks)
Each module file gets a doc comment and // TODO: implement marker.
Acceptance Criteria
crates/alknet-typedef/Cargo.tomlexists withjsonschemaandserde_json(preserve_order) dependenciesjsonschemadependency uses workspace path (path = "../../jsonschema") or git/crates.io as appropriatecrates/alknet-typedef/src/lib.rsexists with module declarations for all 9 modules- Module skeleton files exist:
error.rs,schema.rs,data_access.rs,offset_map.rs,layout_builder.rs,sequential_reader.rs,tunion.rs,validation.rs,engine.rs - Root
Cargo.tomlmemberslist includescrates/alknet-typedef cargo check -p alknet-typedefsucceedscargo clippy -p alknet-typedefsucceeds with no warnings- Dual licensing:
MIT OR Apache-2.0(workspace-inherited) - No tokio dependency (WASM-clean by construction)
serde_jsonhaspreserve_orderfeature enabledcargo build --workspacestill succeeds (old code untouched)
References
- docs/architecture/crates/typedef/README.md — crate overview and design principles
- docs/architecture/crates/typedef/overview.md — purpose, dependencies, scope boundaries
- docs/architecture/decisions/095-alknet-typedef-purpose-scope-jsonschema-engine.md — ADR-095
- docs/research/alknet-typedef/findings.md — POC results
- /workspace/jsonschema/ — the jsonschema crate (v0.46.5)
- /workspace/alknet-typedef-poc/ — POC code (disposable reference)
Notes
This is the foundational setup task for alknet-typedef. All subsequent typedef/* tasks depend on this one. The crate is dependency-light:
jsonschema+serde_jsononly. No tokio, no platform deps — WASM-clean by construction. Thejsonschemacrate is already in the workspace at/workspace/jsonschema/but not yet used by any alknet crate — typedef is the first consumer.
Summary
To be filled on completion