pour-review-priors
Pour Review / Priors Panel
An inline, config-declared review surface: at capture time, Pour reads back the most-relevant prior captures for the module being logged — matched, ranked, and summarized entirely from
config.toml— and renders them beside the form. The user never writes a query. Concrete first use case: dialing in a brew by seeing your most similar past brews side by side, each one a whole real recipe. See the story: priors_at_the_pour.
1. Motivation
Pour writes rich structured frontmatter but offers no read-back at the point of decision. To answer "what did I do last time for this roaster?" the user must leave the terminal, open Obsidian, and build or find a Dataview/Bases view. That context switch is exactly the friction the manifesto exists to kill — and it happens at the worst moment, mid-capture, kettle on.
The manifesto's Capture First, Synthesize Later cedes reflection to Obsidian. This feature is not reflection; it is decision support in service of the very next capture — which is capture-first by definition. Bases owns the Sunday table; it cannot live in the terminal capture flow. That gap is the feature.
The value is not parsing and presenting frontmatter (Bases already does that — commodity). The value is curation + placement + timing: your closest priors, beside the fields you are about to fill, without leaving the terminal, with no query to author.
2. Concept
The panel is reference, not prescription. Every value it shows comes from one capture the user actually made. It never blends values across captures by default, because a median dose next to a median yield next to a median time reads like a recipe and is one nobody brewed.
A per-module [modules.<key>.priors] block declares:
match_on— the fields that define "similar", ordered most → least important. Priors are scored by how many of these agree with the form's current values (§4.1).rank_by— a tie-breaker between equally similar priors (defaultrecent). Finding the all-time best captures is Obsidian's job (Bases/Dataview), not the panel's.show— which fields get a panel row. Defaults to every visible field, so the panel lines up with the form.limit— how many priors to show, one column each (default 3).summary— opt-in aggregate column (§6). Off by default.
At form-open and whenever a match_on field or a hard-filter gate changes, the resolver:
- Collects the module's prior captures (via
/search/or FS scan — §7). - Applies hard filters: a field that gates other fields through
show_whenmust match exactly, so espresso priors never appear on a pour-over form (§4.1). - Scores the rest by similarity and orders them, with
rank_bythen recency breaking ties (§5). - Renders the top
limitpriors as columns whose rows line up with the form's fields (§8.1).
The panel is read-only. It never writes, never blocks submit, and never fires at submit time.
3. Schema
[modules.coffee.priors]
match_on = ["bean", "brewer", "grinder", "intent"] # similarity, most → least important
rank_by = "rating desc" # tie-breaker only
limit = 3 # one column per prior
# show defaults to every visible field; summary = true adds a median column (§6)
# richer match modes use object form (§4.2); bare string = equality
[modules.me.priors]
match_on = [
{ field = "tags", mode = "overlap" }, # #tag overlap in body
{ field = "date", mode = "window", days = 90 },
]
rank_by = "recent"
Every key is optional. Zero-config default (no [priors] block at all): match_on = every wikilink/select field in config order; rank_by = "recent"; show = every visible field; limit = 3; summary = false. The hard filter (§4.1) needs no config. This makes a useful panel appear for me/note with no setup, while coffee opts into richness.
3.1 rank_by grammar
| Form | Meaning | Example |
|---|---|---|
"<field> desc" / "<field> asc" |
Sort by a field | rating desc — best shots |
"<field> max" / "<field> min" |
Single extreme (PR-style) | weight_g max — heaviest set |
"recent" |
Newest capture first | journals |
"none" |
Preserve scan order, unranked | — |
"best" is domain-defined by rank_by — the primitive has no built-in notion of quality.
Since L1.5, rank_by only breaks ties between equally similar priors (§5). Similarity decides the order. A user who wants their all-time best captures builds that view in Obsidian. max/min matter less under this model; whether they ship at all is open (GitHub issue #11).
4. Match Semantics
4.1 Similarity scoring
Two steps, in order:
- Hard filter. A field that gates other fields through
show_when(coffee:brew_method) and has a value on the form must match exactly. Priors with a different value are dropped, because their fields describe a different form. This comes from the module'sshow_whenrules, so it needs no config and no coffee-specific code. - Score. For each remaining prior, count the
match_onfields where the prior agrees with the form's current value. Fields the user hasn't filled are ignored. A higher count ranks first. Equal counts are broken by which fields agree, inmatch_onorder, so agreeing onbeanbeats agreeing onintent.
Nothing is dropped for scoring low. If no prior agrees on anything past the hard filter, the panel still shows the closest priors and its header says so (no close match).
The new-bag story still holds. A new bean agrees on nothing in bean, so its brews with the same brewer and grinder rise to the top on their own, without a separate widening step. The strict cascade (L1) is the special case where only full agreement counts.
Weighting (L1.5): a plain count. Order matters only between equal counts, compared field by field in match_on order, so a prior agreeing on bean alone outranks one agreeing on intent alone, but a prior agreeing on brewer and grinder outranks one agreeing on bean alone. An order-weighted score would let the first key outvote all the others, which is the strict cascade again by another name.
No minimum score (L1.5). The panel is never hidden for scoring low. no close match appears only when the form has at least one match_on field filled. At form-open with nothing filled there is nothing to miss, so the header stays similar and the order falls to rank_by and recency.
Missing gate key (L1.5). A prior with no value at all for a filled gate is dropped along with the mismatches. Nothing shows it describes the current form's shape.
Hidden fields don't count (L1.5). The form keeps a field's value after show_when hides it, the same way it does for submit. The resolver sees only the values of fields the form currently shows, so a brewer picked under Pour Over and left behind by a switch to Espresso neither gates, scores, nor turns the header into no close match. Submit drops hidden fields by the same rule.
4.2 Match modes
| Mode | Config | Semantics | Phase |
|---|---|---|---|
equality |
bare string "roaster" |
exact frontmatter value match | L1 |
wikilink |
bare string on a wikilink field |
strip [[ ]]/alias/fragment, compare targets |
L1 (special case of equality) |
overlap |
{field, mode="overlap"} |
non-empty intersection of list/tag values counts as agreement | L2 |
window |
{field, mode="window", days=N} |
capture within N days of today; a filter, not a score | L2 |
Bare string ⇒ equality (or wikilink if the field is declared wikilink = true). Object form ⇒ explicit mode. Simple stays simple; complexity is pay-as-you-go.
4.3 Text-only modules (me/note)
No wikilink/select/number to match on. Zero-config behavior: recent-N of the same module, unfiltered, PLUS #tag-in-body overlap when the body contains inline tags (parse #\w+, match on intersection). This gives journals a "recent context" rail without demanding schema they don't have.
5. Ranking
Columns are ordered left to right by:
- Similarity score (§4.1), highest first.
rank_by, for priors with equal scores. Withrank_by = "<field> desc|asc", a prior missing that field sorts after the ones that have it.- Recency, newest first.
A prior missing the rank_by field (an unrated brew) is still shown, with its column dimmed. The header reads similar, plus the rank_by label when one is set (similar · rating desc). It never claims "best": the panel shows what is close, not what is good.
6. Summary Column (opt-in, per-field-type)
Off by default. summary = true adds one extra column on the right, labeled with its aggregation, that summarizes each row across the displayed priors. It is off by default because it mixes values from different captures, which is exactly what §2 warns against. It earns its place where an average is the point: a stable process variable (water temp), or a lift module's working weight.
When enabled, each shown field summarizes per its type, with an optional per-field override:
| Field type | Default agg | Override options |
|---|---|---|
number |
median (outlier-robust) → repeat: 15g · 1:16 · 2:55 |
mean · max · min · latest |
static_select / dynamic_select / tags |
mode (most common) → most-seen venue: The Fillmore |
latest |
text / textarea |
omitted | — |
Median is the default — a single 40s pull won't drag the target on a small, noisy set. mean is available where central tendency over every value is what you want (stable process vars — water temp; a lift module's working-set average). Configured with the same bare-string-vs-object pattern as match_on (§4.2):
show = [
"dose_g", # median (default)
"time_s", # median
{ field = "water_temp_c", agg = "mean" },
]
Rows with no summarizable type stay blank in the summary column. Ratios (1:16) are a coffee-specific render of two numeric fields; the primitive summarizes each number independently — ratio formatting is a display concern (§8.3), not a summary type.
7. Data Path (hybrid, mirrors ADR-001-Hybrid-Transport-Layer)
Two-tier, matching the existing transport fallback:
-
API up —
POST /search/withContent-Type: application/vnd.olrapi.jsonlogic+json, building a JsonLogic predicate tree frommatch_on. JsonLogic is chosen over Dataview DQL because it is injection-safe —match_onvalues (user-controlled roaster/bean names) ride as JSON data, never interpolated into a query string — while still covering equality (==), wikilink equality, list-overlap (in), and date windows (>=). Obsidian returns matching files with frontmatter. Fast; filtering pushed server-side. See obsidian-local-rest-api §search.{"and":[ {"==":[{"var":"frontmatter.roaster"},"Onyx"]}, {"==":[{"var":"frontmatter.brew_method"},"V60"]} ]} -
API down — filesystem scan of the module's
source/output directory:list_directory_entries→read_filewithAccept: application/vnd.olrapi.note+jsonsemantics (frontmatter parse) → filter/rank in-process. Bounded: stop oncelimitmatches are found per tier.
[Deviation: neither L1 nor L1.5 calls POST /search/. Both paths list the module folder (list_directory_entries), then read every note in it: the API path as note+json, the FS path from disk. The resolver filters in-process (see Resolved #1). The fetch stops at 500 notes, not at limit matches per tier. The folder is the module path up to its last /, taken literally, so a strftime or {{field}} token in the folder part, like the default config's Coffee/%Y/, points at a folder that doesn't exist and the panel shows its empty state.]
Why not the in-memory history log? HistoryEntry (src/data/history.rs) stores only id, module_key, timestamp, vault_path, first_field — not field values. The heatmap's "pure in-memory view" trick does not apply; the corpus must be read from the notes. (Enriching history.jsonl with field values is a possible future fast-path — see §11 — but deliberately out of L1 to avoid a log-schema change.)
New transport surface: a search(module, predicate) -> Vec<CaptureFrontmatter> method wrapping /search/ with the FS-scan fallback. read_file and list_directory_entries already exist; a YAML frontmatter reader and a wikilink stripper do NOT — the codebase writes frontmatter (src/output/frontmatter.rs) and wraps wikilinks but has no reader/stripper and no YAML-parser crate (ADR-002 hand-rolls YAML writing). Both are built as shared src/data/-style foundation in L1 (see §10) and reused by pour-lookup-fields. On the API path, Obsidian returns pre-parsed frontmatter via application/vnd.olrapi.note+json, so the reader is exercised only on the FS-fallback path.
8. UX
8.1 TUI (L1.5 target)
One column per prior, and each panel row sits on the same screen line as the form field it describes. The form's labels label the panel, so the panel carries no field-name column and three priors fit in roughly the L1 panel width.
▽ pour coffee — Coffee ┌ similar · rating desc ──────┐
│ ★4.5 ★4 ★3.5 │
Brew method* Pour Over │ · · · │
Intent Bright │ Balanced · Balanced │
Brewer Switch │ · · V60 │
Bean Cyesha Honey │ · Benj Paz · │
Grinder K-Ultra │ · · · │
▸ Grind setting <empty> │▸ 6.5 7 6 │
Dose (g) 18 │ · 16 · │
Yield (g) <empty> │ 270 250 280 │
Total time (s) <empty> │ 165 150 185 │
Water temp <empty> │ 94 96 93 │
Filter <empty> │ Sibarist Sibarist Cafec │
Recipe add rows │ │
Rating <empty> │ 4.5 4 3.5 │
│ 3d 1w 2w │
└─────────────────────────────┘
(illustrative values)
- Column = one real prior. Read top to bottom, it is a whole capture. Nothing is blended (summary column aside, §6).
- Row = the field beside it. Read across, it is the range for that field. The active field's row is highlighted across the panel.
·means "same as the form's current value". A value that differs from the current selection renders highlighted, so the user sees at a glance how close each prior is. A value filled from a field's configdefaultcounts as current like any other, so at form-open the Dose row above shows·for every prior brewed at 18 g. The marks are computed each frame from the live form, so typing a dose moves them without a new fetch.- Column header: the
rank_byvalue when set (★4.5). Column footer: age (3d,1w). [Deviation: L1.5 prints the stored value without the★. The glyph would assume everyrank_byfield is a rating.] - Unrated priors (missing
rank_by) render dimmed (§5). - Row alignment is the hard part. Some form items take two lines (callout fields), and the preset row sits above the fields. Panel row heights must come from the same visible-field item list
tui/form/render/fields.rsbuilds, not from a parallel count. - Composite fields render blank. Presets are how you reuse recipe stages, so the panel doesn't summarize them. Textarea fields stay blank unless listed in
show. - Narrow terminals drop columns (3 → 2 → 1) instead of moving the panel below the form, so rows stay aligned. Below one column's width the panel collapses to a one-line hint. L1.5 thresholds: the form keeps 60 columns and each panel column is 10 wide, so 3 columns need 94, 2 need 84, 1 needs 74. The summary column (§6) is dropped before any prior.
- Appears automatically when any prior survives the hard filter. With none, a one-line empty state.
Ctrl+Rtoggles the panel (collapse/expand).- Trigger timing: resolve at form-open and on any
match_onor gate field change. A gate re-resolves even when it isn't inmatch_on, because it changes which priors survive. Never at submit (read-only). Reuse the pour-lookup-fields trigger model.
8.2 PWA
Out of scope for L1 (like lookup-fields). L2: needs the contract amendment (§9) landed first per feedback_contract_first. Side-by-side columns do not fit a phone. The PWA needs its own presentation of the same data, for example one card per prior in form-field order, swiped. Design it in L2.
8.3 Rendering notes
- Column widths derived from
showfield types (numbers right-aligned, capped precision). [Deviation: L1.5 uses one fixed 9-cell width for every column, left-aligned. Longer values truncate with….] - Shared prefixes are elided. When a value is too long for its cell and shares a leading run with a different value on the same screen line, either another column or the form's own value, the panel replaces the shared run with
…, cut back to a word boundary. Beans namedYesPlz - HomestarandYesPlz - SOE Ethiopiaread…Homestarand…SOE Ethi…rather thanYesPlz -…twice. Values that fit are shown whole.·is still decided on the full value. - Ratio display (
1:16) is opt-in per module via a display hint, not a summary type — deferred to L2. L1 shows rawdose_g/yield_g.
9. API Contract Impact
Deferred to L2 (PWA). When it lands:
POST /api/v1/priors/{module}
body: { match_values: { <field>: <value>, … } }
→ 200 { tier: "roaster+method", rank: "rating desc",
rows: [ { … frontmatter subset … } ],
summary: { dose_g: 15, … } | null }
→ 200 { tier: null, rows: [], summary: null } # empty state
No submit-path change — this is a pure read endpoint. Contract amendment lands before PWA UI per contract-first discipline.
10. Phasing
L1 — Coffee's exact path (TUI)
- Foundation (new, folded into L1): a YAML frontmatter reader (parses the
---block of Pour-written notes into key/values; must not crash on richer externally-edited YAML but need not fully model it) and a wikilink stripper ([[Target|Alias]]/[[Target#Frag]]→Target), built as sharedsrc/data/-style utilities with their own tests. Reused by pour-lookup-fields. Design note (Architect's call, record in impl-notes): crate (e.g.serde_yaml) vs. hand-rolled, weighed against round-trip fidelity with the ADR-002 hand-rolled writer — if a crate is chosen, assess whether ADR-002 needs an amendment. - Schema:
[modules.<key>.priors]withmatch_on(equality + wikilink),rank_by(<field> desc/asc),show,limit; zero-config default. - Resolver in
src/priors/(new module): cascade match, qualifying-first + dim-texture rank, numeric-median summary. - Transport:
search()wrapper —/search/JsonLogic fast path + FS-scan fallback (both in L1, per ADR-001-Hybrid-Transport-Layer). - TUI: right/below panel, header (with qualifier logic §5.4),
Ctrl+Rtoggle, form-open + field-change triggers. - Tests:
tests/priors_resolver.rs(cascade, qualifying/texture split, all-texture degeneration, summary source),tests/priors_transport.rs(JsonLogic search + FS fallback parity), plus a JsonLogic-builder unit test asserting no value reaches the query as a string literal. - Docs:
field-types.mdgains the[priors]block; this spec →shipped. - Deferred, specced: tag-overlap, recency-window, non-numeric summaries,
me/notepanels, PWA. Vocabulary designed up front so these are pure additions — no re-architecture.
L1.5 — Reference columns (TUI)
Replaces L1's row panel with the column layout. Driven by first real use (2026-10): the L1 panel showed back fields the user had already filled and rarely found similar brews.
- Resolver: hard filter from
show_whengates + similarity scoring (§4.1) in place of the cascade; ordering per §5. - Output shape: an ordered list of priors (columns) with per-field cell values, a same-as-current flag per cell, and the header/footer values. Drop the
repeat:line. - Config:
limitdefault 3,showdefault every visible field, newsummarykey (defaultfalse), zero-configmatch_on= everywikilink/select field. Noconfig_versionbump (additive / defaults only). - TUI: column panel aligned to form rows (§8.1),
·for same-as-current, active-row highlight, column dropping on narrow terminals. - Tests: scoring and hard filter in
tests/priors_resolver.rs(new-bag case, no-close-match case, tie-breaks), plus a render test pinning row alignment with a two-line form item. - Docs:
field-types.md[priors]block, this spec's deviation notes removed as they close, architecture overview. - Carries over unchanged: corpus fetch (
search.rs, API note+json / FS scan), the frontmatter reader, the wikilink stripper, the JsonLogic builder, config deserialization.
L2 — Generalization + PWA
- Match modes
overlap,window. - Per-field-type summary (mode for selects/tags), for the opt-in summary column.
me/noterecent-N +#tagoverlap.POST /api/v1/priors/{module}+ PWA panel.
L3 — Optional fast-path + standalone surface
history.jsonlfield-value enrichment for pure-in-memory review (if FS scan feels slow at scale).pour review <module>standalone read surface on the same engine (only if a real need surfaces — Bases covers exploration).
11. Out of Scope (v1)
- A query language / filter UI at capture time — forever. The config is the query; capture stays low-load. This is the load-bearing boundary.
- Standalone browse/explore screen — Bases/Dataview own exploration.
pour review <module>is an L3 maybe, not a goal. - Writing back to notes — read-only, like all review surfaces.
- Cross-module priors — single-module scope per capture.
history.jsonlenrichment — L3 only; avoid a log-schema change in L1.
12. Open Questions
Resolved (design interview, 2026-07-13)
Naming→ Priors; config key is[modules.<x>.priors].Missing-field rows in ranking→ qualifying-first, then dim texture (§5), not exclusion. Header drops the rank qualifier when texture is mixed in.DQL vs JsonLogic→ JsonLogic (injection-safe), and the/search/fast path ships in L1 alongside the FS fallback.Summary aggregation→ configurable per shown field, defaultmedian(§6).mean/max/min/latestvia object form.Zero-config→ numeric + select fields, first 4 by config order (§3), user-overridable.showNarrow terminal→ stack below the form, full width (§8.1). Carries a min-terminal-height caveat (open #2 below). Superseded by L1.5 (2026-10-02): narrow terminals drop columns and the panel stays beside the form.
Resolved (L1 build, 2026-07-13)
JsonLogic frontmatter accessor shape→{"var": "frontmatter.<key>"}, confirmed from the Obsidian Local REST API OpenAPI spec (obsidian-local-rest-api-openapi.yaml,/search/examples:find_by_frontmatter_value). Equality uses{"==": [...]}. [Deviation: the spec claimed/search/returns "matching files with frontmatter"; the API actually returns[{filename, result}], so the L1 build fetches each note's frontmatter viaAccept: application/vnd.olrapi.note+json. And, to keep the two transport paths provably equivalent under the new-bag cascade, L1 fetches the module corpus once and runs the (pure, tested) resolver in-process rather than pushing each cascade tier server-side; the injection-safe JsonLogic builder ships and is tested as the documented query surface, so server-side filtering remains a localized future change.]Stack-below min height→ 9-row form minimum: the stacked panel is only rendered as a box when ≥ 6 rows remain after reserving 9 rows for the form; otherwise it collapses to the one-line summary hint (▸ repeat: … — ^R for rows). TheCtrl+Rcollapse reserves a single hint row. Superseded by L1.5 (2026-10-02): there is no stacked layout, so there is no height budget. The one-line hint takes the bottom row.
Resolved (L1 review, 2026-10-02)
Panel shape→ one column per prior, rows aligned to form fields (§8.1). Considered and rejected: inline ghost hints in the form, sourced per field. They read as prescription, and per-field aggregation invents a recipe.Same-as-current cells→ render as·, so differences stand out.Ordering→ similarity first;rank_byis a tie-breaker (§5). Best-of views belong in Obsidian. Weighting details are the Architect's call.Summary line→ opt-in summary column, off by default (§6).
Still open
- Window timezone —
mode="window"usestoday_local(server-side, per pour-lookup-fields §11.2). Document the same caveat. (L2 — only relevant oncewindowmode lands.) - Minimum similarity — show the closest priors even when nothing agrees past the hard filter (current spec), or hide the panel below some score? Architect's call in L1.5, revisit with use. L1.5 chose: no minimum, and a plain-count score with earlier-field tie-breaks (§4.1). Revisit once the corpus is larger.
13. Cross-references
- priors_at_the_pour — the story / vision framing.
- pour-lookup-fields — shares frontmatter-read + wikilink-resolution + trigger-model plumbing; slot this behind it. [Deviation: priors shipped first. Lookup-fields has not started, so L1 built the shared reader and stripper itself.]
- history_heatmap_dashboard — sibling review surface (cadence vs. content).
- ADR-001-Hybrid-Transport-Layer — the API→FS fallback this data path mirrors.
- obsidian-local-rest-api —
POST /search/DQL/JsonLogic contract. - pour_without_obsidian —
pour querylineage; this is its first concrete increment. - pour-api-contract — L2 amendment target (§9).
14. Change Log
-
2026-10-02 (L1.5 built) — Reference columns landed in the TUI. The resolver hard-filters on
show_whengates, scores by plainmatch_onagreement count with earlier-field tie-breaks, and orders by score,rank_by, then recency. No minimum score;no close matchneeds at least one filledmatch_onfield. Config:limitdefaults to 3,showto every non-textarea, non-composite field, zero-configmatch_onto every wikilink/select field in config order, and a new opt-insummarykey. Noconfig_versionbump. The panel draws one column per prior with rows placed from the form's own item heights,·for values equal to the live form (defaults included), dimmed columns for priors missingrank_by,rank_byvalues as column headers and ages as footers. Narrow terminals drop columns, then fall back to a one-line hint; the stacked layout andrepeat:line are gone. Composite rows render blank. The resolver ignores values of fieldsshow_whenhides, and cells elide a prefix shared with another value on the same row. Deviation notes closed by this work were removed. -
2026-10-02 (L1.5 specced) — First real use showed the L1 panel was not useful: zero-config showed fields the user had already filled, and the strict cascade rarely found similar brews on a 17-brew corpus. Revised to reference columns: one column per real prior, rows aligned to the form,
·for same-as-current, similarity scoring with ashow_whenhard filter in place of the cascade,rank_bydemoted to tie-breaker,repeat:line replaced by an opt-in summary column. L1 behavior annotated as deviations. New phase L1.5 (§10). -
2026-07-13 (L1 shipped) — Coffee's exact path landed (TUI). Shared foundation
src/data/frontmatter_read.rs(hand-rolled reader — see ADR-007-Frontmatter-Reader) +src/data/wikilink.rsstripper.src/priors/resolver (cascade widens by dropping the most-specific/front key — the spec's "tail" wording; the story'sbean → roaster+methodordering is authoritative), injection-safe JsonLogic builder, transport corpus-fetch (API note+json / FS scan). Config[priors]block deserializes the full L1+L2 vocabulary; L1 validation rejectsoverlap/windowmodes andmax/minrank forms. Open questions #1 (accessor shape) and #2 (stack-below min height) resolved above. Noconfig_versionbump (additive, all-optional block). Deferred to L2/L3 unchanged. -
2026-07-13 — Initial draft. Scoped via design interview: inline TUI panel, config-declared query (never user-authored), pluggable
rank_by, ordered new-bag match cascade, per-field-type summaries, hybrid/search→FS data path, zero-config defaults. L1 = coffee's exact path; full vocabulary designed but deferred to L2/L3. Status: not yet scheduled — requires roadmap allocation behind pour-lookup-fields.