Skip to content

feat(server): add the provider adapter seam (step 18a) - #315

Merged
opficdev merged 4 commits into
mainfrom
chore/server-18a-provider-seam
Dec 6, 2026
Merged

opficdev merged 4 commits into
mainfrom
chore/server-18a-provider-seam

Conversation

@opficdev

@opficdev opficdev commented Dec 6, 2026

Copy link
Copy Markdown
Member

Step 18a of docs/bridge-to-rust.md: the adapter seam. Every provider instance now reaches its adapter through traits, and every row of the registry still points at the bridge, so the protocol and behavior are unchanged. Later steps (18k ACP, 18l Codex, 18n Claude) switch one row at a time.

What changes

  • New core crate tern-server-provider (uses wire, bridge):
    • ProviderAdapter (capabilities, selection transition plan, account prompt commands, open_session) and SessionRuntime (every Operation of upstream's session runtime, the context window, close), ported from ProviderAdapter.ts. Inputs and answers stay JSON encoded as upstream's schemas, which the server already reads and stores.
    • ProviderEvent (typed ProviderAdapterV2Event for Rust adapters to build) and SessionEvent (a session's event, its end, a continuation offer, an adapter's exit) on one channel to Turns.
    • AdapterError, which keeps the bridge's error text, so stored failures do not depend on which adapter ran.
    • ids: turns/ids.rs moved here (own commit) and the rest of IdAllocator.ts ported, except the fixtures' ids.
    • RuntimeRequests: the open questions and approvals a Rust adapter waits on, written once.
    • Registry: one row per built-in driver plus a fallback; BridgeAdapter implements the traits on the bridge protocol.
  • tern-server composes the registry (every row the bridge) in attach_bridge, and the MCP sign-in runs on the session's runtime.
  • tern-server-threads opens sessions, runs their operations and takes their events through the traits. Sessions hold their runtime; an adapter that exits ends only its own sessions. Checkpoints, handoffs, workspaces, titles, terminals, devices and continuation requests are still asked of the bridge directly (their own steps; continuations move with the first adapter that offers them, 18k).
  • The bridge example runs its Replay turn through BridgeAdapter.
  • Docs: crates.md (row, tier, edges), crates.svg regenerated, bridge-to-rust.md marks 18a done, server-orchestration.md.

Checks

  • cargo fmt --all, cargo clippy --workspace --all-targets --locked -- -D warnings, scripts/check-layers.py (53 crates, 0 allowed edges).
  • cargo test --workspace --locked with a scratch HOME and TERN_KEYCHAIN=off.
  • Replay turn through the seam (cargo run -p tern-server --example bridge, Node 26.13.1): session opened with its operations, thread.ensure, turn.start, turn completed in 5.2 s, startup 0.77 s, 360 MB resident.
  • Every own_* harness unchanged, run by CI's harnesses job.

🤖 Generated with Claude Code

opficdev and others added 4 commits December 6, 2026 11:01
The new core crate tern-server-provider is the adapter seam of step 18a in
docs/bridge-to-rust.md. Its first piece is turns/ids.rs, moved unchanged;
tern-server-threads re-exports it where it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the derived and allocated ids the adapters name their rows with:
subagent and delegated task threads, provider items as nodes and
messages, runtime requests with their node and card, raw events, plans
and context handoffs, so every Rust adapter allocates ids as upstream's
does. The fixtures' command and project ids are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tern-server-provider takes the ProviderAdapter and SessionRuntime traits
ported from ProviderAdapter.ts, the events and errors they report, the
runtime request table Rust adapters share, the instance-to-adapter
registry, and the bridge-backed adapter. tern-server composes a registry
whose every row is the bridge, and tern-server-threads opens sessions,
runs their operations and takes their events through the traits instead
of calling the bridge's session methods. The protocol and what tern does
are unchanged; the Replay example now runs its turn through the seam.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@opficdev
opficdev enabled auto-merge (squash) December 6, 2026 02:02
@opficdev
opficdev merged commit 9821e24 into main Dec 6, 2026
20 checks passed
@opficdev
opficdev deleted the chore/server-18a-provider-seam branch December 6, 2026 02:09
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