Repository navigation
V0-11: Automatic Note Organization with Prompt A - #31
Merged
Merged
Conversation
Implements the Enrichment Workflow for the V0-11 issue. After a Note is created or edited, the controller debounces 800ms, captures a request token, calls Ollama /api/chat, parses the structured response, and applies the parsed fields to the Note through the manual-provenance gate. Highlights: - Migration 0008 widens the provenance CHECK to admit the new 'ai' value and adds the enrichment_revision + last_enriched_at columns. - Provenance enum grows an 'Ai' variant; the workspace layer bumps the revision on every commit that touches a Note. - Enrichment Workflow module owns the approved Prompt A, the JSON schema, the candidate selection algorithm, the per-field truncation, the response parser, and the application gate. - The Tauri command 'enrich_note' runs the same provider-agnostic contract for local Ollama and consented Ollama Cloud, with the bearer key read from the macOS keychain on demand. - Manual fields are never overwritten by AI; Re-enrich and Replace is the only path that bypasses the gate, and the UI now surfaces an explicit confirmation dialog before committing. - Typed failures (stale / invalid_schema / provider / unavailable) leave the Note untouched and the UI renders a single retry affordance. - Visible provenance: 'AI organized' badge when the Note has been enriched, and a small 'AI' chip on Note Type and Annotation when the value is AI-authored. Tests: - 95 Rust tests cover schema, parser, gate, persistence, and the stale / manual / force / reopen paths. Contract test asserts the system prompt byte-for-byte against the approved Prompt A and exercises both a small-model and large-model fixture. - 118 TypeScript tests cover the workspace-snapshot submit return shape, the enrichment controller debounce + cancel + retry + replace confirmation, and the existing App, Note, and Thinking Graph flows. Closes #12
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12
What this delivers
V0-11 of the Nodepad app — automatic Note Organization for Local AI and consented Cloud AI Workspaces. After a Note is created or edited, the Enrichment Workflow debounces 800 ms, captures a request token (workspace, note, revision, policy, endpoint, model), calls Ollama
/api/chatwith the approved Prompt A, validates the structured response, and atomically applies one Note Type, zero-to-three Labels, an optional Annotation, and zero-to-five strong symmetric Relationships to the Note.How it satisfies each acceptance criterion
unavailablefailure when policy ismanual.EnrichmentClienttrait +HttpEnrichmentClientfor both endpoints; the bearer key is read from the macOS keychain only for the Cloud path.select_candidatestakes four most-recent + diversity fillers, capped at ten; target ≤ 8 000, candidate ≤ 500, annotation ≤ 300, full request ≤ 16 000 Unicode scalar values. Same-Workspace scope is enforced at the Tauri command.WorkspaceStore::apply_enrichment_outcomeopens a single transaction that updates the Note row, attaches new Labels, and inserts newAi-provenance Relationships. The new fields are markedProvenance::Aiand the Note'slastEnrichedAtis set.Provenance::Manualalways wins;DefaultandAimay be refreshed. Testsapply_enrichment_never_overwrites_a_manual_label_membership,apply_enrichment_never_writes_a_manual_note_type, andapply_enrichment_does_not_change_note_textprove it.replace_pendingstate, the NoteCard renders analertdialogwith Replace / Keep manual buttons, and theforceflag bypasses the manual-provenance gate only after the thinker confirms.parse_keeps_a_prompt_injection_inside_a_valid_fieldproves an injection inside an Annotation is stored as data.RequestToken.revisionis re-read at apply time; mismatch returnsWorkspaceFailureCode::Stale. Testsapply_enrichment_rejects_stale_revisionandapply_enrichment_drops_results_when_the_thinker_edits_during_inferenceprove the path. The UI renders a typed retry state.apply_enrichment_outcomeonly writesnote_type,note_type_provenance,annotation,annotation_provenance,enrichment_revision,last_enriched_at. Testapply_enrichment_does_not_change_note_textproves it.system_prompt_is_byte_for_byte_approvedasserts the system prompt string equals the approved Prompt A;parse_passes_small_and_large_model_fixturesexercises the parser with both aphi3:latestand allama3.1:70btoken;response_schema_matches_the_approved_contractasserts the JSON schema equals the spec.Pre-implementation
docs/audits/issue-12-simplicity-audit.mdrecords the prd-simplicity-audit. Gate: PROCEED. Zero BLOCK items; the few CAUTION items became part of the implementation (manual-provenance gate, request-token invalidation, explicit confirmation).Tests
cargo test --manifest-path src-tauri/Cargo.toml --lib— 95 passed, 0 failed.npm run test— 118 passed, 0 failed (across 8 test files).npm run check— typecheck + lint + test + rust test + tauri smoke all pass.fallow audit --base main— 0 introduced dead code; the 2 introduced complexity findings (NoteEnrichmentBadge,useEnrichmentController) are intrinsic to a state-machine component.Out of scope (explicitly fenced out per the issue)
Synthesis, URL network retrieval, model management, other providers, hidden reas 8000 oning display, automatic merging, and prompt variants beyond approved Prompt A.