Nudge the assessor and the embedder when a sync pass adds mail #47

Merged
svc-agent-writer merged 1 commit from feat/nudge into main 2026-10-31 13:28:02 +00:00

Merge after #46. This branch is stacked on it, so the diff shows #46's commit until #46 merges.

Summary

Before this change, the assessor (and in #46 the embedder) looked for new rows every poll_seconds (default 60). New mail could therefore wait up to a minute for its triage class, and so for a wake.

  • Assessor and EmbedWorker each get a nudge event. Each tick clears it first, so mail that arrives during a tick starts the next tick at once.
  • SyncWorker._loop sets every nudge after a pass that added at least one message. With IDLE, a pass runs as soon as INBOX changes, so triage and embedding now start seconds after mail lands.
  • poll_seconds stays as the fallback, which retries a failed Jev call.
  • A stop also sets the nudges, so sync shuts down at once instead of after up to poll_seconds.
  • The assess module docstring says that backlog_days only bounds the first enable: each message is sent to Jev once.

Test plan

  • make check: 124 passed, audit clean.
  • test_a_nudge_ticks_before_the_poll_and_a_stop_ends_the_wait: with poll_seconds = 3600, a nudge runs a second tick at once, and stop plus nudge ends the thread.
  • test_a_pass_that_adds_mail_nudges: a pass that adds 0 messages does not nudge, and a pass that adds 2 does.

🤖 Generated with Claude Code

Merge after #46. This branch is stacked on it, so the diff shows #46's commit until #46 merges. ## Summary Before this change, the assessor (and in #46 the embedder) looked for new rows every `poll_seconds` (default 60). New mail could therefore wait up to a minute for its triage class, and so for a wake. - `Assessor` and `EmbedWorker` each get a `nudge` event. Each tick clears it first, so mail that arrives during a tick starts the next tick at once. - `SyncWorker._loop` sets every nudge after a pass that added at least one message. With IDLE, a pass runs as soon as INBOX changes, so triage and embedding now start seconds after mail lands. - `poll_seconds` stays as the fallback, which retries a failed Jev call. - A stop also sets the nudges, so `sync` shuts down at once instead of after up to `poll_seconds`. - The assess module docstring says that `backlog_days` only bounds the first enable: each message is sent to Jev once. ## Test plan - `make check`: 124 passed, audit clean. - `test_a_nudge_ticks_before_the_poll_and_a_stop_ends_the_wait`: with `poll_seconds = 3600`, a nudge runs a second tick at once, and stop plus nudge ends the thread. - `test_a_pass_that_adds_mail_nudges`: a pass that adds 0 messages does not nudge, and a pass that adds 2 does. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An embedder thread in the sync process stores one bge-small-en-v1.5 int8 vector per message (ADR 0005). It copies vectors across moved copies, resumes a backfill, re-embeds on a model change, and uses one core. The image carries the model, fetched and hash-checked at build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New mail no longer waits up to poll_seconds for triage or a vector: a pass that adds messages wakes both threads at once. poll_seconds stays as the fallback that retries a failed call. A stop also wakes them, so shutdown does not wait for the poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.