Skip to content

feat(host): add protocol, in-process host, session store, and client (ENG-379) - #2

Merged
folathecoder merged 2 commits into
mainfrom
eng-379-3-protocol-host-and-sessions
Oct 17, 2026
Merged

folathecoder merged 2 commits into
mainfrom
eng-379-3-protocol-host-and-sessions

Conversation

@folathecoder

@folathecoder folathecoder commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Builds the protocol contract (aldwin.protocol), the in-process transport and turn runner (aldwin.host), the per-step session store (aldwin.host.sessions), and the async client (aldwin.client). Doors can now stream turns, answer approval prompts, stop active turns within a second, switch models, and resume saved conversations without importing aldwin.core or agentling.

Ticket

Changes

  • Protocol (src/aldwin/protocol/messages.py, docs/protocol.md): Added the v1 envelope, 6 request models (hello, turn, stop, approve, history, set_model), 7 event models (text, tool_call, tool_result, approval, history, done, error), discriminated unions (Request, Event, Message), ConfigDict(extra="ignore"), and JSON parsers.
  • Transport (src/aldwin/host/in_process.py): Added ClientTransport and InProcessTransport using inbound and outbound asyncio.Queues with JSON wire validation and clean close sentinels.
  • Sessions (src/aldwin/host/sessions.py): Added SessionStore, StoredSession, and SessionMeta for atomic 0600 per-step saves in sessions/<YYYY-MM-DD>_<shortid>.json, latest-session resume, 60-character title derivation, /new session creation, and render_history(limit=20) with one-line tool summaries.
  • Host runner (src/aldwin/host/runner.py): Added RequestScope (enforcing one terminal event per request), ApprovalBroker (ask, resolve, cancel_all), classify_turn_error, and AldwinHost (handshake check, streaming event mapping, mid-stream and mid-approval stop, set_model, and new_conversation).
  • Client (src/aldwin/client/client.py): Added AldwinClient (connect, turn, stop, approve, history, set_model, new_conversation, close) with re-keyed event demultiplexing.
  • Tests (tests/): Added FakeModel and FakeTurn in tests/fakes/model.py, plus tests/test_protocol.py, tests/test_sessions.py, tests/test_host_runner.py, and tests/test_client.py covering TC-01 through TC-30.

How it was tested

  • Automated:
    • uv run pytest -v --cov=aldwin (91 passed in 0.61s, 94% total coverage; 100% on protocol/, 100% on host/in_process.py, 95% on host/sessions.py, 93% on host/runner.py, 93% on client/client.py)
    • uv run ruff check src tests and uv run ruff format --check src tests (all passed)
    • uv run mypy --strict src tests (0 issues across 28 files)
  • Manual:
    • Verified all test cases TC-01 through TC-30 and manual checks M-01 through M-03 in ENG-391.

Folarin Akinloye added 2 commits October 17, 2026 01:47
…(ENG-379)

Implement the v1 13-message Pydantic protocol, queue-backed in-process transport, atomic per-step session store, single-turn runner with RequestScope and ApprovalBroker, and AldwinClient API.
@folathecoder
folathecoder merged commit 8e277ea into main Oct 17, 2026
4 checks passed
@folathecoder
folathecoder deleted the eng-379-3-protocol-host-and-sessions branch October 17, 2026 01:52
@folathecoder folathecoder self-assigned this Oct 18, 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