clawdforge/clients
Kayos 22e57e3dad clients/c: v0.2 multi-turn Session API
- cf_session_t (opaque), cf_session_options_t, cf_turn_options_t,
  cf_turn_event_t, cf_turn_result_t, cf_session_state_t, cf_session_list_t
- cf_session_new / _turn / _close (idempotent) / _free, _state_get,
  _list_get, plus cf_session_id / _agent accessors
- cf_turn_result_text concatenates type=="text" events into a single
  string, lazily cached, OWNED by the result (caller must not free)
- Session-id allow-list ([A-Za-z0-9_-]+) validated client-side everywhere
  it lands in the URL path — same pattern as cf_admin_revoke_token, no
  reverse-proxy traversal foothold
- Bearer hygiene preserved: regression test covers cf_session_new /
  state_get / list_get and asserts the bearer never lands in
  cf_error_t.message
- v0.1 surface unchanged. Existing types (cf_client_t, cf_run_*, etc.)
  are byte-identical. cJSON 1.7.18 preserved.

Tests (21 → 34, +13):
- session_turn_round_trip — full create + turn + close, event parsing
- session_close_idempotent — close × 3, DELETE on the wire ONCE
- session_turn_after_close_returns_error — CF_ERR_USAGE, no HTTP
- session_cross_token_returns_404 — CF_ERR_API + http_status==404
- session_validates_id_traversal — "a/../healthz" rejected pre-network
- session_list_get — 2-row mock parsed; null last_turn_at → -1
- session_state_get — full state shape parsed
- turn_result_text_concatenates — skips non-text + empty content
- session_free_idempotent — NULL-safe across all v0.2 freers
- turn_result_memory_clean — valgrind regression guard
- session_turn_with_files — files + timeout_secs serialised
- session_bearer_never_leaks — 3 fallible paths, bearer stays out
- session_null_arg_defenses — every entry point rejects NULLs

Verification:
- cmake --build build (Release, -Werror -Wall -Wextra -Wpedantic
  -Wshadow): clean
- ctest --test-dir build: 34/34 pass
- valgrind --leak-check=full: 12,678 allocs == 12,678 frees, 0 errors,
  0 leaks
- ASan build: 34/34 pass clean
- UBSan build (-fsanitize=undefined -fno-sanitize-recover=all): 34/34
  pass clean

README adds "Multi-turn / Sessions (v0.2)" section: lifecycle example,
idempotent-close note, event/text ownership rules, state + listing,
memory ownership table, what's not in v0.2.

Spec: memory/spec-clawdforge-v0.2.md
Server core: 940861f
2026-04-29 07:08:50 -07:00
..
bash clients/bash: v0.2 multi-turn session subcommands 2026-04-29 07:00:40 -07:00
c clients/c: v0.2 multi-turn Session API 2026-04-29 07:08:50 -07:00
cpp clients/cpp: apply audit findings — protocol-error guard + libcurl redirect clamp (bae34a7 → next) 2026-04-28 23:41:41 -07:00
csharp clients/csharp: v0.2 multi-turn Session API 2026-04-29 06:59:45 -07:00
go clients/go: v0.2 multi-turn Session API 2026-04-29 06:34:12 -07:00
java clients/java: v0.2 multi-turn Session API 2026-04-29 06:50:02 -07:00
kotlin clients/kotlin: v0.2 multi-turn Session API 2026-04-29 07:03:54 -07:00
mcp clients/mcp: v0.2 multi-turn session tools 2026-04-29 06:49:49 -07:00
php clients/php: v0.2 multi-turn Session API 2026-04-29 06:51:17 -07:00
python clients/python: v0.2 multi-turn Session API 2026-04-29 06:35:27 -07:00
ruby clients/ruby: v0.2 multi-turn Session API 2026-04-29 06:46:52 -07:00
rust clients/rust: v0.2 multi-turn Session API 2026-04-29 06:39:37 -07:00
swift clients/swift: v0.2 multi-turn Session API 2026-04-29 07:00:56 -07:00
typescript clients/typescript: v0.2 multi-turn Session API 2026-04-29 06:38:55 -07:00