Skip to content

feat(mcp): a message a connected app writes carries a mark, for the person and for the assistant - #385

Merged
IvanJS17 merged 6 commits into
mainfrom
feat/messages-a-connected-app-writes-are-marked
Nov 28, 2026
Merged

IvanJS17 merged 6 commits into
mainfrom
feat/messages-a-connected-app-writes-are-marked

Conversation

@IvanJS17

@IvanJS17 IvanJS17 commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

A message a connected app writes into a conversation now carries a mark of its own. The person sees it where the message is drawn, and the assistant is told, on that message only, that it was sent through an app the person connected. Main conversations, matter conversations and the threads of a table review work the same way, for a new conversation and for an existing one.

What changed

  • Migration 20261128_02_litt_message_origin.sql: origin ('mcp' only), origin_grant_id (FK to mcp_grants, on delete set null) and origin_label (<= 120) on chat_messages and tabular_review_chat_messages. Re-runnable, no backfill, no policy or grant change. schema.sql carries the same block and ledger line.
  • The tools that write a message pass the connection's mark on every call (start_chat, send_chat_message, the matter and workflow tools, send_tabular_chat_message); the three insert points write it through chatOriginColumns. Nothing in a request body can set it.
  • The assistant reads a marked message after one fixed line ([Sent through an app the person connected to LiTT, on their behalf; not typed by them in LiTT.], never the app's name) and the text inside an <app-message nonce> fence, built like the workflow fence (same nonce, same neutralization, which now also covers app-message). One policy paragraph in the system prompt says to treat it as the person's request, subject to system rules. The review thread's prompt gets the paragraph when a marked message is present.
  • Which messages of the history carry the mark is decided by text: a message is marked when its text equals the stored text of a message an app wrote in that conversation. No position is involved, so a history that differs from the stored rows keeps every mark on the right message. A message the person typed with exactly the same text carries it too (the mark restricts nothing).
  • A failed read of the marks ends the turn with the internal error (chat, matter chat, review thread); the send-times read keeps its behaviour.
  • GET /chat/:id no longer returns origin_grant_id; the review thread read returns origin and origin_label only.
  • Web: one line of plain text under the message ("Desde " / "From ", or "Desde una app conectada" / "From a connected app"), in the conversation view, the matter panel and the review thread panel.
  • The memory curator's transcript says when a person's message was sent through a connected app (User (sent through a connected app): …); a transcript without such messages is unchanged, and what is eligible for memory is unchanged.
  • The account, conversations and table-review downloads keep origin and origin_label and no longer carry the connection's id (conversations and messages).
  • docs/mcp-server.md describes the rule.

Why

A person who continues, on the web, a conversation an app wrote into should be able to see which messages came from the app, and the assistant should be told too. The mark is information: it changes no permission and asks for no confirmation, and a person asking through their own app is not told "data only".

Testing

Backend: new tests for the fence and its neutralization, the exact model input (including text that holds the line and fence tags), the unchanged input of an ordinary conversation, storing the mark for new and existing conversations in chat, matter chat and review threads, web requests unable to set it, the failing read, histories that differ from the stored rows, and the reads that serve clients. Frontend: component, mapper and review-thread tests; coverage gate at 100 % lines, functions and statements. Typechecks (backend, tests, contracts, frontend, word-add-in) and the source-reading tests pass. The whole backend suite and the migration on a database run in CI.

Also: the curator transcript with and without app-written messages and the select per table; the three downloads without the connection's id; the table-review turn handing the mark to the stored row. Each new assertion was checked against a change that breaks it.

Deploy notes

One migration that adds nullable columns, check constraints and a foreign key to two small tables (brief lock, one scan to validate). The previous backend keeps working on the migrated database. Messages written before the migration are not marked. The system prompt of every conversation gains one paragraph (how to read a message sent through an app), so each conversation's cached prompt is rebuilt once after the deploy. Going back to the previous backend after apps have written messages is not advised: its conversation read returns whole rows, the connection's id included.

…erson and for the assistant

Every message a connected app writes into a conversation (assistant, matter
or table-review thread; new or existing) is stored with a mark of its own.
The person sees one line of plain text under it; the assistant reads it after
one fixed line and inside a fence of its own, as the person's request sent
through an app, subject to system rules. Which history messages carry the
mark is decided by the stored text. One migration that adds nullable columns
to the two message tables.
Both migrations of 2026-11-28 are listed in the schema ledger, in filename order.
…written messages with a list

The three route suites answered every read with one object. The read of
the messages a connected app wrote expects rows, as the database returns,
and a turn fails when it cannot be read.
…ext colour

The same grey as the other secondary text, so it reads on a light background.
…rk of an app-written message

The curator's transcript says when a person's message was sent through a
connected app; nothing else in it changes. The account, conversations and
table-review downloads keep a message's origin and the app's name and do not
carry the connection's id. One test pins that a table-review turn hands the
mark down to the stored message.
@IvanJS17
IvanJS17 merged commit 862f561 into main Nov 28, 2026
14 checks passed
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.

2 participants