Five-slice navigable map of the entire codebase under
docs/architecture-map/. Each slice is a self-contained
breadcrumbed sub-tree:
01-frontend (16) Svelte/SvelteKit UI
02-tauri-runtime (26) src-tauri commands + lifecycle
03-audio-transcription (16) audio + transcription crates
04-llm-formatting-mcp (19) llm, ai-formatting, mcp, cloud
05-core-storage-hotkey-build core, storage, hotkey, workspace,
(26) CI, dev glue
Plus master README.md and data-flow-end-to-end.md tracing
audio bytes from microphone to FTS5 search to MCP read.
Generated by 5 parallel subagents on 2026/05/09 against
HEAD 3c47000. Each page has YAML frontmatter, file:line code
refs, sibling cross-links, plain-English summaries.
Aggregated debt surfaced (full lists in master README):
RB-08 macOS power assertion, schema head drift v14 vs v15,
VAD blocked on ort version conflict, streaming primitives
not wired into live.rs, no prompt versioning, MCP has no
auth, cloud-providers in-memory keystore, SettingsPage
2 484 LOC, commands/live.rs 1 737 LOC, dual theme system,
brand rename to Lumenote pending across the codebase.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5.2 KiB
5.2 KiB
name, type, slice, last_verified
| name | type | slice | last_verified |
|---|---|---|---|
| LLM extract_tasks surface | architecture-map-page | 04-llm-formatting-mcp | 2026/05/09 |
LLM extract_tasks surface
Where you are: Architecture map → LLM, Formatting, MCP → extract_tasks
Plain English summary. extract_tasks reads a transcript and pulls out the action items the speaker actually committed to. Output is a JSON array of imperative sentences, possibly empty. The GBNF accepts an empty array, the prompt asks the model to return one when nothing was committed. A feedback-conditioned variant supports HITL few-shot examples.
At a glance
- Crate:
magnotia-llm - Path:
crates/llm/src/lib.rs:294(extract_tasks) and:358(extract_tasks_with_feedback) - LOC: ~50 across both methods
- Public surface:
pub fn extract_tasks(&self, transcript: &str) -> Result<Vec<String>, EngineError>pub fn extract_tasks_with_feedback(&self, transcript: &str, examples: &[prompts::FeedbackExample]) -> Result<Vec<String>, EngineError>
- External deps that matter: GBNF sampler from llama-cpp-2;
serde_jsonfor the array parse. - Tauri command that calls this (slice 2, best guess):
commands::tasks::extract_tasks_from_transcript_cmd(src-tauri/src/commands/tasks.rs:346), wired viasrc-tauri/src/lib.rs:366. The actual call is attasks.rs:364—tokio::task::spawn_blocking(move || engine.extract_tasks_with_feedback(&transcript, &examples)).
What's in here
extract_tasks (crates/llm/src/lib.rs:294)
Convenience wrapper that calls extract_tasks_with_feedback(transcript, &[]).
extract_tasks_with_feedback (crates/llm/src/lib.rs:358)
Steps:
- If
transcript.trim().is_empty(), returnOk(Vec::new())immediately. No model touch — distinct fromcleanup_textwhich returns an empty string. The empty-vec convention matches what callers expect from "the speaker said nothing actionable". - Borrow the loaded model via
loaded_model_arc().EngineError::NotLoadedif no model is loaded. - Build the system prompt:
prompts::build_conditioned_system_prompt(prompts::EXTRACT_TASKS_SYSTEM, examples). Same conditioning logic asdecompose_task_with_feedback. - Render a chat prompt with two messages —
("system", system)and("user", &format!("Transcript:\n{transcript}")). - Call
generatewith:max_tokens: 768temperature: 0.0stop_sequences: ["<|im_end|>", "<|im_end_of_text|>"]grammar: Some(grammars::OPTIONAL_TASK_ARRAY_GRAMMAR.to_string())
- Parse the raw output via
parse_string_array.
The empty-array case is the difference from decompose_task: OPTIONAL_TASK_ARRAY_GRAMMAR permits [] as a valid root expansion; TASK_ARRAY_GRAMMAR does not.
Data flow
(transcript: &str, examples: &[FeedbackExample])
→ empty-transcript short-circuit (returns Vec::new())
→ loaded_model_arc()
→ build_conditioned_system_prompt(EXTRACT_TASKS_SYSTEM, examples)
→ render_chat_prompt([(system, system), (user, "Transcript:\n{transcript}")])
→ generate(prompt, GenerationConfig {
max_tokens: 768, temp: 0.0,
stops: [<|im_end|>, <|im_end_of_text|>],
grammar: Some(OPTIONAL_TASK_ARRAY_GRAMMAR),
})
→ parse_string_array(raw)
→ Vec<String>
Prompts and grammars
- System prompt:
prompts::EXTRACT_TASKS_SYSTEMatcrates/llm/src/prompts.rs:40. Crucial line: "Output an empty array if there are no action items." - GBNF:
grammars::OPTIONAL_TASK_ARRAY_GRAMMARatcrates/llm/src/grammars.rs:30. Two root alternatives:"[" ws "]"for the empty case, or"[" ws string tail ws "]"with a recursive tail for one-or-more strings.
See llm-prompts-and-grammars.md for full text.
Watch-outs
- Empty array is a valid, expected output. UI and downstream code must treat
Ok(Vec::new())as the "no tasks" success path, not as an error.extract_corrections-style learning loops should skip empty results entirely. max_tokens: 768is larger thandecompose_task's 512. A long meeting transcript can produce many actions; the looser cap reflects that. It does not bound the count of items, only the total tokens of the JSON literal.- The system prompt is the only thing telling the model "explicit commitments only". A model that ignores instruction would happily list observations and wishes; the GBNF is silent on content. If the cleanup_text-style "translator not editor" framing is ever copied here, that is a deliberate prompt-engineering decision, not a refactor.
- Feedback conditioning weight. Recent-first ordering in
examplesis preserved; the prompt builder appends them as a- Input: ... \n Good output: ...bullet list. Long lists dilute the weighting; the Tauri command atsrc-tauri/src/commands/tasks.rsdecides how many examples to pass. - Same GBNF parse-vs-serde concerns as
decompose_task. The grammar guarantees a valid JSON array shape;serde_json::from_strcan still fail on an unfortunate truncation when output approachesmax_tokens.