Skip to content

feat: Phase 2, the companion chat (1 of 3) - #1

Merged
bketelsen merged 17 commits into
mainfrom
phase2/chat
Oct 21, 2026
Merged

bketelsen merged 17 commits into
mainfrom
phase2/chat

Conversation

@bketelsen

Copy link
Copy Markdown
Contributor

Merge order: this PR, then #(phase 3), then #(restyle). All three PRs target main, so none can merge into another's branch; after this one merges, the next shows only its own commits.

Porter's Phase 2, built 2026-10-19 to 2026-10-20 and kept local until Brian asked on 2026-10-21 to publish it: the thread store with search and the rolling summary, the tool registry over lodge's agent socket, the agent loop, the system prompt, capture and memory, porterd serving the thread over the agent and lodge's sockets, the companion chat in the web UI, and the fixes that keep the model to what its tools did (no claimed actions, ids looked up, drafts written as the owner). Pins kit v0.2.0 and lodge-client client/v0.2.0.

Gates: make check.

bketelsen and others added 17 commits October 19, 2026 19:58
lodge/kit at bab1ed7 (untagged; it has lodgeapp's AgentClient and the
companion manifest flag), mise.toml and mise.lock with golangci-lint
2.13.1, lodge's .golangci.yml, and make verify, check and ci (frostyard/core
ADR-0043, ADR-0044), with lint, race, tidy-check and web-check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thread.list, send, search, confirm, cancel and subscribe, with Turn, Card,
Context and Event (schema/rpc/thread.yaml, hand-written api/thread.go).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SQLite (modernc): turns with their cards and context, an FTS5 index kept by
triggers, the rolling summary, card lookup, and recovery of a reply a
stopped porterd left unfinished.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One MCP client per app, with that app's token, reconnecting once when a
session is gone. Each tool is marked Read, Draft, Write, Change, Capture or
Never (send and post tools, never offered); routines get only Read, Draft
and Write (ADR-0004). Porter's own tools join the registry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each request carries the system prompt (draft 1), the owner's memory note,
the rolling summary, the recent turns and the context. Tools run through
the registry, and their results reach the model wrapped as data. Capture
becomes a card the owner confirms before anything is appended. remember,
search_thread and now are Porter's own tools. Replies stop at 40 tool
calls, and Compact folds old turns into the summary at background priority.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- internal/service implements thread.list, send, search, confirm, cancel
  and subscribe. There is one reply at a time, and events go to subscribed
  connections as the kit's envelope (event "turn" or "working").
- internal/config: /etc/porter/porter.json (owner, time zone, aliases,
  apps), and each app's token in the state directory, set with
  `porterd token set APP` (0600).
- porterd wires the store, one MCP client per app with a token over the
  agent socket, the inference socket, the agent and the service.
- The manifest sets companion: true, and the unit joins lodge-agents.
- Tests: config and tokens, plus a session's whole thread through
  kittest: events, a conflict while replying, list and search.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The thread (paged, kept at the bottom, a reply growing as events arrive),
markdown built as DOM from marked's lexer with no innerHTML and no image
ever loaded, links only to lodge addresses or https with their host shown,
tool and capture cards (confirm with edits, cancel), the input with the
current app's context chip and lodge-client's ask, search in the full app,
light and dark, phone-first. lodge-client is pinned at lodge bab1ed7;
marked 18.0.14; vitest and happy-dom for 50 tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
In the first live run, Porter guessed message ids for draft_reply: one
failed and one drafted a reply on the wrong thread. The prompt now says to
find an id with a search or list tool and use exactly what it returned, and
to link a draft when its tool returns a url.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Porter signed its first live draft "Porter". A draft goes out as the
owner's, so the prompt says to write it in their voice, signed with their
name or not at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
In its first live use the local model wrote "Draft ready" four times
without calling draft_reply, and the history then showed it those
replies as if they were done. porterd now checks a reply's claims
(drafts, captures, memory, tasks) against the reply's tool cards: an
unbacked claim sends the model back once, and if it is still unbacked
the reply says nothing was done. A past reply that called no tool is
marked so in the history. The prompt says the same, and draft_message
is classified as a draft for when mail adds it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e nudge

The claim check caught the next unbacked "Draft created", but the model
still called no tool: its history showed four earlier replies claiming
drafts, and a "[Done in this reply: …]" line it copied. History now
replays a reply's cards as the tool calls they were (a card keeps its
arguments, long strings shortened), with each call's outcome, and
leaves out the text of a past reply that claimed an action no tool
took. The nudge's retry sets tool_choice to required, and falls back
to asking without it if the provider refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A placeholder standing in for a failed reply was copied word for word by
the model as its next answer. The history now leaves out a reply that
claimed an action no tool took, with the owner's turn it answered, and
search_thread leaves it out too; search_thread's hits show the tools a
reply called. A reply that repeats porterd's own words (its notes, or
markers older versions put in the history) counts as failed: it is sent
back once, and left out of the history.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the history fix, the model's first draft_reply guessed message 1
and drafted on another person's thread. A call of a tool that is not a
read now takes only ids a tool returned in this reply, the owner wrote,
the screen shows, or an earlier successful call used; any other id is
refused with a note to look it up first, and nothing is done.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Porter was pinned to lodge commit bab1ed7 for the agent socket client
and the companion's messages; both are now released as v0.2.0
(c31c333, the same kit code). The lockfile resolves client 0.2.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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