docs: architecture map (initial 5-slice generation, 105 pages)
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>
This commit is contained in:
91
docs/architecture-map/02-tauri-runtime/commands/profiles.md
Normal file
91
docs/architecture-map/02-tauri-runtime/commands/profiles.md
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
name: Profiles
|
||||
type: architecture-map-page
|
||||
slice: 02-tauri-runtime
|
||||
last_verified: 2026/05/09
|
||||
---
|
||||
|
||||
# `commands::profiles`
|
||||
|
||||
> **Where you are:** [Architecture map](../../README.md) → [Tauri runtime](../README.md) → [Commands](README.md) → Profiles
|
||||
|
||||
**Plain English summary.** Task 12 storage-backed profiles + per-profile vocabulary terms. Profiles are the unit that scopes a Whisper initial_prompt, a vocabulary list (biases the decoder toward correct spellings), HITL feedback exemplars, and transcripts. Nine commands: profile CRUD (5), profile-term CRUD (3), and the auto-learn pass that diffs an original transcript against an edited transcript and persists likely vocabulary corrections.
|
||||
|
||||
## At a glance
|
||||
|
||||
- Path: `src-tauri/src/commands/profiles.rs`.
|
||||
- LOC: 185.
|
||||
- Tauri commands exposed (9 total):
|
||||
- `list_profiles_cmd(state) -> Result<Vec<ProfileDto>, String>`.
|
||||
- `get_profile_cmd(state, id) -> Result<Option<ProfileDto>, String>`.
|
||||
- `create_profile_cmd(state, name, initial_prompt) -> Result<ProfileDto, String>`.
|
||||
- `update_profile_cmd(state, id, name, initial_prompt) -> Result<(), String>`.
|
||||
- `delete_profile_cmd(state, id) -> Result<(), String>`. The Default profile is guarded at the storage layer (SQLite triggers + Rust pre-checks).
|
||||
- `list_profile_terms_cmd(state, profile_id) -> Result<Vec<ProfileTermDto>, String>`.
|
||||
- `add_profile_term_cmd(state, profile_id, term, note) -> Result<ProfileTermDto, String>`.
|
||||
- `learn_profile_terms_from_edit_cmd(state, profile_id, original_text, edited_text) -> Result<Vec<ProfileTermDto>, String>`.
|
||||
- `delete_profile_term_cmd(state, id) -> Result<(), String>`.
|
||||
- Events emitted: none.
|
||||
- Depends on: `magnotia_storage::{create_profile, update_profile, delete_profile, list_profiles, get_profile, add_profile_term, list_profile_terms, delete_profile_term, ProfileRow, ProfileTermRow}`, `magnotia_ai_formatting::extract_corrections`.
|
||||
- Called from frontend at: Settings → Profiles (full CRUD), profile picker, History viewer (the auto-learn flow runs after the user saves an edit).
|
||||
|
||||
## What's in here
|
||||
|
||||
### `ProfileDto` and `ProfileTermDto` (`src-tauri/src/commands/profiles.rs:31`, `:51`)
|
||||
|
||||
camelCase mirrors of the storage rows. `ProfileDto.initialPrompt` is the saved Whisper prompt; `ProfileTermDto.term` is the vocabulary entry, `note` is a freeform note (used to mark `"Auto-learned from transcript edit"` for the auto-learn flow).
|
||||
|
||||
### `AUTO_LEARNED_NOTE` (`:25`)
|
||||
|
||||
Constant so the auto-learn rows are uniformly tagged.
|
||||
|
||||
### CRUD wrappers
|
||||
|
||||
- `list_profiles_cmd` (`:72`), `get_profile_cmd` (`:82`), `create_profile_cmd` (`:93`), `update_profile_cmd` (`:105`), `delete_profile_cmd` (`:117`). Pure passthroughs to storage.
|
||||
- `list_profile_terms_cmd` (`:127`), `add_profile_term_cmd` (`:138`), `delete_profile_term_cmd` (`:177`). Same pattern.
|
||||
|
||||
### `learn_profile_terms_from_edit_cmd` (`:151`)
|
||||
|
||||
1. Pull the existing terms (so the diff doesn't propose duplicates).
|
||||
2. Call `magnotia_ai_formatting::extract_corrections(&original, &edited, &existing_terms)`.
|
||||
3. Persist each new term via `add_profile_term` with the `AUTO_LEARNED_NOTE`.
|
||||
4. Return the freshly-inserted DTOs.
|
||||
|
||||
The actual diff heuristic lives in the formatting crate; the command file is just wiring.
|
||||
|
||||
## Data flow
|
||||
|
||||
```
|
||||
Settings Profiles tab -> list_profiles_cmd -> [ProfileDto, ...]
|
||||
profile picker -> get_profile_cmd(id)
|
||||
add profile -> create_profile_cmd(name, prompt) -> ProfileDto
|
||||
edit profile -> update_profile_cmd(id, name, prompt) -> ()
|
||||
delete profile -> delete_profile_cmd(id) -> () (Default is rejected at storage)
|
||||
|
||||
Profile terms tab -> list_profile_terms_cmd(profile_id)
|
||||
add term -> add_profile_term_cmd(profile_id, term, note) -> ProfileTermDto
|
||||
delete term -> delete_profile_term_cmd(id) -> ()
|
||||
|
||||
History viewer save edit:
|
||||
-> learn_profile_terms_from_edit_cmd(profile_id, original, edited)
|
||||
-> existing terms from DB
|
||||
-> extract_corrections(original, edited, existing) -> [String]
|
||||
-> add each as a profile term tagged "Auto-learned from transcript edit"
|
||||
-> [ProfileTermDto, ...]
|
||||
```
|
||||
|
||||
## Watch-outs
|
||||
|
||||
- **No `ensure_main_window` guard.** The History viewer is a secondary window (`transcript-viewer`) and needs to call `learn_profile_terms_from_edit_cmd` after a save. So the whole module is callable from anywhere with the secondary-windows capability. If you want to lock down profile *creation* / *deletion*, add `ensure_main_window` to the destructive ones.
|
||||
- **No `PowerAssertion`.** No inference here.
|
||||
- **`extract_corrections` runs synchronously (in the async fn).** Acceptable for the small-text shape of a single transcript edit.
|
||||
- **The Default profile is unkillable.** SQLite trigger rejects the delete. Frontend should grey out the delete button when `profile.id == DEFAULT_PROFILE_ID`.
|
||||
- **Auto-learned terms are recorded one at a time inside a loop** (`:166`). Each iteration is a separate insert. Acceptable; if a future heuristic produces dozens of terms per edit, batch.
|
||||
|
||||
## See also
|
||||
|
||||
- [`commands::mod`](mod.md) — `build_initial_prompt` consumes profile prompt + terms.
|
||||
- [Transcription](transcription.md) — fetches profile + terms before transcribing.
|
||||
- [Live transcription](live.md) — same upstream.
|
||||
- [Tasks](tasks.md) — feedback exemplars are profile-scoped.
|
||||
- [Transcripts](transcripts.md) — every transcript carries a `profileId`.
|
||||
Reference in New Issue
Block a user