Sort, filter and page mail_search on a UTC key; show UTC dates; give mail_thread a cursor #108
Labels
No labels
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:go
svd:hold
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp#108
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #106 (items 2, 6 paging, 10). Decided at triage 2026-11-02: rows show UTC with Z; semantic and hybrid paging are out of scope.
Agent Brief
Category: bug
Summary: Sort, filter and page mail_search on a UTC key; show UTC dates; give mail_thread a cursor
Current behavior:
Sources store the message date as ISO 8601 with the sender's offset. Search order,
sinceandbeforecompare that text with the fallback internaldate, so two messages with offsets +11:00 and +00:00 can sort up to 11 hours out of order, and a bound can include or drop mail by the same amount. Row cells show the first 16 characters of the stored date, which drops the offset. The search cursor is a row offset, so a sync pass between two pages moves rows across the page boundary. mail_thread shows the firstlimitmembers and reportsthread_sizeandshown, but has no cursor, so a thread longer than the cap can never be read past it.Desired behavior:
Z, minute precision as today. mail_read keeps the stored form with its offset.sinceandbeforeaccept a date (YYYY-MM-DD) or a date-time with an offset, compare as UTC instants, and keep inclusive and exclusive semantics. A plain date means midnight UTC.next_cursor=-still means no more.moreandtotalstay in the footer.cursorand returnsnext_cursorwiththread_sizeandshown, paging oldest first.Key interfaces:
SearchParams:since,beforeand the cursor change meaning; the store's filter builder and search query use the UTC key.mail_searchandmail_threadsignatures:cursoron mail_thread; parameter descriptions say UTC.Acceptance criteria:
2026-01-01T09:00:00+11:00and2026-01-01T01:00:00+00:00sort with the +00:00 one first (newest first), andsince=2026-01-01includes only the +00:00 one (2026-01-01T01:00Z) whilesince=2025-12-31includes both.since=2026-01-01T00:00:00+11:00is the same bound assince=2025-12-31T13:00:00Z.2025-12-31T22:00Z.next_cursor=-.Store(reader=True)on an unmigrated store raises a clear error rather than writing.make checkpasses.Out of scope:
Filed under: operator word "accept" sha256:c125d0397b60
⏸ SVD architect gate: dev/mail-mind-mcp#108 sort-filter-and-page-mail-search-on-a-utc-key-show-utc-dates
Status: CLEAN after 0 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity
substrate· dispatch efforthighRun:
20261102T111548Z-fe47ae00Held because: CLEAN but 3 open risk(s) (2 verification · 1 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
python scripts/bench_search.py --queriesfor base and head at least three times each. Pass: the head medians of the 'lorem' and '1234' rows (keyword search at 210k rows) are ≤ 10% above base. Record every number in the PR. The script uses only store.search(SearchParams(...)), whose shape is unchanged, so one script runs against both trees. [verification]uv run python3 -m pytest -q -m "not integration"on the host. If a test outside the Primary Files fails on ordering or format, fix it only while the total stays ≤ 16 files. Otherwise stop and report that file instead of widening scope. [verification]Change: Add a stored messages.date_utc column at schema v14 ('YYYY-MM-DD HH:MM:SS' UTC). It is computed by
_utc_key(), which isCOALESCE(_copy_date(row), the same GLOB-guarded datetime(internaldate), '')and mirrors_copy_dateat store.py:276. AFTER INSERT and AFTER UPDATE OF date, internaldate triggers keep it current, so raw INSERTs in the bench and tests stay correct; this mirrors messages_recipients_ad at :268. Amessages_date_utc (date_utc DESC, id DESC)index is created in a_V14_SCRIPTrun by_add_columnsafter the ALTERs (mirroring_V5_INDEXES). A chunked_fill_utc_keysbackfill runs on the writer's open, mirroring_fill_recipientsat :558-571; the reader keeps the existing_wait_for_schemaerror._filterscomparesdate_utcagainst_utc_bound(since/before)(date = midnight UTC, offset date-time converted, invalid → invalid_argument), with a+under keyset=True like the account term at :1564. A newsearch_pagereturns (rows, total, more) and pages by the row-value keyset(date_utc, id) < (?, ?);search()stays a two-tuple wrapper, so its 62 test callers are unchanged. In server.py: opaque base64url keyset cursors (mirroring ids.encode_source/decode at ids.py:51-70) for keyword/filter mail_search and mail_triage_rows, while ranked modes keep offset cursors;_row_cellsshowsYYYY-MM-DDTHH:MMZ; mail_thread gets a cursor and anext_cursor=X thread_size=N shown=Mfooter, with joined_thread ordered by (date_utc, id); people and evidence read NULLIF(date_utc,''); changesatis shown with Z. mail_read is unchanged.Files:
src/mail_mind_mcp/store.py·src/mail_mind_mcp/server.py·README.md·tests/test_utc_dates.py·tests/test_store.py·tests/test_server.py·tests/test_copies.py·tests/test_copy_collapse.py·tests/test_panel.py·tests/test_evidence.py·tests/test_embed_scans.py·tests/test_recipients.py·tests/test_attachment_vectors.py·tests/test_attachments.pyDecision: accept the 3 open risk(s) above and dispatch this spec (
svd:go), or park (svd:skip) / re-spec (svd:respec)?Your call (when this issue is held at the gate via
svd:hold):svd:go— approve; Half-B dispatch accepts exactly this spec (open risks accepted)svd:firebesidesvd:go— approve AND authorise the Half-B fire from the phone; never on its ownsvd:skip— park it; dispatch refuses it and the issue stays for a humansvd:respec— discard this spec; the next Half-A run re-produces it with this record as prior-attempt contextSpec:
/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-sort-filter-and-page-mail-search-on-a-utc-key-show-utc-dates.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-sort-filter-and-page-mail-search-on-a-utc-key-show-utc-dates.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#108 sort-filter-and-page-mail-search-on-a-utc-key-show-utc-dates completed integration verify.
39e4f75ec739e4f75: no remote checks (none reported); local host suite 864 passed, 8 skipped, 0 failed.39e4f75; the repo has no CI (.woodpecker files are added by the architect). — reported as absent, not blocking (gh#633)codex-svd ship --run-id 20261102T113230Z-19b0fa26 --confirm-merge)