Implement ratatoskr.sessions — create + list against Worldtree #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The
--sendnon-interactive mode (design-brief §8b) needs to create a session before streaming when invoked with--new. The Textual TUI's startup session picker (design-brief §4) needs to list existing sessions. Both touch the session-lifecycle API but neither belongs inratatoskr.sse_client, which is scoped to per-turn streaming.Without these primitives,
--send --newcan't synthesize a fresh session against Worldtree, and the TUI picker has no source for itsDataTableofGET /sessionsresults.Solution
Implement
src/ratatoskr/sessions.pyper the contract atdocs/contracts/issues/2.contract.md. Two entry points + two shared dataclasses:create_session(client, agent_id) -> SessionInfo— POST/sessions.list_sessions(client, *, include_archived=False, limit=50, cursor=None) -> SessionPage— GET/sessions; cursor-paginated.SessionInfo— frozen dataclass carrying the shape both endpoints share (session_id,agent_id,created_at,last_active,metadata) plus list-response-only fields (name,archived,tags) typed as optional.SessionPage— frozen dataclass:items: list[SessionInfo],next_cursor: str | None.Spec-conformance discipline mirrors issue #1: no
core.*/worldtree.*imports (boundary already enforced bytests/test_no_worldtree_imports.py); caller owns thehttpx.AsyncClientandAuthorizationheader lifecycle.Out of scope (this issue)
GET /sessions/{id},PATCH /sessions/{id},DELETE /sessions/{id}— admin-side or mutate-side operations outside Ratatoskr's TUI surface (per design-brief §4 negative clauses: "no in-app rename", "no in-app session deletion").GET /sessions/{id}/messages(history pagination) — deferred until the TUI needs scrollback-replay; not used by--send.Benefits
--send --new(the next vertical slice toward exercisingsse_clientend-to-end against a live Worldtree).sse_clientfor turn streaming + cancel,sessionsfor session lifecycle.Acceptance
uv run pytest tests/.tests/test_no_worldtree_imports.pycontinues to pass (no Worldtree-source imports added).uv run ruff check src/ tests/clean.55101e909abcd2219833266b6f905c5bc956e0f0).Dependencies
ratatoskr.sse_client) closed-on-main. Not a code dependency —sessions.pydoes not import fromsse_client.py— but a convention dependency: the API-consumption posture (caller-owned httpx client, async-native, no Worldtree imports, response-parsing into typed dataclasses) is established there andsessions.pyfollows the same shape.Closed — shipped. ratatoskr.sessions create+list implemented via TDD (commit
4ba143c, Volva-reviewed ind6f9327).