From 7c945890f4d5a583e6ab9578a0812ce56bffd491 Mon Sep 17 00:00:00 2001 From: iz0eyj Date: Wed, 25 Nov 2026 22:01:19 +0100 Subject: [PATCH] docs: document Markdown/LaTeX rendering, context compositor and [SPEAKER] provenance --- README.md | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1c2432f..aa2c5ae 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,16 @@ offline, same-origin so no CORS). It is a thin client over a **session-aware API - `PATCH /api/sessions/{id}` — rename (only before the first interaction) and/or replace the session's own settings instance. +**Rendering.** Assistant replies are rendered server-side from Markdown to +sanitized HTML (`src/render.rs`, `pulldown-cmark` + `pulldown-latex`): headings, +lists, tables, code, links and **LaTeX math** (`$…$` inline, `$$…$$` block) +compiled to native **MathML** — no client-side math library, no Node. Raw HTML in +model output is escaped and link/image URLs are scheme-filtered +(`http`/`https`/`mailto`/relative), so a reply can never inject script. The +rendered HTML travels as `content_html` beside the raw text in `GET …/messages` +and in the agent `final` event; the GUI injects it via `innerHTML` **only for +assistant bubbles**, while user text stays plain `textContent`. + **Settings & identity.** Each session owns a *settings instance* (system prompt, notes, sampling) snapshotted from the global defaults at creation (**copy-on-create**): editing a session affects only it, editing the defaults @@ -121,6 +131,19 @@ structural identity reminder ("your name is …, your personal folder is …") i prepended to the model's context — not an editable setting. The GUI exposes all of this in a ⚙️ settings panel (per-session or general). +**Context composition.** A dedicated **context compositor** (`src/context.rs`) +assembles the model prompt from named sections delimited by `…`, +each closed by its tag plus a blank line so boundaries are explicit. The static +sections — `SYSTEM_PROMPT` (identity + speaker convention + the session's system +prompt) and `TOOL_USE` (a compact tool manual) — live in the SQLite +`context_sections` table: seeded, editable without recompiling, and extensible by +adding a row. The interactive `DIALOG` region wraps the real role messages +(history + new turn) so the engine keeps its turn structure. Every turn carries a +prompt-only `[SPEAKER: name - YYYY-MM-DD HH:MM]` provenance stamp in the server's +local time — framework metadata for the model, **never shown in the browser**: any +tag the model echoes back is stripped from stored/displayed content and from +history before re-tagging, breaking the duplication loop. + **Uploads.** The 📎 button attaches files and images. Bytes land in a single **shared** store (`~/.strata-ctl/uploads/`, filename converted to a uuid keeping the extension); nothing is bulk-injected into context. Content is classified by @@ -195,6 +218,11 @@ shared JSON config ──► InklingFormatter ──► Engine supervisor ── embedded web assets. - `store` — the persistent session/context store: a `Store` trait with a bundled SQLite implementation (WAL), used by the GUI API. +- `context` — the context compositor: builds the model prompt from named SQLite + sections (`SYSTEM_PROMPT`, `TOOL_USE`) plus the `DIALOG` region, applying + per-turn `[SPEAKER]` provenance (prompt-only). +- `render` — server-side Markdown → sanitized HTML with LaTeX → native MathML + (`pulldown-cmark` + `pulldown-latex`) for assistant replies. ## Building and running @@ -242,11 +270,14 @@ later adaptation round. ## Status -Working and tested (124 tests, plus 2 real-file tests run on demand). Text, images, +Working and tested (140 tests, plus 3 real-file tests run on demand). Text, images, the full client-side tool loop, the Anthropic endpoint, the web GUI (session -context, streaming, stats, **file/image upload**) and **agent mode** (the model -using `shell_exec` on the host) have been validated live against the real Inkling -engine. +context, streaming, stats, **file/image upload**, assistant **Markdown/LaTeX +rendering** with native MathML) and **agent mode** (the model using `shell_exec` +on the host) have been validated live against the real Inkling engine. The +**context compositor** (named sections stored in SQLite — `SYSTEM_PROMPT` / +`TOOL_USE` / `DIALOG`) and prompt-only **[SPEAKER] provenance** are in place, +verified against the real chat template. Not yet implemented (honest gaps): forced `tool_choice` (`required` / named function returns a clear 400), multi-slot batching, logprobs / structured output, automatic