magi-cli 0.274.0

Blind multi-agent implementation competition: N agents implement, M judges rank blind, deliberate, vote privately, winner survives double review + E2E gate
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# Chat

Conventions for this area of magi. `AGENTS.md` indexes these files: read this
one before changing the code it covers.

## Chat personas are a tone, never a behaviour

`src/persona.rs` holds the built-ins (`default`, `magi`, `rei`, `misato`,
`ritsuko`, `shinji`, `asuka`, `kaworu`); the web Chat picks one per
conversation (`Talk::persona`, `POST /api/talks/{id}/persona`, `#talk-persona`
beside the agent select). `default` is empty, is the initial choice, and the
briefing is byte-for-byte unchanged for it.

- **Tone only.** `talk::briefing_with` appends a `# Persona (tone only)`
  section that says facts, commands, task ids, duplicate-warning handling, the
  write policy and "tell the operator the task id" stay exact. A persona is never
  copied into the `<instruction>` given to `magi task add`: implementers stay
  neutral. Nothing but the prompt enforces this.
- **Config lives in `[talk]`**: `[[talk.personas]]` with `id`, `name`, `prompt`.
  Entries add to the built-ins; a built-in's id overrides it in place; `default`
  cannot be redefined. `Config::load_layers` validates (non-blank, unique) and,
  as for any array outside `array_merge_policy`'s append list, two layers
  declaring it is refused.
- **The persona is independent of the agent.** Switching it keeps the CLI seat:
  `Talk::persona_dirty` makes the next turn prefix a `# Persona update` block
  (a plain-voice notice when going back to `default`), and is cleared only after
  a turn succeeds. A fresh seat's briefing already carries the persona. A stored
  id the config no longer has is treated as `default` with a warning.
- **The avatar is display only.** `src/persona_icon.rs` embeds an original
  built-in SVG per built-in persona (`assets/ui/avatars/`, a coloured circle and
  an initial or silhouette - never character artwork) plus a generic one for
  configured ids. `[[talk.personas]] icon` (optional, may override a built-in;
  on `default` it is the only field allowed, so the briefing for `default` stays
  byte-for-byte unchanged) is a `data:image/(png|jpeg|gif|webp);base64,` URI or
  an absolute / `~/` path to a `.png/.jpg/.jpeg/.gif/.webp`, at most 256 KiB
  (the string, the decoded data, the file). A built-in id may omit `name` and
  `prompt` and keeps the built-in's. Icon shape, existence and content are
  checked at serve time; invalid icons (including blank, relative path, `..`,
  other extension, other data type or oversize) fall back to the built-in
  without invalidating the config or interrupting conversation operations.
- **One serving path.** The client only ever gets server-built URLs
  (`TalkView::persona_avatar`, `PersonaEntry::avatar`, `&v=` is a fingerprint of
  the setting); the `icon` string never leaves the server.
  `GET /api/talks/{id}/avatar?persona=<id>` (`web::talk_avatar`) loads the icon
  (regular file, size-capped read, strict base64), requires the bytes' magic
  number to match the declared type (`sniffed_mime`), and answers with
  `attachment_response` (`nosniff`). Anything else - missing, oversize, spoofed,
  unreadable config, unknown persona, `builtin=1` (the page's one retry after a
  load error) - is a `tracing::warn` and the built-in SVG (CSP
  `default-src 'none'; sandbox`, `nosniff`), never an error. Custom SVG is never
  served.
- **Absolute paths are exposed to whoever can reach the deck** (the tailnet; there
  is no authentication) as the image they name, nothing more. Relative paths are
  refused because the repository layer is read from `<remote>/<base>` and
  extracted elsewhere, so they would point at nothing.
- **Invariant:** `persona::section_base` / `section_for` / `update_block*` never
  read `Persona::icon`; `an_icon_never_reaches_the_briefing` pins it.
- Both new `Talk` fields are `#[serde(default)]`; `talk::SCHEMA` is unchanged.

## Chat defaults are remembered by the browser and checked by the server

The web Chat remembers the last Agent / Persona / Implementers the operator
chose and starts the *next new* conversation with them. Existing conversations
keep their own stored values.

- **Storage is `localStorage["magi-talk-defaults"]`** (JSON `{agent, persona,
  implementers}`), like the theme and split width. Chosen over a machine-layer
  or state-file setting because it needs no new server state; consequence
  accepted: it does not follow the operator across devices.
- **Written only after a manual switch succeeded** (`switchTalkAgent` /
  `Persona` / `Implementers`), one field at a time, from the TalkView the
  server returned, even if the operator navigated away before the response.
  Only the on-screen conversation update is guarded by its id.
  Never from `renderTalk` / `loadTalk` / `startTalk`: opening an
  old conversation would overwrite the operator's last choice with its values.
  A chatter-chain fallback that rewrites `talk.agent` is not a choice.
- **Applied only at creation**: `startTalk` sends `preferred_agent`, `persona`,
  `implementers` in `POST /api/talks`. `talk::begin_with` (`begin` is the
  all-`None` wrapper) checks each against the repo's current config and drops
  an unfit one on its own, never a 400: unrunnable / unknown agent -> chatter
  chain head; unknown persona -> default; implementers outside 1..=3 or refused
  by `check_implementers` -> 1. Wrong JSON types are dropped the same way.
- **`preferred_agent` is not `agent`.** `agent` is strict (an unknown id is an
  error); `preferred_agent` is soft, and `agent` wins when both are sent. A
  preferred agent other than the chain head is an explicit choice
  (`fallback = false`); the head itself keeps `fallback = true`. A valid
  preferred agent also works when the chatter chain cannot resolve; in that
  case it is an explicit choice with `fallback = false`.
- Persona and implementers are set before the single save and the dirty flags
  stay false: the new seat's briefing already carries them.

## Chat list status is derived, display-only triage

`src/chat_status.rs` gives every `TalkListView` row a `chat_status`
(`kind`, short `reason`, `owner_count`, optional `link`). `Inventory::collect`
reads the evidence once: native inquiries with a live `Decision`
(`AwaitingOwner` = owner; `Queued` / `InProgress` / `RetryNeeded` = waiting /
working-if-the-task-runs / attention; `Resolved` and archived never count),
still-open legacy `land-approval` questions not mirrored by a native
`question:<id>` inquiry, and task state through `Task::chat`, then
`filed_by_chat`, then `origin_chat`. A decision whose `repo` no longer matches
its task (a superseded assignment) is skipped; items are counted by id, so
several tasks or decisions aggregate once each. `derive` is pure, precedence:
needs owner, attention, working, waiting, unknown (unattributable unreadable
inquiry), closed, completed, idle. A goal contributes only through its saved
state (`Owner` = owner, `Paused` = attention, `Runnable` = waiting); a bare or
`Waiting` goal and a `Done` task alone are never activity or approval.

- **Cheap.** The inventory is cached in `SharedMonitor::chat_inventory` keyed by
  the monitor's queue, question, decision and loop revisions; per-row work is a
  map lookup. No forge call, agent call or transcript read. The parsed row cache
  keeps only the goal counts.
- **Refresh.** `app.js` reloads the Chat list whenever queue, question or
  notification revisions move, not only `talks_rev`.
- **Needs owner filter.** `page_ids` lists a chat owing a decision with the open
  ones even when closed, so the client filter over loaded rows never depends on
  walking closed history for decisions. Closed goal headers are bounded reads;
  older layouts with goals after turns are classified when their row is loaded.
  Selecting Needs owner automatically enumerates history through the existing
  paginated row endpoint, not through transcript requests or a cold header scan.
  The ordinary unfiltered initial list remains bounded.
- **Display only.** Nothing here approves, resolves or controls anything; the
  link is a plain route (`#/decisions`, `#/tasks/<id>`), a sibling of the card.

## Chat implementer count changes a command, not a tone

`Talk::implementers` (1..=3, `#[serde(default)]` to 1 = Solo, `talk::SCHEMA`
unchanged) only changes which filing command the briefing teaches:
`--solo` for 1, `--implementers N` (never with `--solo`) otherwise, built in
`talk::briefing_for` at all three places the briefing names it. It follows the
persona's dirty-flag style (`implementers_dirty`, a `# Task filing update`
prefix, cleared only after a successful turn); a turn with no resumable session
re-sends the policy whenever it is not Solo. Enforcement is the prompt only;
`POST /api/talks/{id}/implementers` validates 1..=3 and the *conversation's*
repo config (`talk::check_implementers`), so `--repo` pointing elsewhere is
checked only when the task runs.

`src/main.rs::resolve_repo` also resolves chat filing's short `--repo` names.
`[repos] auto_clone` defaults to false; when enabled, only a validated explicit
`owner/repo` with no local match is confirmed by `gh` and cloned into the first
root's GitHub layout, using literal `clone_command` argv (default: `gh repo clone`).
Local ambiguity still fails, bare names and stats never clone, and repository
config continues to come from the remote base commit.

## Attention reports use the task-decision chat transport

`src/notices.rs` is a durable outbox for facts, never an owner decision.
`notice_delivery::sweep` runs after task decision and completion reconciliation,
before `chat_notify::start_turns` / `consult::drain_turns`. Producers record through
`notices::raise` / `raise_in` / `raise_with`; explicit release-bump stores use
`Notices::raise_with` for the same page decision, never an independent webhook.

- Reuse `task_chat::destination`: reserve `Task::chat` under the task lock,
  release it before any talk operation, prefer the existing chat, reopen closed
  chats. Creation uses the chatter chain, default persona and Solo.
- A run with no queue task uses `notice-run-<full-run-id>`. True global reports
  use `notice-operations`, one persistent conversation per home. Its first
  creation saves the daemon repo context; `begin_with_id` serializes creation.
- Keys are kind + subject, never prose. `Notice::raise_again` alone decides
  repeat paging for both chat delivery generations and `[notify]`: newer cause
  or severity rise, never wording changes. Stamp cause starts with `since`
  (task held_at, run pass started_at), rather than poll time. For legacy records
  without `since`, a cause starting after the saved `last_at` is new.
- The talk saves `notice:<stable-id>:<delivery-id>:<generation>` with its automatic
  draft, then the outbox saves the receipt. The persisted delivery id distinguishes
  recurrences after history pruning; legacy records retain their old receipt key.
  Retries cannot spend a second turn. Queue
  all drafts before starting talks so reports per conversation coalesce.
  Unsent owner drafts are never started by a report.
- Recheck current task/run state before delivery. Released holds, replaced runs
  and runs positively observed to have moved on are read without delivery.
  Read errors defer; a terminal run alone never clears a release-bump failure.
  Covers/covered_by retain kind and cause-time matching, including questions
  retired after task-chat delivery only when the notice already records that
  question in covered_by, and posted task completion receipts. A delivered
  question alone cannot cover a later unrelated failure in the same run pass.
  Release-watch supplies a separate cause identity (phase plus head/check or
  release progress); material state transitions advance delivery without using
  message prose as a key.
- Legacy unread history follows the same checks. Read/dismissed history never
  replays. Pending unread deliveries are exempt from the 200-record history cap.
- Automatic reports use a fixed English heading, scrubbed/defused/clipped facts,
  full task/run IDs, state and PR. The briefing permits investigation and summary;
  only an owner's request authorizes supported `magi task control` actions.
- The bell/list remains as a compatibility view for deferred/unavailable
  destinations and legacy records. Do not retire it while these remain visible.
  `notifications_rev` is unchanged in the events tuple, HealthView and app.js
  applyRevisions_/initial load; keep all three aligned if removing the UI later.

## Telling the chat how a task it filed ended

`src/chat_notify.rs`. A chat is single-turn: it speaks only when the owner
writes, so "I will tell you when it finishes" cannot be kept by the agent.
magi keeps it. When a task the chat filed itself (`Task::filed_by_chat`:
`Source::Agent` with `queue::CHAT_NODE`, `run` = the talk id; an inherited
`origin_chat` on a follow-up does **not** count) is `Done`, `Held` or
`Blocked`, a fixed English notice (`prompt::chat_task_notice`, heading
`CHAT_TASK_NOTICE_HEADING`) is queued as a draft of that talk and the talk's
own turn machinery runs it. No new seat, no new waiter, never a fresh agent.

- **A reconciler, not a hook.** `chat_notify::sweep` runs on every
  `daemon::poll` tick beside `resolve_blockers`, so `magi task done`, the web
  Hold button, `hold_machine` and a restart are all covered the same way.
  `Failed` is the loop's retry state and `Queued` / `Running` / `Parked` are
  intermediate: none notifies. The last failed attempt becomes `Held`, which does.
- **Once.** `Task::chat_notice` (`queue::SCHEMA` 13, `#[serde(default)]`)
  records the key of the last state reported or skipped
  (`Task::chat_notice_key`: held by `held_at`, blocked by what it waits on,
  done once per task, including legacy `done#N` records). A release or requeue
  does not clear it; a new hold or block cause has a new key.
  `Queue::put_unlocked` never rewinds a newer record. Records below schema 13
  are not notified, so an upgrade does not replay history.
- **Two writes, one idempotent.** Lock order is task, then talk: `sweep` runs
  inside `Queue::modify`, calls `talk::queue_once_matching`, which saves the
  draft and the key in `Talk::notified` in one write, then the task record is
  saved. A
  crash between them is repaired by the next sweep (the key is found, nothing
  is queued twice). `Talk::notified` is never pruned by a drain or a close,
  and recognizes the same task's legacy completion keys even after an
  intervening hold notice.
- **Closed or deleted is skipped** (`ChatNoticeOutcome::Skipped`, recorded so
  it is not retried), never reopened - unlike `consult::begin`. A transient I/O
  error records nothing and the next tick retries.
- **Starting the turn.** `chat_notify::start_turns` reserves a detached Chat
  worker for notification-only pending input. The worker takes the talk's
  cross-process turn lease and retains its existing seat/session. An operator's
  unsent or recovered draft is never started by an automatic notice.
- **Scheduler replacement cancels nothing.** Already-reserved Chat jobs continue;
  later service ticks use the replacement generation. Explicit parking still
  suppresses new automatic starts.
- **The notice is not the owner's word.** It is automatic data: the chat
  briefing tells the agent never to treat it as an owner request.
- **`magi talk post <talk-id> <message>`** appends an agent turn
  (`Turn::posted_by` = the posting run) without a draft, a lease or a turn.
  `chat_notify::authorize_post`: `MAGI_RUN` and `MAGI_NODE` must both be set,
  the node may not be `chat`, and the run must belong to a task whose own
  source is that talk. It writes under `Talks::guard` onto the freshest
  record; `talk::turn`'s tail keeps posts that landed while the CLI ran, and
  the next resumed turn carries them as a `# Posted by a task` block. A codex
  implementer runs unsandboxed (see "codex is the only seat whose read-only
  mode is enforced"), so it reaches the talks store like a claude seat does.
- **Known noise.** A `Blocked` task is reported again whenever its blockers or
  reason change (conductor block, unblock, block again).
- The briefing (`talk::briefing_for`) tells the chat it cannot wait or push and
  that filed tasks and registered watches report back; `Talk::notified` and
  `Turn::posted_by` are `#[serde(default)]`, `talk::SCHEMA` is unchanged.

## The chat controls tasks and runs directly

`src/chat_control.rs`, `magi task control resume|recover-base|hold|release|retry|rerun-checks|decide|abandon`.
`recover-base` alone bridges an explicit standing-chat exhaustion recovery to
`Runner::authorize_base_recovery_request`; `src/base_recovery_control.rs` owns
request receipts and the exact-run queue marker. Keep its owner/execution locks
through authorization and queue publication. Ordinary resume never grants a new
base interval. Persisted decision actions carry the exact stop and episode and
must agree with the eligible and routed task owner.
It adds who-may-ask and what-about, nothing else: every effect reuses an
existing transition (`resume::pin_queued`, extracted from the daemon's
`ResumeRun` branch; `Task::hold_manual`; `Task::release_operator`;
`Task::edit`; `daemon::rerun_checks_once`, extracted from `RerunChecks`;
`driver::abandon_proven_dead`). Do not reimplement them here.

- **Authorization.** `MAGI_NODE=chat` and `MAGI_RUN` equal to an open talk id
  (`chat_watch::authorize`). Targets resolve normally: any task id, not only
  the tasks this chat filed, since the owner may direct any work from a chat.
  Execution commands need a full run id. An open consultation does not block
  these commands.
- **Resume queues, never starts.** It pins the task (`OperatorResume`, no question) and the loop resumes under the execution lease.
  Question なしの再送では同じ run の既存 pin を維持し、履歴を増やさない。
  `resume_override.question_id` は空文字列とし、架空の Question ID を記録しない。
  Only the task's latest run can be resumed.
- **Retry** is `Task::edit` plus `release_operator("chat")` in one save; the
  accounting is `release`'s (attempts restart, runs/passes/resumption history
  stay). Only queued or held tasks, as `edit` allows.
- **Rerun** は `--request <id> --head <sha> --workflow <id>` を受け取り、
  `chat-controls/<talk>/<request>.json` に受付を記録する。ledger の識別子は
  `chat:<talk>:<request>`。同一 ID の別操作への使い回しと結果不明時の再送を拒否し、
  共通遷移で head・workflow の一致を再確認する。
- **Abandon** needs only the owner's request (no phrase): the shared Dead-only
  judge (`driver::abandon_proven_dead`) runs under the owner lock, and a Live
  or Unknown driver is refused.
- **Transport.** 通常のチャットは既存の sandbox・network・cwd を維持し、
  queue / questions / choice-actions / run / transcript への書き込み権限を追加しない。
  `chat_control::bridge` が型付き操作だけをランチャーへ渡す。Unix は識別情報を
  検証した継承 FD と capability 認証付き Unix socket、Windows は認証付き named
  pipe を使う。backend 本体への FD 継承だけでは通常ツール子プロセスへ届かない。
  sandbox が socket を拒否する場合は検証済み FD が必要で、権限を追加しない。
  ランチャーは起動時の talk と home を固定し、要求ごとに open と既存遷移の条件を
  検証する。任意コマンド、パス、別の talk は要求できない。merge 承認は `decide`
  で回答として記録し、既存の land 処理が保存済み head に対して実行する。
  FD のフレームは未リンク lock FD の POSIX process lock、両経路の操作全体は
  同じ launcher lock で直列化し、request ID で応答を照合する。socket は認証 ACK
  の後だけ操作を送る。送信後の切断は結果不明で、自動再送・ローカル実行をしない。
  準備失敗は会話を止めないが、再割り当てと base recovery は認証を必須とする。
  完了・中断・fallback は通信路を破棄し、同じ会話の次ターンで新しい能力を渡す。
  detached worker / watcher / setup へは環境変数と検証済み FD を継承させない。
  両経路が使えない場合は launcher/backend の基盤障害として報告する。会話の
  開き直しは修復策ではない。詳細と復旧手順は `docs/seat-write-scope.md` を参照。
  CLI を席の外から実行する場合も、従来どおり chat / open talk の認可が必要。
- **Answers.** A chat seat's `magi answer --reply` / `--reply-other`
  (`MAGI_NODE=chat`) is sent as `Operation::Answer` / `Operation::ReplyOther`
  through the same `chat_control::dispatch` (bridge, or the local route with
  the same Unavailable + `MAGI_ALLOW_WRITE=1` fallback), and the launcher
  records it with the terminal's own `ask::record_answer` /
  `consult::reply_other`, an obsolete approval's run-record dismissal
  included. So a read-only chat answers without any write grant; an open
  question or consultation never widens a turn's access (`talk::turn` takes
  `allow_write` from `[talk] allow_write` alone). Terminal, deputy and other seats write
  directly. `--say` stays direct.
- The Question system is untouched and keeps working in parallel.

## Telling the chat how a command it watched ended

`src/chat_watch.rs` implements `magi talk watch [--timeout <seconds>] --
<executable> <arguments...>`. Only `MAGI_NODE=chat` and an exact `MAGI_RUN`
matching an existing open talk authorize it; there is no destination flag.
Arguments are literal (explicitly invoke `sh -c` for shell syntax), the job
uses the caller's current directory, and neither the supervisor nor its job
inherits `MAGI_RUN` / `MAGI_NODE`.

- **Durable reservations.** Under `<home>/chat-watches/store.lock`, reserve
  one of four global slots before spawning a detached supervisor. The CLI
  prints a watch id after startup acknowledgement. Default timeout is 900
  seconds, maximum 3600; zero is refused. Limits are constants in
  `chat_watch`, not additional configuration. Incomplete staging directories
  are ignored; a published reservation is reconciled, never rerun.
- **Supervision outlives serve.** An OS file lock on the job's `lease.lock`
  lasts for the supervisor's whole lifetime and releases on death, replacing
  heartbeat expiry guesses. PID plus process start time identify the child.
  A launch wrapper cannot execute until its identity is persisted and it is
  armed; a crash in the spawn/save gap leaves only an inert wrapper. Unix
  process groups and Windows kill-on-close job objects contain descendants.
  Timeout and normal exit clean up the group/tree and reap the direct child.
  Pipe reads continually retain at most 8192 combined bytes of stdout/stderr;
  inherited pipes cannot extend the supervisor's wait indefinitely.
- **Loss is a result, never a retry.** When a released lease leaves no result,
  sweeping terminates a child only with corroborated identity (or a gone group
  leader), records an unknown result, and never executes the job again.
  Unavailable process identity retains the reservation rather than risking
  another process. Exit codes, signals, startup failure and timeout are
  distinct reports. Killing a supervisor can lose its in-memory output tail.
- **The existing delivery path.** `daemon::poll` sweeps watches beside task
  notices, then `chat_notify::start_turns` uses `chat_worker::drain_turns` in the
  talk's own session and lease. Atomic result records and
  `talk::queue_once` with `watch:<id>:finished` tolerate a restart between
  saving the draft and marking delivery. Transient I/O failures retry; closed
  or deleted talks are skipped and never reopened by this passive watch path.
  Task decision delivery (`task_chat`) deliberately reopens closed talks. Delivery waits until the
  next serve startup if serve is stopped; the job continues independently.
- **Automatic text stays automatic.** `prompt::chat_watch_notice` creates a
  fixed English report with scrubbed, clipped, defused output quoted as
  untrusted data. `prompt::is_completion_notice` keeps a report from starting
  an owner's unsent draft, and the chat briefing treats it as data, never as an
  owner request. The chat briefing
  forbids promises to report back unless task filing or watch registration
  succeeded. Watches do not grant additional repository write permissions.

## Handing a question to the chat it came from

`src/consult.rs`. A task filed by the standing chat (`Source::Agent` with
`queue::CHAT_NODE`, `run` = the talk id) can raise a question the owner would
rather talk through there. `POST /api/questions/{id}/consult` and `magi answer
<id> --ask-chat` queue the question (id, summary, detail, choices, instructions
from `prompt::chat_consult`) as a draft of that talk; the chat agent answers it
with `magi answer` or puts the decision points to the owner in the chat.

- **One judge.** `consult::origin_talk` is the only place that decides a
  question has a chat to ask (open question, task from a chat, existing
  talk, and never `bump::NOTICE_NODE`). Closed talks can be reopened. Merge
  approvals can be consulted; silence is a hold. The chat records the owner's
  decision with `magi answer <id> --reply <choice>`, merge included; delivery
  itself decides nothing.
  `QuestionView::can_consult_chat` records eligibility. Navigation uses
  `consult::associated_talk` / `associated_talk_with_watches` separately:
  `Question::run_names_task()` distinguishes exact task ids from run ids;
  association also treats `reconcile::NODE` + `reconcile::SEAT` questions
  as task references (review-start divergence is filed under the task id);
  release-watch records naming the question supply typed `run` / `held_task`
  links only when exactly one record matches; ambiguous watch links are ignored.
  Conflicting resolved owners suppress navigation. Follow-up ancestry
  uses `chat_talk_of`. Both web origin paths preload the same links once per
  request, skipping watch-store reads unless a `bump::NOTICE_NODE` question
  with seat `release-watch` is present. `origin_chat` enables "Open chat"
  ("Open chat (closed)" for a closed talk); a physically missing talk has no
  button. These extra links
  never expand consultation eligibility or change `daemon::task_of_question`.
- **Never a choice.** Nothing is added to `Question::choices` and
  `Question::answer` is untouched. The question stays `Open`; `Question::consult`
  (`ask::SCHEMA` 6, `#[serde(default)]`) only records that the chat was asked, so
  a second tap is a no-op. Written through `Questions::update`.
- **The talk-turn gate is cross-process.** `Ui::talk_turns` (in-process, source of the 409 / queued / busy responses) is layered with an on-disk lease, `<talks>/<id>.turn` (`Talks::claim_turn` -> `talk::TurnLease`; not a `*.json`, so `list` ignores it and `revision` skips it). Content `{token, pid, beat_at}`; held means a beat within `talk::TURN_LEASE_TTL` (90 s), no pid checks. Acquire is `create_new`; a stale or unreadable lease is replaced only under a short-lived exclusive `<id>.turn.lock` (aged out after 10 s), so one taker wins. Release / beat only act while the file still carries the guard's own token. The web claim inserts into `live` first, then takes the lease, and undoes the insert if the lease is refused; `is_thinking` is `live` or `Talks::turn_held`. `talk::respond` and `talk::say` take a `&TurnLease` for that talk (checked against the talk's id) and run the turn inside `TurnLease::beating` every `talk::TURN_BEAT` (20 s), no extra task, so a starter without a lease does not compile; `turn` stays private. A crashed turn leaves the talk busy for up to 90 s. `magi answer --ask-chat` (`consult::start_turn`) takes the lease *before* `consult::begin`, then drains the draft and runs the turn synchronously; a lease held elsewhere is reported (`Started::Busy`, non-zero exit) and leaves no consult record or draft. `say` against a lease held by another process answers 409 (`TalkTurnStart::Foreign`) rather than queueing, since no local drain loop would ever answer that draft. Every change to an existing lease (takeover, beat, release) happens under the `.turn.lock`, new leases are published by hard-linking a complete file, and a beat that finds the lease taken over stops the turn. Publication (`publish_exclusive`) is `hard_link` first; only an *unsupported* error falls back to an exclusive `create_new` of the path itself, written through that handle (never a `rename` over it), and `lease_blocks` treats an empty file younger than 10 s as held. Removing a lock is `remove_if_carries` (rename aside, verify, restore exclusively), used by both `TurnLock::take` and its `Drop`; no path-only compare-and-unlink exists, so a fourth party publishing during the microseconds the file is aside can still overlap with the displaced holder until TTL (warned). A guard releases the on-disk lease before the in-process slot.
- **Consultation activity is persisted separately from question resolution.**
  Answered/abandoned questions and questions with `consult_outcome` are no
  longer active consultations. `magi answer --reply-other` saves the owner's
  alternative as a note and ends consultation without changing
  `Question::answer`, Open status, choice actions or waiter. A consultation
  adds no restriction to the chat: the same turn can investigate, answer and
  run `magi task` commands for the owner.

- **No new seat, no new waiter.** The text goes in through `talk::queue`, and
  the talk's own turn gate and session run it. The web route starts the drain
  when the turn slot is free; the CLI takes the lease and runs the turn itself
  (or reports that another process holds it). The question's `answer_timeout` is not extended.

## Operator chat avatar

The operator avatar is display only and has no configuration. Its dedicated
`assets/ui/avatars/operator.svg` is served at `/avatars/operator.svg` with the
same policy as built-in persona SVGs. `TalkView.operator_avatar` carries its
fingerprinted URL for both saved and optimistic turns. It is not a persona and
must not be added to the persona roster or briefing.

## Completion reports refresh evidence before speaking

`chat_notify::sweep` queues the automatic notice together with its structured
`CompletionReference` in the same talk write as the deduplication key. The sweep
stays local and synchronous. `talk::turn` refreshes task/run ownership, the latest
run, open questions and a bounded read-only PR observation before constructing
any fresh, resumed or fallback prompt; it holds no store lock during the lookup.
Saved PR state is historical, and a failed forge lookup never proves an open PR.
Reports distinguish execution, PR creation, approval and merge; post-merge release
actions and incomplete verification stay visible. Automatic events authorize
reporting and read-only investigation, never new tasks or repository edits.

## Automatic chat notification display is separate from agent input

`Message.body` remains the authoritative input for conversation resumption,
including provenance explanations and agent directives. `Message.display` is an
optional notification-time snapshot generated with the same scrubbing and bounds
as that input, saved under the same lock as the draft, completion reference and
deduplication key. Never rebuild it from current task or watch state.
`TalkView` projects display facts for history, queued sends and saved reply quotes;
new reply excerpts use those facts too. Legacy compatibility requires MAGI sender
provenance or an exact `CompletionReference.notice` match and a complete known
template; unknown bodies and operator prose remain literal. Watched output is
untrusted text in an expandable element; links use the existing safe URL renderer.

`TalkView.turn_messages_md` (turn/message indices, including one slot for legacy
turns) and `pending_messages_md` are transient Markdown ASTs for normalized MAGI
sends. Parse `NoticeDisplay.facts`, never completion agent input or watched output.
Other MAGI bodies may use Markdown unless they are an unrecognized completion
template. Operator sends stay literal. Both notification surfaces use the shared
Markdown DOM renderer, with literal fallback when an AST is absent.

Consultations also save `prompt::chat_consult_display` through
`talk::queue_magi_display`: question facts and choices only, without the answer,
merge or posting directives in `chat_consult`. Older MAGI consultations without a
snapshot get a generic display placeholder rather than reconstructing mutable
question state or guessing the boundary within arbitrary question detail.

## Web avatar overrides

The web settings avatar editor stores display-only machine-wide overrides under
`ui.home/avatars`: `operator.data` and `personas/<hex ID chunks>/icon.data`.
Persona IDs are UTF-8 encoded as reversible hex directory components, never
sanitized filenames; overrides apply to that ID across repositories and existing
conversations. The MAGI sender remains separate at `ui.home/magi-icon.data`, even
when a persona has ID `magi`. Do not copy overrides into persona prompts or talk
records. Precedence: uploaded override, explicit built-in reset, then the existing
`[[talk.personas]].icon` resolution and built-in fallback. “Use configuration”
removes the override, while “Reset to built-in” deliberately bypasses configured
images. Settings uploads accept raster data URIs only; configured absolute and
`~/` image paths keep their established behavior. Avatar URLs include override
fingerprints and responses use `no-cache`; refresh conversation views and cached
persona choices after edits. Orphaned saved persona IDs remain editable.

## Automatic chat delivery receipts

Automatic attention (`notice_delivery`), task decisions (`task_chat`) and task
outcomes (`chat_notify`) share `notice_semantics` and
`talk::queue_semantic_notice`. Compare confirmed task/run failure evidence,
execution pass, state, target head and required decision; source IDs, delivery
generations and generic timestamps are not new evidence. Unknown causes retain
their literal evidence. Structured decision context supersedes explanatory
wording, while choices, effects and merge targets remain significant.
A decision covers its underlying failure report; a failure report does not
cover an unpresented decision.

Under `Talks::guard`, reread the talk and persist transport keys, semantic
receipts, pending content and any reopen together. A semantic duplicate still
acknowledges its source and decision routing but neither appends content nor
reopens the chat. Receipts survive drains, closes and restarts and are never
count-pruned. Conductor resumption concerns with no verified new blocker or
state change remain notice history without waking a chat. These receipts never
resolve questions, change holds or authorize work. Owner input and explicitly
requested updates/watches bypass semantic suppression.

## Chat search navigation evidence

`src/web.rs::chat_text_key` and `assets/ui/app.js::chatTextKey` must use the
same fingerprint: FNV-1a with 32-bit wrapping over Unicode scalar values,
formatted as eight lowercase hex digits plus `:` and the scalar count. Search
message URLs carry this fingerprint and the turn timestamp to detect shifted
transcript indices without putting message bodies in browser history. This is
navigation evidence, not an authentication or integrity check. Search leaves
must mirror the UI's message rows (`messages` when present, otherwise the turn).

## Durable chat goals

`chat_goal` retains multiple owner-authorized requests on `Talk`, separate from
conversation openness, task completion and CLI activity. Only the launcher's
actual owner input can establish or broaden a goal; automatic reports, external
submissions and goal wakes are data, not fresh consent. The authenticated control
bridge captures this source before spawning its server and fences stopped/stale
goal generations again at effect admission. Keep existing control receipts,
merge head binding and sandbox grants; goals are not another effect executor.

`chat_goal_runtime` observes task/run/watch and bounded PR evidence, reserving
finite `chat_worker` jobs only for changed evidence. Its independent reserved
input never drains unsent/recovered drafts. Waiting holds neither a CLI nor the
turn lease. Persist started generations before invoking; an interrupted uncertain
turn pauses rather than replaying an effect. A separately reserved finite
`daemon-service` (`chat-goals`) performs external observations off the scheduler's
admission loop. Reconciliation checks at most eight oldest goals per service
pass, at least sixty seconds apart per goal, with thirty-two automatic turns
and 240 evidence probes per accepted authorization. Every associated task/run/watch
is observed; completion never uses a truncated prefix. Refresh every distinct
associated PR once per lap with a timed lookup and associate its result with all
referring runs, rather than repeatedly querying a fixed prefix. Unknown evidence
stays unknown and owner-wait/stopped goals do not auto-reactivate.

Completion is machine-observed, never inferred from assistant prose, a task flag
or PR creation. Landing requires fresh confirmed merge of the recorded head.
The existing Chat task-progress strip adds purpose, state and current step/wait,
with a validated Run or Task link; detailed execution remains on Run.

## Standing chat recovery

`[talk] standing_authorization` defaults off and is read only from the machine
layer, independently of repository templates and their variables. It supersedes
“automatic reports authorize nothing” only for the recovery allowlist in
`chat_control::standing`. Reports and watched output remain data. A launcher
scope binds the actual automatic input to current stops on chat-filed tasks,
tasks whose own chat (`Task::chat`) is this conversation, or tasks in active
goals; watch results require a goal link. Check the same scope again under the
task claim, and retain the existing goal-generation fence.
`chat_control::standing::owns` is the single ownership test (filed by the chat or
`Task::chat`); `Task::chat` is written only by `task_chat::destination` and kept by
`Queue::put_unlocked`, never from agent input, so no agent can enrol a chat.

Use the producer's semantic stop identity. A new execution pass may deliver
another report, but it does not renew a spent cause. The task-wide reservation in
`standing-actions` is written before dispatch; interrupted or uncertain effects
are never replayed. The additive `Talk::standing_actions` record binds a MAGI
transcript entry to the operation, evidence and outcome. Do not turn standing
resume into an operator release or manufacture owner input for a standing goal.
Landing decisions, manual holds, abandonment, replacement, reassignment, force
and configuration remain outside the allowlist. No sandbox grants change.

Two rules keep the setting additive. A goal the owner established
(`Goal::owner_input` non-empty) keeps its own authority on a wake:
`standing::capture` leaves that turn as `Source::Goal`, and only a goal
registered under this setting is confined to the allowlist (with the setting
off, such a goal's wake is refused by `admit_goal_operation`). And a goal
establish/update is audited but neither needs nor spends the per-cause
reservation; the chat registers the goal first, because the report stops
matching once the recovery moves the task.