Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

test(ops-inbox): een opruiming mag nooit een lopend gesprek begraven (#978)

Aurora Capital75cf38b45f3c
diff --git a/claude-ops/skills/ops-inbox/SKILL.md b/claude-ops/skills/ops-inbox/SKILL.md
index 86298cc9..1a5b0511 100644
--- a/claude-ops/skills/ops-inbox/SKILL.md
+++ b/claude-ops/skills/ops-inbox/SKILL.md
@@ -146,7 +146,7 @@ Every run, in order:
Before drafting to any person, load `relations` for their brief and open
commitments.
1. Resolve WhatsApp accounts (`ops-wa-accounts` — never hardcode a port). Scan every agent-enabled number.
-2. Freshness: `~/bin/wa-inbox-fresh.sh` (blocking, bounded). Then `bin/ops-inbox-scan` (defaults to every enabled account, `--debt-days 90`). Never an unread listing: unread is a display state and is empty for every thread already opened on a phone. Forgotten unanswered asks (archived/read, still their ball, inside 90 days) come back tagged `forgotten`.
+2. Freshness: `~/bin/wa-inbox-fresh.sh` (blocking, bounded). Then `bin/ops-inbox-scan` (defaults to every enabled account, `--debt-days 90`). Never an unread listing: unread is a display state and is empty for every thread already opened on a phone. Forgotten unanswered asks (archived/read, still their ball, inside 90 days) come back tagged `forgotten` — on WhatsApp AND on email, where a Gmail filter or category can hide a live thread from `in:inbox` entirely.
2b. **Every other channel in the same pass, in parallel:** iMessage/SMS (`$HERMES_HOME/bin/imessage-inbox-scan --days 30` — copies `-wal`/`-shm` first or recent messages are invisible; alphanumeric shortcodes and OTP bodies are `fyi`, never `needs_reply`). Slack (`conversations_unreads`, DMs first). Telegram user dialogs if configured. Email is already in the scan. A miss on one channel is not absence on another.
3. **All-context sweep** (Rule 9 + `references/details.md` "ALL CONTEXT SOURCES"): query every configured calendar, mailbox, and messaging channel before any schedule claim or NEEDS_REPLY draft. Google Calendar alone is not enough — Notion show/calendar databases count when Notion is configured.
4. `bin/ops-inbox-archive-set` report-only. Present KEEP vs ARCHIVE; `--apply` only after explicit OK.
@@ -204,6 +204,27 @@ who reads on a phone leaves every real thread at zero unread, so an unread-only
reports inbox zero over a mailbox full of unanswered asks. The working set is what has not
been DEALT WITH (`handled=0`, falling back to `archived=0`), never what has not been seen.
+**AND NEVER SUBSTITUTE A LABEL FOR A CONVERSATION — measured 2026-09-16, email.** The same
+defect has a second shape: `in:inbox` is a LABEL, not a state of the conversation. A Gmail
+filter, a category (Promotions/Updates/Social/Forums), a mute, or one stray archive strips
+INBOX from a live thread, and an inbox-only query then reports the mailbox clean while a
+counterparty waits. Real miss: Salim Jawad at Believe delivered the finished UGC fan videos
+on the `MRT Gen AI Videos` thread; Gmail had filed that thread out of the inbox, so three
+consecutive scans said email was handled and nobody answered him. `ops-inbox-scan` now runs
+a second email pass (`--debt-days`, default 90) over archived, non-promo, human mail and
+reopens every thread whose NEWEST message is inbound and never answered; those rows arrive
+in `email.needs_reply` tagged `forgotten: true` with a `forgotten_count` and a note. The
+rule to carry into any channel you add: **debt is DIRECTION, not label or unread state.**
+The honest test is always "whose message is last in this thread, and did we answer after
+it" — never "is it still in the inbox".
+
+**Slack is an unread listing, so it inherits the same blind spot.**
+`conversations_unreads` only sees what Sam has not opened; a DM he read on his phone and
+never answered is invisible to it. When a Slack answer matters, confirm direction with
+`conversations_history` on the DMs that matter rather than trusting an empty unreads
+result. An empty unreads result means "nothing new was left unseen", never "nobody is
+waiting".
+
**ON SAM'S BOX THE WHATSAPP ZERO IS ALWAYS A LIE — measured 2026-09-06.** Every chat in
both stores is archived and `handled` is maintained on 3 of 1808 rows, so the scan prints
`whatsapp: every chat is archived and handled is not maintained ... inbox zero, not flag
@@ -313,12 +334,16 @@ classification (and _better_ — it merges each person's lid↔phone chats into
conversation and resolves real names from `contacts`) for free. Reserve agent fan-out for
genuine reasoning, not for reading a database.
-`ops-inbox-scan` JSON always includes `whatsapp` / `email` buckets (`needs_reply`, `waiting`, `groups`, `fyi`) plus `whatsapp_account` and `counts`. Partial failure still emits valid JSON.
+`ops-inbox-scan` JSON always includes `whatsapp` / `email` buckets (`needs_reply`, `waiting`, `groups`, `fyi`) plus `whatsapp_account` and `counts`. Partial failure still emits valid JSON. Email rows carrying `forgotten: true` were archived or filtered out of the inbox but still owe a reply (see `forgotten_count` and the matching note) — treat them exactly like inbox rows.
**What the script does NOT do — and what you do next, in the MAIN session (no subagents):**
1. **Slack** — one `mcp__slack__conversations_unreads {include_messages:true}` call. One
round-trip; a subagent is pure overhead. Skip entirely if prefs show 0 workspaces.
+ Remember what this call can and cannot see: it is an UNREAD listing, so a DM Sam read on
+ his phone and never answered does not appear. Empty unreads is not "nobody is waiting".
+ For any workspace where a real answer is owed, check direction with
+ `mcp__slack__conversations_history` on the DMs that matter.
2. **Telegram** — one `mcp__plugin_ops_telegram__list_dialogs` call (skip the
Pocket ops bot dialog — that's automation). Skip if unconfigured.
3. **FULL-THREAD AWARENESS GATE on the few NEEDS_REPLY candidates** — the script's WhatsApp
diff --git a/claude-ops/tests/test-ops-inbox-archive-set.sh b/claude-ops/tests/test-ops-inbox-archive-set.sh
index 9bd02c61..6fea313b 100755
--- a/claude-ops/tests/test-ops-inbox-archive-set.sh
+++ b/claude-ops/tests/test-ops-inbox-archive-set.sh
@@ -36,7 +36,12 @@ sed 's/[[:space:]]*#.*$//' "$SCAN" >"$CODE"
grep -q 'EMAIL_QUERY="in:inbox"' "$CODE" \
|| fail "email working set must default to the whole inbox"
-grep -q 'newer_than' "$CODE" \
+# EMAIL_QUERY itself must carry no recency slice. `newer_than` is legitimate
+# elsewhere in the script: the forgotten-debt sweep is deliberately bounded by
+# --debt-days, exactly like the WhatsApp one. Scope the ban to the inbox query.
+grep -q 'EMAIL_QUERY="[^"]*newer_than' "$CODE" \
+ && fail "email query must not be sliced by a recency window"
+grep -q 'EMAIL_QUERY="\$EMAIL_QUERY newer_than' "$CODE" \
&& fail "email query must not be sliced by a recency window"
grep -q 'WHERE {done_pred} OR' "$CODE" \
|| fail "whatsapp working set must be a done-flag predicate, not a recency slice"
diff --git a/claude-ops/tests/test-ops-inbox-email-forgotten-debt.sh b/claude-ops/tests/test-ops-inbox-email-forgotten-debt.sh
index 204c41e0..c258d223 100755
--- a/claude-ops/tests/test-ops-inbox-email-forgotten-debt.sh
+++ b/claude-ops/tests/test-ops-inbox-email-forgotten-debt.sh
@@ -116,6 +116,15 @@ cat >"$FIX/archived.json" <<'JSON'
"subject": "50% off everything",
"labels": ["CATEGORY_PROMOTIONS"]
},
+ {
+ "id": "swept-oneway-1",
+ "threadId": "t-swept-oneway",
+ "date": "2026-09-13 09:00",
+ "internalDateIso": "2026-09-13T09:00:00+02:00",
+ "from": "Cold Pitch <[email protected]>",
+ "subject": "Quick intro about our platform",
+ "labels": ["CATEGORY_PERSONAL"]
+ },
{
"id": "robot-1",
"threadId": "t-robot",
@@ -155,11 +164,27 @@ cat >"$FIX/sent.json" <<'JSON'
}
JSON
+# A bulk sweep stamps every archived thread in one second. That watermark must
+# silence the one-way pitch, and must NOT silence a conversation Sam is in:
+# archiving is a filing decision, never proof that a reply was sent. On
+# 2026-09-16 a watermark over 1007 threads wiped all 12 genuine two-way threads
+# out of the result — this fixture pins that it cannot happen again.
+WM_DIR="$TMP/hermes/state"
+mkdir -p "$WM_DIR"
+cat >"$WM_DIR/ops-email-sweep-watermarks-sam_example.com.json" <<'JSON'
+{
+ "t-believe": "2026-09-16 09:00:00+00:00",
+ "t-swept-oneway": "2026-09-16 09:00:00+00:00"
+}
+JSON
+
run_scan() {
OPS_TEST_FIXTURES="$FIX" \
PATH="$TMP/bin:$PATH" \
GOG_ACCOUNT="[email protected]" \
+ GMAIL_ACCOUNT="[email protected]" \
GOG_KEYRING_PASSWORD="test" \
+ HERMES_HOME="$TMP/hermes" \
"$SCAN" --email-only --debt-days 90 2>/dev/null
}
@@ -187,6 +212,12 @@ else
&& ok "archived thread where they spoke last comes back as forgotten" \
|| bad "Believe thread landed in '$b'"
+ # Same thread also carries a sweep watermark. A conversation Sam wrote into
+ # must survive it; only the direction test may close it.
+ [ "$b" = "needs_reply:forgotten" ] \
+ && ok "bulk sweep watermark does not bury a two-way conversation" \
+ || bad "watermark buried a thread Sam participated in"
+
b="$(bucket_of "$OUT" "Still in the inbox")"
[ "$b" = "needs_reply:live" ] \
&& ok "ordinary inbox thread stays live, not forgotten" \
@@ -207,6 +238,11 @@ else
&& ok "no-reply sender stays shut" \
|| bad "robot mail came back as '$b'"
+ b="$(bucket_of "$OUT" "Quick intro about our platform")"
+ [ "$b" = "ABSENT" ] \
+ && ok "one-way pitch we swept stays filed (watermark honoured)" \
+ || bad "swept one-way pitch came back as '$b'"
+
grep -q "archived/filtered thread" <<<"$OUT" \
&& ok "scan states that it reopened filtered mail" \
|| bad "no note explaining the email reopen"