Mercurial
diff .claude/skills/zenbu-seobeo-networking/SKILL.md @ 248:b8b6e726964a
[style] Use Dowa type aliases in C
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 04 Aug 2026 02:44:06 -0700 |
| parents | |
| children | 745fd127b2a1 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.claude/skills/zenbu-seobeo-networking/SKILL.md Tue Aug 04 02:44:06 2026 -0700 @@ -0,0 +1,105 @@ +--- +name: zenbu-seobeo-networking +description: Use this skill when changing or extending seobeo, the C networking layer for HTTP clients, HTTP/static servers, routing, streaming, TLS, or WebSockets. +--- + +# Seobeo Networking + +Use this skill for the `seobeo/` networking library and any server code built on top of it. + +## Mental model + +`seobeo` is the shared C networking layer. It provides: + +- TCP server/client handles in `s_network.c`. +- TLS helpers in `s_ssl.c`. +- Static file and HTTP routing in `s_web.c`. +- Curl-like HTTP client APIs in `s_http_client.c`. +- WebSocket client/server support in `s_websocket*.c`. +- Snapshot/test utilities in `snapshot_creator.c`. +- Public API declarations in `seobeo/seobeo.h`. +- Internal types in `seobeo/seobeo_internal.h`. + +Prefer using public APIs from `seobeo.h` in applications. Only reach into internals when modifying seobeo itself. + +## Common APIs + +HTTP client: + +```c +Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://example.com/path"); +Seobeo_Client_Request_Set_Method(p_req, "GET"); +Seobeo_Client_Request_Add_Header_Array(p_req, "Accept: application/json"); +Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); +Seobeo_Client_Request_Destroy(p_req); +Seobeo_Client_Response_Destroy(p_resp); +``` + +HTTP routes: + +```c +Seobeo_Router_Init(); +Seobeo_Router_Register("GET", "/api/example/:id", Handler); +Seobeo_Web_Server_Start("site/src", "8080", SEOBEO_MODE_EDGE, 1); +Seobeo_Router_Destroy(); +``` + +Route handler shape: + +```c +Seobeo_Request_Entry *Handler(Seobeo_Request_Entry *req, Dowa_Arena *arena) +{ + Seobeo_Request_Entry *resp = NULL; + Dowa_HashMap_Push_Arena(resp, "status", "200", arena); + Dowa_HashMap_Push_Arena(resp, "content-type", "application/json", arena); + Dowa_HashMap_Push_Arena(resp, "body", "{\"ok\":true}", arena); + return resp; +} +``` + +WebSocket server: + +```c +Seobeo_WebSocket_Server_Init(); +Seobeo_WebSocket_Server_Register("/chat", Chat_Handler, NULL); +``` + +## Build targets + +Choose the smallest library variant that matches the feature: + +- `//seobeo:seobeo_min`: TCP/SSL basics. +- `//seobeo:seobeo_tcp_server`: HTTP server, no WebSocket, no SSL. +- `//seobeo:seobeo_tcp_server_ws`: HTTP server with WebSocket. +- `//seobeo:seobeo_tcp_client`: HTTP client. +- `//seobeo:seobeo_tcp_client_ws`: HTTP client with WebSocket. +- `//seobeo:seobeo`: full combined library. +- `//seobeo:seobeo_debug`: full library with debug logging. + +## Tests + +Run the narrowest relevant tests first: + +```bash +bazel test //seobeo:seobeo_client_test +bazel test //seobeo:seobeo_websocket_test +bazel test //seobeo:seobeo_websocket_server_test +``` + +For API changes, also build downstream users: + +```bash +bazel build //mrjunejune:mrjunejune_server //hg-web:hg_web_server +``` + +## Safety checklist + +- Use Dowa aliases such as `uint8`, `uint32`, and `boolean` with + `TRUE`/`FALSE`; avoid adding `<stdint.h>` `_t` types or `<stdbool.h>` `bool` + to first-party C when the Dowa equivalent exists. +- Keep binary bodies binary-safe: use explicit lengths and `Dowa_Arena_Copy`/`memcpy`, not `strlen`, when forwarding arbitrary bytes. +- Destroy `Seobeo_Client_Request`, `Seobeo_Client_Response`, `Seobeo_Handle`, and WebSocket messages on owned paths. +- Do not swallow network errors. Return explicit HTTP 4xx/5xx responses or propagate error codes. +- Preserve keep-alive, content-length, and response header behavior when touching routing or streaming. +- Be careful with request map keys: existing code uses keys such as `Body`, `Content-Length`, `Authorization`, `HTTP_Method`, `QueryString`, route params like `:filename`, and query-derived keys like `query_path`. +- For WebSockets, respect RFC 6455 requirements: client frames masked, fragmentation handled, control frames handled, and close paths cleaned up.