Skip to content

feat(platform): draft replies on conversations, and add the Jev decisions connector - #3425

Merged
Israeltheminer merged 3 commits into
mainfrom
feat/conversation-drafts-and-jev
Sep 19, 2026
Merged

Israeltheminer merged 3 commits into
mainfrom
feat/conversation-drafts-and-jev

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

Two capabilities that work together: a model that decides whether to act, and a way for what it decides to reach a person.

The conversation draft producer

An agent-drafted reply is an approval on the conversation — resource_type of conversations, resource_id the conversation id. Both halves around it were already built:

  • loadPendingApprovals (domains/conversations/service.ts:451) joins the newest pending row onto the list, and conversation-panel.tsx renders its metadata.emailBody as a pending message.
  • sendMessageViaConnectorInTx (send.ts:352) completes that row when a human sends, stamping sentContent / sentTo / sentAt.

Only the producer was missing. 'conversations' is a declared ApprovalResourceType and the app contract carries it, but the sole INSERT with that type lived in the integration check. This adds the writer those two were written against.

It writes no message. A draft is a proposal, so nothing reaches a customer until a person sends it — and for a mirrored conversation, that human send is also what puts the reply on the API delivery queue.

Migration 0108

A partial unique index for pending conversation rows, the same contract 0074 already gives connector operations. Without it, two runs racing one inbound message each mint a card; the panel shows the newest while a send completes the oldest it finds, marking a draft the reader never saw as the one they sent. The loser now reads the winner's card back (created: false) instead.

No backfill — rows of this type were never minted in production, so there are no duplicates to supersede. If a deployment acquired some by hand the index creation fails loudly rather than choosing a survivor on its own.

The Jev connector

Jev takes a piece of state and named questions and returns typed answers carrying their probability distribution — a choice from a fixed set, a score against ordered levels, or the probability a yes/no statement is true.

It cannot go in a model: field: the openrouter provider is pinned to apiFormat: openai on /api/v1, while decisions answer at their own path with their own body shape, and posting a decisions model to chat/completions answers 400 and says so. A connector is how a workflow reaches it.

It returns no text and cannot draft, so it pairs with an llm node rather than replacing one. What it adds is a number — a workflow can gate an action on confidence rather than on a sentence. Input tokens are billed and output tokens are free, so it costs a fraction of the chat call it takes the decision away from.

Proof

bun run --filter @tale/platform backend:integration against throwaway Postgres + MinIO. The send-lane probe now drives the real producer instead of hand-inserting the approval, and asserts the new rule:

PASS outbound send lane (reply/compose/undo/retry/discard + undo-window job)
     draft=true/false/pending=1 (want true/false/1), … approval=completed/true

First draft created; the racing second returns the winner's card; exactly one pending row survives; the human send still completes it.

A caveat on the full run. The suite truncates at lane 95 (checkConversationApi, 201 !== 403) before reaching this lane. I verified that against a stashed clean tree: same lane, same assertion, same 454/462 tally — pre-existing, unrelated to this branch. To reach lane 96 I temporarily swallowed that throw locally (not committed), which let all 150 lanes run: 676/682 checks passed, and every one of the 6 failures also appears in the clean-tree baseline (object-store seeding, robots crawler ×2, video/whisper ×3 — this host has no ffmpeg).

That checkConversationApi failure is worth someone's attention on its own; it is blocking 55 lanes from ever running in CI or locally.

Also

  • conversation.draft_reply is a write effect even though nothing leaves the building — a draft changes what a person sees, and the approvals gate should be able to hold it like any other write.
  • The shipped-catalog, dispatcher and registry counts are pinned so losing a connector fails loudly; they move with the two new actions.
  • CONV-F12 covers what a person actually sees: the pending message in the reading pane, the send that resolves it, and the second draft that must not produce a twin.
  • bun run lint:manual, lint:sast (0 findings), oxfmt, tsc and 8,785 server tests all green.

🤖 Generated with Claude Code

Jev is a decisions model, not a chat one. It takes a piece of state and
named questions, and returns typed answers carrying their probability
distribution — a choice from a fixed set, a score against ordered levels,
or the probability a yes/no statement is true.

It cannot go in a `model:` field. The openrouter provider is pinned to
apiFormat openai on /api/v1, while decisions answer at /api/alpha/decisions
with their own body shape; posting a decisions model to chat/completions
answers 400 and says so. A connector is the way a workflow reaches it.

A decision returns no text and cannot draft, so it pairs with an llm node
rather than replacing one. What it adds is a number: a workflow can gate
an action on confidence instead of on a sentence. Input tokens are billed
and output tokens are free, so it costs a fraction of the chat call it
takes the decision away from.
@Israeltheminer
Israeltheminer force-pushed the feat/conversation-drafts-and-jev branch from 0414233 to 44903b2 Compare September 19, 2026 20:10
An agent-drafted reply is an approval on the conversation — resource_type
of conversations, resource_id the conversation id. Both halves around it
were already built: loadPendingApprovals joins the newest pending row onto
the list and the panel renders metadata.emailBody as a pending message,
and sendMessageViaConnectorInTx completes that row when a human sends.
Only the producer was missing, so nothing outside the integration check
ever minted one.

It writes no message. A draft is a proposal, so nothing reaches a customer
until a person sends it — and for a mirrored conversation that human send
is also what puts the reply on the API delivery queue.

Migration 0108 carries a partial unique index for pending conversation
rows, the same contract the connector gate already has. Two runs racing
one inbound message would otherwise each mint a card, and the panel shows
the newest while a send completes the oldest it finds — marking a draft
the reader never saw as the one they sent. The loser now reads the
winner's card back instead.

No backfill: rows of this type were never minted in production, so there
are no duplicates to supersede.
The producer is only reachable from a workflow once it is an action, so
conversation.draft_reply joins the connector on the native backend beside
the mailbox actions, with the store method and rim binding it needs.

Its effects are write even though nothing leaves the building: a draft
changes what a person sees in the Inbox, and the approvals gate should be
able to hold it like any other write.

The shipped-catalog, dispatcher and registry counts are pinned so that
losing a connector fails loudly; they move with the two new actions.

CONV-F12 covers the behaviour a person actually sees — the pending message
in the reading pane, the send that resolves it, and the second draft that
must not produce a twin.
@Israeltheminer
Israeltheminer force-pushed the feat/conversation-drafts-and-jev branch from 44903b2 to a6e181d Compare September 19, 2026 20:17
@Israeltheminer
Israeltheminer merged commit 6d64921 into main Sep 19, 2026
56 checks passed
@Israeltheminer
Israeltheminer deleted the feat/conversation-drafts-and-jev branch September 19, 2026 21:51
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