8000 feat(sources): shared routing rules for an email account by adeelahmad · Pull Request #597 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(sources): shared routing rules for an email account - #597

Merged
adeelahmad merged 4 commits into
mainfrom
claude/project-thread-kxg3y5
Oct 18, 2026
Merged

adeelahmad merged 4 commits into
mainfrom
claude/project-thread-kxg3y5

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: routing rules for a shared inbox (#153, #184) lived only on each watch, so an account watched in several mailboxes needed the same rules copied onto every watch, and agents had no way to read or change any of them.

After: an IMAP or Gmail account can carry shared routing rules that every watch on it uses. A watch tries its own rules first, then the account's, then sends the message to its namespace, so a watch's rule can still make an exception. With no shared rules nothing changes.

How:

  • storage_source.routes (email accounts only), checked with mail_routes.check like a watch's rules; mail_routes.decide tries the watch's list, then the account's. poll_watch records shared: true on a file a shared rule decided.
  • PUT /api/v1/sources/{id}/routes saves them (audited source.routes); GET /sources shows them. The routes preview takes shared_routes (else the saved ones) and each row says shared; its namespace now defaults to "".
  • MCP mail_routing lists every email account's shared rules and each watch's own, as lines (from: *@acme.com = finance, the format mailbox.routes already uses), and set_mail_routing replaces an account's shared rules or one watch's own.
  • Web: Sources › an email account's More menu › Routing rules opens the same rules editor in shared mode, with the preview; a watch's preview marks rules that came from the account ("shared rule 2").

Motivation and Context

The queued item "Global admin-level routing rules for a shared source (one IMAP inbox to namespaces)" in the feature list (#153 #184).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote a fragment in changelog.d/imap-shared-routes.md.

Done questions (AGENTS.md)

  • Goal: shared rules for one inbox feeding several namespaces; merged on green CI.
  • Agents: REST API plus MCP mail_routing / set_mail_routing (test_agents_read_and_change_routing_rules).
  • Zero setup: nothing new to install or configure.
  • Fewest clicks: one menu item opens the editor; Enter in a pattern saves; the first namespace is preselected.
  • Configurable: edited in the web app; the default is no shared rules.
  • Light: plain pattern matching, no model calls.
  • Private and secure: admin-only endpoint and tools (write scope for changes), audited; no new outside input, so no threat-model change.
  • Cost: no model calls.
  • User decides: rules apply only when an admin saves them; existing watches behave exactly as before.
  • Upgrades: n/a, an optional new field on a schemaless table; missing means no rules.
  • Honest: README and docs/requirements.md list it with its checks.
  • Tests, docs and generated files updated (openapi.json and the client regenerated with tooling).
  • Open standards; no new dependencies.
  • Refine later: rules set through MCP lines drop rule names; a decision-model "pick among namespaces" rule stays planned; the preview can briefly show the previous rules while typing (existing debounce behaviour).
  • Reuse: reuses mail_routes, the watch rules editor and the line format from the assistant's mailbox.

Local CI (ci/local-ci.sh): backend (embedded SurrealDB), Next.js, pre-commit and title pass; server and upgrade jobs re-running after Docker was started.


Generated by Claude Code

An IMAP or Gmail account can carry routing rules every watch on it uses,
tried after the watch's own rules and before its namespace. PUT
/api/v1/sources/{id}/routes saves them, the routes preview takes
shared_routes and says which list decided, and the MCP tools
mail_routing and set_mail_routing read and change every account's and
watch's rules as lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UyrGrwCVGT6fLPEubx5puU
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UyrGrwCVGT6fLPEubx5puU
@adeelahmad adeelahmad self-assigned this Oct 18, 2026
@adeelahmad
adeelahmad merged commit bb548ce into main Oct 18, 2026
12 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-kxg3y5 branch October 18, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0