# Sip Graph — AI Exchange & Share Card Spec (`sip-graph-ai-spec/4`)

Give this file to Claude, ChatGPT, or another AI assistant once at the start of a chat so it can read your Sip Graph brews, tastings, and Share Cards accurately and write recipes, coffees, or gear that Sip Graph imports cleanly.

Canonical spec: https://sipgraph.coffee/api/ai-spec. Older `brew-recipe/1`, `brew-coffee/1`, `brew-profile/1`, and `brew-export/2` payloads retain their format names.

---

## 1. General Rules for Your AI

1. **Always start from what was actually brewed.** Read `actual_recipe` and `brew_log` (real dose, real water grams per pour, real `g/s` / `ml/s` flow rates, real timing, observations, and Hot → Warm → Cool tasting notes). Never diagnose from `planned_recipe` when actual measurements exist.
2. **Collaborate — do not dump a generic list of guesses.** If the brewer shares a cup or link without specifying their goal or key context is missing, ask **2–3 focused questions first** (what they want better in the next cup, unlogged technique/bed cues, or whether their gear/water/history matters). When their wider gear shelf, mineral bottles, other coffees, or earlier brews would sharpen your advice, output a ready-to-paste `brew-request/1` JSON block for Sip Graph's Home AI Bridge.
3. **Always emit a pasteable JSON block when recommending an action.** Send **one JSON block per paste** (`brew-recipe/1` for a recipe, or `brew-bundle/1` for combined gear/coffee/recipe). From a single cup, propose at most one primary change toward the brewer's goal, explain what to taste for, and return the adjusted recipe as `brew-recipe/1`.
4. Omit unknown fields. Never fabricate water chemistry, roast dates, pour flow rates, spout heights, or unlogged timings.
5. Respect `logged_live`:
   - `logged_live: true` → the brewer ran the live bench timer.
   - `logged_live: false` → the brewer logged a past/manual brew without the live timer. Treat times and weights as brewer-recalled rather than live-timed.
6. Use grams, degrees Celsius, seconds, centimetres, milligrams per litre, and ppm as CaCO₃ where specified. Allowed `roast_level` values: `ultralight`, `light`, `medium-light`, `medium`, `medium-dark`, `dark`.

### 1.1 Ultralight & Light Roast Resting Rules
- Treat roast age, including 60 days off roast, as context. A date alone cannot establish that an ultralight is ready, at peak or stale.
- Use bloom expansion, bubbles and crema as qualitative gas and wetting observations. Judge flavour readiness from the cup and its changes over time.
- Use the roaster's guidance for the specific lot and brew method when available. Offer 3–5 weeks or 6–10+ weeks only as possible, lot-dependent tasting windows. Give a range with uncertainty when the lot is unknown.
- Ask how the bag was sealed, when it was opened and when it was frozen or thawed. Track time frozen separately (`practical_age_days` = days since roast minus sealed days frozen). A room-temperature age estimate is approximate, and aroma can fade while CO₂ remains.
- If the brewer wants to diagnose rest, suggest one repeat with the same recipe, grind and water. Compare aroma, sweetness and finish at similar temperatures. Consider staling and extraction alongside under-resting when a cup is muted or woody.

---

## 2. Formats You Send Back to Sip Graph (Paste-In)

### 2.1 Recipe — `brew-recipe/1`

Include `format`, `dose_g` and `pours`. Give each pour its cumulative total and a start cue. Omit other fields when unknown.

```json
{
  "format": "brew-recipe/1",
  "coffee": "Scenery Worka Chelbesa",
  "dose_g": 13.7,
  "water_g": 200,
  "grinder": "1Zpresso ZP6",
  "grind": 5.2,
  "temp_c": 93,
  "dripper": "Origami S",
  "paper": "CAFEC Abaca",
  "kettle_model": "Fellow",
  "kettle": "off the base",
  "water": {
    "batch_g": 500,
    "base": "ZeroWater",
    "drops": { "CaCl2": 10, "MgCl2": 7, "MgSO4": 3 }
  },
  "pours": [
    {
      "to_g": 50,
      "start": "ready",
      "flow_g_s": 9,
      "spout_cm": 1,
      "pattern": "spiral",
      "circle_s": 2,
      "after": "swirl",
      "log": ["rise", "bubbles"]
    },
    {
      "to_g": 150,
      "start": "0:35",
      "flow_g_s": 9,
      "spout_cm": 1,
      "pattern": "spiral",
      "circle_s": 2,
      "after": "none"
    },
    {
      "to_g": 200,
      "start": "drained",
      "flow_g_s": 9,
      "spout_cm": 1,
      "pattern": "circles",
      "circle_size": "mid",
      "circle_s": 2,
      "after": "none"
    }
  ],
  "finish": {
    "how": "tail",
    "cue": "stream breaks into drops"
  },
  "notes": "One clear goal or note for this cup."
}
```

**Recipe fields**
- **`to_g` is cumulative** (total on the scale at the end of that pour, strictly increasing; last pour matches `water_g`).
- **`start` values:**
  - Pour 1: `"ready"`
  - Pour 2+: `"m:ss"` (clock), `"water ~1 cm above the bed"`, `"a little water on top"`, `"water at the bed"`, or `"drained"` (water below the bed). Pour 2 also accepts `"when the bubbling calms"`, `"when the shine is gone"` and `"by smell"`.
- **Water** accepts `water.drops` (bottle or salt name to drop count in `water.batch_g`), `water.recipe` (e.g. `"Holy water recipe"`), or `water.ppm_caco3` (e.g. `{"MgSO4":39.02,"CaCl2":34.15,"MgCl2":43.90}` or `{"gh":60,"kh":20}`). These can coexist with `water.base`. `water_recipe` and `minerals_ppm` are top-level aliases. Include drops only when the source gives them or the bottle calibration and batch support the calculation.
- **`spout_cm`** is numeric or qualitative. `spout_height` and `height` are aliases. Values map to cm as follows: `low` 1, `medium-low` 2, `medium` 3.5, `medium-high` or `medium+` 5.5, `high` 7.5.
- **`flow_g_s`** is numeric or qualitative. `flow` and `kettle_flow` are aliases. Values map to g/s as follows: `gentle` or `slow` 5, `medium-slow` 6.5, `medium` 8, `medium-strong` or `medium+` 10, `strong` or `fast` 12.
- **`circle_s`** is seconds per circle. `speed` and `circle_speed` are aliases. Values map to seconds as follows: `slow` 3.5, `medium-slow` 2.8, `medium` 2, `fast` 1.2.
- **`pattern`:** `"spiral"`, `"circles"`, `"centre"` (when `"circles"`, optional `circle_size`: `"wide" | "mid" | "centre"`).
- **`melodrip: true`** replaces `spout_cm`, `pattern`, `circle_size`, and `circle_s` on that pour.
- **`after`:** `"none" | "swirl" | "stir"` (when `"stir"`, optional `stir_strokes`: integer `1–12`).
- **`log`** can list `"time and scale"`, `"rise"`, `"bubbles"`, `"dry grounds"`, `"bloom state"`, `"still bubbling"`, `"smell"`, `"water on the bed"` and `"dripping"` where applicable. Put technique prose in `note` for the pour.
- **`finish.how`:** `"drain" | "lift" | "tail" | "extra"` (`"extra"` also accepts `extra_g`).
- **`finish.cue`** (when `how !== "drain"`): `"stream breaks into drops" | "a little water on top" | "no water on top"`.
- **`kettle`:** `"off the base" | "on the base between pours"`.
- **`valve`** (optional, switch drippers): `[{"state": "closed" | "open", "at": "0:00"}]`.
- **Past brew** uses `"log_as_past_brew": true` for a reconstructed cup. Include `total_brew_s` in seconds or `total_time` in `m:ss` if known. Leave the flag out for a recipe to try next.
- Reference gear and coffee by the brewer's names. Use a `brew-bundle/1` to include new gear or coffee records alongside the recipe.

---

### 2.2 Coffees — `brew-coffee/1`

```json
{
  "format": "brew-coffee/1",
  "coffees": [
    {
      "name": "Scenery Worka Chelbesa",
      "display_name": "Chelbesa",
      "original_name": "Scenery Worka Chelbesa",
      "roaster": "Scenery",
      "origin_country": "Ethiopia",
      "region": "Gedeb",
      "village": "Worka Chelbesa",
      "producer": "Worka Chelbesa",
      "lot": "Lot 12",
      "variety": ["Heirloom"],
      "altitude_m": { "min": 1950, "max": 2150 },
      "harvest": "2025/26",
      "washing_station": "Worka Chelbesa",
      "process": {
        "label": "Double Fermentation Washed",
        "base": "washed",
        "extras": ["double fermentation"],
        "scope": "lot",
        "steps": [
          {"stage": "cherry_hold", "duration": {"min": 24, "max": 24, "unit": "h"}, "oxygen": "sealed_valve"},
          {"stage": "depulp"},
          {"stage": "mucilage_fermentation", "water": "submerged", "target_ph": 4.3},
          {"stage": "wash"},
          {"stage": "dry", "method": ["raised_beds"]}
        ]
      },
      "roast_level": "light",
      "roast_date": "2026-10-15",
      "bag_notes": "white peach, jasmine, bergamot"
    }
  ]
}
```

The example illustrates the shape. Use the bag title verbatim as `original_name` and record a personal nickname as `display_name` when supplied. Add `village` when sourced. `preferred_water` can hold this coffee's saved preference using `base_id`, `base`, `batch_g`, `drops`, `recipe_name`, `note`, and `saved_at`.

Optional `bags[]` tracks multiple purchases/batches or split sub-bags (e.g. half shelf, half frozen): `{id, label, roast_date, bought_g, used_g, opened_date, in_freezer, freeze_date, defrost_date, frozen_periods: [{from, to}], rebagged, rebagged_into, valve_taped_date}`. Practical resting age (`practical_age_days`) counts calendar days off `roast_date` minus days frozen (freezing pauses aging; defrosting resumes it). Each saved brew automatically estimates bean consumption (`dose_g`, `+0.3 g` if chaff removed, `+~0.4 g × dose/14` clamped `0.1–1.0 g` if ugly beans removed).

Use structured `process.steps` in source order, with an empty array when the source gives no steps. Keep the source's process name in `label` and optionally attach `source: {url, text}`, where `text` is a short quote.

| Field | Allowed values |
|---|---|
| `base` | `washed`, `natural`, `honey`, `other` |
| `extras[]` | `double fermentation`, `anaerobic`, `carbonic maceration`, `thermal shock`, `co-fermented`, `yeast inoculated`, `extended fermentation`, `cold fermentation`, `zero fermentation`, `experimental`, `decaf` |
| `steps[].stage` | `harvest_selection`, `cherry_hold`, `depulp`, `mechanical_demucilage`, `mucilage_fermentation`, `thermal_shock`, `wash`, `soak`, `dry`, `rest`, `hull`, `decaf`, `other` |
| `steps[].oxygen` | `open`, `sealed`, `sealed_valve`, `co2`, `vacuum` |
| `steps[].water` | `dry`, `submerged` |
| `steps[].method[]` for drying | `patio`, `raised_beds`, `parabolic`, `mechanical`, `shade`, `cold_room` |
| `steps[].method[]` for decaf | `swiss_water`, `ea_sugarcane`, `co2`, `mc` |
| `dries_with` | `fruit`, `mucilage`, `parchment`, `seed` |
| `scope` | `lot`, `usual`, `unclear` |

Each step can also include `duration: {min, max, unit}` (`h` or `d`), `temp_c: {min, max}`, `target_ph`, `additives`, `moisture_end_pct`, `note`, and `basis: "stated" | "inferred"`. Supply `target_ph` only when the source specifies a pH target.

---

### 2.3 Gear & Water Profile — `brew-profile/1`

```json
{
  "format": "brew-profile/1",
  "grinders": [{ "name": "1Zpresso ZP6", "unit": "numbers", "range": { "min": 3.5, "max": 6.5, "step": 0.1 } }],
  "kettles": [{ "name": "Fellow", "gooseneck": true, "holds_temp": false }],
  "drippers": [{ "name": "Origami S", "valve": false }],
  "papers": [{ "name": "CAFEC Abaca" }],
  "carafes": [{ "name": "Glass carafe", "empty_g": 245 }],
  "scales": [{ "name": "0.1g scale", "resolution_g": 0.1 }],
  "waters": [{ "name": "ZeroWater", "kind": "filtered tap", "ions": { "tds_mg_l": { "value": 0, "source": "measured" } } }],
  "bottles": [{ "name": "Calcium chloride", "kind": "single", "salt": "CaCl2", "strength": { "mode": "ppm_caco3_per_drop_l", "value": 1, "source": "label" } }],
  "roasters": [{ "name": "Scenery", "city": "London", "country": "United Kingdom" }],
  "remove": [{ "kind": "carafe", "name": "Old server" }]
}
```

Use the exact existing name for an update. Omit collections that the brewer did not ask to edit. To remove an item, use its singular `kind` and exact `name`; removal archives it so prior brews can still reference it. Only include ion numbers when sourced (`"label"` or `"measured"`).

### 2.4 Multi-action paste — `brew-bundle/1`

Include any combination of `profile` (or its alias `gear`), `coffees`, a single `recipe`, and an optional context `request`. Use `summary` for a short description. Use `log_as_past_brew: true` only when logging a past cup. The same flag inside a standalone recipe works independently.

```json
{
  "format": "brew-bundle/1",
  "profile": {"papers": [{"name": "CAFEC Abaca"}]},
  "coffees": [{"name": "Scenery Worka Chelbesa", "original_name": "Scenery Worka Chelbesa", "roaster": "Scenery"}],
  "recipe": {
    "format": "brew-recipe/1",
    "coffee": "Scenery Worka Chelbesa",
    "paper": "CAFEC Abaca",
    "dose_g": 14,
    "water_g": 210,
    "pours": [{"to_g": 50, "start": "ready"}, {"to_g": 210, "start": "0:40"}],
    "total_time": "2:45"
  },
  "log_as_past_brew": true,
  "summary": "Add the coffee and filter, then log the cup."
}
```

### 2.5 Ask for missing context — `brew-request/1`

Ask the brewer for missing context directly, or give them this block to paste into Sip Graph's Home AI Bridge. The brewer can copy the requested selection back to the chat in one tap. `need` is a subset of `gear`, `coffees`, and `brews`. Supply `coffee` to narrow the request and `reason` to explain it briefly.

```json
{"format":"brew-request/1","need":["gear","brews"],"coffee":"Scenery Worka Chelbesa","reason":"Check the grinder and compare the last two cups."}
```

### 2.6 Spreadsheet / Excel Migration Workbook (`.xlsx` or `.csv`)

When a brewer uploads an existing Excel/CSV coffee log to migrate into Sip Graph (`AI Helper → Import Excel / CSV`), **research unclear coffee names first** and **decompose compound cells into granular columns** (e.g. separate `producer`, `washing_station`, `village`, `region`, `origin_country`, `varieties`, and `process` while preserving the exact bag title in `coffee_name` and respecting the brewer's `display_name` preference). Ask the brewer when critical fields like `roast_level` are unclear — never invent unknown facts.

Return a downloadable `.xlsx` workbook with up to 4 named sheets (or `.csv` if `.xlsx` export is unavailable):
- **`Coffees`**: `coffee_name, display_name, roaster, origin_country, region, washing_station, producer, varieties, altitude_m, roast_level, roast_date, process_label, process_base, process_extras, bag_notes, url`
- **`Gear`**: `kind (grinder|dripper|paper|kettle|carafe|scale|water|bottle|roaster), name, brand, unit (numbers|clicks), has_valve (yes|no), empty_g, gh_ppm, kh_ppm, salt, ppm_per_drop_l`
- **`Brews`**: `brew_id, date, coffee_name, grinder, grind_setting, dripper, paper, kettle, water_name, water_drops, dose_g, water_g, temp_c, total_brew_s, final_drain_s, beverage_yield_g, tail_g, finish_kind, pours, bloom_aroma, notes, next_note`
- **`Tastings`**: `brew_id, date, coffee_name, overall_1_to_10, would_brew_again, lead_voice, balance, tension_scope, flavour_notes, mouthfeel_weight, mouthfeel_surfaces, clarity, finish, card_sentence, private_notes`

Link `Brews` and `Tastings` with matching `brew_id` values (e.g. `b1`, `b2`). `flavour_notes` accepts comma-separated notes or stage-tagged strings like `hot: lime, peach | warm: honey | cool: black tea`.

---

## 3. Reading Sip Graph Exports & Share Cards

A public Share Card link at `/s/<id>` covers one cup. It intentionally excludes the brewer's email, account identifiers, general gear shelf, unrelated coffees, earlier brews, and private notes. The author may publish a cup sentence in `card_sentence`. If you need the brewer's wider setup or history, ask them or use the context request above.

WhatsApp image compression can strip PNG metadata. Read the QR code or visible `sipgraph.coffee/s/<id>` URL, then fetch `https://sipgraph.coffee/s/<id>?format=ai` or request the link with `Accept: text/markdown`. This returns the available recipe, brew log, tasting, and a link to this AI spec. Use `?format=json` for the structured share snapshot. The same formats work at `/api/share?id=<id>&format=ai` or `&format=json`.

### 3.1 Brew Record — `brew-record/0.5`
Exported inside `brew-export/2` JSON or Share Card PNG metadata:
- `logged_live`: `boolean` (`true` = live bench timer; `false` = manual post-hoc log).
- `log_source`: `"live_bench" | "manual" | "standalone_taste"`.
- `brew_mode`: `"just" | "quick" | "full"`.
- `total_brew_s`, `final_drain_s`, `brew_ended_at`, `carafe_empty_g`, `carafe_full_g`, `coffee_g`, `tail_g`.
- `bloom_aroma[]`: timestamped bloom aromas tapped while logging (`[{ note: "sweet"|"fruity"|"floral"|"acidic"|"chocolate"|"green"|"sulfur"|"bitter", t_s: number }]`). `bloom_bubbles_stopped_s` (optional integer seconds) records when the brewer tapped "Bubbles stopped now" live during the bloom wait.
- `water`: records the actual kettle water prepared in Prep (`plain: true` when brewed with plain base water / no mineral drops — never assume planned drops were added if `water.plain === true` or `water.drops` is empty).
- `tail`: optional 2nd-cup tail evaluation (`{ tared: boolean, handling: "separate"|"added_back"|"extra_2nd_cup", extra_water_g?: number, like: "good"|"mixed"|"bad", str: "weak"|"mid"|"strong", words?: string }`).
- `pours[]`: each has `plan`, actual `start`, `ctr` (seconds vs planned stop), `scale` + `scaleSrc` (`"read" | "confirmed_plan" | null`), `grams`, `flow`, `flag`, `note`, `edited_post_hoc`, and visual `obs[]` (marked `late: true` if filled after the brew).
- `prep`: explicit checks only (`null` when unlogged).
- `recipe`: exact `brew-recipe/1` block.
- `tasting`: Sip Graph v6 `tasting/4` object (see §3.2).

### 3.2 Sip Graph Tasting Record — `sip-graph/tasting` (`tasting/4`)
- `tasted_stages`: subset of `["hot", "warm", "cool"]` that the brewer actually tasted.
- `passes`: `{ hot?, warm?, cool? }` — each maps the 4 flavor voices (`acid`, `fruit`, `sweet`, `bitter`) to a 4-element integer array `[start, middle, finish, aftertaste]` on scale `0–5` (`0` absent, `1` hint, `2` mild, `3` clear, `4` bold, `5` vivid).
- `lead_voice`, `stage_leads`, `stage_balances`, `stage_tension_scopes`: dominant impression & balance per stage (`tension_scope`: `"whole" | "first_slight" | "late_slight"`).
- `qualities`: per-voice character descriptors (e.g., `acid: ["bright", "juicy"]`).
- `pins[]`: specific flavor notes `{ word, voice, quality?, phase: "aroma"|"start"|"mid"|"end"|"after", fade: "full"|"mid"|"end"|"after", presence: "hint"|"clear"|"upfront", color?, stages?: ["hot"|"warm"|"cool"] }`.
- `feel`: `{ weight, surfaces[], finish, balance, tension_scope, clarity, integration, ripeness, vibrancy }`.
- `off_flavours[]`, `bypass[]`, `mineral_cups[]`, `most[]`, `blind[]`, `overall` (`0–10`), `would_brew_again`, `notes`.

### 3.3 PNG Share Card Metadata (`iTXt` chunks before first `IDAT`)
Sip Graph Share Cards (`1080×1350` PNG) embed uncompressed UTF-8 `iTXt` chunks filtered strictly by the brewer's chosen privacy/share style:

| Chunk keyword | Present in `Pure Print` | `With Memory` | `With Recipe` | `Full Story Card` |
|---|---|---|---|---|
| `Title` | Yes | Yes | Yes | Yes |
| `Description` | Yes (factual, no recipe) | Yes (factual, no recipe) | Yes (factual) | Yes (factual) |
| `SipGraph-System` | Yes | Yes | Yes | Yes |
| `Repeat-Recipe` | **Omitted** | **Omitted** | Yes (`brew-recipe/1`) | Yes (`brew-recipe/1`) |
| `BrewGuide-Data` | Portrait only (no recipe/private notes) | Portrait + `card_sentence` (no recipe/private notes) | Portrait + `recipe` + `brew_log` (no private notes) | Full public cup (`recipe` + `brew_log` + `card_sentence`; private `notes` stay private) |
