Skip to content

KAN-712 feat(api): scaffold kanban-api crate with ApiError and ChangeEventFrame#344

Open
fulsomenko wants to merge 5 commits into
developfrom
max/kan-712
Open

KAN-712 feat(api): scaffold kanban-api crate with ApiError and ChangeEventFrame#344
fulsomenko wants to merge 5 commits into
developfrom
max/kan-712

Conversation

@fulsomenko

Copy link
Copy Markdown
Owner

Add kanban-api crate with the shared HTTP wire types used by kanban-server and kanban-http-backend:

  • Add crates/kanban-api/src/v1/error.rs: ApiError { code: String, message: String } with Display and serde round-trip
  • Add crates/kanban-api/src/v1/events.rs: ChangeEventFrame { writer_instance_id: Uuid, detected_at: DateTime, correlation_id: Uuid, issued_by: ClientId } with constructor and serde round-trip
  • Add crates/kanban-api/src/v1/mod.rs and lib.rs re-exporting both types
  • Update crates/kanban-api/Cargo.toml to add kanban-core dependency (for ClientId)
  • 5 tests covering ApiError construction, Display, serde round-trip, and ChangeEventFrame construction and serde round-trip

What: New kanban-api crate with two types: ApiError (returned by all server error responses) and ChangeEventFrame (broadcast over WebSocket on every successful mutation). The crate has no dependency above kanban-domain and forms the stable wire contract between server and clients.

Why: kanban-server and kanban-http-backend both need to share these types without circular dependencies. Defining them in a dedicated crate with minimal deps keeps the boundary clean.

How: ChangeEventFrame carries all four observability fields (writer_instance_id, detected_at, correlation_id, issued_by) from day one so the wire format does not need to be versioned later. KAN-731 (which would have added correlation_id and issued_by separately) is now redundant.

Testing: cargo test --package kanban-api (5 tests pass), cargo clippy --all-targets --all-features -- -D warnings (clean).

…, clean constructor API

Add ErrorCode enum with SCREAMING_SNAKE_CASE serialisation covering all
KanbanError variants. Replace string code field on ApiError with ErrorCode.
Add #[non_exhaustive] and #[serde(rename_all = "snake_case")] to both
ApiError and ChangeEventFrame. Split ChangeEventFrame::new into new (explicit
timestamp) and now (Utc::now convenience). Add serde(default) on
correlation_id and issued_by with nil fallbacks for backward-compatible
deserialisation. Make v1 private in lib.rs and re-export canonical names at
the crate root.
@fulsomenko fulsomenko self-assigned this Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant