From Daniel (2026-10-14):
- Assume several people and agents work in one session, and that needs management.
- What agents and people output should render in rich mode.
- Several agents and people work on the same graph. He doesn’t know the requirements exactly, nor how far that is Moonkale’s concern as the frontend versus the database’s.
- Annotating things with comments would be nice.
Builds on ADR-0025 Sessions are the outermost state, Collaboration (presence today, CRDT editing later), Annotations (comments, designed), Agent Sessions and Profiles (now conversations) and the Security rules.
What agents may show in the UI, what working on the graph adds, the share buttons and private terminal input are in Agents in the UI and on the Graph (2026-10-29).
1. Participants: people and agents in a session
SW-nn.
- SW-01 Participants with roles. A session lists who takes part:
- people, as owner, editor, commenter or viewer;
- agents, each a saved agent (model and profile) with a sponsor: the person on whose behalf it acts, and whose permissions it can never exceed.
- SW-02 Identity needs accounts. A shared session needs to know who is who, which a single server token can’t say. Accounts and roles on the server (Remote and Server Modes, not built) come first. On one desktop with one person, every participant but the agents is that person.
- SW-03 Presence includes agents. Who is here, what they have open, where their cursor is (it exists for people), extended to agents: what an agent is reading or editing now, shown like a person’s cursor, with its sponsor’s colour.
- SW-04 Tasks for agents. An agent gets a task inside the session, scoped (these sources, this subgraph, read-only or with proposals). Tasks queue visibly with their state (waiting, working, needs approval, done), and a person can pause, redirect or stop one.
- SW-05 Approvals have an inbox. An agent’s writes wait for approval (the policy gate). With several agents, they collect in one place per session: what each wants to change, as a reviewable proposal (SW-23), approved or rejected whole or in part, by anyone whose role allows it.
- SW-06 Every change is attributed: who did it, and for an agent also on whose behalf and under which task. The entity log already records who, when and what; it gains the agent-and-sponsor pair.
- SW-07 An activity feed per session: what happened while you were away (edits, approvals, finished tasks, new comments), each linking to its place.
- SW-08 Budgets per agent: tokens, time, number of writes, sources it may touch. Over budget, it stops and asks.
2. Output that renders as rich text
Built (2026-10-14): conversation messages, from people and agents alike, render as Markdown (editors/agent/src/markdown.rs): headings, lists, tables, code blocks, emphasis, task lists, links. It is safe by construction:
- raw HTML is shown as text;
- links keep their target only for http(s), mailto and relative paths;
- images are never loaded, because a remote image URL can carry data out (prompt injection, Security), so they show as links the user can open;
- math is kept as styled source.
Next (SW-11 to SW-15):
- SW-11 math through the shared renderer (Math Delimiters and Renderers);
- SW-12 wiki-links in messages open their node;
- SW-13 code blocks highlighted with the code view’s grammars;
- SW-14 a proposed change renders as a diff;
- SW-15 the same renderer for comments (§4), run outputs and task summaries, so everything people and agents write reads alike.
WP-49 first slice (validated 2026-10-30)
SW-05/SW-14/SW-20/SW-21/SW-23 now have a local-agent text slice.
graph.fetch returns an opaque decimal version string. editor.propose takes
1–64 existing files with those versions and their proposed text; editor.replace
is the single-file compatibility path and also requires the read version.
Submission never edits a buffer, including in sessions that allow other writes.
The session’s Proposals inbox holds all conversations’ requests, original/proposed
text and file checkboxes. Approve/reject operates on the selected subset.
File creation remains one absence-checked proposal; shell/extension calls retain
the existing explicit policy reviews in the same inbox.
Selected file-backed buffers apply together through the existing coordinated
multi-document proposal/history API. Files persist in order with a per-file
report because a filesystem offers no cross-file transaction. Sources advertising
atomic_text apply a source’s text changes in one checked transaction. Existing,
normal Sophia store-truth folders preview with propose_files and apply with
replace_files_checked; generated filesystem text is never written. No migration
is implied by opening a folder. Unreadable/missing/derived authoritative stores
keep the read-only fallback; the cache writer remains disabled.
A stale source version or editor lease found in preflight refuses the selected buffer batch before mutation and opens the shared WP-51 three-way editor. Late conflicts at source commit or view preparation open that same review immediately. Ordered-save conflicts retain earlier results, mark successful files finished and review only the failed file. Missing view acknowledgements retain the approved unsaved buffers and report that persistence was unavailable. Busy reviews reject late selection, rejection and dismissal events. Choosing a side or editing its result reopens the proposal for a second approval against a newly captured version. The proposing agent and submission time are shown; current authors and modification times are explicitly unavailable until sources provide them.
Validation: eight proposal-model and four Sophia adapter tests, all AGENTS gates, 64 browser matrix runs (including ten consecutive 6× CPU-throttled Git journeys), and three final affected-suite regressions pass. The final proposal screenshot was inspected. Authoritative writes refuse syntax or normalization failures rather than losing unparsed definitions; derived views refresh after successful store writes.
The inbox is bounded, in-memory, per outer session and shared across its local conversations. Account roles, durable multi-agent tasks/inbox synchronization, property/structural writes remain later adapters. WP-14 extends this inbox with typed SQL row batches (below).
3. Many people and agents on one graph: the database’s job and Moonkale’s
The short answer to “how far is it Moonkale’s concern”: the database guarantees that each write is correct; Moonkale makes sure people see each other, see conflicts, and can review what agents do. For sources with no database behind them (files, flow documents), Moonkale supplies the guarantees itself.
| Concern | The database (when there is one) | Moonkale |
|---|---|---|
| A write is all or nothing | transactions | groups a proposal’s edits into one transaction; for files, writes atomically (temp file and rename, the jail) |
| Two writers don’t corrupt each other | isolation (locks, MVCC) | — |
| Rules hold (types, keys, cardinality, shapes) | constraints, triggers, SHACL (oxilite), predicate schemas (tiramemsu) | shows the refusal at the place it applies |
| Someone changed it since I read it | row versions, or conflict errors | optimistic writes: every write names the version it read (SW-20); a mismatch is shown, never silently overwritten |
| History of every change | only some keep one (tiramemsu never forgets; oxilite has versioning; Postgres doesn’t) | the entity log for every source, with attribution (SW-06) |
| Who is working on what, right now | — | presence, soft claims (SW-22) |
| Seeing a conflict and choosing | — | a conflict view: both sides, who and when, keep one, merge, or reopen (SW-21) |
| Reviewing an agent’s changes before they land | — | proposals (SW-23) |
| Undo my change, not yours | — | per-actor undo through the entity log or CRDT (SW-24) |
| Working on a copy, merging later | branching where the store has it (git for files, some databases) | scenario copies (LT-14) and proposals where it doesn’t |
| Text and flow documents edited at once | — | a CRDT per document (Collaboration, Phase 4–5) |
Requirements:
- SW-20 Optimistic writes. Every write through the
Sourcewrite API (text and typed SQL row writes built) carries the version it was based on. The source refuses a stale one, and Moonkale shows why. Last-writer-wins is never silent. - SW-21 A conflict view with both sides, their authors and times, and the choices. It is the same view for a cell, a node’s property, a flow block’s parameter and a file.
- SW-22 Soft claims, not locks. “Daniel is editing this subgraph” or “agent X works on these files” is shown to everyone, and others are warned before editing there, never blocked. Hard locks are left to the database when it has them.
- SW-23 Proposals (changesets): a set of edits across sources, made by an agent (always) or a person (optionally), reviewed as a whole with a diff per source, commented on (§4), and applied atomically where the source can (one transaction), or in order with a report where it can’t. An agent’s work is a proposal by default.
- SW-24 Per-actor undo: undo the last change I made, even after others changed things elsewhere, through the entity log (structure) or the CRDT (text).
- SW-25 Remote changes arrive live:
changes_sincealready exists for folders; it extends to every source that can report changes, so a session never works on a stale picture without saying so.
4. Comments on anything
Annotations already designs comments: anchored to a node and an optional range, in threads, resolvable, labelled, imported from GitHub issues, and stored as nodes in the graph. What this request adds:
-
SW-30 Anchors everywhere people work: text ranges, graph nodes and edges, flow blocks, table cells and rows, plot points, a proposal’s hunk, a run’s step.
-
SW-31 Comments render rich, with the renderer of §2.
-
SW-32 Mentions:
@personnotifies, and@agentasks that agent to act on the thread, as a task (SW-04) scoped to the anchor, under the gate, answering in the thread. It’s the same pattern as replying to a review comment. -
SW-33 Comments drive review: a proposal is approved with its comments resolved, or sent back with them.
-
SW-34 Where comments live (decided by Daniel, 2026-10-14: both, by setting). Comments always live in the state store of the source’s host, the database, at least as their working home. Two settings decide the rest:
comments.permanent(default off): while off, the database holds comments as an intermediary. Open threads stay; a resolved thread is removed after a retention period (default 30 days) unless it has been exported. Turned on, the database keeps every comment for good, as it keeps the entity log.comments.git(default off):off;on-demand(Export comments and Import comments commands write and read.moonkale/comments.jsonlin the folder, one thread per line, merged by id, so they travel through git); orsync(the file is written on every change and read after a pull, so the repository carries them).
The settings are per source in the session, with a user default. Comments on database and graph sources live in the store only (there is no repository to export into), and the export command offers a file anywhere.
5. Tools act on the graph too: compilers, parsers, checkers
Daniel (2026-10-14): compilers and parsers also act on the graph, beside agents and people. They do, more than either:
- the index’s parsers create nodes and edges for every symbol;
- language servers attach diagnostics and types;
- reasoners infer triples (KG-15);
- type systems and provers attach proofs (North Star §7);
- compilers lower a definition into IR and machine code (§3 there);
- formatters and code actions rewrite text;
- codegen writes files (the flow libraries);
- Lenticulum runs write beliefs (LT-10).
So tools are a third kind of actor, with rules of their own:
- SW-40 Tools are actors, with identity: a tool’s output names the tool, its version and its configuration, and the versions of the inputs it read (content hashes). This is the provenance a proof annotation needs anyway.
- SW-41 Derived data is marked as derived: a parser’s symbol, a reasoner’s inference and a compiler’s IR are derived, never mixed with what a person or an agent authored. They show as such, can be hidden as a layer, and are never edited in place. You edit the input, and the tool reruns.
- SW-42 Derived data goes stale, visibly: when an input changes, what was derived from it is marked stale until the tool reruns, never silently kept as current. That is the incremental index of WP-21 (a one-file change touches only its facts), generalised to every tool.
- SW-43 Tools that write go through the same doors as people: a formatter, a code action, codegen or a migration that changes authored content is attributed (SW-06), undoable (SW-24), and, when not run by the person themselves, a proposal (SW-23). “Format on save” is the person’s own action; a codegen run an agent triggers is the agent’s proposal.
- SW-44 Derived data never conflicts with authored data: it is recomputed, not merged. Two tools deriving the same fact differently (two type checkers, two reasoners) is a disagreement, shown side by side like tiramemsu’s conflict review (KG-31), not a write conflict.
- SW-45 Humans first: tool runs yield to interactive work. They are scheduled with priorities, cancellable, and budgeted, so a recompile never blocks the frame that shows a keystroke (CED-R22).
Order (proposal)
- Comments (WP-50): the Annotations steps with SW-30, SW-31 and SW-34; useful alone, even single-user.
- Proposals and optimistic writes (WP-49): SW-20, 21 and 23, together with writes to database sources (R-41); they make agents’ work reviewable.
- Participants, roles and agent tasks (WP-48): SW-01 to 08. It needs accounts on the server first.
Per-actor undo and claims come with the CRDT phase of Collaboration.
SQL rows (WP-14, 2026-10-30)
SW-20 applies to rows as well as text. source.read_rows returns source-checked
keys, typed values and opaque row versions. editor.propose accepts optional
rows: [{source, batch: {ops: [...]}}] alongside files. Each operation names
its table, key, expected version and typed update/insert/delete. Inserts assert
absence. Submission never writes authored data, including trusted sessions.
The same session inbox shows table diffs and file diffs, with per-source row batch selection. It preflights every selected database before applying buffers; source commit rechecks all versions in the transaction. SQL batches are atomic within one database. Different databases and filesystem files persist in order, with earlier successes retained and reported after a later refusal. There is no claim of a transaction spanning unrelated sources. A stale row has a comparison of its read, proposed and current values; choosing mine prepares a new review, and choosing current discards that operation. Reopen reads current values again. Direct person edits use the same typed write API, and undo is a checked write.
SQLite and Turso accept usable primary keys or an unshadowed rowid; DuckDB requires a primary key. Views, generated columns, unusable identity, read-only sources/attachments and lossy value projections refuse. SQL text remains read-only. Source-provided current author/time metadata, accounts and durable multi-agent inboxes remain later work.
WP-14 validation: four SQL engine/identity tests (shared multi-case acceptance for each engine), eleven proposal-model tests, all AGENTS gates and the complete 59-suite smoke/structural/Sophia/default-graph browser set pass. The mixed review and both cell conflict screenshots were inspected. Existing-file persistence still reports ordered results across independent sources; no cross-source atomic commit is claimed.