refactor: drop alktype dependency; add BAST doc for chunk header

- Remove alktype from Cargo.toml (its only usage was a thin wrapper
  over jsonschema::options().build())
- Replace alktype::validation::build_validator with direct jsonschema
  in dispatch.rs
- Add docs/architecture/chunk-header.bast.json — the chunk header's
  BAST (Binary Abstract Syntax Tree) machine-readable wire spec
- Embed as channels::wire::CHUNK_HEADER_BAST via include_str! so
  downstream Rust crates can consume it without a file lookup
- Add test asserting the embedded BAST doc is valid JSON and matches
  the wire format
- Update AGENTS.md §10 and implementation-specialist.md: BAST docs
  are the contract; trivial/hot-path formats stay hand-rolled,
  complex formats use the alktype engine or codegen

Verification:
- cargo test: 543 passed, 0 failed
- cargo clippy --all-targets -- -D warnings: clean
- cargo fmt --check: clean
- cargo doc --no-deps: clean
- BAST doc compiles + round-trips against alktype v0.2.0 engine
This commit is contained in:
glm-5.2 committed 2026-08-17 06:08:13 +00:00
1 parent 08e7df2aa0
commit 44d4b496e8
10 files changed
+95 -42

No files matched your search

+2 -2
View File
@@ -272,8 +272,8 @@ feature flags) or in the downstream alknet crate.
- `@alkdev/alknet: docs/architecture/` — the source architecture docs
these were ported from (renumbered from alknet ADR-001..094 to alkcall
ADR-001..045)
- `@alkdev/alktype` — the binary struct engine, used for channels chunk
header layout and JSON payload schema validation
- `@alkdev/alktype` — the binary struct engine; compiles BAST documents
(e.g. `chunk-header.bast.json`) into readers/writers/validators
- `@alkdev/pubsub` — the TypeScript EventEnvelope prior art the call
wire format was derived from
+8
View File
@@ -21,6 +21,14 @@ multiplexing on the `BiStream` the channels layer gives it.
8 bytes of header, followed by `length` bytes of opaque payload.
The machine-readable spec is the BAST document
[`chunk-header.bast.json`](chunk-header.bast.json) (embedded in the
crate as `channels::wire::CHUNK_HEADER_BAST`). BAST is plain JSON —
any language can consume it; the `alktype` crate compiles it into
readers/writers/validators, and future codegen derives
language-specific implementations. The Rust implementation is
hand-rolled (the hot path); the BAST document is the contract.
| field | offset | width | meaning |
|-------|--------|-------|---------|
| `channel_id` | 0 | 4 (BE) | The logical channel this chunk belongs to. Channel 0 is pre-negotiated as `alk/call` (ADR-036). Channels 1..N are opened dynamically via `channel/open` (ADR-037). |
+12
View File
@@ -0,0 +1,12 @@
{
"$defs": {
"ChunkHeader": {
"kind": "struct",
"endian": "big",
"fields": [
{ "name": "channel_id", "kind": "uint32" },
{ "name": "length", "kind": "uint32" }
]
}
}
}
+5 -1
View File
@@ -355,7 +355,11 @@ These were checked and are correct — the rename does not affect them:
- **No logic changes:** the rename is purely mechanical. No function
signatures, trait bounds, or control flow change. ✓
- **No new dependencies, no feature flag changes.** ✓
- **`alktype` dependency unaffected.** ✓
- **`alktype` dependency:** dropped in a follow-up commit (the only
usage, `alktype::validation::build_validator`, was a thin wrapper
over `jsonschema`; the chunk header BAST document
`docs/architecture/chunk-header.bast.json` carries the wire-format
spec without the dependency). ✓
- **483 tests pass before the rename; they should all pass after.** ✓
- **The `alknet/` prefix in `derive_alpn_from_op_name` is the only
non-mechanical change** — the function's logic stays the same, only