aboutsummaryrefslogtreecommitdiff
path: root/.ai/workflows/triage-intake.personal-gmail.org
blob: 7d1ab4ddc11bb8d5d309bc6fa8b0ab459ee3a0b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#+TITLE: Triage Intake — Personal Gmail Source
#+AUTHOR: Craig Jennings
#+DATE: 2026-05-26

# Source plugin for the triage-intake engine. See triage-intake.org for the
# contract and the Phase A-D orchestration. This file declares ONE source.

* Source: personal-gmail
:PROPERTIES:
:ORDER:         20
:ENABLED:       mcp google-docs-personal present
:ANCHOR:        epoch
:SUBAGENT_OVER: 50
:END:

** Scan

Personal Gmail unread in the inbox since the anchor:

#+begin_src text
mcp__google-docs-personal__listMessages  q="is:unread in:inbox after:<anchor-epoch>"  maxResults=100
#+end_src

⚠ *Express the cutoff as the literal UNIX epoch* — =after:1778856990=, not =after:YYYY/MM/DD=. Gmail's =after:YYYY/MM/DD= operator only supports day resolution; the =YYYY/MM/DD HH:MM:SS= form is NOT valid syntax — Gmail parses the space as a term separator, treats =HH:MM:SS= as a search term that never matches, and returns 0 results, silently masking unread mail. The engine supplies =<anchor-epoch>= because this source declares =ANCHOR: epoch=.

⚠ *Do NOT add =-category:promotions -category:social=.* That filter masked 67 promo+social messages across two runs (2026-05-04, 2026-05-06), both needing a follow-up sweep. Pull the full unfiltered set; the trash-leaning bias in Classify handles promotions and social directly.

⚠ *The MCP caps at =maxResults=100= and exposes NO =pageToken= parameter.* The response carries a =nextPageToken=, but the tool can't consume it, so a pile over 100 is silently truncated — the tail below the cap never gets classified, and every later anchored sweep skips it (it predates the new anchor). This is exactly how a 300+ backlog accumulated invisibly by 2026-07-08. Two consequences:

- *Never treat a 100-row result as complete.* When a scan returns exactly 100, walk the tail in *date slices*: re-query with =before:<oldest-full-day-seen>= (day resolution), repeat until a page returns fewer than 100, dedupe by message id across slices (the day-resolution boundary overlaps).
- *Never report =resultSizeEstimate= as a count.* It's unreliable — observed stuck at "201" across three different queries whose real union exceeded 300.

*** Backlog-residue check (every sweep — cheap, mandatory)

The anchored scan is blind to anything unread from *before* the anchor. After it, run one probe for pre-anchor residue:

#+begin_src text
mcp__google-docs-personal__listMessages  q="is:unread in:inbox before:<anchor-YYYY/MM/DD>"  maxResults=5
#+end_src

If it returns any messages, surface one loud line in the sweep summary: "Backlog: unread predating the anchor exists (N+ shown; date-slice to inventory)" and offer a backlog sweep. Never fold the residue into a quiet sweep — an anchored "no changes" claim is only true for the window the scan saw. (Added 2026-07-08 after ~300 pre-anchor unread accumulated unseen; the probe returns actual messages, so it works where the estimate lies.)

** Classify

Bias: *trash-leaning* — personal Gmail is high noise volume.

- *Noise-trash:* newsletters, Substacks, retail/SaaS marketing, social digests, redundant aggregator digests (Notion/Miro daily), wrong-recipient mail, past-event calendar artifacts.
- *Noise-keep:* receipts, order confirmations, statements — low value but worth the audit trail.
- *FYI:* substantive personal mail with no action owed.
- *Action:* an explicit ask, a reply owed, a time-sensitive personal matter.

** Render

#+begin_example
**Personal Gmail — N unread.** <one-line classification summary>
- Action: <items, if any, with thread links>
- FYI: <items, if any>
- Noise: N trash candidates, M keep
#+end_example

Omit the block if zero unread.

** Actions

- trash       :: =mcp__google-docs-personal__trashMessage= id=<message-id>  (recoverable from Gmail Trash for 30 days)
- mark-read   :: =mcp__google-docs-personal__modifyMessageLabels= id=<message-id> removeLabelIds=["UNREAD"]
- star+read   :: =mcp__google-docs-personal__modifyMessageLabels= id=<message-id> addLabelIds=["STARRED"] removeLabelIds=["UNREAD"]
- attach-fetch:: =.ai/scripts/gmail-fetch-attachments.py --profile personal --message-id <message-id> --output-dir <PATH>=