AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
About Files History Releases Proposed changes Issues For developers
Let AIEN read both inboxes and send from its own address
merged d2ab7c9c4b7250e7 #84 · opened 2026-09-22 12:55 UTC · closed 2026-09-22 19:58 UTC · merged 2026-09-22 19:58 UTC
Imported from GitHub aien-dev/aien-sovereign-core-mv#84, by drakestapleton
Base 36280cb8c36e3dfab4cc311304df692f1fbd6dbe · Head 0a82518947a5587823fcf87999b78c4158ac77cc
Merged on GitHub as 28cbb983fef5135a9b5d077a330b4a8e17421b0d ; reachable from main 007ac4ac5ee5edc6f79f411b1706752293604044 (observed 2026-11-18T16:35:51Z)
drakestapleton wrote on 2026-09-22 12:55 UTC
Problem and result
AIEN cannot access the Gandi-hosted drake@aienos.com and aien@aienos.com inboxes. This adds Rust commands to list and read both mailboxes over TLS and send as aien@aienos.com through authenticated Gandi SMTP. Drake's personal address remains read-only to AIEN.
Verification proof
rustfmt --edition 2024 and git diff --check: passed.
Initial GitHub CI passed formatting, workspace compilation, Clippy, unit and integration tests, and invariant audits: https://github.com/aien-dev/aien-sovereign-core/actions/runs/35730165871
Targeted Rust build on Spark: passed for commit 9a10442 .
Live Drake IMAP login and AIEN IMAP login: passed using the two hardware vault entries. No private message content was printed.
Gandi SMTP accepted a self-addressed message from aien@aienos.com. The connector then found and read that exact message in AIEN's inbox (subject AIEN connector check 4815c1d , UID 1).
CI rerun for the final diagnostic commit is in progress.
Release limits
The connector is a CLI transport for authorized AIEN workflows. It does not schedule unsolicited replies or write mail contents to disk. The production spark-mail binary has not been replaced.
Certifications
No plaintext credentials were added to source or disk configuration.
No em dashes or en dashes were added.
Sovereign Defense Covenant: Section 6 Retroactive Inception applies.
Apply it
git checkout -b patch-d2ab7c9c4b7250e7 36280cb8c36e3dfab4cc311304df692f1fbd6dbe
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/d2ab7c9c4b7250e7 .patch | git am
Raw patch (mbox) · Diff
Provenance
This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:
github-import 1
aien-dev/aien-sovereign-core-mv
84
0a82518947a5587823fcf87999b78c4158ac77cc
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":84,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/84","export_sha256":"d815604dc795b494a931d4c9d256159461266bed51d6da460421ed1d94dab90f ","imported_utc":"2026-11-18T16:35:51Z"}
Changes
diff --git a/Cargo.lock b/Cargo.lock
index 7f6599f8 ..464de565 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -65,6 +65,39 @@ dependencies = [
"tokio",
]
+[[package]]
+name = "aien-inference-protocol"
+version = "0.1.0"
+dependencies = [
+ "async-trait",
+ "bytes",
+ "futures-util",
+ "serde",
+ "serde_json",
+ "tokio",
+]
+
+[[package]]
+name = "aien-inference-runtime"
+version = "0.1.0"
+dependencies = [
+ "aien-inference-abi",
+ "aien-inference-protocol",
+ "aien-kv-cache",
+ "aien-scheduler",
+ "anyhow",
+ "async-trait",
+ "bytes",
+ "chrono",
+ "futures-util",
+ "parking_lot",
+ "serde",
+ "serde_json",
+ "tokio",
+ "tracing",
+ "uuid",
+]
+
[[package]]
name = "aien-kv-cache"
version = "0.1.0"
@@ -93,6 +126,32 @@ dependencies = [
"parking_lot",
]
+[[package]]
+name = "aien-protocol-types"
+version = "0.1.0"
+dependencies = [
+ "hex",
+ "serde",
+ "serde_json",
+ "thiserror 1.0.69",
+ "uuid",
+]
+
+[[package]]
+name = "aien-provenance"
+version = "0.1.0"
+dependencies = [
+ "aien-protocol-types",
+ "bitflags 2.13.2",
+ "hex",
+ "p256",
+ "serde",
+ "serde_json",
+ "sha2 0.10.9",
+ "thiserror 1.0.69",
+ "uuid",
+]
+
[[package]]
name = "aien-runtime"
version = "0.1.0"
@@ -107,6 +166,7 @@ dependencies = [
"parking_lot",
"serde",
"serde_json",
+ "sha2 0.10.9",
"tempfile",
"thiserror 1.0.69",
"tokio",
@@ -205,6 +265,12 @@ version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470 "
+[[package]]
+name = "arrayvec"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b "
+
[[package]]
name = "arrayvec"
version = "0.7.8"
@@ -321,6 +387,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90 "
dependencies = [
"axum-core 0.5.6",
+ "base64 0.22.1",
"bytes",
"form_urlencoded",
"futures-util",
@@ -339,8 +406,10 @@ dependencies = [
"serde_json",
"serde_path_to_error",
"serde_urlencoded",
+ "sha1",
"sync_wrapper",
"tokio",
+ "tokio-tungstenite 0.29.0",
"tower",
"tower-layer",
"tower-service",
@@ -398,6 +467,12 @@ dependencies = [
"syn 2.0.119",
]
+[[package]]
+name = "base16ct"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6 "
+
[[package]]
name = "base64"
version = "0.13.1"
@@ -452,11 +527,20 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb "
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a "
+
[[package]]
name = "bitflags"
version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06 "
+dependencies = [
+ "serde_core",
+]
[[package]]
name = "blake3"
@@ -464,7 +548,7 @@ version = "1.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae "
dependencies = [
- "arrayvec",
+ "arrayvec 0.7.8",
"cc",
"cfg-if",
"constant_time_eq",
@@ -480,6 +564,21 @@ dependencies = [
"generic-array",
]
+[[package]]
+name = "block-buffer"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa "
+dependencies = [
+ "hybrid-array",
+]
+
+[[package]]
+name = "bufstream"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8 "
+
[[package]]
name = "bumpalo"
version = "3.20.3"
@@ -554,6 +653,16 @@ dependencies = [
"rand_core 0.10.1",
]
+[[package]]
+name = "charset"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1f927b07c74ba84c7e5fe4db2baeb3e996ab2688992e39ac68ce3220a677c7e "
+dependencies = [
+ "base64 0.22.1",
+ "encoding_rs",
+]
+
[[package]]
name = "chrono"
version = "0.4.45"
@@ -626,6 +735,12 @@ dependencies = [
"cc",
]
+[[package]]
+name = "cmov"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a "
+
[[package]]
name = "colorchoice"
version = "1.0.5"
@@ -667,6 +782,12 @@ dependencies = [
"static_assertions",
]
+[[package]]
+name = "const-oid"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c "
+
[[package]]
name = "constant_time_eq"
version = "0.4.2"
@@ -735,7 +856,7 @@ dependencies = [
"rusqlite",
"serde",
"serde_json",
- "sha2",
+ "sha2 0.10.9",
"spark-crumbs 0.1.0 (git+https://github.com/aien-dev/spark-crumbs?rev=9355a92bc9adfe95a6ec5f8ac926f38a0b6e7db2 )",
"tokio",
"tower-http 0.5.2",
@@ -744,6 +865,12 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "cpubits"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae "
+
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -793,7 +920,7 @@ version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"crossterm_winapi",
"libc",
"mio 0.8.11",
@@ -825,6 +952,22 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "crypto-bigint"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271 "
+dependencies = [
+ "cpubits",
+ "ctutils",
+ "getrandom 0.4.3",
+ "hybrid-array",
+ "num-traits",
+ "rand_core 0.10.1",
+ "subtle",
+ "zeroize",
+]
+
[[package]]
name = "crypto-common"
version = "0.1.7"
@@ -835,6 +978,17 @@ dependencies = [
"typenum",
]
+[[package]]
+name = "crypto-common"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453 "
+dependencies = [
+ "getrandom 0.4.3",
+ "hybrid-array",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "csv"
version = "1.4.0"
@@ -856,6 +1010,16 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "ctutils"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e "
+dependencies = [
+ "cmov",
+ "subtle",
+]
+
[[package]]
name = "curve25519-dalek"
version = "4.1.3"
@@ -865,7 +1029,7 @@ dependencies = [
"cfg-if",
"cpufeatures 0.2.17",
"curve25519-dalek-derive",
- "digest",
+ "digest 0.10.7",
"fiat-crypto",
"rustc_version",
"subtle",
@@ -939,6 +1103,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a "
dependencies = [
+ "const-oid",
"pem-rfc7468",
"zeroize",
]
@@ -986,8 +1151,20 @@ version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292 "
dependencies = [
- "block-buffer",
- "crypto-common",
+ "block-buffer 0.10.4",
+ "crypto-common 0.1.7",
+]
+
+[[package]]
+name = "digest"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2 "
+dependencies = [
+ "block-buffer 0.12.1",
+ "const-oid",
+ "crypto-common 0.2.2",
+ "ctutils",
]
[[package]]
@@ -1001,19 +1178,40 @@ dependencies = [
"syn 3.0.6",
]
+[[package]]
+name = "downcast-rs"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2 "
+
[[package]]
name = "dunce"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813 "
+[[package]]
+name = "ecdsa"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0681a4fc24c767085329728d8dfba959af91228aa4610cca4f8ce317ba46ae0 "
+dependencies = [
+ "der",
+ "digest 0.11.3",
+ "elliptic-curve",
+ "rfc6979",
+ "signature 3.0.0",
+ "spki",
+ "zeroize",
+]
+
[[package]]
name = "ed25519 "
version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53 "
dependencies = [
- "signature",
+ "signature 2.2.0",
]
[[package]]
@@ -1024,7 +1222,7 @@ checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9 "
dependencies = [
"curve25519-dalek",
"ed25519 ",
- "sha2",
+ "sha2 0.10.9",
"subtle",
"zeroize",
]
@@ -1035,6 +1233,43 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34 "
+[[package]]
+name = "elliptic-curve"
+version = "0.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d65aa39b3a5c1c9c1b745c9a019234bb7a21b77abcb4f4d266d706e2d577d65 "
+dependencies = [
+ "base16ct",
+ "crypto-bigint",
+ "crypto-common 0.2.2",
+ "digest 0.11.3",
+ "ff",
+ "group",
+ "hybrid-array",
+ "pem-rfc7468",
+ "pkcs8",
+ "rand_core 0.10.1",
+ "sec1",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "email-encoding"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "420b9da095f052ea597503e39073b5b3c522f7db933fbac202d91d24492693fd "
+dependencies = [
+ "base64 0.23.1",
+ "memchr",
+]
+
+[[package]]
+name = "email_address"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449 "
+
[[package]]
name = "encoding_rs"
version = "0.8.41"
@@ -1123,12 +1358,33 @@ dependencies = [
"windows-sys 0.59.0",
]
+[[package]]
+name = "ff"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f "
+dependencies = [
+ "rand_core 0.10.1",
+ "subtle",
+]
+
[[package]]
name = "fiat-crypto"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d "
+[[package]]
+name = "filedescriptor"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d "
+dependencies = [
+ "libc",
+ "thiserror 1.0.69",
+ "winapi",
+]
+
[[package]]
name = "find-msvc-tools"
version = "0.1.13"
@@ -1290,6 +1546,17 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "group"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4 "
+dependencies = [
+ "ff",
+ "rand_core 0.10.1",
+ "subtle",
+]
+
[[package]]
name = "h2"
version = "0.4.19"
@@ -1345,6 +1612,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70 "
+[[package]]
+name = "hmac"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f "
+dependencies = [
+ "digest 0.11.3",
+]
+
[[package]]
name = "hmac-sha256"
version = "1.1.14"
@@ -1360,6 +1636,17 @@ dependencies = [
"windows-sys 0.61.2",
]
+[[package]]
+name = "hostname"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd "
+dependencies = [
+ "cfg-if",
+ "libc",
+ "windows-link",
+]
+
[[package]]
name = "http"
version = "1.5.0"
@@ -1411,6 +1698,17 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9 "
+[[package]]
+name = "hybrid-array"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17 "
+dependencies = [
+ "subtle",
+ "typenum",
+ "zeroize",
+]
+
[[package]]
name = "hyper"
version = "1.11.1"
@@ -1624,6 +1922,31 @@ dependencies = [
"icu_properties",
]
+[[package]]
+name = "imap"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c617c55def8c42129e0dd503f11d7ee39d73f5c7e01eff55768b3879ff1d107d "
+dependencies = [
+ "base64 0.13.1",
+ "bufstream",
+ "chrono",
+ "imap-proto",
+ "lazy_static",
+ "native-tls",
+ "nom 5.1.3",
+ "regex",
+]
+
+[[package]]
+name = "imap-proto"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16a6def1d5ac8975d70b3fd101d57953fe3278ef2ee5d7816cba54b1d1dfc22f "
+dependencies = [
+ "nom 5.1.3",
+]
+
[[package]]
name = "indexmap"
version = "2.14.2"
@@ -1774,6 +2097,43 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe "
+[[package]]
+name = "lettre"
+version = "0.11.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2c646bd5cc763b1087b15493e29a64be6147ba8f19342004fa52048ee596eae "
+dependencies = [
+ "base64 0.23.1",
+ "email-encoding",
+ "email_address",
+ "fastrand",
+ "futures-util",
+ "hostname",
+ "httpdate",
+ "idna",
+ "mime",
+ "native-tls",
+ "nom 8.0.0",
+ "percent-encoding",
+ "quoted_printable",
+ "socket2",
+ "tokio",
+ "url",
+]
+
+[[package]]
+name = "lexical-core"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe "
+dependencies = [
+ "arrayvec 0.5.2",
+ "bitflags 1.3.2",
+ "cfg-if",
+ "ryu",
+ "static_assertions",
+]
+
[[package]]
name = "libc"
version = "0.2.189"
@@ -1866,6 +2226,17 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc04a4c58212d57930a24bf47d3fa87485264a3a054e9c10e042eb373573ad3c "
+[[package]]
+name = "mailparse"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3da03d5980411a724e8aaf7b61a7b5e386ec55a7fb49ee3d0ff79efc7e5e7c7e "
+dependencies = [
+ "charset",
+ "data-encoding",
+ "quoted_printable",
+]
+
[[package]]
name = "matchers"
version = "0.2.0"
@@ -2044,12 +2415,23 @@ version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4 "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"cfg-if",
"cfg_aliases 0.1.1",
"libc",
]
+[[package]]
+name = "nom"
+version = "5.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b "
+dependencies = [
+ "lexical-core",
+ "memchr",
+ "version_check",
+]
+
[[package]]
name = "nom"
version = "7.1.3"
@@ -2180,7 +2562,7 @@ version = "6.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cc3cbf698f9438986c11a880c90a6d04b9de27575afd28bbf45b154b6c709e2 "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"libc",
"once_cell",
"onig_sys",
@@ -2202,7 +2584,7 @@ version = "0.10.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45 "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"cfg-if",
"foreign-types",
"libc",
@@ -2264,6 +2646,19 @@ dependencies = [
"ureq",
]
+[[package]]
+name = "p256"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2c9239b2dbc807adbbe147e8cf72ea7450c3a0aabe62cb8e75ff4ec22e1f72a "
+dependencies = [
+ "ecdsa",
+ "elliptic-curve",
+ "primefield",
+ "primeorder",
+ "sha2 0.11.0",
+]
+
[[package]]
name = "parking_lot"
version = "0.12.5"
@@ -2320,6 +2715,16 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd "
+[[package]]
+name = "pkcs8"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7 "
+dependencies = [
+ "der",
+ "spki",
+]
+
[[package]]
name = "pkg-config"
version = "0.3.34"
@@ -2341,6 +2746,27 @@ dependencies = [
"portable-atomic",
]
+[[package]]
+name = "portable-pty"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4a596a2b3d2752d94f51fac2d4a96737b8705dddd311a32b9af47211f08671e "
+dependencies = [
+ "anyhow",
+ "bitflags 1.3.2",
+ "downcast-rs",
+ "filedescriptor",
+ "lazy_static",
+ "libc",
+ "log",
+ "nix",
+ "serial2",
+ "shared_library",
+ "shell-words",
+ "winapi",
+ "winreg",
+]
+
[[package]]
name = "potential_utf"
version = "0.1.6"
@@ -2365,6 +2791,33 @@ dependencies = [
"zerocopy",
]
+[[package]]
+name = "primefield"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c555a6e4eb7d4e158fcb028c835c3b8642206ddc279b5c6b202ef9a8bdb592f4 "
+dependencies = [
+ "crypto-bigint",
+ "crypto-common 0.2.2",
+ "ff",
+ "rand_core 0.10.1",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "primeorder"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c9f42978c78a00e3d68f69fc03e57a234debae69da4020a4fb588fcdcd07b06 "
+dependencies = [
+ "elliptic-curve",
+ "once_cell",
+ "primefield",
+ "serdect",
+ "wnaf",
+]
+
[[package]]
name = "proc-macro2"
version = "1.0.107"
@@ -2440,6 +2893,12 @@ dependencies = [
"proc-macro2",
]
+[[package]]
+name = "quoted_printable"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "478e0585659a122aa407eb7e3c0e1fa51b1d8a870038bd29f0cf4a8551eea972 "
+
[[package]]
name = "r-efi"
version = "5.3.0"
@@ -2463,7 +2922,7 @@ dependencies = [
"rand 0.8.8",
"serde",
"serde_json",
- "sha2",
+ "sha2 0.10.9",
"spark-crumbs 0.1.0 (git+https://github.com/aien-dev/spark-crumbs?rev=9355a92bc9adfe95a6ec5f8ac926f38a0b6e7db2 )",
]
@@ -2605,7 +3064,7 @@ version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
]
[[package]]
@@ -2727,6 +3186,16 @@ dependencies = [
"web-sys",
]
+[[package]]
+name = "rfc6979"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b "
+dependencies = [
+ "crypto-bigint",
+ "hmac",
+]
+
[[package]]
name = "ring"
version = "0.17.14"
@@ -2747,7 +3216,7 @@ version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"chrono",
"csv",
"fallible-iterator",
@@ -2782,7 +3251,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"errno",
"libc",
"linux-raw-sys",
@@ -2877,7 +3346,7 @@ version = "14.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63 "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"cfg-if",
"clipboard-win",
"fd-lock",
@@ -2923,13 +3392,27 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49 "
+[[package]]
+name = "sec1"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d56d437c2f19203ce5f7122e507831de96f3d2d4d3be5af44a0b0a09d8a80e4d "
+dependencies = [
+ "base16ct",
+ "ctutils",
+ "der",
+ "hybrid-array",
+ "subtle",
+ "zeroize",
+]
+
[[package]]
name = "security-framework"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"core-foundation 0.10.1",
"core-foundation-sys",
"libc",
@@ -3027,6 +3510,27 @@ dependencies = [
"serde",
]
+[[package]]
+name = "serdect"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e "
+dependencies = [
+ "base16ct",
+ "serde",
+]
+
+[[package]]
+name = "serial2"
+version = "0.2.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b16809bc35793b19ce4e0c53924bc0dce3937f15487997cfdaed936004180730 "
+dependencies = [
+ "cfg-if",
+ "libc",
+ "windows-sys 0.61.2",
+]
+
[[package]]
name = "sha1"
version = "0.10.7"
@@ -3035,7 +3539,7 @@ checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8 "
dependencies = [
"cfg-if",
"cpufeatures 0.2.17",
- "digest",
+ "digest 0.10.7",
]
[[package]]
@@ -3046,7 +3550,18 @@ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283 "
dependencies = [
"cfg-if",
"cpufeatures 0.2.17",
- "digest",
+ "digest 0.10.7",
+]
+
+[[package]]
+name = "sha2"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4 "
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "digest 0.11.3",
]
[[package]]
@@ -3058,6 +3573,22 @@ dependencies = [
"lazy_static",
]
+[[package]]
+name = "shared_library"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11 "
+dependencies = [
+ "lazy_static",
+ "libc",
+]
+
+[[package]]
+name = "shell-words"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77 "
+
[[package]]
name = "shlex"
version = "2.0.1"
@@ -3101,6 +3632,16 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de "
+[[package]]
+name = "signature"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5 "
+dependencies = [
+ "digest 0.11.3",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "simd_cesu8"
version = "1.2.0"
@@ -3170,6 +3711,24 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "spark-aegis"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "blake3",
+ "chrono",
+ "clap",
+ "libc",
+ "libloading 0.8.9",
+ "regex",
+ "reqwest 0.12.28",
+ "serde",
+ "serde_json",
+ "tempfile",
+ "tokio",
+]
+
[[package]]
name = "spark-cockpit-rs"
version = "0.1.0"
@@ -3179,14 +3738,18 @@ dependencies = [
"chrono",
"form_urlencoded",
"futures-util",
+ "portable-pty",
"regex",
"reqwest 0.13.5",
+ "rusqlite",
"serde",
"serde_json",
+ "spark-adapters",
"spark-hive",
"tokio",
"toml",
"tower-http 0.7.1",
+ "uuid",
]
[[package]]
@@ -3248,7 +3811,7 @@ dependencies = [
"serde",
"serde_json",
"tokio",
- "tokio-tungstenite",
+ "tokio-tungstenite 0.24.0",
"tracing",
"tracing-subscriber",
]
@@ -3295,13 +3858,19 @@ dependencies = [
name = "spark-harvester"
version = "0.1.0"
dependencies = [
+ "aien-protocol-types",
+ "aien-provenance",
+ "bitflags 2.13.2",
"chrono",
"clap",
+ "hex",
+ "p256",
"regex",
"reqwest 0.12.28",
"serde",
"serde_json",
- "sha2",
+ "sha2 0.10.9",
+ "tempfile",
"thiserror 1.0.69",
"tokio",
"tracing",
@@ -3345,6 +3914,10 @@ dependencies = [
"axum 0.8.9",
"chrono",
"clap",
+ "imap",
+ "lettre",
+ "mailparse",
+ "native-tls",
"reqwest 0.13.5",
"serde",
"serde_json",
@@ -3403,6 +3976,16 @@ dependencies = [
"lock_api",
]
+[[package]]
+name = "spki"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d9efca8738c78ee9484207732f728b1ef517bbb1833d6fc0879ca898a522f6f "
+dependencies = [
+ "base64ct",
+ "der",
+]
+
[[package]]
name = "spm_precompiled"
version = "0.1.4"
@@ -3487,7 +4070,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"core-foundation 0.9.4",
"system-configuration-sys",
]
@@ -3703,10 +4286,22 @@ dependencies = [
"rustls-pki-types",
"tokio",
"tokio-rustls",
- "tungstenite",
+ "tungstenite 0.24.0",
"webpki-roots 0.26.11",
]
+[[package]]
+name = "tokio-tungstenite"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f72a05e828585856dacd553fba484c242c46e391fb0e58917c942ee9202915c "
+dependencies = [
+ "futures-util",
+ "log",
+ "tokio",
+ "tungstenite 0.29.0",
+]
+
[[package]]
name = "tokio-util"
version = "0.7.19"
@@ -3784,7 +4379,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5 "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"bytes",
"http",
"http-body",
@@ -3801,7 +4396,7 @@ version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840 "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"bytes",
"futures-util",
"http",
@@ -3820,7 +4415,7 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c "
dependencies = [
- "bitflags",
+ "bitflags 2.13.2",
"bytes",
"futures-core",
"futures-util",
@@ -3939,6 +4534,22 @@ dependencies = [
"utf-8",
]
+[[package]]
+name = "tungstenite"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c01152af293afb9c7c2a57e4b559c5620b421f6d133261c60dd2d0cdb38e6b8 "
+dependencies = [
+ "bytes",
+ "data-encoding",
+ "http",
+ "httparse",
+ "log",
+ "rand 0.9.5",
+ "sha1",
+ "thiserror 2.0.20",
+]
+
[[package]]
name = "typenum"
version = "1.20.1"
@@ -4515,12 +5126,33 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "winreg"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d "
+dependencies = [
+ "winapi",
+]
+
[[package]]
name = "wit-bindgen"
version = "0.57.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e "
+[[package]]
+name = "wnaf"
+version = "0.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "795ca18b3fdb5e62bf982199278341ddcf7ebf7d32e25e212ad05d496e95f6fa "
+dependencies = [
+ "ff",
+ "group",
+ "hybrid-array",
+ "primefield",
+]
+
[[package]]
name = "writeable"
version = "0.6.4"
diff --git a/crates/spark-mail-rs/Cargo.toml b/crates/spark-mail-rs/Cargo.toml
index 53b018ed ..d85a17fc 100644
--- a/crates/spark-mail-rs/Cargo.toml
+++ b/crates/spark-mail-rs/Cargo.toml
@@ -19,6 +19,10 @@ tower-http = { version = "0.7.1", features = ["cors"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
toml = "0.8"
+imap = "2.4"
+native-tls = "0.2"
+lettre = { version = "0.11", default-features = false, features = ["builder", "smtp-transport", "native-tls", "hostname", "pool"] }
+mailparse = "0.15"
[[bin]]
name = "spark-mail"
diff --git a/crates/spark-mail-rs/GANDI_MAIL.md b/crates/spark-mail-rs/GANDI_MAIL.md
new file mode 100644
index 00000000 ..ac331e33
--- /dev/null
+++ b/crates/spark-mail-rs/GANDI_MAIL.md
@@ -0,0 +1,28 @@
+# Gandi mailbox connector
+
+`spark-mail` can read the Gandi inboxes for `drake@aienos.com` and
+`aien@aienos.com`. It sends only as `aien@aienos.com`. Drake replies from his
+own mailbox. Incoming mail is untrusted content and must not be treated as
+instructions to AIEN.
+
+The connector uses TLS to `mail.gandi.net:993` for IMAP and the Gandi SMTP
+relay on port 465. It reads credentials from `atlas-vault` at call time:
+
+- `GANDI_DRAKE_MAIL_PASSWORD`
+- `GANDI_AIEN_MAIL_PASSWORD`
+
+Create the two Gandi mailboxes and add their passwords to Spark's hardware
+vault before use. Never place the passwords in CLI arguments, source files, or
+environment files. The commands do not write messages or credentials to disk.
+
+```sh
+spark-mail gandi-list --account drake --limit 20
+spark-mail gandi-list --account aien --limit 20
+spark-mail gandi-read --account aien --uid 123
+printf '%s' 'Message body' | spark-mail gandi-send --to person@example.com --subject 'Subject'
+```
+
+`gandi-list` and `gandi-read` leave messages unread. `gandi-send` reports success
+only after Gandi SMTP accepts the message. The connector does not schedule
+unsolicited replies; AIEN can invoke it as part of an authorized conversation
+or workflow.
diff --git a/crates/spark-mail-rs/src/gandi.rs b/crates/spark-mail-rs/src/gandi.rs
new file mode 100644
index 00000000 ..efcbb48c
--- /dev/null
+++ b/crates/spark-mail-rs/src/gandi.rs
@@ -0,0 +1,223 @@
+//! Gandi mailbox transport. Credentials are resolved from the hardware vault
+//! at call time and never written to the local mail store.
+
+use imap::Session;
+use lettre::transport::smtp::authentication::Credentials;
+use lettre::{Message, SmtpTransport, Transport};
+use mailparse::MailHeaderMap;
+use native_tls::TlsConnector;
+use serde::Serialize;
+use std::io::{Error, ErrorKind};
+use std::net::TcpStream;
+use std::path::PathBuf;
+use std::process::Command;
+
+const HOST: &str = "mail.gandi.net";
+
+#[derive(Clone, Copy, Debug, Eq, PartialEq, clap::ValueEnum)]
+pub enum Account {
+ Drake,
+ Aien,
+}
+
+impl Account {
+ pub fn address(self) -> &'static str {
+ match self {
+ Self::Drake => "drake@aienos.com",
+ Self::Aien => "aien@aienos.com",
+ }
+ }
+
+ fn vault_key(self) -> &'static str {
+ match self {
+ Self::Drake => "GANDI_DRAKE_MAIL_PASSWORD",
+ Self::Aien => "GANDI_AIEN_MAIL_PASSWORD",
+ }
+ }
+}
+
+#[derive(Debug, Serialize)]
+pub struct MailSummary {
+ pub uid: u32,
+ pub from: String,
+ pub subject: String,
+ pub date: String,
+}
+
+#[derive(Debug, Serialize)]
+pub struct MailDetail {
+ pub uid: u32,
+ pub from: String,
+ pub subject: String,
+ pub date: String,
+ pub body: String,
+}
+
+fn vault_password(account: Account) -> Result<String, Error> {
+ let home = std::env::var_os("HOME")
+ .map(PathBuf::from)
+ .ok_or_else(|| Error::new(ErrorKind::NotFound, "HOME is not set"))?;
+ let local = home.join(".local/bin/atlas-vault");
+ let binary = if local.is_file() {
+ local
+ } else {
+ PathBuf::from("atlas-vault")
+ };
+ let output = Command::new(binary)
+ .args(["get", account.vault_key()])
+ .output()?;
+ if !output.status.success() {
+ return Err(Error::new(
+ ErrorKind::PermissionDenied,
+ format!(
+ "mail credential {} is unavailable in atlas-vault",
+ account.vault_key()
+ ),
+ ));
+ }
+ let password = String::from_utf8(output.stdout)
+ .map_err(|_| Error::new(ErrorKind::InvalidData, "vault returned invalid UTF-8"))?;
+ let password = password.trim_end_matches(['\r', '\n']);
+ if password.is_empty() {
+ return Err(Error::new(
+ ErrorKind::InvalidData,
+ "vault returned an empty mail credential",
+ ));
+ }
+ Ok(password.to_owned())
+}
+
+fn imap_session(account: Account) -> Result<Session<native_tls::TlsStream<TcpStream>>, Error> {
+ let tls = TlsConnector::builder()
+ .build()
+ .map_err(|_| Error::other("could not initialize TLS"))?;
+ let client = imap::connect((HOST, 993), HOST, &tls)
+ .map_err(|_| Error::other("could not connect to Gandi IMAP over TLS"))?;
+ client
+ .login(account.address(), vault_password(account)?)
+ .map_err(|_| Error::new(ErrorKind::PermissionDenied, "Gandi IMAP login failed"))
+}
+
+fn header_value(headers: &[mailparse::MailHeader<'_>], name: &str) -> String {
+ headers.get_first_value(name).unwrap_or_default()
+}
+
+fn plain_body(part: &mailparse::ParsedMail<'_>) -> Option<String> {
+ if part.ctype.mimetype == "text/plain" {
+ return part.get_body().ok();
+ }
+ part.subparts.iter().find_map(plain_body)
+}
+
+pub fn list(account: Account, limit: usize) -> Result<Vec<MailSummary>, Error> {
+ let mut session = imap_session(account)?;
+ session
+ .examine("INBOX")
+ .map_err(|error| Error::other(format!("cannot open inbox: {error}")))?;
+ let mut uids: Vec<u32> = session
+ .uid_search("ALL")
+ .map_err(|_| Error::other("cannot search inbox"))?
+ .into_iter()
+ .collect();
+ uids.sort_unstable_by(|a, b| b.cmp(a));
+ let mut messages = Vec::new();
+ for uid in uids.into_iter().take(limit.min(100)) {
+ let fetched = session
+ .uid_fetch(uid.to_string(), "BODY.PEEK[HEADER]")
+ .map_err(|_| Error::other("cannot fetch mail headers"))?;
+ if let Some(raw) = fetched.iter().next().and_then(|item| item.header()) {
+ let (headers, _) = mailparse::parse_headers(raw)
+ .map_err(|_| Error::new(ErrorKind::InvalidData, "invalid mail headers"))?;
+ messages.push(MailSummary {
+ uid,
+ from: header_value(&headers, "From"),
+ subject: header_value(&headers, "Subject"),
+ date: header_value(&headers, "Date"),
+ });
+ }
+ }
+ let _ = session.logout();
+ Ok(messages)
+}
+
+pub fn read(account: Account, uid: u32) -> Result<MailDetail, Error> {
+ let mut session = imap_session(account)?;
+ session
+ .examine("INBOX")
+ .map_err(|error| Error::other(format!("cannot open inbox: {error}")))?;
+ let fetched = session
+ .uid_fetch(uid.to_string(), "BODY.PEEK[]")
+ .map_err(|_| Error::other("cannot fetch message"))?;
+ let raw = fetched
+ .iter()
+ .next()
+ .and_then(|item| item.body())
+ .ok_or_else(|| Error::new(ErrorKind::NotFound, "message UID not found"))?;
+ let parsed = mailparse::parse_mail(raw)
+ .map_err(|_| Error::new(ErrorKind::InvalidData, "invalid mail message"))?;
+ let body = plain_body(&parsed).unwrap_or_else(|| "[No plain-text body]".to_string());
+ let detail = MailDetail {
+ uid,
+ from: header_value(&parsed.headers, "From"),
+ subject: header_value(&parsed.headers, "Subject"),
+ date: header_value(&parsed.headers, "Date"),
+ body,
+ };
+ let _ = session.logout();
+ Ok(detail)
+}
+
+pub fn send_as_aien(to: &str, subject: &str, body: &str) -> Result<(), Error> {
+ if subject.trim().is_empty() || body.trim().is_empty() {
+ return Err(Error::new(
+ ErrorKind::InvalidInput,
+ "subject and body are required",
+ ));
+ }
+ let message = Message::builder()
+ .from(
+ Account::Aien
+ .address()
+ .parse()
+ .map_err(|_| Error::other("invalid AIEN address"))?,
+ )
+ .to(to
+ .parse()
+ .map_err(|_| Error::new(ErrorKind::InvalidInput, "invalid recipient address"))?)
+ .subject(subject)
+ .body(body.to_owned())
+ .map_err(|_| Error::new(ErrorKind::InvalidInput, "invalid mail content"))?;
+ let transport = SmtpTransport::relay(HOST)
+ .map_err(|_| Error::other("could not initialize Gandi SMTP over TLS"))?
+ .credentials(Credentials::new(
+ Account::Aien.address().to_owned(),
+ vault_password(Account::Aien)?,
+ ))
+ .build();
+ transport
+ .send(&message)
+ .map_err(|_| Error::other("Gandi SMTP did not confirm delivery"))?;
+ Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn identities_have_separate_vault_keys() {
+ assert_eq!(Account::Drake.address(), "drake@aienos.com");
+ assert_eq!(Account::Aien.address(), "aien@aienos.com");
+ assert_ne!(Account::Drake.vault_key(), Account::Aien.vault_key());
+ }
+
+ #[test]
+ fn empty_mail_is_rejected_before_vault_access() {
+ assert_eq!(
+ send_as_aien("person@example.com", "", "body")
+ .unwrap_err()
+ .kind(),
+ ErrorKind::InvalidInput
+ );
+ }
+}
diff --git a/crates/spark-mail-rs/src/lib.rs b/crates/spark-mail-rs/src/lib.rs
index b9ea27d7 ..e90724f4 100644
--- a/crates/spark-mail-rs/src/lib.rs
+++ b/crates/spark-mail-rs/src/lib.rs
@@ -1,5 +1,6 @@
pub mod api;
pub mod cortex_sync;
+pub mod gandi;
pub mod models;
pub mod relay;
pub mod smtp_server;
diff --git a/crates/spark-mail-rs/src/main.rs b/crates/spark-mail-rs/src/main.rs
index 1559f1d2 ..10df32cb 100644
--- a/crates/spark-mail-rs/src/main.rs
+++ b/crates/spark-mail-rs/src/main.rs
@@ -2,11 +2,13 @@ use clap::{Parser, Subcommand};
use serde::Deserialize;
use spark_mail::api::{ApiState, create_router};
use spark_mail::cortex_sync::CortexSync;
+use spark_mail::gandi::{self, Account};
use spark_mail::models::SendEmailRequest;
use spark_mail::relay::MailRelay;
use spark_mail::smtp_server::run_smtp_server;
use spark_mail::store::MailStore;
use std::fs;
+use std::io::Read;
use std::net::SocketAddr;
use std::path::PathBuf;
use std::sync::Arc;
@@ -50,6 +52,24 @@ enum Commands {
from: Option<String>,
},
IngestTest,
+ GandiList {
+ #[arg(long, value_enum)]
+ account: Account,
+ #[arg(long, default_value_t = 20)]
+ limit: usize,
+ },
+ GandiRead {
+ #[arg(long, value_enum)]
+ account: Account,
+ #[arg(long)]
+ uid: u32,
+ },
+ GandiSend {
+ #[arg(long)]
+ to: String,
+ #[arg(long)]
+ subject: String,
+ },
}
#[derive(Deserialize, Default)]
@@ -92,6 +112,25 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
.init();
let cli = Cli::parse();
+ let command = cli.command.unwrap_or(Commands::Run);
+ match command {
+ Commands::GandiList { account, limit } => {
+ println!("{}", serde_json::to_string(&gandi::list(account, limit)?)?);
+ return Ok(());
+ }
+ Commands::GandiRead { account, uid } => {
+ println!("{}", serde_json::to_string(&gandi::read(account, uid)?)?);
+ return Ok(());
+ }
+ Commands::GandiSend { to, subject } => {
+ let mut body = String::new();
+ std::io::stdin().read_to_string(&mut body)?;
+ gandi::send_as_aien(&to, &subject, &body)?;
+ println!("Gandi SMTP accepted the message from aien@aienos.com");
+ return Ok(());
+ }
+ _ => {}
+ }
let store = Arc::new(MailStore::new(cli.mail_dir));
let cortex = Arc::new(CortexSync::new(None));
let operator_email = load_operator_email();
@@ -104,7 +143,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
&operator_email,
));
- match cli.command.unwrap_or(Commands::Run) {
+ match command {
Commands::Run => {
println!("📬 AIEN Sovereign Mail Engine starting...");
println!(" Local NVMe Storage: {}", store.base_path.display());
@@ -204,6 +243,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let sent = relay.send_email(req).await.map_err(std::io::Error::other)?;
println!("Test message saved and indexed into Cortex: {}", sent.id);
}
+ Commands::GandiList { .. } | Commands::GandiRead { .. } | Commands::GandiSend { .. } => {
+ unreachable!()
+ }
}
Ok(())