Repository navigation
Conversation
The groundwork of Rules and Automatic Replies kept on an IMAP server in Sieve; nothing in the window uses it yet. - proto::managesieve: a ManageSieve client (RFC 5804) over any Read + Write stream: capabilities, STARTTLS, SASL PLAIN (RFC 4616) or XOAUTH2 / OAUTHBEARER (RFC 7628), LISTSCRIPTS, GETSCRIPT, PUTSCRIPT, CHECKSCRIPT, SETACTIVE, DELETESCRIPT, HAVESPACE, LOGOUT. A referral is never followed; a script's name is quoted and its text sent as a counted literal; every line, string, response and count is bounded, a listing that can't be kept whole is refused and one command keeps at most a megabyte. - net::sieve: an IMAP account's Sieve scripts on its IMAP host, port 4190, or on the host and port named for it (Account::sieve_host, sieve_port), over STARTTLS only (plain only to loopback, for the tests); the sign-in goes to those hosts alone. write replaces MailCraft's script only while it is still what MailCraft last wrote there (SHA-256 digest) and never makes another script inactive; write_own writes the owner's own script back only while it is still the one read and active, after HAVESPACE. When no session can be had it says what it found (Reach), naming the host and port, telling a port that expects TLS from the first byte by a TLS hello on a connection of its own. A fake ManageSieve server for the tests (fake_sieve.rs). - engine::sieve: the bounded Sieve reader (RFC 5228 tokens and comments, with where each is and why a text stops being Sieve) and quoting; engine::sieve_check: a whole script, or a block for MailCraft's script, checked with a line and column for each problem, from one table of the commands, tests and tags of RFC 5228 and its extensions, with what each needs and what it can do. - Fuzz targets managesieve and sieve_check, in fuzz.yml; property tests. - Docs: architecture (proto, net), mail privacy rules (where Sieve scripts go); progress and revision fragments; translation catalogues. Human-reviewed, AI-assisted, nobody's mailbox harmed.
- engine::sieve: MailCraft's own script, "mailcraft", written from the replies (vacation, RFC 5230; a time range as currentdate, RFC 5260, with relational's :value, RFC 5231; inside the organisation by the address's domain) and read back; every value one quoted string, so no reply, address or domain changes the script's shape (property tests). - Account::sieve_written keeps the digest of what MailCraft last wrote, never the text (sha2, in the browser too). account.automaticReplies and account.setAutomaticReplies take IMAP accounts; sync.applySieve (host only) takes in what the server has. A script changed elsewhere is never written over unless the owner chooses Replace with MailCraft's, bound to the script as seen; the owner's own active script stays active; contactsOnly and, without date tests, a time range are refused. - account.edit's sieve: another ManageSieve host or port (Account Settings › Sieve server); what was known of the server before is forgotten when it changes. - The window: File › Info's line and Try again, the Automatic Replies dialog in its Sieve shape, the status bar only while MailCraft's script is the one running; what was found where the server was looked for is said, naming the host and port. The desktop app's Sieve job runs on a background thread (sieve_job.rs); flow tests through it to the fake server. - Docs: ROADMAP item 11, gap 17, ui-parity Backstage, mail privacy rules; fragments and release note; translation catalogues. Human-reviewed, AI-assisted, nobody's mailbox harmed.
In the current Rules and Alerts layout; the relayout comes in UCSLabs#2058. - Rules an IMAP account's server can keep go into MailCraft's script after the replies, one block each, when Sieve says them exactly (sender's, recipients', subject's and body's words and addresses, mail to me, size; move, copy, delete, mark as read, flag, clear the flag, stop); the others stay on this computer, saying which part. sync.sieveScript says what the script is to become; Rules and Alerts says what keeps them off the server, with Replace with MailCraft's. - The owner's own active script (and MailCraft's once changed elsewhere) read with a bounded parser and its rules listed under its name, with webmail names, header tests and switched-off rules (sieve_elsewhere, sieve_rainloop; Condition::Header in the model). - Change Rule (rules.edit), Sieve rules (rules.addSieve, rules.editSieve), the Sieve editor with the local check and the server's CHECKSCRIPT, the owner's script edited whole (sieve.ownScript, sieve.putOwnScript), RainLoop/SnappyMail filters changed in place (rules_webmail), every rule changed in the builder when that loses nothing, else as its Sieve (sieve.ownBlock, sieve.putOwnBlock, rules.toSieve). - Agents: every new command has a class; Sieve that sends, answers, runs a program, is unknown or unreadable asks as send, from sieve_check's table. - Tests: engine, model, flow tests to the fake server, kittest tests of the builder and the Sieve editor inline; hostile_params_never_panic covers the new commands. - Docs: mcp, mail privacy rules, gaps, ROADMAP, ui-parity, parity checklist (Change Rule); fragments and release notes; translations. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…r and its tests tightened From CodeRabbit's review of UCSLabs#2058: - The probe that tells a silent server reads on until it has the two bytes a TLS record begins with, within the same wait, when the first read brings one. - The fake server keeps the first bytes across reads before answering a TLS hello, says the same capabilities in its greeting and on CAPABILITY (SASL and STARTTLS only before sign-in, VERSION only when set), refuses a literal larger than any script before allocating, and answers PUTSCRIPT with its configured warnings. - It keeps what each connection that isn't greeted received, and the tests of servers that don't greet assert that the first connection got nothing and a second one only a TLS hello, without the password. - The password test asserts that nothing was sent to a server offering no password mechanism. Human-reviewed, AI-assisted, nobody's mailbox harmed.
…es need variables, exact server names From CodeRabbit's review of UCSLabs#2058: - `:last` without `:index` is an error (RFC 5260). - setflag, addflag, removeflag and hasflag with their variable need `variables` (RFC 5232); with the flags alone `imap4flags` is enough. - Every required extension, known here or not, is looked for on the server by its exact name; one rule says what gives what (spamtestplus gives spamtest, vacation-seconds gives vacation), and a block needing spamtestplus no longer needs spamtest too. - What each `ihave` in an `allof` names counts in its block (not in `anyof`, nor under `not`). - After a tag not known here, in a whole script requiring an extension MailCraft doesn't know, the positional count is left to the server. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 1 with main merged in, and its fixes after CodeRabbit's review. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 1 with main merged in, and its fixes after CodeRabbit's review. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…aren't kept on the server As the maintainer suggested on UCSLabs#2058, and as the owner decided: two rules of an IMAP account meant for the server (switched on, made in the form, each one Sieve can say) that move mail to different folders, the first of them not stopping the rules after it, are not written to the server's script. There a message both match would be filed into both folders, where MailCraft ends with it in one. Both run on this computer. - `sieve_rules::folder_clash` says which other rule and which folders; `server_cannot` gives NotOnServer::FolderClash, and `not_on_server_said` the full text, naming both rules and both folders. - Rules and Alerts says it under each rule, and the builder of a new one; `rules.list` and `rules.edit` say it as "why" for agents. - Asked for the server explicitly (`rules.add`/`rules.edit` with "server": true, `rules.keepOnServer`), the command fails with the same text. Otherwise the rule stays meant for the server, and goes there once the other one stops, moves into the same folder, is switched off or deleted. - Delete counts as a move to Deleted Items; copies, and Sieve rules the owner wrote, are left out. Tests: two_rules_moving_one_message_to_different_folders_both_run_here_and_say_which (engine) and each_rule_says_which_other_rule_and_folders_keep_both_off_the_server (kittest). Gap 17, its revision row and the release note say so. Human-reviewed, AI-assisted, nobody's mailbox harmed.
…the Sieve editor and their tests From CodeRabbit's review of UCSLabs#2058: - An agent's question shows Sieve text as it is: each line with its spaces at both ends, blank lines too, joined by ⏎. - The builder lets go of a rule deleted by another command on the next frame, not only after a command of its own. - A filter of a webmail's script is offered only its own account's folders, and another can't be saved. - The Sieve editor paints the gutter for the rows in view only. - Tests: a property over canonical webmail filters that requires the save to succeed and the bytes to stay; Edit as Sieve… reached through the row's right-click menu; the no-owner-script case on a server with MailCraft's script alone; the cursor at the problem's line and column. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 1 with main merged in, and its fixes after CodeRabbit's review. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 2 with part 1 and main merged in. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…the owner's script Part 1's check now looks for every required extension on the server, known here or not. The owner's whole script still refuses only a known extension the server lacks: one MailCraft doesn't know stays a warning, as its contract says (sieve_own_tests covers both). Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…nse codes, a broken session sends nothing CodeRabbit on UCSLabs#2106: - A listing with more than one ACTIVE script is refused (RFC 5804 has at most one). - An unknown response code's arguments are passed over whole, lists nested in them and all (RFC 5804 §4 extension-data); unbalanced parentheses are still an error. - After an answer that wasn't read to its end (too many lines, too long, unreadable, BYE), or a command that couldn't be sent, the session is broken and sends nothing more: a later command would take the leftover OK for its own. A whole NO, or a name refused before sending, leaves it usable. - LOGOUT: a NO or a garbled answer is an error, and so is a LOGOUT that couldn't be sent; BYE or a hang-up after it is a goodbye. - HAVESPACE: only QUOTA and QUOTA/... say there is no room. - A quoted string counts its escapes towards the 1024-octet limit; longer goes as a literal. - U+061C is taken out of a server's words like the other direction marks. - The session's Debug output shows counts, never the server's IMPLEMENTATION text. - The invalid-UTF-8 fixture declares its literal's real length. Human-reviewed, AI-assisted, nobody's mailbox harmed.
…e script read last, stops seen while waiting CodeRabbit on UCSLabs#2106: - read: the capabilities are asked for again once signed in (they may change then, RFC 5804 §1.7); a server that refuses CAPABILITY keeps what it said before. - write: the listing is read again after PUTSCRIPT, just before SETACTIVE; a script another program made active meanwhile stays active (AnotherActive). The window that remains is said. - write_own: the script's text first, then the listing, last before PUTSCRIPT: one switched off while its text was read isn't written. - The greeting's first words are waited for when they come in pieces (a line, or the 16 bytes looked at, within the same wait), so what answered is told the same either way. - A stop is seen while the greeting is waited for and while the TLS hello's answer is, in slices of 100 ms, and no reason is made of a probe that was stopped. - The fake refuses DELETESCRIPT of a script it doesn't have (RFC 5804 §2.10). - Tests: the stop test waits on the fake's connection instead of a sleep; the silent cases require the TLS hello on the second connection; the split-alert reading is tested without a socket, and the socket peer's waits are bounded; the oversized-literal test fails on a timeout. Human-reviewed, AI-assisted, nobody's mailbox harmed.
…t to right in allof, unknown guards CodeRabbit on UCSLabs#2106: - `:last` needs `:index` only where the command has one (the index tests, deleteheader); `addheader :last` and `duplicate :last` stand on their own (RFC 5293, RFC 7352). - In an `allof`, the tests after an `ihave` may use what it names (RFC 5463 §3: left to right, once it held); not before it, not in `anyof`. - One predicate says when what isn't known here is a warning (an unknown require, or an unknown `ihave` guard, never in a block); the positional count and the order of arguments after an unknown tag follow it. - Required extensions are looked up in a set, for the server check and for `declared`: a require list of tens of thousands of names is checked in linear time. Human-reviewed, AI-assisted, nobody's mailbox harmed.
CodeRabbit on UCSLabs#2106: the five ManageSieve texts left empty in cs, de, es, fr, hu, it, ka, nl, pl, ro and zh_CN, and the 84 Sieve texts in he, ja, pt_BR, pt_PT and sl, as drafts marked fuzzy; with the new text of a session that can't go on. No translation of main changed. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
… them CI on UCSLabs#2108: a_canonical_filter_saved_unchanged_is_written_back_byte_for_byte generated names with a Hangul filler (U+115F, U+3164), which mailcraft_names takes out of every name on purpose; the code is right. The generator keeps only names mailcraft_names::incoming leaves as they are, through the crate's own function, so it can't drift from it. The RainLoop and elsewhere name properties check names the same way instead of a hand-made list. The two CI seeds are in proptest-regressions, and a plain test pins both cases: read without the filler, saved unchanged with that name and the rest byte for byte. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
he, ja, pt_BR, pt_PT and sl had none of Automatic Replies' texts; the other catalogues one. Drafts, marked fuzzy, for review by native speakers. Human-reviewed, AI-assisted, nobody's mailbox harmed.
With part 3's texts as fuzzy drafts in every catalogue (he, ja, pt_BR, pt_PT and sl had none of them, the others 11), for review by native speakers. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…script after a write, stops in the handshake, quieter probe and Debug - A BYE (REFERRAL) to CAPABILITY or HAVESPACE after signing in is said as a referral: only a refusal that leaves the session usable falls back (ManageSieve::is_broken). - write: the listing after the write says whether the script is active, whether or not it is to be made active. - write_own: a plain NO to GETSCRIPT for a script the listing no longer has is a change (the script is gone), RFC 5804 §2.9 having NONEXISTENT as a SHOULD; a listed one keeps the refusal. - check: the server's words are capped again after the secret is blanked out. - The TLS handshake after STARTTLS watches the stop flag; a stop is said as one, not as a failed secure connection. - The probe's TLS hello resumes no earlier session. - Capabilities' Debug shows counts and flags, none of the server's words. - LOGOUT: a timeout with the connection open is an error; OK, BYE and a hang-up are goodbyes. - A cancelled sign-in reads one response; data in place of NO ends the session. - Tests: the fake's CAPABILITY must be accepted; the redaction test uses a real literal and checks the exact refusal. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
No conflicts. `cargo xtask i18n` re-sorted the catalogues (the branch's entry for "A name must follow the colon." moves after main's new "A message to somebody who has no Public key …"), and `cargo xtask parity` counts main's new command (405). Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 1 brings in main. Conflicts: - crates/i18n/po/*.po (15 catalogues): both sides added entries next to each other. Merged entry by entry against the merge base: every entry of either side kept with its translation, none blank where either side had one, no translation changed on both sides; then `cargo xtask i18n`. Checked: 0 of main's translations lost or changed, 0 of this branch's. Main's "Automatic replies are kept on the mail server, and MailCraft can set them only for accounts that sign in with Microsoft so far …" stays gone: this part replaced it with the ManageSieve wording. - docs/gaps.md: row 16 (encryption) takes main's new text, which this part hadn't touched; row 17 keeps this part's Sieve automatic replies. docs/parity-checklist.md regenerated with `cargo xtask parity`. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 2 brings in part 1 and main. Conflicts: - crates/i18n/po/*.po and messages.pot: both sides added entries next to each other. Merged entry by entry against the merge base (every entry of either side kept with its translation, none blank where either side had one, none changed on both sides), then `cargo xtask i18n`. Checked: 0 of main's translations lost or changed, 0 of part 2's, 0 of this branch's. - docs/gaps.md: row 16 (encryption) takes main's new text, which this part hadn't touched; row 17 keeps this part's text (part 2's row 17 is unchanged since the merge base). docs/parity-checklist.md regenerated with `cargo xtask parity`. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Conflicts: - .github/workflows/fuzz.yml: the list of fuzz targets keeps both sides' (this branch's managesieve and sieve_check, main's zimbra). - fuzz/Cargo.toml: both [[bin]] entries kept (sieve_check, then main's zimbra). - docs/parity-checklist.md: regenerated with `cargo xtask parity`. Catalogues: refreshed with `cargo xtask i18n`; no translation of main's or of this branch's was lost. Main added Turkish (tr.po): fuzzy drafts for this branch's 85 texts. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 1 now has main in it. Conflicts: - crates/engine/src/cmd/account.rs: servers_text keeps main's Zimbra account line and this part's Sieve server in the IMAP line. - crates/ui-egui/src/auto_replies.rs: main lays the dialog's rows out with crate::rtl::line (right-to-left languages); this part's time range that the server can't keep and its "everyone outside, or nobody" for a Sieve server are kept, their rows laid out the same way. - docs/ui-parity.md: Backstage keeps this part's Automatic Replies for a Sieve server and main's Print and Save as PDF. - docs/parity-checklist.md: regenerated with `cargo xtask parity`. - Catalogues: merged entry by entry and refreshed with `cargo xtask i18n`; no translation of main's, of part 1's or of this branch's was lost. Turkish: fuzzy drafts for this part's 31 texts. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 2 now has main in it. Conflicts: - docs/parity-checklist.md: regenerated with `cargo xtask parity`. - Catalogues: merged entry by entry and refreshed with `cargo xtask i18n`; no translation of main's, of part 2's or of this branch's was lost. Turkish: fuzzy drafts for this part's 209 texts. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Catalogues merged entry by entry (main's new entries and translations kept, none of either side's lost; 17 catalogues). Main's new guard test (every host an account sends a secret to is shown and fingerprinted) names every Account field: the ManageSieve server an IMAP account names in Account Settings (sieve_host, sieve_port) is one its sign-in goes to, so it is now in Confirm Servers' text and in the fingerprint here already, as part 2 had it, and the test changes it like the IMAP and SMTP hosts. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 1 with main merged. Account Settings' ManageSieve server meets main's GNOME accounts (account.edit's text says both), Zimbra and calendar homes in the fingerprint and Confirm Servers; the last written script's digest is named in main's every-field guard test as no place anything goes. Docs take main's text with the Sieve lines kept; catalogues merged entry by entry, none lost (17). Human-reviewed, AI-assisted, nobody's mailbox harmed.
Part 2 brings main, and with it UCSLabs#1177's rule editing: rules.edit, rule_for_edit, Rule::changed_parts and the editor's Save that sends only the parts changed. This part had an edit path of its own; the two are one now, main's: - rules.edit runs main's rule_for_edit for every rule; what isn't given stays. This part's own rule_edited is a thin wrapper over it, and its whole-rule replacement and refusal of a rule a Microsoft account's server keeps are gone (cannot_edit has no Microsoft reason; main's "not read yet" and "no answer yet" are reasons of it instead). - On an IMAP account whose server keeps MailCraft's Sieve script, the script is written again whole, so the edited rule is placed as this part placed it (checked whole, a folder clash, kept here by choice); main's checks of a server's own copy are for other servers. - A rule or filter of the owner's own script takes the change part by part (edited_parts): what the change doesn't make differ is kept as the script has it. - The agent's questions about rules.edit are main's; the Sieve and webmail ones are kept. The Rules dialog keeps this part's builder, with main's can_edit, saved() and "New Rule" button; a word with a semicolon isn't shown in the builder, as on main. - This part's Change Rule tests move to rules_edit_sieve_tests.rs, next to main's rules_edit_tests.rs, which is main's unchanged. - The every-field guard test names sieve_offers too. Catalogues merged entry by entry, none lost (17). Human-reviewed, AI-assisted, nobody's mailbox harmed.
… rules.edit takes it Tests: one part of a webmail filter changed (its name, then its folder) with the others kept from its settings as read, " YES " and all, the other filter byte for byte, a part a filter can't have refused, a change that makes nothing differ writing the script as it was; a new name alone for a rule of the owner's own script rewriting only its comment, a new condition rewriting its `if` with the script's own actions and stop. The tests that wrote a whole rule again now say what the parts left out keep (a filler in a filter's name stays until it is renamed; a rule's stop stays when the change doesn't name it). Docs and fragments: Change Rule follows rules.edit as it is since UCSLabs#1177, and changing a rule a Microsoft account's server keeps is no longer named as a gap. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Main's Edit button had come into each rule's row beside this part's Change pencil, which opens every kind of rule; it goes, and the held-key test tabs past the same buttons again. A borrow clippy finds needless. Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
Reworked onto main's rule-editing model from #1177, now that it's merged. What changed:
|
|
|
Tried at 45af231, with tests at that head and Pigeonhole's 1. A rule change takes the place of a replies change that is still waiting
A test for #[test]
fn a_rule_change_keeps_a_waiting_replies_change() {
let (mut app, account, answers, jobs) = window();
read(&mut app, account, &answers, SieveResult { state: Some(state(&RULES, None, None)), ..Default::default() });
let inbox = app.session.mailbox.folder_of_kind(account, mailcraft_model::FolderKind::Inbox).unwrap();
app.session.mailbox.folder_mut(inbox).unwrap().remote = "INBOX".into();
// A read under way, its answer not taken in yet: the replies change waits behind it.
app.sieve.read.clear();
answers.lock().unwrap().push_back(SieveResult { account, state: Some(state(&RULES, None, None)), ..Default::default() });
app.execute("account.automaticReplies", json!({"account": account})).unwrap();
app.execute("account.setAutomaticReplies", json!({"account": account, "status": "alwaysEnabled", "internal": "Away."})).unwrap();
// Before it starts, a rule kept on the server is added.
app.execute(
"rules.add",
json!({"name": "Lists", "account": account, "conditions": [{"type": "fromContains", "value": "list"}], "actions": [{"type": "moveTo", "value": inbox}]}),
)
.unwrap();
for _ in 0..4 {
app.poll_sieve();
}
let writes: Vec<String> = jobs.lock().unwrap().iter().filter_map(|(_, w, _)| w.as_ref().map(|w| w.text.clone())).collect();
assert!(writes.last().is_some_and(|t| t.contains("Away.") && t.contains("fileinto")), "last write: {:?}", writes.last());
}One write goes out, with 2. Rules and Alerts' Replace with MailCraft's turns Automatic Replies offWith replies on, once MailCraft's script is changed elsewhere (a webmail adding a filter to the active script, say), the replies are no longer known, and the Rules window's Replace with MailCraft's writes the script with them off ( A test that fails on its last line at 45af231 ( #[test]
fn replace_from_the_rules_window_keeps_the_replies() {
let (mut app, account, answers, jobs) = window();
let (_, rule) = with_rule(&mut app, account, &answers);
app.poll_sieve();
app.execute("account.setAutomaticReplies", json!({"account": account, "status": "alwaysEnabled", "internal": "Away."})).unwrap();
app.poll_sieve();
assert_eq!(app.auto_replies_on(), vec![account]);
let ours = jobs.lock().unwrap().iter().rev().find_map(|(_, w, _)| w.clone()).unwrap().text;
let edited = format!("{ours}if header :contains \"subject\" \"invoice\" {{ fileinto \"INBOX/Lists\"; }}\r\n");
read(&mut app, account, &answers, SieveResult { state: Some(state(&RULES, Some(SCRIPT_NAME), Some(&edited))), ..Default::default() });
assert!(app.sieve_rules_note(account).is_some_and(|(_, replace)| replace));
app.sieve_rules_write(account, true);
app.poll_sieve();
let written = jobs.lock().unwrap().iter().rev().find_map(|(_, w, _)| w.clone()).unwrap().text;
assert!(written.contains(&format!("# rule {rule}")));
assert!(written.contains("Away."), "the replies aren't in what was written");
}3. A Sieve rule that replies or refuses stops the whole script while Automatic Replies are on
So while replies are on, such a message gets no reply at all, neither MailCraft's nor the rule's. No later rule files it, and the refused sender's mail lands in the Inbox. ( The first script, as MailCraft wrote it# MailCraft: automatic replies kept on this server. Changed elsewhere, MailCraft leaves it as it is.
require ["vacation", "fileinto"];
if address :domain :is "from" "example.org" {
vacation :days 7 :addresses ["ada@example.org"] :handle "mailcraft-internal" "Away until Monday.";
} else {
vacation :days 7 :addresses ["ada@example.org"] :handle "mailcraft-external" "Away until Monday.";
}
# rule 19
# Sieve rule: Boss
if address :is "from" "boss@example.org" {
vacation :days 1 "At the airport: call me.";
}
# rule 20
if address :all :contains "from" ["boss@"] {
fileinto "INBOX/Lists";
}Human-reviewed, AI-assisted, nobody's mailbox harmed. |



Builds on #2106, #2107
Part 3 of 4 of #2057: rules kept on an IMAP account's server, in Sieve. It builds on part 2
(
sieve/2-replies, #2107), which builds on part 1 (#2106). Until those are merged, thisdiff against
mainincludes them too. This part's own changes are the commits after part 2's head.Rules and Alerts keeps its current layout here. The relayout comes last, in #2058.
Part of #2057, which the last part (#2058) closes.
What it does for the person using MailCraft
Rules kept on the server for IMAP accounts whose server keeps Sieve scripts, as for Microsoft
accounts. A rule goes into MailCraft's script, after the Automatic Replies, when Sieve can do all
of it:
to you, size;
It then runs while MailCraft is closed. Any other rule stays on this computer, and Rules and
Alerts says which part keeps it there. Two rules that move mail to different folders, the first
not stopping processing, both stay on this computer (the server would file a message both match
into both folders), and each names the other rule and both folders; asked for the server
explicitly, they are refused with that text. A rule kept in MailCraft's script looks for the sender's
and recipients' words in their addresses, as on Microsoft accounts.
Rules and Alerts says what keeps them off the server. No ManageSieve; no
fileinto; theowner's own script runs instead; or MailCraft's script was changed elsewhere, then with
Replace with MailCraft's (the owner's click only, bound to the script the owner saw).
The rules of the owner's own Sieve script (made in webmail or another program) are listed under
the script's name:
# rule:[…], RainLoop's and SnappyMail's filter names);File › Info says when that script sends the automatic replies itself.
Change Rule (
rules.edit) follows main's rule-editing model from Reules edit #1177. There is one editpath: main's
rules.edit,rule_for_editand the editor's "send only what changed" Save. A changenames only the parts it changes (name, conditions, exceptions, actions); every other part stays as
it was. The pencil beside a rule, or a double click, opens the rule builder filled in. Save changes
the rule in place, keeping its place in the order and whether it is on. On a Sieve account:
so the rule is checked whole, as a new one is (what Sieve can't say keeps it on this computer,
with why);
A new name alone rewrites only its
# rule:[…]comment and leaves itsifbyte for byte. Achanged condition, exception or action rewrites its
if, with the parts the change didn't nametaken from the script as read;
come from the change only when the change names them, and otherwise from the filter's settings as
read (" YES " and all). A filter with settings MailCraft doesn't know is still read-only.
A rule a Microsoft account's server keeps is changed as main changes it. This part's earlier own
edit path, which refused those rules and replaced a rule whole, is gone.
Sieve rules (
rules.addSieve,rules.editSieve): a rule written in Sieve itself, for what thebuilder can't say. It is kept in its place in MailCraft's script, and its
requires are joinedinto the script's one
require. It is checked first with part 1's local check and never run here.The Sieve editor (Rules and Alerts › Advanced… › New Sieve rule…, or the pencil on a Sieve
rule) has line numbers. Mistakes are marked and listed as you type, and a click on one goes there.
Check asks the server's CHECKSCRIPT inside MailCraft's whole script and gives the line numbers
as the rule's own. Save waits while there is a mistake.
The owner's own active script, edited whole (Advanced… › Edit your Sieve script…,
sieve.ownScript/sieve.putOwnScript). It is written back exactly as typed (CRLF kept), onlywhile the server's script is still the one read and still active, and where HAVESPACE says there
is room. Otherwise nothing is written, and Reload reads it again.
RainLoop / SnappyMail filters changed in place. Each filter is a rule you can change, switch
on or off, move or delete, and New Filter… adds one. The filter's settings (base64 JSON) and its
Sieve are written together in the webmail's own shape, and the rest of the script is left byte for
byte. A filter with settings MailCraft doesn't know, or one changed by hand, is shown read-only
with why.
Every rule of a Sieve account can be changed. The builder is used when it loses nothing, and
otherwise the rule's own Sieve text (
sieve.ownBlock,sieve.putOwnBlock). Only that rule's bytesare replaced, in the text whose digest was read, and an extension it needs joins
require. Editas Sieve… is in a row's menu. One of MailCraft's own rules that the builder can't show is edited
as Sieve and kept as a Sieve rule from then on (
rules.toSieve).Agents. Every new command has an approval class, read from part 1's table. An agent's Sieve
rule, or a change of the owner's script, is asked about as a send when it can send mail or
answer a sender (
redirect,vacation,reject,ereject,notify,report,include), whenit hands mail to a program (
pipe,filter,execute), when it uses a command not known, or whenit can't be read. A word in a string or a comment is no command. Sieve that only changes messages
(
addheader,deleteheader,replace,enclose) is asked as settings, and the question says so.The question shows the agent's Sieve as its own text, never as an instruction. A change to a
webmail filter that files into Deleted Items is asked as a delete. A builder or editor with an
unsaved draft in Rules and Alerts is reported to the agent gate as unsaved.
Specs it follows
address,header,size,fileinto,stop,allof/anyof, comments),copy (RFC 3894), imap4flags (RFC 5232), body (RFC 5173), and the other extensions of part 1's
table for Sieve rules and the owner's script.
# RAINLOOP:SIEVEline, each filter's settings as base64JSON in a comment before its Sieve) is the shape those webmails write. The tests use synthetic
scripts in that shape.
How it was tested
to the fake ManageSieve server on loopback, with invented rules, scripts and a synthetic
SnappyMail-shaped script.
sieve_rules,sieve_elsewhere,sieve_own,sieve_blocks,rules_sieve,rules_webmail,rules_edit_sieve(the stack's Change Rule tests, moved beside main'srules_edittests, which pass unchanged),sieve_effects,sieve_rainloop. New: one part of a webmail filter or of a rule of the owner's own script changed with every other part kept byte for byte, a part a filter can't have refused, an edit that names nothing writing nothing.hostile_params_never_panicruns the new commands with junk Sieve, digests and ids. Model testscover the header condition.
layout) and the webmail filters.
script.
cargo xtask cipasses on this branch: all 14 steps (fmt, assets, spdx, test-files, workflows, layers, wasm-clock, i18n, release-notes, docs-log, clippy, test, wasm, deny).Known limits (this part's share)
this computer, with why.
same tests, match types, comparators and actions. Otherwise it is changed as its Sieve text.
Deleting, moving and switching off such a rule are left to the script's text.
The webmail may put its own version back, and the editor warns about that.
just before it is made. That narrows, but can't close, the moment in which a change made elsewhere
is written over.
is changed as its Sieve text on a Sieve account. JMAP's Sieve is still to come (Full Stalwart support: shared mailboxes, Sieve, and two-way calendars and contacts over JMAP #1722).
Docs
docs/mcp.md(approval classes),docs/mail-privacy-rules.md,docs/gaps.md,ROADMAP.md,docs/ui-parity.md(Rules and Alerts as it is laid out here) anddocs/parity-checklist.md.Progress, revision and release-note fragments, and the translation catalogues (
cargo xtask i18n;new texts as fuzzy drafts).
Human-reviewed, AI-assisted, nobody's mailbox harmed.