From 92956edf3d32e584c8a68824d127aa50222be6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 28 Oct 2026 09:03:13 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20init:=20workspace,=20iz-core=20b?= =?UTF-8?q?asics,=20store=20and=20initial=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 + Cargo.lock | 3500 +++++++++++++++++++++++ Cargo.toml | 61 + config/iz.example.toml | 29 + crates/iz-core/Cargo.toml | 32 + crates/iz-core/migrations/0001_init.sql | 308 ++ crates/iz-core/src/board.rs | 155 + crates/iz-core/src/config.rs | 259 ++ crates/iz-core/src/error.rs | 37 + crates/iz-core/src/lib.rs | 16 + crates/iz-core/src/limits.rs | 31 + crates/iz-core/src/secret.rs | 149 + crates/iz-core/src/store/migrate.rs | 62 + crates/iz-core/src/store/mod.rs | 358 +++ crates/iz-core/src/store/snapshot.rs | 87 + crates/iz-core/src/time.rs | 44 + crates/iz-core/src/token.rs | 50 + crates/iz-core/src/zones.rs | 112 + crates/iz-web/Cargo.toml | 14 + crates/iz-web/src/main.rs | 5 + docs/architecture.md | 231 ++ docs/contracts.md | 241 ++ docs/conventions.md | 169 ++ docs/reference/old-inventory.md | 530 ++++ 24 files changed, 6487 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 config/iz.example.toml create mode 100644 crates/iz-core/Cargo.toml create mode 100644 crates/iz-core/migrations/0001_init.sql create mode 100644 crates/iz-core/src/board.rs create mode 100644 crates/iz-core/src/config.rs create mode 100644 crates/iz-core/src/error.rs create mode 100644 crates/iz-core/src/lib.rs create mode 100644 crates/iz-core/src/limits.rs create mode 100644 crates/iz-core/src/secret.rs create mode 100644 crates/iz-core/src/store/migrate.rs create mode 100644 crates/iz-core/src/store/mod.rs create mode 100644 crates/iz-core/src/store/snapshot.rs create mode 100644 crates/iz-core/src/time.rs create mode 100644 crates/iz-core/src/token.rs create mode 100644 crates/iz-core/src/zones.rs create mode 100644 crates/iz-web/Cargo.toml create mode 100644 crates/iz-web/src/main.rs create mode 100644 docs/architecture.md create mode 100644 docs/contracts.md create mode 100644 docs/conventions.md create mode 100644 docs/reference/old-inventory.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ff05151 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +target/ +config/iz.toml +data/ +*.db +*.db-wal +*.db-shm +*.key diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..e064cf9 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3500 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common 0.1.7", + "generic-array", +] + +[[package]] +name = "aead" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" +dependencies = [ + "crypto-common 0.2.2", + "inout 0.2.5", +] + +[[package]] +name = "aegis" +version = "0.9.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41585f248ed9406567ae6d61ca2a55ed3dc7348e65203a01229881253acb95e3" +dependencies = [ + "cc", + "softaes", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures 0.2.17", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead 0.5.2", + "aes", + "cipher 0.4.4", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "allocator-api2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "antithesis_sdk" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8ed6751597568a284314fd9e2db420665898600109dedc7d8d9b588f00ae9c4" +dependencies = [ + "libc", + "libloading", + "linkme", + "once_cell", + "rand 0.8.8", + "rustc_version_runtime", + "serde", + "serde_json", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arc-swap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380962b3d93b99642e50b9febf72c071e97e8b32d86eae9cf4ef582bb960ae6e" +dependencies = [ + "rustversion", +] + +[[package]] +name = "aristo" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcdeefa800110050103e2459a2f8dbdbd560ad046e30f1f87e24ce19c2cb8bde" +dependencies = [ + "aristo-macros", +] + +[[package]] +name = "aristo-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d64a66d21a80182b35b1741997a6d2456911f54b7eb1918aa4e2382fc205268d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "assoc" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdc70193dadb9d7287fa4b633f15f90c876915b31f6af17da307fc59c9859a8" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bigdecimal" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa3f3d8cbf4dffcfe4991de61d012bef509a409ecbe9dd41049bfe32b4d4653" +dependencies = [ + "autocfg", + "libm", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease 0.2.37", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex 1.3.0", + "syn 2.0.119", + "which", +] + +[[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" + +[[package]] +name = "bitpacking" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a7139abd3d9cebf8cd6f920a389cf3dc9576172e32f4563f188cae3c3eb019" +dependencies = [ + "crunchy", +] + +[[package]] +name = "bitvec" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[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 = "bon" +version = "3.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05442cd7005532d0cfedec676b5b9333d2b4c7c3afabe2b1a9ce2742fbe2ee6" +dependencies = [ + "bon-macros", +] + +[[package]] +name = "bon-macros" +version = "3.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93833e97ac7c46ba97045afcf247238c27057538fcf2f06344662ddd5f567be6" +dependencies = [ + "darling", + "ident_case", + "prettyplease 0.3.0", + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "branches" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7436b21fd6195415058eb41c9090e156b556bc7e0377bb57c5c026a421521525" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex 2.0.1", +] + +[[package]] +name = "census" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4c707c6a209cbe82d10abd08e1ea8995e9ea937d2550646e02798948992be0" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "cfg_block" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cipher 0.5.2", + "cpufeatures 0.3.1", + "rand_core 0.10.1", +] + +[[package]] +name = "chacha20poly1305" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb" +dependencies = [ + "aead 0.6.1", + "chacha20", + "cipher 0.5.2", + "poly1305", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common 0.1.7", + "inout 0.1.4", +] + +[[package]] +name = "cipher" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" +dependencies = [ + "block-buffer", + "crypto-common 0.2.2", + "inout 0.2.5", +] + +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32c" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a47af21622d091a8f0fb295b88bc886ac74efcc613efc19f5d0b21de5c89e47" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "crc32fast" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "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 = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", +] + +[[package]] +name = "ctutils" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe3e9d21d39e6f39ff46e03d5b621424f88ee23d8a1672c6bfc9ccc7f2da4f6a" +dependencies = [ + "cmov", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.9", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "datasketches" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c286de4e81ea2590afc24d754e0f83810c566f50a1388fa75ebd57928c0d9745" + +[[package]] +name = "defmt" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "defmt-parser" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0" +dependencies = [ + "thiserror", +] + +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common 0.2.2", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "downcast-rs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "env_filter" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900d271a03799a1ee8d1ca9b19893b48ca674a9284fefcfb85f05e74ed314217" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de671bd27a75a797dc9ae289ba1e77276e75e2026408aab65185384e2d5cd3f6" +dependencies = [ + "env_filter", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "erased-serde" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e59b668157f32d3459d4bd634861a06ffa2503a461ca5f0916b9f0252605e66" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fastbloom" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7f34442dbe69c60fe8eaf58a8cafff81a1f278816d8ab4db255b3bef4ac3c4" +dependencies = [ + "getrandom 0.3.4", + "libm", + "siphasher", +] + +[[package]] +name = "fastdivide" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afc2bd4d5a73106dd53d10d73d3401c2f32730ba2c0b93ddb888a8983680471" + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "fs4" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8640e34b88f7652208ce9e88b1a37a2ae95227d84abec377ccd3c5cfeb141ed4" +dependencies = [ + "rustix 1.1.6", + "windows-sys 0.59.0", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "genawaiter" +version = "0.99.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86bd0361bcbde39b13475e6e36cb24c329964aa2611be285289d1e4b751c1a0" +dependencies = [ + "genawaiter-macro", +] + +[[package]] +name = "genawaiter-macro" +version = "0.99.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b32dfe1fdfc0bbde1f22a5da25355514b5e450c33a6af6770884c8750aedfbc" + +[[package]] +name = "generator" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be81b31c9ce4caf7f3178eeb90662bb1864d3ad363ec6bdada3201adff19c37" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows-link", + "windows-result", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 5.3.0", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", + "wasm-bindgen", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2 0.2.21", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "htmlescape" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "hybrid-array" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" +dependencies = [ + "typenum", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collator" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24cb0205c419b2036da3f9082964905d6849b3f2130dd4a517940c45899a544b" +dependencies = [ + "icu_collator_data", + "icu_collections", + "icu_locale_core", + "icu_locale_fallback", + "icu_normalizer", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "zerovec", +] + +[[package]] +name = "icu_collator_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183f47e821a327661c1ebe152f61d5b6c2000010d228cadbbf226e0e2b8c2634" + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe8fa57bcddc15cb921582ee5259c5b77da39f946f188ca5213fad24d9241236" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_locale_data", + "icu_locale_fallback", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "serde", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locale_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64014dac577a11d8d2cee48517c73c1984bd72ab11031e934269bd3cefb2ad9" + +[[package]] +name = "icu_locale_fallback" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406e9ae5b95d8aa37db6293405931b766a6172d1848daee22d70eb44aa78a43c" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632ebbd0c5c3637ba1a40bdf8288f2cb9d2268e73441a69d5fc73d7cfbaa87c" + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "serde", + "stable_deref_trait", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "inout" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b5cf4372d022092674a83b8febf5865f7a573cc0c5baec5e49c879b6a20978f" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "intrusive-collections" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "189d0897e4cbe8c75efedf3502c18c887b05046e59d28404d4d8e46cbc4d1e86" +dependencies = [ + "memoffset", +] + +[[package]] +name = "inventory" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +dependencies = [ + "rustversion", +] + +[[package]] +name = "io-uring" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3bd0ecfbb87805f538bb7b32e5239ca0763890c623e349860ecba69469f2bb" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "libc", +] + +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "iz-core" +version = "0.1.0" +dependencies = [ + "base64 0.23.1", + "chacha20poly1305", + "hex", + "ipnet", + "jiff", + "rand 0.10.3", + "serde", + "serde_json", + "sha2", + "subtle", + "tempfile", + "thiserror", + "time", + "tokio", + "toml", + "tracing", + "turso", + "ulid", +] + +[[package]] +name = "iz-web" +version = "0.1.0" + +[[package]] +name = "jiff" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b005715dcbeb0089a3c0dab99f2ff1cc3b2525323552703d648585d342a383" +dependencies = [ + "defmt", + "jiff-core", + "jiff-static", + "jiff-tzdb", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e52fe76043ccecc9005d2305ebaadf7d7fc0cc89ca6baa10a94d6bc68c7128c" +dependencies = [ + "defmt", + "log", +] + +[[package]] +name = "jiff-static" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc9817253cf7c7ee4684451bd327e88d6f3658014e54a29198625590650695c" +dependencies = [ + "jiff-core", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8377070c6bae868759445e5a77f66d84f0b72f3a054bfb00e6d038b8282da7" + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "levenshtein_automata" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2cdeb66e45e9f36bfad5bbdb4d2384e70936afbee843c6f6543f0c551ebb25" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libmimalloc-sys" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9" +dependencies = [ + "cc", +] + +[[package]] +name = "linkme" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3045e122bd98aef8ec3ad58ce84f0791f64e70163d1a02710af4aa11a4d54cc5" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77060ebe535362c3da75682cd17b0431017b6e7c5661e714fc69a7ad017d1301" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "lru" +version = "0.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" +dependencies = [ + "hashbrown 0.16.1", +] + +[[package]] +name = "lz4_flex" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "measure_time" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51c55d61e72fc3ab704396c5fa16f4c184db37978ae4e94ca8959693a235fc0e" +dependencies = [ + "log", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miette" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" +dependencies = [ + "cfg-if", + "miette-derive", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "mimalloc" +version = "0.1.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862" +dependencies = [ + "libmimalloc-sys", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "murmurhash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2195bf6aa996a481483b29d62a7663eed3fe39600c460e323f8ff41e90bdd89b" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "oneshot" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "269bca4c2591a28585d6bf10d9ed0332b7d76900a1b02bec41bdc3a2cdcda107" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "ordered-float" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ownedbytes" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fbd56f7631767e61784dc43f8580f403f4475bd4aaa4da003e6295e1bab4a7e" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "pack1" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b7bb0ecf2e447b1f20ee94ee79ef6eed1e9d4b3c36ce1903b9dea3bf205523" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pastey" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "poly1305" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c" +dependencies = [ + "cpufeatures 0.3.1", + "universal-hash 0.6.1", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.5.1", +] + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "serde_core", + "writeable", + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + +[[package]] +name = "prettyplease" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" +dependencies = [ + "proc-macro2", + "syn 3.0.9", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" +dependencies = [ + "anyhow", + "itertools 0.14.0", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "rapidhash" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" +dependencies = [ + "rustversion", +] + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "roaring" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bd8a37d17a58532776dcdf6041ce64929adca78e8489d5cacbafe99229d3e1" +dependencies = [ + "bytemuck", + "byteorder", +] + +[[package]] +name = "rust-stemmers" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46a2036019fdb888131db7a4c847a1063a7493f971ed94ea82c67eada63ca54" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustc_version_runtime" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dd18cd2bae1820af0b6ad5e54f4a51d0f3fcc53b05f845675074efcc7af071d" +dependencies = [ + "rustc_version", + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +dependencies = [ + "serde_core", +] + +[[package]] +name = "sha1_smol" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "shuttle" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab17edba38d63047f46780cf7360acf7467fec2c048928689a5c1dd1c2b4e31" +dependencies = [ + "assoc", + "bitvec", + "cfg-if", + "generator", + "hex", + "owo-colors", + "rand 0.8.8", + "rand_core 0.6.4", + "rand_pcg", + "scoped-tls", + "smallvec", + "tracing", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simsimd" +version = "6.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fb3bc3cdce07a7d7d4caa4c54f8aa967f6be41690482b54b24100a2253fa70" +dependencies = [ + "cc", +] + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "sketches-ddsketch" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53e2f8d4e9c692f23a90208fad6a64862f413e286d533f1f649f160e2d5caee" +dependencies = [ + "serde", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" + +[[package]] +name = "softaes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4fdfe13e1c42e45f497416afb8dc4e783bf0e25b7be9077c1c77c5fb14cb998" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.119", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "symlink" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tantivy" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "861facfabd71044968f364837f9a083b56464ba5a59079f88706ee5c451ca069" +dependencies = [ + "aho-corasick", + "arc-swap", + "base64 0.22.1", + "bitpacking", + "bon", + "byteorder", + "census", + "crc32fast", + "crossbeam-channel", + "datasketches", + "downcast-rs", + "fastdivide", + "fnv", + "fs4", + "htmlescape", + "itertools 0.14.0", + "levenshtein_automata", + "log", + "lru", + "lz4_flex", + "measure_time", + "memmap2", + "once_cell", + "oneshot", + "rayon", + "regex", + "rust-stemmers", + "rustc-hash 2.1.3", + "serde", + "serde_json", + "sketches-ddsketch", + "smallvec", + "tantivy-bitpacker", + "tantivy-columnar", + "tantivy-common", + "tantivy-fst", + "tantivy-query-grammar", + "tantivy-stacker", + "tantivy-tokenizer-api", + "tempfile", + "thiserror", + "time", + "typetag", + "uuid", + "winapi", +] + +[[package]] +name = "tantivy-bitpacker" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fed3d674429bcd2de5d0a6d1aa5495fed8afd9c5ecce993019caf7615f53fa4" +dependencies = [ + "bitpacking", +] + +[[package]] +name = "tantivy-columnar" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c57166f5bcfd478f370ab8445afb4678dce44801fa5ce5c451aaf8595583c5dc" +dependencies = [ + "downcast-rs", + "fastdivide", + "itertools 0.14.0", + "serde", + "tantivy-bitpacker", + "tantivy-common", + "tantivy-sstable", + "tantivy-stacker", +] + +[[package]] +name = "tantivy-common" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf10915aa75da3c3b0d58b58853d2e889efbaf32d4982a4c3715dde6bba23e5" +dependencies = [ + "async-trait", + "byteorder", + "ownedbytes", + "serde", + "time", +] + +[[package]] +name = "tantivy-fst" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d60769b80ad7953d8a7b2c70cdfe722bbcdcac6bccc8ac934c40c034d866fc18" +dependencies = [ + "byteorder", + "regex-syntax", + "utf8-ranges", +] + +[[package]] +name = "tantivy-query-grammar" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfadb8526b6da90704feb293b0701a6aae62ea14983143344be2dc5ce30f1d82" +dependencies = [ + "fnv", + "nom", + "ordered-float", + "serde", + "serde_json", +] + +[[package]] +name = "tantivy-sstable" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2cfc3ac5164cbadc28965ffb145a8f47582a60ae5897859ad8d4316596c606" +dependencies = [ + "futures-util", + "itertools 0.14.0", + "tantivy-bitpacker", + "tantivy-common", + "tantivy-fst", + "zstd", +] + +[[package]] +name = "tantivy-stacker" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cbb051742da9d53ca9e8fff43a9b10e319338b24e2c0e15d0372df19ffeb951" +dependencies = [ + "murmurhash32", + "tantivy-common", +] + +[[package]] +name = "tantivy-tokenizer-api" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac258c2c6390673f2685813afeeafcb8c4e0ee7de8dd3fc46838dcc37263f98" +dependencies = [ + "serde", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "serde_core", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "toml" +version = "1.1.8+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-appender" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c" +dependencies = [ + "crossbeam-channel", + "symlink", + "thiserror", + "time", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "turso" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1cf9c519a3a971e845a42c870930557cb53c2368c5737d4c78f8fbfd0444e98" +dependencies = [ + "mimalloc", + "thiserror", + "tracing", + "tracing-subscriber", + "turso_core", + "turso_sdk_kit", + "turso_sync_sdk_kit", +] + +[[package]] +name = "turso_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "810ee7b139fd6aa9304cb2fa278c1be0bb964c92457e2a24c1d384196ce5e217" +dependencies = [ + "aegis", + "aes", + "aes-gcm", + "allocator-api2 0.4.0", + "antithesis_sdk", + "arc-swap", + "aristo", + "bigdecimal", + "bitflags 2.13.2", + "branches", + "bumpalo", + "bytemuck", + "cfg_aliases", + "cfg_block", + "chrono", + "crc32c", + "crc32fast", + "crossbeam-epoch", + "crossbeam-utils", + "either", + "fallible-iterator", + "fastbloom", + "getrandom 0.2.17", + "getrandom 0.3.4", + "hex", + "icu_collator", + "icu_locale", + "intrusive-collections", + "io-uring", + "libc", + "libloading", + "libm", + "loom", + "miette", + "num-bigint", + "num-traits", + "pack1", + "parking_lot", + "pastey", + "polling", + "rand 0.9.5", + "rapidhash", + "regex", + "regex-syntax", + "roaring", + "rustc-hash 2.1.3", + "rustix 1.1.6", + "ryu", + "serde_json", + "shuttle", + "simdutf8", + "simsimd", + "smallvec", + "strum", + "strum_macros", + "tantivy", + "tempfile", + "thiserror", + "tracing", + "tracing-subscriber", + "turso_ext", + "turso_macros", + "turso_parser", + "twox-hash", + "uncased", + "uuid", + "windows-sys 0.61.2", +] + +[[package]] +name = "turso_ext" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5003ed7e98f082fe4114627c8d7c7ab569c27766e9bd350a0c09af06ad3fd46" +dependencies = [ + "chrono", + "getrandom 0.4.3", + "turso_macros", +] + +[[package]] +name = "turso_macros" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74770c0d0c8b272b479b5343f19dbd2f8f2677d85a4d6222fc214dcac2882beb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "turso_parser" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bb856ec8306ad7ed1c13fc61de6a79452bf646ca53d99bb4cc646d5bfc4ff" +dependencies = [ + "bitflags 2.13.2", + "memchr", + "miette", + "strum", + "strum_macros", + "thiserror", + "turso_macros", +] + +[[package]] +name = "turso_sdk_kit" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819a17926d04dbeb5b03f00cdab6ed7351bbb6778d00840364b9af62bca02914" +dependencies = [ + "bindgen", + "env_logger", + "parking_lot", + "tracing", + "tracing-appender", + "tracing-subscriber", + "turso_core", + "turso_ext", + "turso_sdk_kit_macros", +] + +[[package]] +name = "turso_sdk_kit_macros" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f315d7f8c5bba49d1c7ca000664a455085cb95f0fa8031c6dc1f67d6d0f28e1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "turso_sync_engine" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8d37dca9e05cc090ca3d73083f82fc63b0d11c33550308ca5d93668a8441b71" +dependencies = [ + "base64 0.22.1", + "bytes", + "crc32c", + "genawaiter", + "http", + "libc", + "prost", + "roaring", + "serde", + "serde_json", + "thiserror", + "tracing", + "turso_core", + "turso_parser", + "uuid", +] + +[[package]] +name = "turso_sync_sdk_kit" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fe4b961c9cc90f6339447dabfe83ed13a498721e41378932ab7eaf8ddd6976" +dependencies = [ + "bindgen", + "env_logger", + "genawaiter", + "parking_lot", + "tracing", + "tracing-appender", + "tracing-subscriber", + "turso_core", + "turso_sdk_kit", + "turso_sdk_kit_macros", + "turso_sync_engine", +] + +[[package]] +name = "twox-hash" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86a801b3cea342a06d468c8710662aa29e5e05e4f5c0d62f00bbb7f2ad7941c2" +dependencies = [ + "rand 0.10.3", +] + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "typetag" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c90e86058a30d42a1a928dfb4b49bb33c98c3a2b4909492e6b0881cd94798ec2" +dependencies = [ + "erased-serde", + "inventory", + "once_cell", + "serde", + "typetag-impl", +] + +[[package]] +name = "typetag-impl" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f153acc4e99a5f2a5aefa09fb078be54e26271b2813f6041200b224c098d8328" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "ulid" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "947dde63b6d514cc5e044edad4e0ca7261afd1099d16c83d942cb2b2f348689c" +dependencies = [ + "rand 0.10.3", + "web-time", +] + +[[package]] +name = "uncased" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common 0.1.7", + "subtle", +] + +[[package]] +name = "universal-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" +dependencies = [ + "crypto-common 0.2.2", + "ctutils", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8-ranges" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" +dependencies = [ + "getrandom 0.4.3", + "js-sys", + "serde_core", + "sha1_smol", + "wasm-bindgen", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.44", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "serde", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.1.2+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..749027d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,61 @@ +[workspace] +resolver = "3" +members = [ + "crates/iz-core", + "crates/iz-web", +] + +[workspace.package] +version = "0.1.0" +edition = "2024" +license = "AGPL-3.0-or-later" + +[workspace.dependencies] +# external crates (versions are the latest releases when added) +base64 = "0.23.1" +chacha20poly1305 = "0.11.0" +hex = "0.4.3" +ipnet = "2.12.2" +jiff = { version = "0.2.38", default-features = false, features = ["std", "tzdb-bundle-always"] } +rand = "0.10.3" +serde = "1.0.229" +serde_json = "1.0.154" +sha2 = "0.11.1" +subtle = "2.6.1" +tempfile = "3.27.0" +thiserror = "2.0.21" +time = { version = "0.3.55", features = ["formatting", "parsing", "macros"] } +tokio = { version = "1.54.1", features = ["macros", "rt", "sync"] } +toml = "1.1.8" +tracing = "0.1.44" +turso = "0.8.3" +ulid = "3.0.0" + +# internal crates +iz-core = { path = "crates/iz-core" } + +[workspace.lints.rust] +unsafe_code = "forbid" + +[profile.dev] +# Line tables keep file:line in backtraces but drop variable info; binaries and links are much smaller. +debug = "line-tables-only" + +[profile.dev.package.sha2] +# Hashes attachments and audit digests at boot and on upload; unoptimized it is slow. +opt-level = 3 + +[profile.dev.package.turso_core] +# Migrations run through turso_core on every test's fresh store; unoptimized it is slow. +opt-level = 3 + +[profile.dev.package.turso_parser] +opt-level = 3 + +[profile.dev.package.chacha20poly1305] +# Seals secrets at rest on every save and open; unoptimized it is slow. +opt-level = 3 + +[profile.release] +lto = true +codegen-units = 1 diff --git a/config/iz.example.toml b/config/iz.example.toml new file mode 100644 index 0000000..b1bc69d --- /dev/null +++ b/config/iz.example.toml @@ -0,0 +1,29 @@ +# iz configuration (development defaults). Copy to config/iz.toml or let iz create it on first run. +# Secrets are not stored here: the OIDC client secret and the mail password are entered in the admin UI. + +# Database file. The -wal and -shm files sit next to it. +database = "data/iz.db" +# Directory for the instance key (iz.key), attachments and other local files. +data_dir = "data" +# HTTP listen address. Keep it on loopback behind a reverse proxy. +listen = "127.0.0.1:7654" +# Public base URL used in links and mail. No trailing slash. +base_url = "http://127.0.0.1:7654" +# Peers whose X-Forwarded-For is trusted for client IPs. Addresses or CIDR networks. +trusted_proxies = [] + +# Identity provider (OpenID Connect). Uncomment to enable sign-in. +# [oidc] +# issuer = "https://im.example.com" +# client_id = "iz" + +# Attachments in the external Files service instead of local disk. +[in_store] +enabled = false + +# Scheduled backups. Uncomment to enable. +# [backup] +# dir = "data/backups" +# interval_hours = 24 +# keep = 14 +# healthcheck_url = "https://hc.example.com/ping/iz" diff --git a/crates/iz-core/Cargo.toml b/crates/iz-core/Cargo.toml new file mode 100644 index 0000000..9621371 --- /dev/null +++ b/crates/iz-core/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "iz-core" +description = "Domain types, store, migrations, config, secrets and pure board rules for iz" +version.workspace = true +edition.workspace = true +license.workspace = true +publish = false + +[lints] +workspace = true + +[dependencies] +base64.workspace = true +chacha20poly1305.workspace = true +hex.workspace = true +ipnet.workspace = true +jiff.workspace = true +rand.workspace = true +serde.workspace = true +serde_json.workspace = true +sha2.workspace = true +subtle.workspace = true +thiserror.workspace = true +time.workspace = true +tokio.workspace = true +toml.workspace = true +tracing.workspace = true +turso.workspace = true +ulid.workspace = true + +[dev-dependencies] +tempfile.workspace = true diff --git a/crates/iz-core/migrations/0001_init.sql b/crates/iz-core/migrations/0001_init.sql new file mode 100644 index 0000000..02d9aa4 --- /dev/null +++ b/crates/iz-core/migrations/0001_init.sql @@ -0,0 +1,308 @@ +-- 0001: the first iz schema (docs/architecture.md section 3). Applied by store/migrate.rs, which records +-- the version in schema_migrations. Ids are ULID text. Timestamps are RFC 3339 UTC text with 9 fractional +-- digits (time::now_stamp), fixed width, so text order is time order. Deadlines are YYYY-MM-DD text. +-- Booleans are INTEGER 0/1 with a CHECK. + +CREATE TABLE members ( + sub TEXT PRIMARY KEY, + email TEXT NOT NULL, + name TEXT NOT NULL, + im_admin INTEGER NOT NULL DEFAULT 0 CHECK (im_admin IN (0, 1)), + disabled INTEGER NOT NULL DEFAULT 0 CHECK (disabled IN (0, 1)), + locale TEXT CHECK (locale IS NULL OR locale IN ('en', 'tr')), + locale_override TEXT CHECK (locale_override IS NULL OR locale_override IN ('en', 'tr')), + zoneinfo TEXT NOT NULL DEFAULT 'UTC' CHECK (length(zoneinfo) BETWEEN 1 AND 64), + role TEXT NOT NULL DEFAULT 'member' CHECK (role IN ('admin', 'member', 'viewer', 'none')), + theme TEXT NOT NULL DEFAULT 'system' CHECK (theme IN ('system', 'light', 'dark')), + ui TEXT NOT NULL DEFAULT 'instrument' CHECK (ui IN ('instrument', 'ledger')), + picture_version INTEGER NOT NULL DEFAULT 0 CHECK (picture_version >= 0), + im_updated_at TEXT, + first_seen_at TEXT NOT NULL, + last_sign_in_at TEXT +); + +-- Local sessions. Only the SHA-256 of the cookie token is stored. `sid` is the im browser session id, +-- used by back-channel logout. +CREATE TABLE sessions ( + id TEXT PRIMARY KEY, + sub TEXT NOT NULL REFERENCES members(sub) ON DELETE CASCADE, + token_hash TEXT NOT NULL UNIQUE, + csrf_token TEXT NOT NULL, + sid TEXT, + created_at TEXT NOT NULL, + expires_at TEXT NOT NULL, + last_seen TEXT NOT NULL, + user_agent TEXT, + ip TEXT +); +CREATE INDEX sessions_by_sub ON sessions(sub); +CREATE INDEX sessions_by_sid ON sessions(sid) WHERE sid IS NOT NULL; +CREATE INDEX sessions_by_expiry ON sessions(expires_at); + +-- Logout-token ids already accepted. A replayed jti is refused until its row expires. +CREATE TABLE seen_logout_jti ( + jti TEXT PRIMARY KEY, + expires_at TEXT NOT NULL +); +CREATE INDEX seen_logout_jti_by_expiry ON seen_logout_jti(expires_at); + +-- One board per instance for now, but every board-scoped table carries board_id. +-- next_task_number is the per-board counter behind task keys (PREFIX-); it only goes up. +CREATE TABLE boards ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 100), + key_prefix TEXT NOT NULL CHECK (length(key_prefix) BETWEEN 2 AND 6 AND key_prefix NOT GLOB '*[^A-Z]*'), + next_task_number INTEGER NOT NULL DEFAULT 1 CHECK (next_task_number >= 1), + created_at TEXT NOT NULL +); + +CREATE TABLE columns ( + id TEXT PRIMARY KEY, + board_id TEXT NOT NULL REFERENCES boards(id) ON DELETE CASCADE, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 60), + position INTEGER NOT NULL, + is_done INTEGER NOT NULL DEFAULT 0 CHECK (is_done IN (0, 1)), + created_at TEXT NOT NULL, + -- Columns are retired, never deleted, so transitions keep naming them. + deleted_at TEXT +); +CREATE INDEX columns_by_board ON columns(board_id, position); +-- At most one done column per board. The store makes sure there is always exactly one. +CREATE UNIQUE INDEX columns_one_done ON columns(board_id) WHERE is_done = 1 AND deleted_at IS NULL; + +CREATE TABLE tags ( + id TEXT PRIMARY KEY, + board_id TEXT NOT NULL REFERENCES boards(id) ON DELETE CASCADE, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 60), + position REAL NOT NULL, + is_default INTEGER NOT NULL DEFAULT 0 CHECK (is_default IN (0, 1)), + color TEXT CHECK (color IS NULL OR length(color) BETWEEN 1 AND 20), + created_at TEXT NOT NULL +); +CREATE INDEX tags_by_board ON tags(board_id, position); +CREATE UNIQUE INDEX tags_name_per_board ON tags(board_id, name COLLATE NOCASE); +CREATE UNIQUE INDEX tags_one_default ON tags(board_id) WHERE is_default = 1; + +CREATE TABLE tasks ( + id TEXT PRIMARY KEY, + board_id TEXT NOT NULL REFERENCES boards(id) ON DELETE CASCADE, + key TEXT NOT NULL, + -- One level of subtasks. The trigger below enforces it for the whole table. + parent_id TEXT REFERENCES tasks(id) ON DELETE CASCADE, + title TEXT NOT NULL CHECK (length(title) BETWEEN 1 AND 200), + description TEXT NOT NULL DEFAULT '' CHECK (length(description) <= 20000), + column_id TEXT NOT NULL REFERENCES columns(id) ON DELETE RESTRICT, + tag_id TEXT NOT NULL REFERENCES tags(id) ON DELETE RESTRICT, + deadline TEXT CHECK (deadline IS NULL OR deadline GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'), + -- UTC instant, same fixed-width format as every other stamp (30 characters). + meeting_at TEXT CHECK (meeting_at IS NULL OR (length(meeting_at) = 30 AND meeting_at LIKE '%Z')), + position REAL NOT NULL, + created_by TEXT NOT NULL REFERENCES members(sub) ON DELETE RESTRICT, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + done_at TEXT, + deleted_at TEXT, + CHECK (parent_id IS NULL OR parent_id <> id), + UNIQUE (board_id, key) +); +CREATE INDEX tasks_by_column ON tasks(board_id, column_id, position); +CREATE INDEX tasks_by_parent ON tasks(parent_id) WHERE parent_id IS NOT NULL; +CREATE INDEX tasks_by_tag ON tasks(tag_id); +CREATE INDEX tasks_by_deadline ON tasks(board_id, deadline) WHERE deadline IS NOT NULL; + +-- One level of subtasks. A task may get a parent only if that parent is top-level, the task has no +-- children of its own, and it is not its own parent. The same rules hold when a task is inserted with +-- a parent. Each rejection aborts the statement with the message the store shows the user. +CREATE TRIGGER tasks_subtask_insert_one_level +BEFORE INSERT ON tasks +WHEN NEW.parent_id IS NOT NULL + AND (SELECT parent_id FROM tasks WHERE id = NEW.parent_id) IS NOT NULL +BEGIN + SELECT RAISE(ABORT, 'subtasks may only be one level deep'); +END; + +CREATE TRIGGER tasks_subtask_update_one_level +BEFORE UPDATE OF parent_id ON tasks +WHEN NEW.parent_id IS NOT NULL + AND ( + (SELECT parent_id FROM tasks WHERE id = NEW.parent_id) IS NOT NULL + OR EXISTS (SELECT 1 FROM tasks WHERE parent_id = NEW.id) + ) +BEGIN + SELECT RAISE(ABORT, 'subtasks may only be one level deep'); +END; + +CREATE TABLE task_assignees ( + task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + sub TEXT NOT NULL REFERENCES members(sub) ON DELETE CASCADE, + assigned_at TEXT NOT NULL, + PRIMARY KEY (task_id, sub) +); +CREATE INDEX task_assignees_by_sub ON task_assignees(sub); + +CREATE TABLE task_watchers ( + task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + sub TEXT NOT NULL REFERENCES members(sub) ON DELETE CASCADE, + created_at TEXT NOT NULL, + PRIMARY KEY (task_id, sub) +); +CREATE INDEX task_watchers_by_sub ON task_watchers(sub); + +-- blocked is blocked by blocking. Cleared edges stay for history and stop counting. +CREATE TABLE dependencies ( + blocked_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + blocking_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + created_at TEXT NOT NULL, + cleared_at TEXT, + PRIMARY KEY (blocked_id, blocking_id), + CHECK (blocked_id <> blocking_id) +); +CREATE INDEX dependencies_by_blocking ON dependencies(blocking_id); + +CREATE TABLE comments ( + id TEXT PRIMARY KEY, + task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + author TEXT NOT NULL REFERENCES members(sub) ON DELETE RESTRICT, + body TEXT NOT NULL CHECK (length(body) BETWEEN 1 AND 10000), + created_at TEXT NOT NULL, + edited_at TEXT, + deleted_at TEXT +); +CREATE INDEX comments_by_task ON comments(task_id, created_at); + +CREATE TABLE attachments ( + id TEXT PRIMARY KEY, + task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + comment_id TEXT REFERENCES comments(id) ON DELETE SET NULL, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 255), + mime TEXT NOT NULL, + size INTEGER NOT NULL CHECK (size >= 0), + sha256 TEXT NOT NULL CHECK (length(sha256) = 64), + uploaded_by TEXT NOT NULL REFERENCES members(sub) ON DELETE RESTRICT, + created_at TEXT NOT NULL, + location TEXT NOT NULL DEFAULT 'local' CHECK (location IN ('local', 'in', 'moving')) +); +CREATE INDEX attachments_by_task ON attachments(task_id); + +-- One row per card move (and the initial placement, where from_column is NULL). +CREATE TABLE transitions ( + id TEXT PRIMARY KEY, + task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + from_column TEXT REFERENCES columns(id) ON DELETE RESTRICT, + to_column TEXT NOT NULL REFERENCES columns(id) ON DELETE RESTRICT, + actor TEXT NOT NULL REFERENCES members(sub) ON DELETE RESTRICT, + at TEXT NOT NULL +); +CREATE INDEX transitions_by_task ON transitions(task_id, at); + +-- Activity trail. task_id is NULL for account or board events. actor is NULL for system events. +CREATE TABLE activity ( + id TEXT PRIMARY KEY, + task_id TEXT REFERENCES tasks(id) ON DELETE CASCADE, + actor TEXT REFERENCES members(sub) ON DELETE SET NULL, + subject TEXT REFERENCES members(sub) ON DELETE SET NULL, + kind TEXT NOT NULL CHECK (kind IN ( + 'task_created', 'task_edited', 'task_moved', 'task_deleted', + 'assigned', 'unassigned', 'tag_changed', 'parent_changed', + 'link_added', 'link_removed', 'unblocked', + 'deadline_set', 'deadline_cleared', 'clock_set', 'clock_cleared', + 'watch_changed', 'comment_added', 'comment_edited', 'comment_deleted', + 'file_added', 'file_deleted', 'reminded', 'account_changed' + )), + detail TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(detail)), + at TEXT NOT NULL +); +CREATE INDEX activity_by_task ON activity(task_id, at); +CREATE INDEX activity_recent ON activity(at); + +-- Mail rules. One action per rule: send mail. Only status rules may name a column. +CREATE TABLE mail_rules ( + id TEXT PRIMARY KEY, + board_id TEXT NOT NULL REFERENCES boards(id) ON DELETE CASCADE, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 120), + trigger TEXT NOT NULL CHECK (trigger IN ( + 'status', 'unblocked', 'created', 'assigned', 'unassigned', 'commented', + 'deadline_set', 'deadline_cleared', 'retitled', 'linked', 'unlinked', 'deleted' + )), + column_id TEXT REFERENCES columns(id) ON DELETE CASCADE, + tag_id TEXT REFERENCES tags(id) ON DELETE CASCADE, + audience TEXT NOT NULL CHECK (audience IN ('assignees', 'board', 'creator', 'watchers')), + include_details INTEGER NOT NULL DEFAULT 0 CHECK (include_details IN (0, 1)), + enabled INTEGER NOT NULL DEFAULT 1 CHECK (enabled IN (0, 1)), + subject_template TEXT NOT NULL CHECK (length(subject_template) BETWEEN 1 AND 120), + created_at TEXT NOT NULL, + CHECK (column_id IS NULL OR trigger = 'status') +); +CREATE INDEX mail_rules_by_board ON mail_rules(board_id); + +-- Outbox. The unique key decides who owns a send: one claim per (rule, event, task, recipient). +-- A NULL rule_id (notices, reminders, tests) is never equal to another NULL, so those rows are not +-- deduplicated by this index; the reminder worker deduplicates them by its own key. +CREATE TABLE mail_outbox ( + id TEXT PRIMARY KEY, + rule_id TEXT REFERENCES mail_rules(id) ON DELETE SET NULL, + event_id TEXT NOT NULL, + task_id TEXT REFERENCES tasks(id) ON DELETE CASCADE, + recipient TEXT NOT NULL REFERENCES members(sub) ON DELETE CASCADE, + kind TEXT NOT NULL CHECK (kind IN ('rule', 'notice', 'reminder', 'test')), + subject TEXT NOT NULL, + body TEXT NOT NULL, + state TEXT NOT NULL DEFAULT 'pending' CHECK (state IN ('pending', 'sent', 'failed', 'abandoned')), + attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0), + last_error TEXT, + claimed_at TEXT, + next_attempt_at TEXT NOT NULL, + sent_at TEXT, + created_at TEXT NOT NULL, + UNIQUE (rule_id, event_id, task_id, recipient), + CHECK (state <> 'sent' OR sent_at IS NOT NULL) +); +CREATE INDEX mail_outbox_due ON mail_outbox(state, next_attempt_at); +CREATE INDEX mail_outbox_by_task ON mail_outbox(task_id); + +-- Ledger of rule verdicts. task_id has no foreign key, so the ledger survives task deletion. +CREATE TABLE mail_decisions ( + id TEXT PRIMARY KEY, + rule_id TEXT NOT NULL REFERENCES mail_rules(id) ON DELETE CASCADE, + event_id TEXT NOT NULL, + task_id TEXT, + outcome TEXT NOT NULL CHECK (outcome IN ( + 'owed', 'already_owed', 'no_recipients', 'not_matched', 'disabled', 'task_gone' + )), + detail TEXT NOT NULL DEFAULT '', + created_at TEXT NOT NULL, + UNIQUE (rule_id, event_id, task_id) +); +CREATE INDEX mail_decisions_recent ON mail_decisions(created_at); + +-- Clock reminders, one per assignee and task. Rebuilt whenever the meeting time, assignees, done state +-- or deletion of the task changes. +CREATE TABLE reminders ( + task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE, + sub TEXT NOT NULL REFERENCES members(sub) ON DELETE CASCADE, + due_at TEXT NOT NULL, + sent_at TEXT, + PRIMARY KEY (task_id, sub) +); +CREATE INDEX reminders_due ON reminders(due_at) WHERE sent_at IS NULL; + +-- Append-only. Purged only through the admin CLI. +CREATE TABLE audit_log ( + id TEXT PRIMARY KEY, + at TEXT NOT NULL, + actor_id TEXT, + actor_kind TEXT NOT NULL CHECK (actor_kind IN ('member', 'admin', 'system', 'anonymous')), + action TEXT NOT NULL, + target_kind TEXT NOT NULL, + target_id TEXT, + ip TEXT, + data TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(data)) +); +CREATE INDEX audit_log_by_at ON audit_log(at); + +-- Runtime settings (UI overrides of the file config, and stored values such as the sealed SMTP password). +CREATE TABLE settings ( + key TEXT PRIMARY KEY CHECK (length(key) BETWEEN 1 AND 100), + value TEXT NOT NULL, + updated_at TEXT NOT NULL +); diff --git a/crates/iz-core/src/board.rs b/crates/iz-core/src/board.rs new file mode 100644 index 0000000..d29af8f --- /dev/null +++ b/crates/iz-core/src/board.rs @@ -0,0 +1,155 @@ +//! Pure board rules (docs/architecture.md section 5): overdue, dependency cycles, card ordering and +//! task keys. No I/O here, so every rule can be tested as a truth table. + +use std::collections::{HashMap, HashSet, VecDeque}; +use std::hash::Hash; + +use jiff::Timestamp; +use jiff::civil::Date; +use jiff::tz::TimeZone; + +/// Whether a task is overdue. +/// +/// A done task is never overdue. A task with a meeting time is overdue when that instant is at or +/// before `now`; the meeting time is more precise than a day, so it wins over `deadline`. A task +/// with only a day is overdue when that day is before today in `viewer_zone`, so the same card can +/// be late for one viewer and on time for another. +pub fn is_overdue( + done: bool, + deadline: Option, + meeting_at: Option, + now: Timestamp, + viewer_zone: &TimeZone, +) -> bool { + if done { + return false; + } + if let Some(meeting) = meeting_at { + return meeting <= now; + } + match deadline { + Some(day) => day < now.to_zoned(viewer_zone.clone()).date(), + None => false, + } +} + +/// Whether adding `new_edge` to `edges` would create a cycle. +/// +/// An edge `(blocked, blocking)` means `blocked` waits for `blocking`. Adding `(x, y)` closes a +/// cycle when `y` already waits, directly or through other edges, for `x`, or when `x == y`. +/// Pass only live edges (not cleared ones); a cleared edge no longer blocks anything. +pub fn would_cycle(edges: &[(T, T)], new_edge: (T, T)) -> bool { + let (blocked, blocking) = new_edge; + if blocked == blocking { + return true; + } + // Follow blocked -> blocking from `blocking`; reaching `blocked` means a cycle. + let mut next: HashMap> = HashMap::new(); + for &(from, to) in edges { + next.entry(from).or_default().push(to); + } + let mut seen = HashSet::from([blocking]); + let mut queue = VecDeque::from([blocking]); + while let Some(node) = queue.pop_front() { + if node == blocked { + return true; + } + for &to in next.get(&node).into_iter().flatten() { + if seen.insert(to) { + queue.push_back(to); + } + } + } + false +} + +/// A position for a card placed between two neighbours (`None` at an end of the column). +/// +/// Positions are floats so that moving a card rewrites only that card. An empty column starts at +/// `1.0`; a card at either end moves by `1.0`; a card between two neighbours takes the midpoint. +pub fn position_between(before: Option, after: Option) -> f64 { + match (before, after) { + (None, None) => 1.0, + (Some(b), None) => b + 1.0, + (None, Some(a)) => a - 1.0, + (Some(b), Some(a)) => (b + a) / 2.0, + } +} + +/// A task key: `PREFIX-n`, for example `IZ-42`. The counter `n` comes from the board row. +pub fn format_key(prefix: &str, n: u64) -> String { + format!("{prefix}-{n}") +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::zones::parse_zone; + + fn ts(s: &str) -> Timestamp { + s.parse().unwrap() + } + + fn day(y: i16, m: i8, d: i8) -> Option { + Some(Date::new(y, m, d).unwrap()) + } + + #[test] + fn overdue_truth_table() { + let utc = TimeZone::UTC; + let now = ts("2026-10-28T12:00:00Z"); + // 1. A done task is never overdue, even with a past deadline. + assert!(!is_overdue(true, day(2026, 10, 1), None, now, &utc)); + // 2. A past meeting time is overdue. + assert!(is_overdue( + false, + None, + Some(ts("2026-10-28T11:59:59Z")), + now, + &utc + )); + // 3. A meeting exactly at now is overdue. + assert!(is_overdue(false, None, Some(now), now, &utc)); + // 4. A future meeting is not overdue, even when the day is in the past. + assert!(!is_overdue( + false, + day(2026, 10, 1), + Some(ts("2026-10-28T13:00:00Z")), + now, + &utc + )); + // 5. A day before today is overdue; today itself is not. + assert!(is_overdue(false, day(2026, 10, 27), None, now, &utc)); + assert!(!is_overdue(false, day(2026, 10, 28), None, now, &utc)); + // 6. No date at all is never overdue. + assert!(!is_overdue(false, None, None, now, &utc)); + // 7. The day rule uses the viewer's zone: 23:30Z is already 10-29 in Tokyo. + let late_utc = ts("2026-10-28T23:30:00Z"); + let tokyo = parse_zone("Asia/Tokyo").unwrap(); + assert!(!is_overdue(false, day(2026, 10, 28), None, late_utc, &utc)); + assert!(is_overdue(false, day(2026, 10, 28), None, late_utc, &tokyo)); + } + + #[test] + fn cycles_are_detected_over_live_edges() { + // An edge is (blocked, blocking). + assert!(!would_cycle::(&[], (1, 2))); + assert!(would_cycle::(&[], (3, 3))); + // 1 waits for 2; now 2 waits for 1 closes a loop. + assert!(would_cycle(&[(1, 2)], (2, 1))); + // 1 waits for 2 and 2 waits for 3; 3 waiting for 1 closes a three-step loop. + assert!(would_cycle(&[(1, 2), (2, 3)], (3, 1))); + // An unrelated edge does not close anything. + assert!(!would_cycle(&[(1, 2), (2, 3)], (1, 3))); + assert!(!would_cycle(&[(1, 2)], (4, 2))); + } + + #[test] + fn positions_and_keys() { + assert_eq!(position_between(None, None), 1.0); + assert_eq!(position_between(Some(2.0), None), 3.0); + assert_eq!(position_between(None, Some(2.0)), 1.0); + assert_eq!(position_between(Some(1.0), Some(2.0)), 1.5); + assert_eq!(format_key("IZ", 42), "IZ-42"); + } +} diff --git a/crates/iz-core/src/config.rs b/crates/iz-core/src/config.rs new file mode 100644 index 0000000..dd48a3c --- /dev/null +++ b/crates/iz-core/src/config.rs @@ -0,0 +1,259 @@ +//! Instance configuration from TOML. Secrets never live here: the OIDC client secret and the SMTP +//! password are entered in the admin UI and sealed in the database. Every struct denies unknown +//! keys, so a misspelled option fails at boot instead of being silently ignored. + +use std::net::{IpAddr, SocketAddr}; +use std::path::{Path, PathBuf}; + +use ipnet::IpNet; +use serde::{Deserialize, Deserializer}; + +use crate::error::{Error, Result}; + +/// The committed example config. Written to the config path when that file is missing. +const EXAMPLE: &str = include_str!("../../../config/iz.example.toml"); + +/// Top-level configuration. +#[derive(Debug, Clone, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Config { + /// SQLite/Turso database file. + #[serde(default = "default_database")] + pub database: PathBuf, + /// Directory for the instance key, attachments and other local files. + #[serde(default = "default_data_dir")] + pub data_dir: PathBuf, + /// HTTP listen address. + #[serde(default = "default_listen")] + pub listen: SocketAddr, + /// Public base URL used in links and mail. No trailing slash. + #[serde(default = "default_base_url")] + pub base_url: String, + /// Peers whose `X-Forwarded-For` is trusted. Entries are CIDR networks or bare addresses. + #[serde(default, deserialize_with = "deserialize_trusted_proxies")] + pub trusted_proxies: Vec, + /// OpenID Connect provider. Absent means sign-in is not configured. + #[serde(default)] + pub oidc: Option, + /// Use of the external Files service for attachments. + #[serde(default)] + pub in_store: InStoreConfig, + /// Scheduled backups. Absent means no backups are scheduled. + #[serde(default)] + pub backup: Option, +} + +/// The identity provider. The client secret is not here; it is sealed in the database. +#[derive(Debug, Clone, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct OidcConfig { + /// Issuer URL, for example `https://im.example.com`. Must be https, or http on loopback. + pub issuer: String, + /// Client id registered with the provider. + pub client_id: String, +} + +/// Switch for storing attachments in the external Files service. +#[derive(Debug, Clone, Default, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct InStoreConfig { + /// Whether the Files service is enabled. Defaults to off. + #[serde(default)] + pub enabled: bool, +} + +/// Scheduled backup policy. +#[derive(Debug, Clone, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct BackupConfig { + /// Directory that receives the backup sets. + pub dir: PathBuf, + /// Hours between backups. Between 1 and 720. + #[serde(default = "default_backup_interval_hours")] + pub interval_hours: u32, + /// Backup sets to keep. Between 1 and 365. + #[serde(default = "default_backup_keep")] + pub keep: u32, + /// Optional URL pinged after each successful backup (for example a dead-man's switch). + #[serde(default)] + pub healthcheck_url: Option, +} + +fn default_database() -> PathBuf { + PathBuf::from("data/iz.db") +} + +fn default_data_dir() -> PathBuf { + PathBuf::from("data") +} + +fn default_listen() -> SocketAddr { + // Loopback by default: the service sits behind a reverse proxy. + SocketAddr::from(([127, 0, 0, 1], 7654)) +} + +fn default_base_url() -> String { + "http://127.0.0.1:7654".to_owned() +} + +fn default_backup_interval_hours() -> u32 { + 24 +} + +fn default_backup_keep() -> u32 { + 14 +} + +/// Parses each entry as a CIDR network, or as a single address (a /32 or /128). +fn deserialize_trusted_proxies<'de, D: Deserializer<'de>>( + deserializer: D, +) -> std::result::Result, D::Error> { + let entries = Vec::::deserialize(deserializer)?; + entries + .iter() + .map(|entry| { + if let Ok(net) = entry.parse::() { + return Ok(net); + } + entry + .parse::() + .map(IpNet::from) + .map_err(|_| serde::de::Error::custom(format!("invalid trusted proxy `{entry}`"))) + }) + .collect() +} + +impl Config { + /// Loads and validates the config at `path`. A missing file is created from the example first. + pub fn load(path: &Path) -> Result { + let text = match std::fs::read_to_string(path) { + Ok(text) => text, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => { + if let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) { + std::fs::create_dir_all(parent)?; + } + std::fs::write(path, EXAMPLE)?; + EXAMPLE.to_owned() + } + Err(e) => return Err(e.into()), + }; + Self::parse(&text).map_err(|e| match e { + Error::Config(msg) => Error::Config(format!("{}: {msg}", path.display())), + other => other, + }) + } + + /// Parses and validates config text. + pub fn parse(text: &str) -> Result { + let config: Config = toml::from_str(text).map_err(|e| Error::Config(e.to_string()))?; + config.validate()?; + Ok(config) + } + + /// The cross-field rules. The loader runs them, and so does any UI override before it is saved. + pub fn validate(&self) -> Result<()> { + if self.database.as_os_str().is_empty() { + return Err(Error::Config("database must not be empty".into())); + } + if self.data_dir.as_os_str().is_empty() { + return Err(Error::Config("data_dir must not be empty".into())); + } + if !(self.base_url.starts_with("https://") || self.base_url.starts_with("http://")) { + return Err(Error::Config( + "base_url must start with https:// or http://".into(), + )); + } + if self.base_url.ends_with('/') { + return Err(Error::Config("base_url must not end with /".into())); + } + if let Some(oidc) = &self.oidc { + validate_issuer(&oidc.issuer)?; + if oidc.client_id.trim().is_empty() || oidc.client_id.len() > 200 { + return Err(Error::Config( + "oidc.client_id must be 1 to 200 characters".into(), + )); + } + } + if let Some(backup) = &self.backup { + if backup.dir.as_os_str().is_empty() { + return Err(Error::Config("backup.dir must not be empty".into())); + } + if !(1..=720).contains(&backup.interval_hours) { + return Err(Error::Config( + "backup.interval_hours must be 1 to 720".into(), + )); + } + if !(1..=365).contains(&backup.keep) { + return Err(Error::Config("backup.keep must be 1 to 365".into())); + } + if let Some(url) = &backup.healthcheck_url + && !(url.starts_with("https://") || url.starts_with("http://")) + { + return Err(Error::Config( + "backup.healthcheck_url must be an http(s) URL".into(), + )); + } + } + Ok(()) + } +} + +/// An issuer must be https. Plain http is allowed only for loopback, which is how a local +/// identity provider is reached in development. +fn validate_issuer(issuer: &str) -> Result<()> { + let loopback = issuer.starts_with("http://127.0.0.1") || issuer.starts_with("http://localhost"); + if issuer.starts_with("https://") || loopback { + Ok(()) + } else { + Err(Error::Config( + "oidc.issuer must be an https URL (http only for loopback)".into(), + )) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn committed_example_parses_and_validates() { + Config::parse(EXAMPLE).unwrap(); + } + + #[test] + fn unknown_keys_are_refused_including_a_secret_in_the_file() { + let err = Config::parse("client_secret = \"x\"\n").unwrap_err(); + assert!(matches!(err, Error::Config(_))); + assert!(Config::parse("[oidc]\nissuer = \"https://im.example.com\"\nclient_id = \"iz\"\nclient_secret = \"x\"\n").is_err()); + } + + #[test] + fn bare_addresses_and_networks_are_trusted_proxies() { + let config = + Config::parse("trusted_proxies = [\"10.0.0.1\", \"192.168.0.0/16\", \"::1\"]\n") + .unwrap(); + assert_eq!(config.trusted_proxies.len(), 3); + assert!(config.trusted_proxies[0].contains(&"10.0.0.1".parse::().unwrap())); + assert!(Config::parse("trusted_proxies = [\"not-an-ip\"]\n").is_err()); + } + + #[test] + fn validation_rejects_bad_cross_field_values() { + assert!(Config::parse("base_url = \"ftp://x\"\n").is_err()); + assert!(Config::parse("base_url = \"https://x/\"\n").is_err()); + assert!( + Config::parse("[oidc]\nissuer = \"http://im.example.com\"\nclient_id = \"iz\"\n") + .is_err() + ); + assert!(Config::parse("[backup]\ndir = \"/srv/b\"\ninterval_hours = 0\n").is_err()); + } + + #[test] + fn missing_file_is_created_from_the_example() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("config").join("iz.toml"); + let config = Config::load(&path).unwrap(); + assert_eq!(std::fs::read_to_string(&path).unwrap(), EXAMPLE); + assert_eq!(config.listen, default_listen()); + } +} diff --git a/crates/iz-core/src/error.rs b/crates/iz-core/src/error.rs new file mode 100644 index 0000000..90d706a --- /dev/null +++ b/crates/iz-core/src/error.rs @@ -0,0 +1,37 @@ +//! The error type shared by iz-core. `Invalid` and `Conflict` carry text that is safe to show the +//! user; everything else is logged and answered with a generic page. + +/// Every failure iz-core reports. +#[derive(Debug, thiserror::Error)] +pub enum Error { + /// Filesystem failure. + #[error("io error: {0}")] + Io(#[from] std::io::Error), + /// A database statement failed. + #[error("database error: {0}")] + Database(String), + /// A migration could not be applied or the history is inconsistent. + #[error("migration error: {0}")] + Migration(String), + /// The configuration file is unreadable or fails validation. + #[error("config error: {0}")] + Config(String), + /// Sealing, opening or the instance key failed. + #[error("crypto error: {0}")] + Crypto(String), + /// The row or resource does not exist, or the viewer may not know that it exists. + #[error("not found")] + NotFound, + /// The request conflicts with the current state (for example a stale move). + #[error("conflict: {0}")] + Conflict(String), + /// The actor may not do this. + #[error("forbidden: {0}")] + Forbidden(String), + /// A value broke a rule the user can fix (length, format, unknown zone). + #[error("invalid value: {0}")] + Invalid(String), +} + +/// Result alias used across iz-core. +pub type Result = std::result::Result; diff --git a/crates/iz-core/src/lib.rs b/crates/iz-core/src/lib.rs new file mode 100644 index 0000000..7208a46 --- /dev/null +++ b/crates/iz-core/src/lib.rs @@ -0,0 +1,16 @@ +//! `iz-core`: domain rules, storage, configuration and secrets for the iz task board. +//! +//! This crate has no HTTP. It keeps the invariants: the schema, the length limits, the board rules +//! (overdue, cycles, ordering), time zone math and sealing of secrets. `iz-web` builds on it. + +pub mod board; +pub mod config; +pub mod error; +pub mod limits; +pub mod secret; +pub mod store; +pub mod time; +pub mod token; +pub mod zones; + +pub use error::{Error, Result}; diff --git a/crates/iz-core/src/limits.rs b/crates/iz-core/src/limits.rs new file mode 100644 index 0000000..a21805b --- /dev/null +++ b/crates/iz-core/src/limits.rs @@ -0,0 +1,31 @@ +//! Every text and size limit in iz, as named constants. Length limits count characters (Unicode +//! scalar values) and are enforced on the server, never only in the HTML form. + +/// Longest task title, in characters. Reason: a title is a card heading; longer text is a description. +pub const TITLE_MAX: usize = 200; +/// Longest task description, in characters. Reason: keeps one row and one page render bounded. +pub const DESCRIPTION_MAX: usize = 20_000; +/// Longest comment body, in characters. Reason: comments are conversation, not documents. +pub const COMMENT_MAX: usize = 10_000; +/// Longest tag (project) name, in characters. Reason: tags are shown as chips on every card. +pub const TAG_NAME_MAX: usize = 60; +/// Longest column name, in characters. Reason: column headings must fit the board width. +pub const COLUMN_NAME_MAX: usize = 60; +/// Longest mail rule name or subject template, in characters. Reason: mail subjects stay short. +pub const RULE_SUBJECT_MAX: usize = 120; +/// Longest mail subject for notices and reminders, in characters. Reason: the mail client truncates later. +pub const MESSAGE_SUBJECT_MAX: usize = 200; +/// Longest mail body for notices, in characters. Reason: bounds the outbox row size. +pub const MESSAGE_BODY_MAX: usize = 20_000; +/// Longest display name, in characters. Reason: names are shown in assignee lists and mail greetings. +pub const DISPLAY_NAME_MAX: usize = 100; +/// Longest attachment file name, in bytes. Reason: matches the common filesystem limit. +pub const FILE_NAME_MAX: usize = 255; +/// Smallest per-file attachment limit an admin may set, in MiB. Reason: zero would refuse every upload. +pub const ATTACHMENT_LIMIT_MIB_MIN: u32 = 1; +/// Largest per-file attachment limit an admin may set, in MiB. Reason: bounds disk use per upload. +pub const ATTACHMENT_LIMIT_MIB_MAX: u32 = 500; +/// Largest reminder lead time, in minutes (one day). Reason: a reminder further ahead is not a reminder. +pub const REMINDER_MINUTES_MAX: u32 = 1440; +/// Largest mail batching window, in minutes. Reason: longer quiet windows delay mail past usefulness. +pub const BATCH_MINUTES_MAX: u32 = 120; diff --git a/crates/iz-core/src/secret.rs b/crates/iz-core/src/secret.rs new file mode 100644 index 0000000..82f0eae --- /dev/null +++ b/crates/iz-core/src/secret.rs @@ -0,0 +1,149 @@ +//! The instance key and sealing of secrets at rest (XChaCha20-Poly1305). Sealed values look like +//! `v1:` + base64(nonce || ciphertext). Plaintext secrets are never stored as a fallback. + +use std::path::Path; + +use base64::prelude::{BASE64_STANDARD, Engine as _}; +use chacha20poly1305::aead::Aead; +use chacha20poly1305::{KeyInit, XChaCha20Poly1305, XNonce}; + +use crate::error::{Error, Result}; + +const PREFIX: &str = "v1:"; +const NONCE_LEN: usize = 24; + +/// Loads the 32-byte instance key at `path`, creating it with mode 0600 if it is missing. +/// A key file that is group or world accessible, or has the wrong length, is refused. +pub fn load_or_create_key(path: &Path) -> Result<[u8; 32]> { + if let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) { + std::fs::create_dir_all(parent)?; + } + match create_key(path) { + Ok(key) => Ok(key), + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => read_key(path), + Err(e) => Err(e.into()), + } +} + +fn create_key(path: &Path) -> std::io::Result<[u8; 32]> { + use std::io::Write; + + let mut key = [0u8; 32]; + rand::fill(&mut key); + + let mut options = std::fs::OpenOptions::new(); + options.write(true).create_new(true); + #[cfg(unix)] + { + use std::os::unix::fs::OpenOptionsExt; + options.mode(0o600); + } + let mut file = options.open(path)?; + let written = file.write_all(&key).and_then(|()| file.sync_all()); + if let Err(e) = written { + // A truncated key would be rejected on every later start, so remove it. + drop(file); + let _ = std::fs::remove_file(path); + return Err(e); + } + Ok(key) +} + +fn read_key(path: &Path) -> Result<[u8; 32]> { + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let mode = std::fs::metadata(path)?.permissions().mode(); + if mode & 0o077 != 0 { + return Err(Error::Crypto(format!( + "instance key {} is group/world accessible (mode {:o}); expected 0600", + path.display(), + mode & 0o777 + ))); + } + } + let bytes = std::fs::read(path)?; + <[u8; 32]>::try_from(bytes.as_slice()).map_err(|_| { + Error::Crypto(format!( + "instance key {} has length {}, expected 32", + path.display(), + bytes.len() + )) + }) +} + +/// Seals `plaintext` under `key` with a fresh random nonce. +pub fn seal(key: &[u8; 32], plaintext: &[u8]) -> Result { + let mut nonce = [0u8; NONCE_LEN]; + rand::fill(&mut nonce); + let cipher = XChaCha20Poly1305::new(key.into()); + let ciphertext = cipher + .encrypt(&XNonce::from(nonce), plaintext) + .map_err(|_| Error::Crypto("sealing failed".into()))?; + let mut blob = Vec::with_capacity(NONCE_LEN + ciphertext.len()); + blob.extend_from_slice(&nonce); + blob.extend_from_slice(&ciphertext); + Ok(format!("{PREFIX}{}", BASE64_STANDARD.encode(blob))) +} + +/// Opens a value produced by [`seal`]. A wrong key, a changed byte or a malformed value is an error. +pub fn open(key: &[u8; 32], sealed: &str) -> Result> { + let encoded = sealed + .strip_prefix(PREFIX) + .ok_or_else(|| Error::Crypto("sealed value has no v1 prefix".into()))?; + let blob = BASE64_STANDARD + .decode(encoded) + .map_err(|_| Error::Crypto("sealed value is not valid base64".into()))?; + if blob.len() < NONCE_LEN { + return Err(Error::Crypto("sealed value is too short".into())); + } + let (nonce, ciphertext) = blob.split_at(NONCE_LEN); + let nonce = <[u8; NONCE_LEN]>::try_from(nonce) + .map_err(|_| Error::Crypto("sealed value has a bad nonce".into()))?; + let cipher = XChaCha20Poly1305::new(key.into()); + cipher + .decrypt(&XNonce::from(nonce), ciphertext) + .map_err(|_| Error::Crypto("sealed value failed authentication".into())) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn seal_open_round_trip_and_fresh_nonce() { + let key = [7u8; 32]; + let sealed = seal(&key, b"hello secret").unwrap(); + assert!(sealed.starts_with("v1:")); + assert_eq!(open(&key, &sealed).unwrap(), b"hello secret"); + assert_ne!(sealed, seal(&key, b"hello secret").unwrap()); + } + + #[test] + fn open_rejects_wrong_key_tampering_and_garbage() { + let key = [7u8; 32]; + let sealed = seal(&key, b"data").unwrap(); + assert!(open(&[8u8; 32], &sealed).is_err()); + let mut tampered = sealed.clone(); + let last = tampered.pop().unwrap(); + tampered.push(if last == 'A' { 'B' } else { 'A' }); + assert!(open(&key, &tampered).is_err()); + assert!(open(&key, "data").is_err()); + assert!(open(&key, "v1:!!!").is_err()); + assert!(open(&key, "v1:AAAA").is_err()); + } + + #[cfg(unix)] + #[test] + fn key_is_created_mode_0600_reloaded_and_loose_modes_refused() { + use std::os::unix::fs::PermissionsExt; + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("sub").join("iz.key"); + let created = load_or_create_key(&path).unwrap(); + let mode = std::fs::metadata(&path).unwrap().permissions().mode(); + assert_eq!(mode & 0o777, 0o600); + assert_eq!(load_or_create_key(&path).unwrap(), created); + std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o640)).unwrap(); + assert!(load_or_create_key(&path).is_err()); + } +} diff --git a/crates/iz-core/src/store/migrate.rs b/crates/iz-core/src/store/migrate.rs new file mode 100644 index 0000000..f048d67 --- /dev/null +++ b/crates/iz-core/src/store/migrate.rs @@ -0,0 +1,62 @@ +//! Migration runner. Each migration runs in its own transaction together with its +//! `schema_migrations` row, so a failed migration leaves nothing behind. Applied migrations are +//! never edited; a change is a new file with the next number. + +use turso::Connection; + +use crate::error::{Error, Result}; +use crate::time::now_stamp; + +/// `(version, sql)` in ascending order. +pub const MIGRATIONS: &[(u32, &str)] = &[(1, include_str!("../../migrations/0001_init.sql"))]; + +fn migration_err(e: turso::Error) -> Error { + Error::Migration(e.to_string()) +} + +/// Applies every migration whose version is not recorded yet. Running it again is a no-op. +pub async fn migrate(conn: &Connection) -> Result<()> { + conn.execute_batch( + "CREATE TABLE IF NOT EXISTS schema_migrations (version INTEGER PRIMARY KEY, applied_at TEXT NOT NULL)", + ) + .await + .map_err(migration_err)?; + + let applied = applied_versions(conn).await?; + for &(version, sql) in MIGRATIONS { + let version = i64::from(version); + if applied.contains(&version) { + continue; + } + let tx = conn.unchecked_transaction().await.map_err(migration_err)?; + tx.execute_batch(sql).await.map_err(migration_err)?; + tx.execute( + "INSERT INTO schema_migrations (version, applied_at) VALUES (?1, ?2)", + (version, now_stamp()), + ) + .await + .map_err(migration_err)?; + tx.commit().await.map_err(migration_err)?; + tracing::info!(version, "applied database migration"); + } + Ok(()) +} + +async fn applied_versions(conn: &Connection) -> Result> { + let mut rows = conn + .query("SELECT version FROM schema_migrations ORDER BY version", ()) + .await + .map_err(migration_err)?; + let mut versions = Vec::new(); + while let Some(row) = rows.next().await.map_err(migration_err)? { + match row.get_value(0).map_err(migration_err)? { + turso::Value::Integer(v) => versions.push(v), + _ => { + return Err(Error::Migration( + "schema_migrations.version is not an integer".into(), + )); + } + } + } + Ok(versions) +} diff --git a/crates/iz-core/src/store/mod.rs b/crates/iz-core/src/store/mod.rs new file mode 100644 index 0000000..3c5393e --- /dev/null +++ b/crates/iz-core/src/store/mod.rs @@ -0,0 +1,358 @@ +//! Turso-backed storage. All metadata lives here. Only the settings functions exist so far; the +//! table modules come with the features that use them. +//! +//! Connections: `conn` is the single writer. Every write, every transaction and every +//! read-then-write sequence runs on it behind its tokio mutex, so transactions never interleave. +//! `readers` is a small pool of `query_only` connections on the same database (WAL), so pure +//! SELECTs run in parallel with each other and with the writer. + +pub mod migrate; +pub mod snapshot; + +use std::path::Path; +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::Duration; + +use tokio::sync::{Mutex, MutexGuard}; +use turso::{Builder, Connection, Database, IntoParams, Row, Value}; + +use crate::error::{Error, Result}; +use crate::time::now_stamp; + +/// How long a connection waits for a lock before it reports `database is locked`. +const BUSY_TIMEOUT: Duration = Duration::from_millis(5000); +/// Number of read-only connections in the pool. +const READER_COUNT: usize = 4; + +/// Cheap to clone. All clones share one writer and one reader pool. +/// +/// Rule for [`Store::read_conn`]: use it only for a function that is a pure SELECT (one statement, +/// or several SELECTs and no writes) that does not need to see a write made in the same call. +/// Anything inside a transaction, any write, and any read-then-write sequence uses the writer. +#[derive(Clone)] +pub struct Store { + inner: Arc, +} + +struct Inner { + /// Keeps the database handle alive as long as any connection exists. + _db: Database, + conn: Mutex, + readers: Vec>, + /// Round-robin start index for `read_conn`. + next_reader: AtomicUsize, +} + +impl Store { + /// Opens (or creates) the database at `path`, applies the connection pragmas and runs the + /// migrations. Opening an up-to-date database changes nothing. + pub async fn open(path: &Path) -> Result { + let path_str = path.to_str().ok_or_else(|| { + Error::Config(format!("database path is not UTF-8: {}", path.display())) + })?; + let db = Builder::new_local(path_str).build().await.map_err(db_err)?; + let conn = db.connect().map_err(db_err)?; + apply_pragmas(&conn).await; + migrate::migrate(&conn).await?; + // Readers are opened after the migrations so that their schema view is current. + let mut readers = Vec::with_capacity(READER_COUNT); + for _ in 0..READER_COUNT { + let reader = db.connect().map_err(db_err)?; + apply_pragmas(&reader).await; + apply_query_only(&reader).await?; + readers.push(Mutex::new(reader)); + } + Ok(Store { + inner: Arc::new(Inner { + _db: db, + conn: Mutex::new(conn), + readers, + next_reader: AtomicUsize::new(0), + }), + }) + } + + /// A pooled read-only connection. Tries each reader without waiting, starting at the round-robin + /// index, and waits on the round-robin one only if all are busy. See the rule on [`Store`]. + pub async fn read_conn(&self) -> MutexGuard<'_, Connection> { + let len = self.inner.readers.len(); + let start = self.inner.next_reader.fetch_add(1, Ordering::Relaxed) % len; + for offset in 0..len { + let idx = (start + offset) % len; + if let Some(guard) = self.inner.readers.get(idx).and_then(|m| m.try_lock().ok()) { + return guard; + } + } + self.inner.readers[start].lock().await + } + + /// The stored value of a setting, or `None` if it was never set. + pub async fn get_setting(&self, key: &str) -> Result> { + let conn = self.read_conn().await; + fetch_opt( + &conn, + "SELECT value FROM settings WHERE key = ?1", + (key.to_owned(),), + |row| col_text(row, 0), + ) + .await + } + + /// Stores a setting, replacing any earlier value. The write is one statement, so it is atomic. + pub async fn set_setting(&self, key: &str, value: &str) -> Result<()> { + let conn = self.inner.conn.lock().await; + conn.execute( + "INSERT INTO settings (key, value, updated_at) VALUES (?1, ?2, ?3) \ + ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at", + (key.to_owned(), value.to_owned(), now_stamp()), + ) + .await + .map_err(db_err)?; + Ok(()) + } +} + +// ---- helpers ---- + +/// Maps a driver error to `Error::Database`. +pub fn db_err(e: turso::Error) -> Error { + Error::Database(e.to_string()) +} + +/// Commits when `outcome` is `Ok` and rolls back otherwise, returning the outcome. Every multi-step +/// write ends with this, so a failed step never leaves a half-written change. +pub async fn finish(tx: turso::transaction::Transaction<'_>, outcome: Result) -> Result { + match outcome { + Ok(value) => { + tx.commit().await.map_err(db_err)?; + Ok(value) + } + Err(e) => { + let _ = tx.rollback().await; + Err(e) + } + } +} + +/// Makes a connection refuse writes. Turso takes `1`, not `ON`. Failure is fatal, because a reader +/// that can write would break the pool's rule. +async fn apply_query_only(conn: &Connection) -> Result<()> { + let mut rows = conn + .query("PRAGMA query_only = 1", ()) + .await + .map_err(db_err)?; + while rows.next().await.map_err(db_err)?.is_some() {} + Ok(()) +} + +/// Applies the connection pragmas, then logs the values in effect. A pragma the engine does not +/// support is logged and skipped, not fatal. +async fn apply_pragmas(conn: &Connection) { + for sql in [ + "PRAGMA journal_mode = WAL", + "PRAGMA synchronous = FULL", + "PRAGMA foreign_keys = ON", + ] { + let applied = async { + let mut rows = conn.query(sql, ()).await?; + while rows.next().await?.is_some() {} + Ok::<(), turso::Error>(()) + } + .await; + if let Err(e) = applied { + tracing::warn!(pragma = sql, error = %e, "database pragma not applied"); + } + } + if let Err(e) = conn.busy_timeout(BUSY_TIMEOUT) { + tracing::warn!(error = %e, "busy_timeout not applied"); + } + for name in ["journal_mode", "synchronous", "foreign_keys"] { + let value = fetch_opt(conn, &format!("PRAGMA {name}"), (), |row| { + col_to_string(row, 0) + }) + .await; + match value { + Ok(v) => tracing::info!(pragma = name, value = ?v, "database pragma in effect"), + Err(e) => tracing::warn!(pragma = name, error = %e, "could not read database pragma"), + } + } +} + +/// Runs a query and maps every row. +pub async fn fetch_all( + conn: &Connection, + sql: &str, + params: P, + map: impl Fn(&Row) -> Result, +) -> Result> +where + P: IntoParams, +{ + let mut rows = conn.query(sql, params).await.map_err(db_err)?; + let mut out = Vec::new(); + while let Some(row) = rows.next().await.map_err(db_err)? { + out.push(map(&row)?); + } + Ok(out) +} + +/// Runs a query and maps the first row, if there is one. +pub async fn fetch_opt( + conn: &Connection, + sql: &str, + params: P, + map: impl Fn(&Row) -> Result, +) -> Result> +where + P: IntoParams, +{ + let mut rows = conn.query(sql, params).await.map_err(db_err)?; + match rows.next().await.map_err(db_err)? { + Some(row) => Ok(Some(map(&row)?)), + None => Ok(None), + } +} + +/// A text column. NULL and other types are a database error here; use a nullable reader for NULLs. +pub fn col_text(row: &Row, i: usize) -> Result { + match row.get_value(i).map_err(db_err)? { + Value::Text(s) => Ok(s), + _ => Err(Error::Database(format!("column {i} is not text"))), + } +} + +/// An integer column. +pub fn col_int(row: &Row, i: usize) -> Result { + match row.get_value(i).map_err(db_err)? { + Value::Integer(n) => Ok(n), + _ => Err(Error::Database(format!("column {i} is not an integer"))), + } +} + +/// Any scalar as text, for diagnostics (pragma values and the like). +pub fn col_to_string(row: &Row, i: usize) -> Result { + match row.get_value(i).map_err(db_err)? { + Value::Text(s) => Ok(s), + Value::Integer(n) => Ok(n.to_string()), + Value::Real(f) => Ok(f.to_string()), + Value::Null => Ok("NULL".into()), + Value::Blob(_) => Ok("".into()), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + /// Inserts the parent rows that a task needs: a board, a column, a tag and a member. + async fn seed_board(store: &Store) -> (String, String, String) { + let conn = store.inner.conn.lock().await; + conn.execute_batch( + "INSERT INTO boards (id, name, key_prefix, created_at) VALUES ('b1', 'Family', 'IZ', 'then'); + INSERT INTO columns (id, board_id, name, position, is_done, created_at) VALUES ('c1', 'b1', 'Todo', 1, 0, 'then'); + INSERT INTO tags (id, board_id, name, position, is_default, created_at) VALUES ('t1', 'b1', 'General', 1.0, 1, 'then'); + INSERT INTO members (sub, email, name, first_seen_at) VALUES ('u1', 'a@example.com', 'Ada', 'then');", + ) + .await + .unwrap(); + ("c1".into(), "t1".into(), "u1".into()) + } + + async fn insert_task(store: &Store, id: &str, parent: Option<&str>) -> Result<()> { + let conn = store.inner.conn.lock().await; + conn.execute( + "INSERT INTO tasks (id, board_id, key, parent_id, title, column_id, tag_id, position, created_by, created_at, updated_at) \ + VALUES (?1, 'b1', ?1, ?2, 'Title', 'c1', 't1', 1.0, 'u1', 'then', 'then')", + (id.to_owned(), parent.map(str::to_owned)), + ) + .await + .map_err(db_err)?; + Ok(()) + } + + #[tokio::test] + async fn open_twice_is_idempotent_and_keeps_settings() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("iz.db"); + { + let store = Store::open(&path).await.unwrap(); + store.set_setting("default_role", "viewer").await.unwrap(); + } + let store = Store::open(&path).await.unwrap(); + assert_eq!( + store.get_setting("default_role").await.unwrap().as_deref(), + Some("viewer") + ); + let conn = store.read_conn().await; + let versions = fetch_all(&conn, "SELECT version FROM schema_migrations", (), |row| { + col_int(row, 0) + }) + .await + .unwrap(); + assert_eq!(versions, vec![1]); + } + + #[tokio::test] + async fn settings_upsert_replaces_the_value() { + let dir = tempfile::tempdir().unwrap(); + let store = Store::open(&dir.path().join("iz.db")).await.unwrap(); + assert_eq!(store.get_setting("k").await.unwrap(), None); + store.set_setting("k", "one").await.unwrap(); + store.set_setting("k", "two").await.unwrap(); + assert_eq!( + store.get_setting("k").await.unwrap().as_deref(), + Some("two") + ); + } + + #[tokio::test] + async fn subtasks_are_one_level_deep() { + let dir = tempfile::tempdir().unwrap(); + let store = Store::open(&dir.path().join("iz.db")).await.unwrap(); + seed_board(&store).await; + insert_task(&store, "top", None).await.unwrap(); + insert_task(&store, "child", Some("top")).await.unwrap(); + // A child of a child is the second level and must be refused. + let nested = insert_task(&store, "grandchild", Some("child")).await; + assert!(nested.is_err(), "two-level nest was accepted"); + // A top-level task that already has children cannot become a subtask. + insert_task(&store, "other", None).await.unwrap(); + let conn = store.inner.conn.lock().await; + let moved = conn + .execute("UPDATE tasks SET parent_id = 'child' WHERE id = 'top'", ()) + .await; + assert!(moved.is_err(), "parent with children became a subtask"); + drop(conn); + // A plain subtask of a top-level task is fine. + insert_task(&store, "sub2", Some("other")).await.unwrap(); + } + + #[tokio::test] + async fn snapshot_is_one_file_that_opens_with_its_data() { + let dir = tempfile::tempdir().unwrap(); + let store = Store::open(&dir.path().join("iz.db")).await.unwrap(); + store.set_setting("marker", "kept").await.unwrap(); + let dest = dir.path().join("copy.db"); + store.snapshot_to(&dest).await.unwrap(); + assert!(!dir.path().join("copy.db-wal").exists()); + let copy = Builder::new_local(dest.to_str().unwrap()) + .build() + .await + .unwrap(); + let conn = copy.connect().unwrap(); + let value = fetch_opt( + &conn, + "SELECT value FROM settings WHERE key = 'marker'", + (), + |row| col_text(row, 0), + ) + .await + .unwrap(); + assert_eq!(value.as_deref(), Some("kept")); + assert!( + store.snapshot_to(&dest).await.is_err(), + "existing target was overwritten" + ); + } +} diff --git a/crates/iz-core/src/store/snapshot.rs b/crates/iz-core/src/store/snapshot.rs new file mode 100644 index 0000000..5ae1400 --- /dev/null +++ b/crates/iz-core/src/store/snapshot.rs @@ -0,0 +1,87 @@ +//! Consistent copies of the database for backups. +//! +//! Method: `VACUUM INTO` on the writer connection, which holds the writer lock for the copy, so no +//! write can interleave. The copy is WAL-mode, so it is checkpointed until its rows are all in the +//! main file, and its empty sidecars are removed. The result is one self-contained file. + +use std::path::Path; + +use turso::Builder; + +use super::{col_int, db_err, fetch_all}; +use crate::error::{Error, Result}; +use crate::store::Store; + +impl Store { + /// Writes a consistent, self-contained copy of the database to `dest`, then fsyncs it. + /// `dest` must not exist. + pub async fn snapshot_to(&self, dest: &Path) -> Result<()> { + if std::fs::symlink_metadata(dest).is_ok() { + return Err(Error::Conflict(format!( + "snapshot target already exists: {}", + dest.display() + ))); + } + let text = dest.to_str().ok_or_else(|| { + Error::Config(format!("snapshot path is not UTF-8: {}", dest.display())) + })?; + let sql = format!("VACUUM INTO {}", sql_string_literal(text)?); + { + let conn = self.inner.conn.lock().await; + conn.execute(&sql, ()).await.map_err(db_err)?; + } + make_self_contained(dest).await?; + std::fs::File::open(dest)?.sync_all()?; + Ok(()) + } +} + +/// Quotes a path for SQL. Rejects NUL, which SQL text cannot carry. +fn sql_string_literal(text: &str) -> Result { + if text.contains('\0') { + return Err(Error::Invalid("path contains NUL".into())); + } + Ok(format!("'{}'", text.replace('\'', "''"))) +} + +/// Checkpoints the copy until every frame is in the main file, then removes empty sidecars. +/// A sidecar that still holds bytes is an error, so a half-copied backup is never reported as good. +async fn make_self_contained(dest: &Path) -> Result<()> { + let text = dest + .to_str() + .ok_or_else(|| Error::Config(format!("snapshot path is not UTF-8: {}", dest.display())))?; + let db = Builder::new_local(text).build().await.map_err(db_err)?; + let conn = db.connect().map_err(db_err)?; + // Columns: busy flag, frames in the log, frames checkpointed. + let status = fetch_all(&conn, "PRAGMA wal_checkpoint(TRUNCATE)", (), |row| { + Ok((col_int(row, 0)?, col_int(row, 1)?, col_int(row, 2)?)) + }) + .await?; + drop(conn); + drop(db); + match status.as_slice() { + [(0, log, done)] if log == done => {} + other => { + return Err(Error::Database(format!( + "checkpoint of the snapshot did not complete: {other:?}" + ))); + } + } + for suffix in ["-wal", "-shm"] { + let mut sidecar = dest.as_os_str().to_owned(); + sidecar.push(suffix); + let sidecar = Path::new(&sidecar); + match std::fs::metadata(sidecar) { + Err(_) => {} + Ok(meta) if meta.len() == 0 => std::fs::remove_file(sidecar)?, + Ok(meta) => { + return Err(Error::Database(format!( + "snapshot still has {} bytes in {}", + meta.len(), + sidecar.display() + ))); + } + } + } + Ok(()) +} diff --git a/crates/iz-core/src/time.rs b/crates/iz-core/src/time.rs new file mode 100644 index 0000000..14283c0 --- /dev/null +++ b/crates/iz-core/src/time.rs @@ -0,0 +1,44 @@ +//! UTC stamps for storage. Format: RFC 3339, 9 fractional digits, `Z` suffix, always 30 characters, +//! so that text order is time order. Local calendar handling lives in `zones.rs`. + +use std::time::Duration; + +use time::{ + OffsetDateTime, SignedDuration, format_description::FormatItem, macros::format_description, +}; + +const FORMAT: &[FormatItem<'static>] = + format_description!("[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:9]Z"); + +/// Formats `at` as a stamp. The format only uses fields that always render, so this cannot fail. +pub fn format_stamp(at: OffsetDateTime) -> String { + at.to_offset(time::UtcOffset::UTC) + .format(FORMAT) + .unwrap_or_default() +} + +/// Current time as a stamp. +pub fn now_stamp() -> String { + format_stamp(OffsetDateTime::now_utc()) +} + +/// The stamp for `now + after`. Saturates at the largest representable time instead of panicking. +pub fn stamp_after(after: Duration) -> String { + let delta = SignedDuration::try_from(after).unwrap_or(SignedDuration::MAX); + format_stamp(OffsetDateTime::now_utc().saturating_add(delta)) +} + +#[cfg(test)] +mod tests { + use super::*; + use time::macros::datetime; + + #[test] + fn stamp_is_fixed_width_utc_with_nine_digits() { + let s = format_stamp(datetime!(2026-10-28 09:05:00.5 UTC)); + assert_eq!(s, "2026-10-28T09:05:00.500000000Z"); + assert_eq!(s.len(), 30); + assert_eq!(now_stamp().len(), 30); + assert!(stamp_after(Duration::from_secs(60)) > now_stamp()); + } +} diff --git a/crates/iz-core/src/token.rs b/crates/iz-core/src/token.rs new file mode 100644 index 0000000..17d443d --- /dev/null +++ b/crates/iz-core/src/token.rs @@ -0,0 +1,50 @@ +//! Random tokens and their hashes. A token is shown once; only its SHA-256 hex is stored, and +//! comparisons use `subtle` so that timing does not reveal matching prefixes. + +use base64::prelude::{BASE64_URL_SAFE_NO_PAD, Engine as _}; +use sha2::{Digest, Sha256}; +use subtle::ConstantTimeEq; + +/// A fresh token: 32 random bytes as unpadded base64url (43 characters). +pub fn generate_token() -> String { + let mut buf = [0u8; 32]; + rand::fill(&mut buf); + BASE64_URL_SAFE_NO_PAD.encode(buf) +} + +/// Lowercase hex SHA-256 of the token. This is what the database stores. +pub fn hash_token(token: &str) -> String { + hex::encode(Sha256::digest(token.as_bytes())) +} + +/// Compares two byte strings in time that depends only on their lengths. +pub fn constant_time_eq(a: &[u8], b: &[u8]) -> bool { + a.ct_eq(b).into() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn token_is_43_url_safe_characters_and_fresh() { + let t = generate_token(); + assert_eq!(t.len(), 43); + assert!( + t.bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b'-' || b == b'_') + ); + assert_ne!(t, generate_token()); + } + + #[test] + fn hash_is_hex_sha256_and_compare_matches_eq() { + assert_eq!( + hash_token("abc"), + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" + ); + assert!(constant_time_eq(b"same", b"same")); + assert!(!constant_time_eq(b"same", b"diff")); + assert!(!constant_time_eq(b"short", b"longer")); + } +} diff --git a/crates/iz-core/src/zones.rs b/crates/iz-core/src/zones.rs new file mode 100644 index 0000000..0295193 --- /dev/null +++ b/crates/iz-core/src/zones.rs @@ -0,0 +1,112 @@ +//! IANA time zones with the bundled tz database (jiff `tzdb-bundle-always`), so the zone rules do +//! not depend on the host's `/usr/share/zoneinfo`. A local wall-clock time is converted to a UTC +//! instant only when it names exactly one instant; a time skipped by a DST gap or repeated by a DST +//! overlap is refused with `Error::Invalid`, because the user has to pick one of the two. + +use jiff::Timestamp; +use jiff::civil::{Date, DateTime}; +use jiff::tz::{AmbiguousOffset, TimeZone}; + +use crate::error::{Error, Result}; + +/// Parses an IANA zone name such as `Europe/Berlin` or `UTC`. Unknown names are `Invalid`. +pub fn parse_zone(name: &str) -> Result { + let name = name.trim(); + if name.is_empty() || name.len() > 64 { + return Err(Error::Invalid( + "time zone name must be 1 to 64 characters".into(), + )); + } + TimeZone::get(name).map_err(|_| Error::Invalid(format!("unknown time zone: {name}"))) +} + +/// Converts a local `date` at `hour:minute` in `zone` to a UTC instant. Errors with `Invalid` when +/// the local time does not exist (DST gap) or happens twice (DST overlap). +pub fn local_to_utc(zone: &TimeZone, date: Date, hour: i8, minute: i8) -> Result { + if !(0..=23).contains(&hour) || !(0..=59).contains(&minute) { + return Err(Error::Invalid(format!( + "time {hour:02}:{minute:02} is out of range" + ))); + } + let local = DateTime::new(date.year(), date.month(), date.day(), hour, minute, 0, 0) + .map_err(|e| Error::Invalid(e.to_string()))?; + let ambiguous = zone.to_ambiguous_zoned(local); + match ambiguous.offset() { + AmbiguousOffset::Unambiguous { .. } => ambiguous + .compatible() + .map(|z| z.timestamp()) + .map_err(|e| Error::Invalid(e.to_string())), + AmbiguousOffset::Gap { .. } => Err(Error::Invalid(format!( + "{local} does not exist in {} (clocks move forward); pick another time", + zone.iana_name().unwrap_or("this zone") + ))), + AmbiguousOffset::Fold { .. } => Err(Error::Invalid(format!( + "{local} happens twice in {} (clocks move back); pick another time", + zone.iana_name().unwrap_or("this zone") + ))), + } +} + +/// The local wall-clock date and time of a UTC instant in `zone`. +pub fn utc_to_local(zone: &TimeZone, at: Timestamp) -> DateTime { + at.to_zoned(zone.clone()).datetime() +} + +#[cfg(test)] +mod tests { + use super::*; + + fn day(y: i16, m: i8, d: i8) -> Date { + Date::new(y, m, d).unwrap() + } + + #[test] + fn berlin_round_trip_in_winter_and_summer() { + let berlin = parse_zone("Europe/Berlin").unwrap(); + // Winter: UTC+1. 09:30 local is 08:30Z. + let winter = local_to_utc(&berlin, day(2026, 1, 15), 9, 30).unwrap(); + assert_eq!(winter.to_string(), "2026-01-15T08:30:00Z"); + assert_eq!( + utc_to_local(&berlin, winter), + DateTime::new(2026, 1, 15, 9, 30, 0, 0).unwrap() + ); + // Summer: UTC+2. 09:30 local is 07:30Z. + let summer = local_to_utc(&berlin, day(2026, 7, 15), 9, 30).unwrap(); + assert_eq!(summer.to_string(), "2026-07-15T07:30:00Z"); + assert_eq!( + utc_to_local(&berlin, summer), + DateTime::new(2026, 7, 15, 9, 30, 0, 0).unwrap() + ); + } + + #[test] + fn berlin_spring_gap_is_refused() { + // Clocks jump from 02:00 to 03:00 on 2026-03-29, so 02:30 does not exist. + let berlin = parse_zone("Europe/Berlin").unwrap(); + assert!(matches!( + local_to_utc(&berlin, day(2026, 3, 29), 2, 30), + Err(Error::Invalid(_)) + )); + } + + #[test] + fn berlin_autumn_overlap_is_refused() { + // 02:30 happens twice on 2026-10-25. + let berlin = parse_zone("Europe/Berlin").unwrap(); + assert!(matches!( + local_to_utc(&berlin, day(2026, 10, 25), 2, 30), + Err(Error::Invalid(_)) + )); + } + + #[test] + fn unknown_zone_and_bad_clock_are_invalid() { + assert!(matches!(parse_zone("Mars/Olympus"), Err(Error::Invalid(_)))); + assert!(matches!(parse_zone(" "), Err(Error::Invalid(_)))); + let utc = parse_zone("UTC").unwrap(); + assert!(matches!( + local_to_utc(&utc, day(2026, 1, 1), 24, 0), + Err(Error::Invalid(_)) + )); + } +} diff --git a/crates/iz-web/Cargo.toml b/crates/iz-web/Cargo.toml new file mode 100644 index 0000000..b6e79a6 --- /dev/null +++ b/crates/iz-web/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "iz-web" +description = "The iz binary: pages, HTTP, workers and CLI" +version.workspace = true +edition.workspace = true +license.workspace = true +publish = false + +[[bin]] +name = "iz" +path = "src/main.rs" + +[lints] +workspace = true diff --git a/crates/iz-web/src/main.rs b/crates/iz-web/src/main.rs new file mode 100644 index 0000000..8ec0922 --- /dev/null +++ b/crates/iz-web/src/main.rs @@ -0,0 +1,5 @@ +//! Entry point of the `iz` binary. This step only prints the name; the boot sequence comes later. + +fn main() { + println!("iz"); +} diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..28e7704 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,231 @@ +# iz architecture + +`iz` is the family's task board: columns, cards with one level of subtasks, dependencies, assignees, +projects (tags), deadlines with meeting times and reminders, comments, attachments with in-page viewers +(images, media, PDF, spreadsheets, slides), an activity trail, and admin-defined mail rules with a durable +outbox. Read `docs/contracts.md` and `docs/conventions.md` first. + +Status: design for the rebuild. `~/Documents/Code/Rust/old_iz` is a feature reference only. +`docs/reference/old-inventory.md` is the parity checklist (sections 2, 5, 8, 11) and its section 9 lists ~65 +defects that must not be carried over. + +--- + +## 1. Goals + +- **Feature parity** with old iz (inventory sections 2 and 11 "rebuild-critical rules"). +- **Better than old iz:** CSRF everywhere; local sessions and back-channel logout instead of per-request + introspection; avatars scoped to members; every write that has several steps is one transaction (card + + links + assignees created atomically); real IANA time zones (DST-correct reminders); server-side length + limits on every text field; sign-out button; security headers and CSP; every page and every mail translated; + retention for activity and mail ledger; `/healthz` checks the DB. + +Not goals now (`docs/backlog.md`): inbound mail / reply-by-mail, several boards or workspaces, custom fields, +time tracking, Gantt views, editing spreadsheets or slides. + +--- + +## 2. Crates and modules + +``` +iz/ + crates/ + iz-core/ domain, store, migrations, config, secret, token, time + zones, authz, board rules, mail rule engine, sniff, sheet/slides readers + iz-web/ binary `iz`: pages, OIDC client, directory mirror, attachments (local or in), SMTP worker, reminders, live, CLI +``` + +**iz-core** +- `error.rs`, `time.rs`, `zones.rs` (`jiff` with the bundled tz database: parse an IANA zone, local โ†” UTC), + `config.rs`, `settings.rs`, `secret.rs`, `token.rs` +- `authz.rs` (section 6), `limits.rs` (every text and size limit as a named constant) +- `board.rs` (pure rules: overdue, done/blocked, key generation, ordering positions, cycle detection), + `clock.rs` (deadline + meeting time rules, inventory 2.4) +- `rules/` (mail rule engine: triggers, audiences, decisions; pure where possible), `mail_text.rs` (subjects and + bodies for every mail kind, both languages) +- `sniff.rs`, `sheet.rs` (`calamine`: xlsx, xls, ods; values only; paging 50 rows ร— 12 columns; correct offsets + for ranges not starting at A1), `slides.rs` (pptx text outline via `zip` + `quick-xml`, size and entry limits + against zip bombs) +- `store/`: `members.rs`, `sessions.rs`, `board.rs`, `tasks.rs`, `deps.rs`, `comments.rs`, `attachments.rs`, + `activity.rs`, `tags.rs`, `rules.rs`, `outbox.rs`, `reminders.rs`, `audit.rs`, `settings.rs`, `snapshot.rs`, + `migrate.rs` + +**iz-web** +- `main.rs`, `boot.rs`, `state.rs`, `admin_cli.rs`, `auth.rs`, `throttle.rs`, `client_ip.rs` +- `oidc/` (same client as `in`, contracts.md 2), `directory.rs`, `family.rs`, `avatar.rs` +- `files/` (`local.rs`, `in_store.rs` = client of contracts.md 5 with a cached client-credentials token, + `serve.rs` = Range, disposition, byte headers like `in`'s architecture section 7) +- `pages/` (`board.rs`, `task.rs` (task modal and its tabs), `new_task.rs`, `people.rs`, `tags.rs`, `rules.rs`, + `logs.rs`, `settings.rs`, `viewer.rs`) +- `mail/` (SMTP via `lettre`, outbox worker with lease, batching, retries), `reminders.rs` (worker), + `live.rs`, `audit.rs`, `views/`, `i18n/`, `assets.rs` +- `assets/nav.js`, `assets/board.js` (drag and drop, card menu, filters with debounce, date and time picker, + dropdowns, file drop zone, escape-key stack), `assets/player.js`, `assets/offline.html`, `assets/sw.js` + +--- + +## 3. Data model + +One workspace and one board per instance (as in old iz). Tables keep a `board_id` so a second board is a +feature, not a migration. + +**members** (mirror of `im`'s directory plus iz state) +- `sub` PK, `email`, `name`, `im_admin`, `disabled`, `locale`, `zoneinfo` (IANA), `picture_version`, + `im_updated_at` +- `role` TEXT NOT NULL CHECK IN ('admin','member','viewer','none') โ€” `none` = in the directory but no access; + `im_admin` always acts as `admin` +- `theme` CHECK IN ('system','light','dark'), `ui` CHECK IN ('instrument','ledger'), `locale_override` NULL +- `first_seen_at`, `last_sign_in_at` NULL +- New directory members get the role in setting `default_role` (default `member`). Adding someone who is not in + `im` happens in `im` (invite); iz only assigns roles. + +**sessions**, **seen_logout_jti**: as in `in`. + +**boards**: `id`, `name`, `key_prefix` (2โ€“6 uppercase letters, setting; default `IZ`), `created_at`. + +**columns**: `id`, `board_id`, `name` (1โ€“60), `position` INTEGER, `is_done` 0/1; exactly one done column per +board (partial unique index). Admin can add, rename, reorder, delete (only when empty) columns. + +**tags** (projects): `id`, `board_id`, `name` (1โ€“60, unique per board, case-insensitive), `position`, `is_default` +(one per board), `color` NULL (from a fixed palette). + +**tasks**: `id`, `board_id`, `key` (UNIQUE per board, `PREFIX-` from a per-board counter: readable and never +reused), `parent_id` NULL (one level, enforced by trigger and by store), `title` (1โ€“200), `description` (โ‰ค20 000), +`column_id`, `tag_id` NOT NULL, `deadline` NULL (date), `meeting_at` NULL (UTC instant), `position` REAL, +`created_by`, `created_at`, `updated_at`, `done_at` NULL, `deleted_at` NULL. + +**task_assignees** (task, sub) PK. **task_watchers** (task, sub) PK โ€” watchers receive "board" audience mail +for that task only if they opted in (used by the rules engine's `watchers` audience). + +**dependencies**: `blocked_id`, `blocking_id`, `created_at`, `cleared_at` NULL; PK (blocked, blocking); +CHECK blocked โ‰  blocking. Cycle check over live, uncleared edges inside the same transaction as the insert. + +**comments**: `id`, `task_id`, `author`, `body` (1โ€“10 000), `created_at`, `edited_at` NULL, `deleted_at` NULL. +Authors may edit and delete their own comments (new: old iz had neither). + +**attachments**: `id`, `task_id`, `comment_id` NULL, `name`, `mime` (sniffed), `size`, `sha256`, `uploaded_by`, +`created_at`, `location` CHECK IN ('local','in','moving'). `local` = bytes in `data_dir/attachments/<2 hex>/`; +`in` = bytes are object `` in `in`'s store; `moving` = being copied between the two. + +**transitions**: `id`, `task_id`, `from_column` NULL, `to_column`, `actor`, `at`. + +**activity**: `id`, `task_id` NULL, `actor` NULL (NULL = system), `subject` NULL, `kind` (enum with CHECK), +`detail` JSON, `at`. Rendered into sentences in the viewer's language at read time. + +**mail_rules**: `id`, `board_id`, `name`, `trigger` (enum CHECK, 12 triggers from inventory 2.9), `column_id` +NULL (only for `status`, CHECK), `tag_id` NULL (new: limit a rule to one project), `audience` CHECK IN +('assignees','board','creator','watchers'), `include_details`, `enabled`, `subject_template` (โ‰ค120), `created_at`. + +**mail_outbox**: as old iz `mail_send` (inventory 4) with `kind` CHECK IN ('rule','notice','reminder','test'), +lease, attempts, backoff, batching window, unique (rule_id, event_id, task_id, recipient). **mail_decisions**: +as old iz. Recipients are always active members with role โ‰  viewer/none, never disabled. + +**reminders**: `task_id`, `sub`, `due_at`, `sent_at` NULL; PK (task_id, sub). Rebuilt for a task in the same +transaction as any change to its meeting time, assignees, done state or deletion. + +**audit_log**, **settings**: per conventions. Settings: SMTP sender (password sealed), limits, batching window, +reminder minutes (0โ€“1440), allowed attachment types, attachment limit (1โ€“500 MiB), attachment location +(`local`|`in`), `default_role`, `key_prefix`, retention days for activity and mail ledger (default 365), +base URL, trusted proxies. + +--- + +## 4. Routes + +Pages (session; Viewer may read, writes need Member, admin pages need Admin; all forms CSRF): + +| Path | What | +|---|---| +| `GET /` | board (inventory 2.2): columns, cards, filters (`tag`, `assignee`, `sort`, `q`), overdue/blocked chips, card menus, drag and drop; `?task=` opens the task modal, `?new=1` the new-task modal | +| `POST /tasks`, `/tasks/{id}/edit`, `/tasks/{id}/move`, `/tasks/{id}/delete`, `/tasks/{id}/assign`, `/tasks/{id}/unassign`, `/tasks/{id}/tag`, `/tasks/{id}/parent`, `/tasks/{id}/links`, `/tasks/{id}/links/remove`, `/tasks/{id}/watch` | task writes | +| `POST /tasks/{id}/comments`, `/comments/{id}/edit`, `/comments/{id}/delete` | comments | +| `POST /tasks/{id}/files` (multipart, streamed), `/files/{id}/delete`; `GET /files/{id}` | attachments | +| `GET /tasks/{key}/files/{id}/view` (also inside the modal via `?file=`) | viewers: image, video, audio, PDF, sheet, slides | +| `GET /people/{sub}` | person card with counts and recent activity (members only, same board) | +| `GET /tags` + POSTs | projects (admin) | +| `GET /columns` + POSTs | columns (admin) | +| `GET /rules` + POSTs | mail rules (admin), sentence rendering, enable switch, edit | +| `GET /logs` | admin: outbox (retry), decisions, activity (filters, keyset paging) | +| `GET /settings` + POSTs | profile/preferences (all); members & roles, sender (check, test), limits, attachment storage (+ migration status), message to members, server (admin) | +| `GET /avatar/{sub}` | photo proxy with disk cache, only for members of this board | +| OIDC client routes, `/-/alive`, live streams, `/healthz`, `/assets/*` | | + +`POST /tasks/{id}/move` carries the column the client last saw; a stale move is refused (`moved_already`), a +move into the done column with open subtasks is refused (`subtasks_open`), as in old iz. + +--- + +## 5. Rules (from inventory section 11, kept exactly) + +- Overdue: done is never overdue; with a meeting time, overdue when the meeting time โ‰ค now; with a day only, + overdue when the day is before today in the viewer's zone. +- Done: entering the done column stamps `done_at`; leaving it clears it; a card with open subtasks cannot enter. +- Subtasks: one level; a parent with children cannot become a subtask; deleting a parent deletes its children. +- Dependencies: no cycles over live edges; soft clear; a finished blocker stops blocking; deleting a blocker + frees its dependents and fires `unblocked`. +- Viewers: read-only, never assigned, never mailed. Members with role `none` or disabled: no access, not mailed. +- Mail: per-recipient claim by unique key; 5 attempts with 5/10/20/40-minute backoff, then abandoned; 1-minute + hold without a sender (no attempt spent); 5-minute lease; batching window per settings with a ceiling of 4 + windows; a decision row for every verdict; the actor of an event is not mailed about it (setting + `mail_actor`, default off). +- Reminders: one per assignee, `reminder_minutes` before the meeting time, in the recipient's zone in the text; + rebuilt on every relevant change; none for past meetings. + +--- + +## 6. Authorization + +`authz::authorize(actor, action)` with `actor` = `Anonymous | Member { sub, role, im_admin, disabled }` and +`action` from: `ReadBoard`, `WriteTask`, `Comment`, `EditComment { author }`, `UploadFile`, +`DeleteFile { uploader }`, `Administer`, `ViewPerson { sub }`. Roles: Admin โЇ Member โЇ Viewer; `none` and +disabled are denied everything (404 for pages, the sign-in card for `/`). Deleting a file: uploader while still a +Member, or Admin. Truth-table tested. + +--- + +## 7. Attachments + +- Limits: per-file limit and allowed extensions from settings; MIME from sniffing; streamed to a temp file with + the limit enforced while reading; hashed while streaming. +- `location = local`: bytes in `data_dir/attachments`. `location = in`: after the local write commits, the + `files` worker PUTs to `in` (contracts.md 5, external id = attachment id) and flips the row to `in`, then + deletes the local copy. Reads stream from wherever the row says; if `in` is unreachable the response is a + translated 503 page, and local bytes are still served for rows not yet moved. +- Switching the setting starts a background migration in either direction, with progress on the settings page. +- Deleting: row deleted in a transaction that records the blob for deletion; the worker deletes the bytes + (local or `in`) afterwards and retries until done. + +--- + +## 8. Workers + +directory mirror, family list, mail outbox, reminders, attachment mover, sweeper (sessions, JTIs, retention of +activity and mail ledger, orphaned temp files), optional backup. All stop with the stop flag. + +--- + +## 9. Live + +Topics: `Board(board_id)` (any card change, columns, tags), `Task(task_id)` (modal contents), `Person(sub)`, +`Admin(Section)` (outbox, decisions, activity, settings, members), `Account(sub)` (preferences, revocation). +Board page fingerprint is cheap (max `updated_at` + counts), so a burst of changes is one refresh. + +--- + +## 10. CLI + +`iz admin backup --out DIR` (DB snapshot + local attachments + manifest), `iz admin backup-verify SET`, +`iz admin restore --from SET --data-dir NEW`, `iz admin export --out DIR` (JSON of the board, tasks, comments, +activity, plus attachments by name), `iz admin set-role `, `iz admin audit-purge +--older-than-days N`. + +--- + +## 11. Build order + +1. Scaffold (workspace, core basics, store + 0001, boot, healthz, assets, shell, nav.js, i18n, headers, 404). +2. OIDC client, sessions, back-channel logout, members mirror, roles, avatars, switcher. +3. Board: columns, tags, tasks, keys, ordering, move rules, filters, search, drag and drop. +4. Task modal: fields, deadline and meeting time, assignees, subtasks, dependencies, comments, activity, delete. +5. Attachments (local), viewers (image, media, PDF, sheet, slides), then `in` storage and migration. +6. Mail: sender settings, outbox worker, rules engine and pages, notices, reminders, logs page. +7. Admin pages (members, tags, columns, limits, server), audit, live topics, sweeper, backup, export, deploy unit, README. diff --git a/docs/contracts.md b/docs/contracts.md new file mode 100644 index 0000000..c910d5a --- /dev/null +++ b/docs/contracts.md @@ -0,0 +1,241 @@ +# Family contracts, v1 + +Status: normative. This file is copied byte for byte into `im/docs/contracts.md`, `in/docs/contracts.md` and +`iz/docs/contracts.md`. A change is made in all three repos in the same sitting, and the version line below is +bumped. The apps share no code. They share only the HTTP contracts written here. + +Contract version: **1** + +--- + +## 1. The family + +| Key | App | Role | Default listen | +|---|---|---|---| +| `im` | Account | OpenID Connect provider, people directory, service registry. Depends on nothing. | `127.0.0.1:7650` | +| `in` | Files | Personal drive. Blob store for the other apps. Depends on `im`. | `127.0.0.1:7655` | +| `iz` | Board | Task board. Depends on `im`, optionally on `in`. | `127.0.0.1:7654` | + +Production origins are `https://.` behind a TLS-terminating reverse proxy (Ferron). Apps bind +`127.0.0.1` only. + +### 1.1 Design rules + +1. **No app is down because another is down.** A signed-in user keeps working in `in` and `iz` while `im` is + unreachable. Only new sign-ins need `im`. Nothing calls `im` on the request path of an ordinary page. +2. **Standards first.** Where a standard exists (OIDC Core, OIDC Discovery, OIDC RP-Initiated Logout, OIDC + Back-Channel Logout, OAuth 2.0 client credentials, RFC 7009 revocation, RFC 7662 introspection), it is used + as written. Extensions are named and listed here. +3. **Machine calls carry a short-lived JWT** issued by `im` through the client credentials grant, with an + audience and scopes. Static shared bearer keys are not used. +4. **Every machine API is versioned** under `/api/v1/`. A consumer accepts unknown JSON fields. A provider keeps + v1 working for at least one release after v2 ships. +5. **Errors are JSON with a real HTTP status** (section 7). + +--- + +## 2. Identity (OIDC) + +`im` is the issuer. Its issuer URL is its public origin with no trailing slash, for example +`https://im.example.com`. + +### 2.1 Discovery + +`GET /.well-known/openid-configuration` returns standard metadata, including: + +- `issuer`, `authorization_endpoint` (`/authorize`), `token_endpoint` (`/token`), `userinfo_endpoint` + (`/userinfo`), `jwks_uri` (`/jwks.json`), `end_session_endpoint` (`/logout`), `revocation_endpoint` + (`/revoke`), `introspection_endpoint` (`/introspect`) +- `response_types_supported: ["code"]`, `grant_types_supported: ["authorization_code", "refresh_token", "client_credentials"]` +- `code_challenge_methods_supported: ["S256"]`, `id_token_signing_alg_values_supported: ["EdDSA"]` +- `token_endpoint_auth_methods_supported: ["client_secret_basic", "client_secret_post"]` +- `backchannel_logout_supported: true`, `backchannel_logout_session_supported: true` +- `scopes_supported: ["openid", "profile", "email", "directory.read", "files.service"]` + +Clients fetch discovery once at boot and cache it. They may hard-code the paths above as a fallback. + +### 2.2 Keys + +- Signing algorithm: **EdDSA (Ed25519)**. `jwks.json` publishes every key that is active or retired within + the last 7 days, as `{"kty":"OKP","crv":"Ed25519","x":...,"kid":...,"use":"sig","alg":"EdDSA"}`. +- `im` rotates the signing key every 90 days and on admin demand. A new key is published 24 hours before it + signs anything. +- Clients cache the JWKS for 1 hour, and refetch at most once a minute when a token names an unknown `kid`. + +### 2.3 Sign-in (authorization code + PKCE) + +1. App redirects the browser to `/authorize` with `response_type=code`, `client_id`, `redirect_uri` (exact match + with a registered URI), `scope` containing `openid` (and `profile email`), `state` (โ‰ฅ128 bits), + `nonce` (โ‰ฅ128 bits), `code_challenge`, `code_challenge_method=S256`. PKCE is mandatory. +2. `im` signs the user in (password, then TOTP or a recovery code if enrolled) and redirects back with + `code` and `state`. Codes live 60 seconds and are single use. A reused code revokes every token issued from it. +3. App posts to `/token` (`grant_type=authorization_code`, `code`, `redirect_uri`, `code_verifier`), client auth + by `client_secret_basic` or `client_secret_post`. Response: `access_token` (JWT, 10 min), `id_token`, + `refresh_token`, `token_type: "Bearer"`, `expires_in`. +4. App validates the `id_token`: signature against JWKS, `iss` exact, `aud` equals its `client_id`, `exp` in the + future, `iat` not more than 5 minutes in the future, `nonce` equal to the one it sent. + +**ID token claims:** `iss`, `sub` (the user's ULID, stable forever), `aud`, `exp`, `iat`, `auth_time`, `nonce`, +`sid` (the `im` browser session id), `email`, `email_verified` (always true: `im` only stores confirmed +addresses), `name`, and the `im` extensions `admin` (bool), `locale` (`en`|`tr`), `zoneinfo` (IANA name, for +example `Europe/Istanbul`), `picture_version` (integer, bumps when the photo changes). + +### 2.4 App sessions + +After step 4 the app creates **its own local session** (its own table, its own `__Host-` cookie, its own CSRF +token), keyed by `sub`, and stores `sid` beside it. The app does not call `im` again for this session. + +- Local session lifetime: at most 12 hours of absolute age. After that the app sends the browser through + `/authorize` again. While the `im` session is alive this is an invisible redirect. +- The app may keep the `refresh_token` only if it needs to call `/userinfo` later. Apps in this family do not. + They discard it. + +### 2.5 Sign-out and revocation + +- **App-initiated sign-out:** the app deletes its local session, then redirects to + `/logout?id_token_hint=...&post_logout_redirect_uri=&state=...` (OIDC RP-Initiated Logout). `im` + ends the `im` session and every app session tied to it (back-channel, below). +- **Back-Channel Logout** (OIDC Back-Channel Logout 1.0): each client registers a `backchannel_logout_uri` + (`/auth/backchannel-logout`). When an `im` session ends (sign-out, admin revoke, password change or + reset, user disabled or deleted, session expired by policy), `im` POSTs `logout_token=` (form-encoded) + to every client that was used in that session. The token carries `iss`, `aud`, `iat`, `exp` (2 min), `jti`, + `events: {"http://schemas.openid.net/event/backchannel-logout": {}}`, and `sid` (and `sub`). For "disable" and + "delete" it carries only `sub`, which means "every session of this user". +- The app validates it like an ID token (no `nonce`; it must carry `events` and must not carry `nonce`), + rejects a reused `jti` for 10 minutes, deletes the matching local sessions, and answers `200` with an empty + body. Any other answer is a failure. +- `im` delivers through a durable outbox: retries with backoff (10 s, 30 s, 1 min, 5 min, then every 15 min) + for 24 hours. Combined with the 12-hour local session cap (2.4), a missed delivery cannot keep a revoked + user signed in for longer than 12 hours, even if the app was down. +- The directory stream (section 3) also carries `disabled: true` and `deleted` events. An app that sees one + deletes the user's local sessions as well. Two independent paths; either one is enough. + +### 2.6 Machine-to-machine tokens + +- A client that calls another app's API asks `im` for a token: `POST /token` + `grant_type=client_credentials&scope=&audience=` with its client auth. (`audience` is the + RFC 8707-style extension parameter; its value is a family key such as `in`.) +- `im` checks the scopes against the client's allowed scopes (set by the admin) and returns an + `access_token` JWT: `iss`, `sub` = `client:`, `azp` = `client_id`, `aud` = target key, `scope` + (space separated), `iat`, `exp` (10 min), `jti`, plus `svc` = the caller's family key. +- The receiving app verifies signature, `iss`, `aud` equals its own key, `exp`, and the scope it needs. It + treats `svc` as the caller's identity. Callers cache the token until 60 s before `exp`. + +| Scope | Granted by default to | Lets the caller | +|---|---|---| +| `directory.read` | every family client | read the people directory and photos at `im` (section 3) | +| `files.service` | `iz` | store and read its own objects in `in` (section 5) | + +--- + +## 3. People directory (im) + +All routes need a client-credentials token with `aud = "im"` and scope `directory.read`. + +### 3.1 Member record + +```json +{ + "sub": "01J...", + "email": "a@example.com", + "name": "AyลŸe Yฤฑlmaz", + "admin": false, + "disabled": false, + "locale": "tr", + "zoneinfo": "Europe/Istanbul", + "picture_version": 3, + "updated_at": "2026-10-28T09:00:00.000000000Z" +} +``` + +### 3.2 Routes + +- `GET /api/v1/directory` โ†’ `{"members":[...], "cursor":""}`. Every account, disabled ones + included (`disabled: true`). Deleted accounts are absent. +- `GET /api/v1/directory/stream` โ†’ `text/event-stream`. Optional `Last-Event-ID` (or `?cursor=`) resumes from a + cursor. Events: + - `event: member`, `data: `: a member was created or changed (including disabled/enabled). + - `event: deleted`, `data: {"sub":"..."}`: the account is gone. + - `event: resync`, `data: {}`: the cursor is too old; fetch `GET /api/v1/directory` again. + - Each event has an `id:` that is a cursor. Keep-alive comments every 30 s. `im` closes the stream after + 50 minutes; the client reconnects with its last cursor. +- `GET /api/v1/people/{sub}/photo` โ†’ image bytes with the stored `Content-Type`, or `404` when there is no photo. + `ETag: "p"`. With `?v=` matching, `Cache-Control: private, max-age=31536000, + immutable`; otherwise `private, no-cache`. Honors `If-None-Match` with `304`. + +Apps mirror the directory into a local `members` table (full fetch, then the stream), so pages never call `im` +to show a name or an avatar. Apps proxy photos through their own origin and cache them on disk keyed by +`(sub, picture_version)`; a browser never talks to `im` for a photo. + +--- + +## 4. Service registry and switcher (im) + +- `GET /api/v1/family` (token with `aud = "im"`, scope `directory.read`) โ†’ + `{"services":[{"key":"in","name":"Files","url":"https://in.example.com","healthy":true,"checked_at":"..."}]}` + in the admin's order. `im` is included as `{"key":"im","name":"Account",...}`. +- The list is owned by `im`'s admin. A service row is created with its OIDC client (the admin gives a key, + a name and the origin; the redirect and back-channel URIs are derived from the origin). Apps do not register + themselves. +- `im` probes each row's `GET /healthz` every 60 s (2 s timeout) and reports `healthy`. Apps fetch the list + every 5 minutes and render the switcher from their copy; a stale copy is fine. + +### 4.1 Health + +Every app serves `GET /healthz` without auth: `200`, body `ok `, `Content-Type: text/plain`. +It checks that the process answers and that a `SELECT 1` on its database succeeds within 1 s; otherwise +`503` with `fail `. + +--- + +## 5. Object store (in) + +`in` stores bytes for other apps in a per-service namespace with its own quota. All routes need a +client-credentials token with `aud = "in"` and scope `files.service`. The namespace is the token's `svc`. +An object is named by the caller's `external_id` (1โ€“128 chars of `[A-Za-z0-9._-]`). + +| Method and path | Request | Success | +|---|---|---| +| `PUT /api/v1/objects/{external_id}` | Raw body; `Content-Type` (stored as given, re-sniffed for display); optional `X-Object-Name` (UTF-8, percent-encoded, โ‰ค255 bytes); optional `If-None-Match: *` | `201` (created) or `200` (replaced), JSON `{"external_id","size","sha256","content_type","created_at"}` | +| `GET /api/v1/objects/{external_id}` | Optional `Range: bytes=a-b` (one range) | `200` or `206`, the bytes, `ETag: ""`, `Content-Length`, `Accept-Ranges: bytes` | +| `HEAD /api/v1/objects/{external_id}` | โ€” | Headers as GET | +| `DELETE /api/v1/objects/{external_id}` | โ€” | `204`; also `204` when already absent (idempotent) | +| `GET /api/v1/usage` | โ€” | `{"quota_bytes": n, "used_bytes": n, "objects": n}` | + +- Uploads stream to disk; the body is never held in memory. A body larger than the remaining quota is refused + with `413` and error code `quota_exceeded` before or while it is read. +- `PUT` is atomic: the new bytes are visible only after they are fully written and fsynced. +- Service objects never appear in a person's drive and do not count against any person's quota. +- The quota per service is set in `in`'s admin page (default 10 GiB). + +--- + +## 6. Users across apps + +- The user id everywhere is `im`'s `sub` (a ULID). Apps never invent their own user ids for people. +- An app learns a user when they first sign in or when the directory names them. A member that the directory + lists but who never signed in still exists in the app (so they can be assigned, mentioned, mailed). +- App-level roles (for example `iz` Admin, Member, Viewer) belong to the app. `im`'s `admin` flag means + "instance administrator" and every app treats it as its own top role. + +--- + +## 7. Errors + +Machine routes answer errors as: + +```json +{"error": "quota_exceeded", "message": "The service quota of 10 GiB is used up."} +``` + +with the matching status: `400 invalid_request`, `401 invalid_token` (with `WWW-Authenticate: Bearer +error="invalid_token"`), `403 insufficient_scope`, `404 not_found`, `409 conflict`, `413 quota_exceeded` or +`too_large`, `429 rate_limited` (with `Retry-After`), `500 internal`, `503 unavailable`. `error` is a stable +machine word; `message` is English for logs and may change. OAuth endpoints (`/token`, `/revoke`, +`/introspect`) use the OAuth error format from their RFCs instead. + +--- + +## 8. Change log + +- **v1** (2026-10-28): first version. diff --git a/docs/conventions.md b/docs/conventions.md new file mode 100644 index 0000000..12c49e4 --- /dev/null +++ b/docs/conventions.md @@ -0,0 +1,169 @@ +# Code conventions + +These rules are the same in `im`, `in` and `iz` (the file is copied into each repo). They are taken from +`forge` (`~/Documents/Code/Rust/forge`, see its `docs/architecture.md`), which is the reference +implementation: when a rule here is unclear, read how forge does it and do the same. + +## 1. Workspace + +- Edition 2024, resolver 3, `unsafe_code = "forbid"` in `[workspace.lints.rust]`, every member ends with + `[lints] workspace = true` and `publish = false`. +- Every dependency version lives in the root `[workspace.dependencies]`, added with `cargo add` at its latest + release (never copied from another project). Members write `foo.workspace = true`. +- Topcoat 0.11 with `default-features = false` and an explicit feature list. Turso (latest stable) for the + database. +- Two crates per app: `-core` (domain types, store, migrations, config, secrets, auth primitives, pure + logic; no HTTP) and `-web` (the binary named ``: Topcoat UI, HTTP APIs, background workers, CLI). + Add a crate only for a real boundary. +- Dev profile: `debug = "line-tables-only"`; `opt-level = 3` for `argon2`, `sha2` and the turso crates, each with + a one-line reason. Release: `lto = true`, `codegen-units = 1`. + +## 2. Boot + +`main.rs` dispatches on positional words: no word or `serve` runs the server, `admin ` runs the CLI. +Config path: `--config `, then `_CONFIG`, then `config/.toml`. Exit 2 on usage errors, 1 on +failure. + +`serve` order: load and validate config โ†’ create `data_dir` (0700) โ†’ load or create `.key` (32 bytes, 0600, +`O_EXCL`) โ†’ open the store (pragmas, migrations) โ†’ layer stored UI overrides on the file config โ†’ spawn +workers โ†’ build the router โ†’ bind โ†’ serve until SIGTERM/Ctrl-C, with one stop flag shared by every listener and +worker. + +Logging: `tracing` + `tracing-subscriber` (`env-filter`), stderr, default `info`, structured fields. Never log +tokens, passwords, cookies, or secrets. + +## 3. Config + +- `config/.example.toml` is committed. `config/.toml` is gitignored. A missing file is created from + the example (dev defaults) on first run. +- `#[serde(deny_unknown_fields)]` on every struct. One `Config::validate()` for cross-field rules, used at load + and when a UI override is saved. +- Secrets never live in the TOML. They are entered in the admin UI (sealed in the DB) or in a separate file + readable only by the service user. +- Runtime settings: a `settings` key/value table with precedence **UI override โ†’ file โ†’ built-in default**, and + each field marked `Live`, `Restart` or `ReadOnly` (forge `server_settings.rs`). + +## 4. Store + +- One writer connection behind a tokio `Mutex`, plus a pool of 4 `PRAGMA query_only` readers. Pure reads use a + reader; writes, transactions and read-then-write sequences use the writer. +- Pragmas on every connection: `journal_mode=WAL`, `synchronous=FULL`, `foreign_keys=ON`, busy timeout 5 s. + Read them back and log them at boot. +- Migrations: `crates/-core/migrations/NNNN_snake_name.sql`, each starting with a comment that says what + it does; listed in `store/migrate.rs` as `(version, include_str!(...))`; each applied in its own transaction + with a `schema_migrations` row. Never edit an applied migration. +- Ids are ULID text. Timestamps are UTC RFC 3339 with 9 fractional digits and `Z` (fixed width, so text order is + time order) from `time.rs` (`now_stamp()`, `stamp_after(d)`). Booleans are `INTEGER` 0/1 with a `CHECK`. +- Column lists are constants (`USER_COLS`) next to their `map_user(row)`; SQL uses `?1, ?2`; ownership goes in + the `WHERE` (`... WHERE id = ?1 AND owner_id = ?2`). +- Multi-statement writes: `unchecked_transaction()` + an async block returning `Result` + one `finish(tx, + outcome)` helper that commits or rolls back. +- Constraints live in the schema (`NOT NULL`, `CHECK`, `UNIQUE`, `REFERENCES ... ON DELETE ...`), not only in Rust. +- Backups: `snapshot_to(path)` with `VACUUM INTO` on the writer, then checkpoint the copy so it is one + self-contained file, then fsync. `admin backup --out DIR` writes the snapshot, the blob tree (where the app + has one) and a `manifest.json` with a sha256 per file. `admin backup-verify SET` checks hashes, + `integrity_check` and contiguous migrations. Never copy a live DB file. + +## 5. HTTP and pages + +- Routes with `#[route(...)]` / `#[page(...)]` and `.discover()`. Anything that must not be public is + registered explicitly on a separate router. +- Handler shape: (1) authenticate, (2) load and authorize, (3) build the view, (4) return it. +- Forms: every field `#[serde(default)]`; every state-changing POST carries a `csrf` field checked in constant + time **before** any side effect (`require_csrf`). Pre-session forms use the `__Host-_precsrf` cookie + (SameSite=Strict). Post/Redirect/Get with notices in the query string (`?notice=...`), not cookies. +- Session cookie: `__Host-_session`, random 32 bytes base64url; the DB stores only its SHA-256. + HttpOnly, Secure, SameSite=Lax, Path=/. +- `safe_next()` for every return path: one leading `/`, not `//` or `/\`, no control characters, โ‰ค2048 bytes. +- One security-headers layer on `/`: `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, + `Referrer-Policy: same-origin`, `Strict-Transport-Security` when the base URL is https, and + `Content-Security-Policy: default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; + form-action 'self'; frame-ancestors 'none'; base-uri 'none'`. **No inline scripts or styles anywhere**; all JS + is in `assets/*.js`. +- Styled 404 page for `Accept: text/html`; 404 for "missing" and for "exists but you may not see it". +- Request bodies are capped per route (`BodyLimit`); upload routes stream. +- Assets (CSS compiled from `style/*.scss` with `grass` in `build.rs`, JS, fonts) are embedded with + `include_str!`/`include_bytes!`, served by routes with `Cache-Control: public, max-age=31536000, immutable`, + and linked with a content-hash query (`/assets/main.css?v=<12 hex>`). Fonts are self-hosted. Nothing is + loaded from a third-party origin. + +## 6. Auth primitives + +- Passwords: argon2id (`Argon2::default()`), PHC strings, always on `spawn_blocking`. Unknown accounts verify + against a fixed dummy hash so timing does not reveal them. +- Tokens: 32 random bytes, base64url; stored as hex SHA-256; compared with `subtle`; shown once. +- Throttle (in memory, sliding window, bounded key count): failed logins per account and per IP, failed second + factors per user; checked before any lookup; `429` with `Retry-After`. +- Secrets at rest: `seal`/`open` with XChaCha20-Poly1305 under the instance key, `v1:` + base64(nonce || + ciphertext). +- Client IP: the TCP peer unless it is in `trusted_proxies`; then `X-Forwarded-For` right to left. + +## 7. Authorization + +One pure function per app, `authz::authorize(actor, resource, role, action) -> Result<(), Denied>`, with +`Denied::{NotFound, Forbidden}`. Every page, form handler, API route and live stream goes through it. It is +unit-tested as a truth table. + +## 8. Live pages + +- `LiveHub` of `watch::Sender` per `Topic` (an enum keyed by what a page is about). Writes call + `live.bump(&topic)` after commit. +- A page that updates live renders `data-live=""`. The stream route authenticates and authorizes + first, then `stream_changes(cx, hub, topics, fingerprint)`: subscribe, read a fingerprint, and send a + data-less `event: changed` only when the fingerprint changes. `retry: 1000`, keep-alive every 30 s, + `X-Accel-Buffering: no`. +- `GET /-/alive` is held by every page (anonymous-safe). It drives the "server restarting" bar and carries + `account` events (sign-out, preference change) for the viewer. +- `assets/nav.js` (one file, progressive enhancement): soft navigation for same-origin links and forms + (`data-hard` opts out), keeps focus/scroll/typed input across swaps, opens one EventSource per distinct + `data-live` URL, re-fetches the page on `changed`, reconnects after 1/2/3 s, never re-sends a POST. + Pages work without JS. + +## 9. Errors + +- One `thiserror` enum per crate: `Io`, `Database`, `Migration`, `Config`, `Crypto`, `NotFound`, + `Conflict(String)`, `Forbidden(String)`, `Invalid(String)`. +- `Invalid` and `Conflict` text is for the user (shown as an alert). Everything else is a 500 with a generic + page and a logged cause. +- Security-sensitive answers are identical for "unknown" and "wrong". + +## 10. Audit + +Append-only `audit_log` (id, at, actor_id, actor_kind, action, target_kind, target_id, ip, data JSON). Written +after the change commits; a failed audit write is logged and never fails the request. Never store secrets in +`data`. Admin page with filters and keyset paging. Purge only through `admin audit-purge --older-than-days N`. + +## 11. i18n + +English and Turkish. `Lang::{En, Tr}`; resolution: the user's stored language, else `Accept-Language`, else +English. Keys are enums per area with an exhaustive `match` on `(key, lang)`, so a missing translation does not +compile. **Every** page, including sign-in, error and mail text, is translated. Sentences with values use small +format helpers, not concatenation in views. + +## 12. Comments and naming + +- `//!` on every module: what it is, what it is not, the invariant it keeps. `///` on every public item and on + every policy constant (with its unit and reason). Inline comments explain why, in full sentences. +- No commented-out code. No `TODO` without a line in `docs/backlog.md`. + +## 13. Tests + +Few and meaningful. Unit tests for pure logic that is easy to get wrong (authz truth table, token and CSRF +compare, `safe_next`, parsers, time math, quota math), store tests on a real temp database (`tempfile`) for +tricky queries and constraints, and one or two in-process router tests per security rule (CSRF refused, +hidden resource is 404, admin page refuses members). No snapshot tests, no browser tests, no mocks of the +database. Tests never write outside their temp dir. + +## 14. Deploy + +`deploy/.service`: dedicated user, `ProtectSystem=strict`, `ReadWritePaths=` the data dir only, +`ProtectHome=yes`, `PrivateTmp=yes`, `PrivateDevices=yes`, `NoNewPrivileges=yes`, `CapabilityBoundingSet=`, +`RestrictNamespaces=yes`, `RestrictSUIDSGID=yes`, `LockPersonality=yes`, `MemoryDenyWriteExecute=yes`, +`SystemCallArchitectures=native`, `SystemCallFilter=@system-service`, `UMask=0077`, `Restart=on-failure`. +`/healthz` per contracts.md 4.1. + +## 15. Git + +Commit messages follow forge's style: gitmoji + type + description, for example +`โœจ feat: sign-in with TOTP and recovery codes`, `๐Ÿ› fix: ...`, `โ™ป๏ธ refactor: ...`, `๐Ÿ“ docs: ...`. +No co-author or "generated with" lines. diff --git a/docs/reference/old-inventory.md b/docs/reference/old-inventory.md new file mode 100644 index 0000000..3f7412c --- /dev/null +++ b/docs/reference/old-inventory.md @@ -0,0 +1,530 @@ +# iz ("Board") feature inventory + +Source: /home/tahinli/Documents/Code/Rust/old_iz (read-only pass; nothing modified). +Crates: iz-core (domain, SQLite-compatible store via `turso`, mail engine, config, secrets, sniffing), iz-web (topcoat HTTP server, pages, handlers, SMTP client, storage client, SSE), iz-client (OIDC client for im, cookie sealing, family registration). +Tests: iz-web/tests/http.rs (227 tests), iz-core/tests/store.rs (212 tests), iz-web/tests/browser/*.mjs (4 Playwright scripts). + +Method note: this inventory was produced by 11 slice reads. Where two slices disagreed, the disagreement is listed in section 9. Items marked (unverified) were not confirmed against a second source. + +--- + +## 1. Purpose summary + +1. iz is a single-workspace board/task tracker: columns (statuses), cards (tasks) with one level of subtasks, dependencies, assignees, comments, deadlines and clock times, and a per-task activity trail. +2. Access is by sign-in through the sibling identity provider im (OIDC, RS256 id_token, per-request token introspection). Roles are Admin, Member, Viewer. +3. Outbound mail only: per-workspace SMTP sender; admin-defined mail rules that fire on board events; invites, notices and clock reminders; a durable outbox with retries, batching and a decision ledger. There is no inbound SMTP server and no reply-by-mail. +4. Attachments live on the local disk or, optionally, in the sibling Files service "in" (bearer-token service API). Upload type is decided by sniffing bytes, not by the browser. +5. Admin screens: members/roles, sender, limits, storage backend, mail rules, outbox/logs, tags (projects), app public address, admin-to-member messages. + +--- + +## 2. User-facing features (grouped) + +Notation: `[role]` is the minimum role the code checks. Routes are method + path. Forms POST and answer 303 to the Referer path with `?refusal=&on=` on refusal. "Redirect target" for most forms is the originating page. + +### 2.1 Sign-in, session, profile + +- Sign-in: `GET /auth/login?next=` (iz-client). Sets the PKCE flight cookie, redirects to im `/authorize`. `next` must start with `/`, not `//`, no `\`, no control chars. +- `GET /auth/callback`: validates state (constant-time), exchanges code at im `/token`, validates id_token, checks nonce, requires `app_session`, introspects it, sets `iz_session`. On error redirects to `/?auth_error=` (codes: invalid_request, invalid_state, exchange_failed, or im's own error string). +- `GET /auth/logout`: clears `iz_session`, redirects to im `/logout?back=`. There is NO sign-out control in the UI (the menu has only Profile and Settings); users must type the URL (unexpected gap). +- Every request calls `iz_client::current_user` (no local validity window): opens the sealed cookie, checks cookie exp, then POST im `/introspect`. `active:false` clears the cookie. A transport failure returns signed-out but keeps the cookie. On an active answer, `store.provision_user(sub, email, name, admin)` runs. +- Provisioning: first sign-in creates the workspace, the board, four columns, the default tag. Admin flag from im makes role Admin; first admin claims workspace_owner (once). Matching by email (case-insensitive) claims a legacy/invited row (keeps id, role, prefs). Every sign-in sets last_signed_in_at. +- Disabled account reads as signed out (`/api/me` returns 401). +- `GET /api/me` `[any session]`: 204 when signed in, 401 otherwise. +- Profile / preferences (Settings > Profile) `[any user]`: `POST /api/save_profile` with `theme` (light|dark), `language` (en|tr), `ui` (instrument|ledger). Refusals BadTheme, BadLanguage, BadUi. Timezone is stored (`user.timezone`) and set through im sync, not editable on this page. +- User menu: display name, email, role label; links Profile (to im `{issuer}/`, data-hard) and Settings. +- Signed-out landing (`GET /` when no session): sign-in card linking `/auth/login`; `?auth_error=` shows a sign-in-failed line. English only. + +### 2.2 Board (home `/`) + +- `GET /` `[any signed-in]`: board page. Signed-out shows sign-in card. Store error shows "something went wrong" with HTTP 200. +- Columns (`board_column`) ordered by position; a column with `is_done=1` is the finished column. Column names are translated for display only for the four seeded names (Backlog, In Progress, Review, Done) in Turkish; custom names pass through. +- Cards (`task` rows with no parent): key (`-`), title, deadline line, project chip (non-default tags only), subtask count `done/total`, comment count, blocked/blocks key chips, assignee avatars. Done cards greyed. Blocked = not done and has an uncleared blocker. +- Card context menu: Open; Move (submenu, one per other column; writers only); Delete (link to `?task=&confirm=delete`, writers only). +- Drag and drop: writers only. Drop on `.column-cards` posts `/api/move_card`. Dropping in the same column is a server no-op. +- Filter bar (GET `/`, auto-submit): project (`tag`), assignee (`assigned`: all / `none` = Nobody / member id), sort (`sort`: deadline default, created (newest first by ULID), title), search (`q`, live, debounced 200 ms). Search matches task_key and title only (Turkish-aware folding), not description, tags or assignees. A bogus tag or assignee id falls back to no filter. +- Chips: overdue count, blocked count (shown when > 0). +- Empty states: "no matches" when search filtered to nothing; empty columns show "no tasks". +- New task: `GET /?new=1` (writers only) opens modal; `POST /api/create_task` `[writer]`: title (required, non-empty), column_id, description, deadline (YYYY-MM-DD), clock_hour/clock_minute (see clock rules), tag_id (default if absent), repeated assignee_id, a link (other_id + direction blocked_by|blocks; missing/unknown direction defaults to blocked_by). Redirects to `/`. Note: a dependency cycle refusal happens AFTER the card is inserted, so the card survives the refusal (bug, see section 9). +- Move: `POST /api/move_card` `[writer]`: task_id, from_column_id, to_column_id. Outcomes: Recorded (writes transition, fires status rules), Unchanged (no-op), Stale (refused MovedAlready: someone else moved it), Held (refused SubtasksOpen: cannot enter a done column while subtasks are open; no override). Target column must be on the task's board (else Forbidden). +- Board query may open `?task=` (task modal) or `?new=1`; both never open together (task wins). `?file=` opens the in-modal file viewer; `?sheet=`/`?rows=`/`?cols=` drive spreadsheet paging; `?sheet=` is reused as slide index for decks. + +### 2.3 Task detail (modal on `/?task=`) + +- Opened by `?task=`; deep-linkable. Server-rendered snapshot (`load_snapshot`): detail, role flags, tags, timezone, linkable tasks, adoptable tasks, notifications, allowed types, attachment limit. +- Tabs (`tab=`): `task` (default), `subtasks` (hidden on subtasks; shows done/total), `files` (count), `comments` (count), `activity`, `mail` (notifications). Unknown tab falls back to task. +- Masthead: breadcrumb to parent (subtasks), inline title edit `[writer]`, status select `[writer]` (posts move_card; viewer sees label), Esc / close link. +- Task tab fields: + - Status (see move_card). + - Project/tag: `POST /api/set_task_tag` `[writer]`. Tag must belong to this board. Writes activity kind `tagged`; deliberately does NOT mail. + - Deadline: day picker (`YYYY-MM-DD`, Clear, Today) plus clock hour (00-23) and minute (00-59), blank "--" option. Clock needs a day; clearing the day with clock set... (clock is kept or cleared per rules below). + - Assignees: `POST /api/assign` `[writer]` (repeated user_id; multi-select; partially applied on first NotFound/Forbidden, no transaction); `POST /api/unassign` `[writer]`. Only roles that can be assigned (Admin, Member) are offered. + - Dependencies (blocked_by / blocks): `POST /api/link_tasks` and `POST /api/unlink_tasks` `[writer]`; direction is a serde enum (unknown value = deserialize failure). Unlink is a soft clear (`cleared_at`). Cycle refused (Cycle). Self-link not rejected in the handler (relies on store). + - Description: inline edit, `POST /api/save_task` `[writer]` (title required; description free text; absent field keeps old value; blank deadline/clock clears). +- Subtasks tab `[writer]` to create/adopt: + - `POST /api/create_subtask` (parent_id, title trimmed non-empty; HTML maxlength 200; lands in lowest-position column (unverified detail)). + - `POST /api/set_parent` (task_id, parent_id; empty parent_id = release/promote). + - One level only: NotNestable. A parent with open children cannot itself become a part. +- Files tab: upload (see 2.7), per-file delete (`POST /api/delete_file` `[uploader or admin]`), file chips link to in-modal viewer (for renderable types) or `/files/?v=` download. +- Comments tab: list (author link to profile, time in viewer zone, plain text), composer `POST /api/post_comment` `[can_comment]`: body trimmed non-empty. Viewer cannot comment. No edit, no delete, no @mentions. +- Activity tab: task-scoped activity lines (sentences). +- Mail tab (notifications): last 10 rule decisions for this task and last 50 sends for this task. Rule name and send error text are admin-only. Send states: Pending, Held (failed with 0 attempts), Failed, Sent, Abandoned. +- Delete: `POST /api/delete_task` `[writer]` is a SOFT delete (deleted_at) of the task and its direct children (grandchildren not touched). Confirmation shows comments going with it, subtasks going with it, dependencies that stop applying, and cards that stop being blocked. Redirects to `/`. No undo. Delete-freed tasks get mailed via "unblocked" rules. +- `POST /api/fetch_task` (JSON snapshot) and `POST /api/what_delete_costs` (JSON deletion cost): exist, no UI caller in these files. + +### 2.4 Clock and deadline rules + +- Deadline: a day (`YYYY-MM-DD`). Overdue rule (one rule everywhere): done is never overdue; with a clock, overdue when clock <= now; day-only overdue when day strictly before today. +- Clock (meeting time): stored as an exact UTC instant. Entered as H:MM 24-hour in the user's timezone (fixed offset from `parse_zone`; no DST). Rules: time needs a day (BadClock otherwise); both hour and minute or neither; blank both = clear; setting a clock overwrites the deadline day with the clock's day. +- Reminders: clock reminders go to each assignee `reminder_minutes` before the meeting (workspace setting, default 15; 0 = off). Reminders are re-derived on any change to clock, done state, deletion, assignees. Clock in past = no reminder. Reminder mail subject `Reminder: (<key>)`, body states meeting time in the recipient's own zone. + +### 2.5 Tags (projects) + +- Each board has tags; every task wears exactly one. A default tag "General" (is_default=1) exists per board; new tasks wear it when no tag is chosen. +- `GET /tags` `[admin]` (non-admin sees a refusal note in English). `?edit=<id>` renders rename form. +- `POST /api/create_tag` `[admin]` name (trimmed, non-empty; duplicate name per board = generic error). `POST /api/rename_tag` `[admin]`. `POST /api/delete_tag` `[admin]`: refused for the default tag (store) and for any tag with live cards (`tag_in_use`); soft-deleted tasks are re-pointed to the default tag, then the tag row is hard-deleted. `POST /api/move_tag` `[admin]` direction up|down (swap with neighbour; silent no-op when no neighbour at exact position; positions can have gaps after delete, so move can silently do nothing). +- No colours, no merge, no tag-level permissions. Tag name length: UI maxlength 60, not enforced server-side. +- Tag events logged as `tag_created`, `tag_renamed`, `tag_deleted`, `tag_moved` (activity kinds via Other). +- Board filter by project: `?tag=<id>`. + +### 2.6 Members, roles, people + +- Member list in Settings > Members `[admin]`: role select (member | viewer; autosubmit), disable/enable, add-member form. +- `POST /api/set_role` `[admin]`: user_id, role. Accepts member and viewer; handler refuses Admin (store accepts Admin via set_role; see section 9); refuses self and owner. Demoting to Viewer removes all of that user's assignments (and re-derives their reminders). +- `POST /api/set_disabled` `[admin]`: user_id, disabled (absent = true; "", 0, false, no, off = false). Refuses self. Does not check target is in workspace (store scopes; unverified). Disabling publishes revoked to that user's open streams. +- `POST /api/add_member` `[admin]`: display_name (required after trim, HTML maxlength 200), email (validated; HTML maxlength 320), role (member|viewer; Admin refused; duplicate address = AlreadyMember). Stores UNTRIMMED name and email (bug). Member row is unclaimed until first sign-in; invite mail is queued (kind invite) when sender is connected. +- Membership sync from im: roster pass every 5 min plus live stream (section 3.2). +- People profile `GET /people/{user_id}` `[any signed-in, same workspace]`: avatar, name, role chip, owner chip, email, joined day (viewer zone), last seen (never signed in = invited), counts (assigned open, assigned done, created, comments), last 8 activity lines authored by that person. Edit link to Settings > Profile only on own profile. Unknown or cross-workspace = 404. +- Avatars: `GET /avatar/{user_id}` `[any signed-in]` proxies the im photo (`directory.photo(sub)`). Anonymous 401, unknown/unlinked/im-failure 404 (empty body; initials shown). ETag `"p<photo_version>"`; with matching `?v=` = `private, max-age=31536000, immutable`; otherwise `private, no-cache`; `If-None-Match` match = 304. No server cache; passes bytes through. KNOWN GAP: no workspace check (any signed-in user of any workspace can fetch another user's photo if they know the id). + +### 2.7 Files and attachments + +- Upload: `POST /files` `[can_comment]` multipart: task_id (must come before file parts), optional comment_id (kept only if on same task), repeated file parts. Redirects to `/?task=<id>&tab=files`, refusals as `refusal=<code>&on=upload_file`. +- Limits: `workspace.attachment_limit_bytes` (default 25 MiB) enforced while streaming (refusal FileTooBig). Server body cap at `/files` = 500 MiB (WIDEST_ATTACHMENT_MB). Read errors while streaming are also reported as FileTooBig (misleading). +- Types: `workspace.allowed_file_types` (empty = all). Matching is the lowercased extension after the last dot against the stored list, exact. Files with no extension refused when the list is non-empty. +- Stored MIME = sniffed from bytes (`iz_core::store::sniff`), never the browser's type. Sniffer yields png, jpeg, gif, avif, heic, webp, pdf, zip, xlsx, ods, pptx, xls, OLE (x-ole-storage), gzip, quicktime, mp4 (any other ftyp brand), webm, wav, flac, ogg, mpeg, text/plain (any valid UTF-8), octet-stream. Never svg or html. +- Sniffing runs inline up to 8 MiB, otherwise on spawn_blocking. +- Activity `FileAdded` only when stored and not attached to a comment. +- Download: `GET /files/{id}` `[any signed-in, same workspace]`. Not found or other workspace = 404 empty body. Auth failure redirects with `on=upload_file` (wrong tag, bug). Local bytes read; stored bytes fetched from in (unreachable = 503 plain text). Whole file buffered in memory for both backends (even for ranges). + - Headers: Content-Type = stored MIME; Content-Disposition inline only if renders inline (image except heic, video, audio, pdf, text/plain) and not `?dl=1`; otherwise attachment. filename and filename* UTF-8. Accept-Ranges bytes; single range only (multi-range = full 200); unsatisfiable = 416; Cache-Control `private, max-age=31536000, immutable`. +- In-modal viewer (`?file=<id>`) for viewer kinds: image, video, audio (custom player), pdf (with Present/fullscreen), sheet (xlsx/xls/ods; paged, 50 rows x 12 cols, sheet tabs), slides (pptx outline: title paragraphs as headings, text only, no notes/images). `.ppt` (binary) and heic have no viewer. +- Spreadsheet reader: values only (no formulas/formatting/charts). Streamed for xlsx; whole-workbook for others (xls/xlsb/ods). Known offset bug in the non-xlsx path (rows/cols misaligned if used range does not start at A1). +- Accept attribute on the file input is derived from allowed types (known extensions mapped to MIME; unknown kept as `.ext`). +- Deleting an attachment: `POST /api/delete_file` `[uploader or admin]`, hard delete; for stored rows, remote bytes are removed first (failure refuses StorageUnavailable and keeps the row). Activity `FileRemoved` (failure ignored). + +### 2.8 Sheet and slides viewers + +- Sheet and slides are NOT task views; they are the in-modal file viewers described in 2.7. No editing, no export. + +### 2.9 Mail rules (Admin) + +- `GET /rules` `[admin]`: list rendered as sentences ("When status becomes [col] send [subject] to [audience]"), enabled switch, stamp (last sent / last fired / never fired), edit link `?edit=<id>`, delete. Note when no sender is connected (links to /settings). +- `POST /api/create_rule` `[admin]`: trigger, column_id, subject (required, trimmed; HTML maxlength 120; no server length check), audience (assignees | board | creator), include_task_details (checkbox). +- `POST /api/update_rule` `[admin]`, `POST /api/set_rule_enabled` `[admin]` (enabled == "true"), `POST /api/delete_rule` `[admin]` (ledger kept per data model; cascade on mail_send/mail_decision via FK per store). +- `POST /api/current_rules` `[admin]`: JSON snapshot (doc says test-only; shipped). +- Triggers (12): status (optional column; no column = any column), unblocked (a delete frees a dependent), created, assigned, unassigned, commented, deadline_set (also clock set), deadline_cleared (also clock cleared), retitled, linked, unlinked, deleted. +- Audiences: assignees (for Assigned/Unassigned: only the person just assigned/removed), board (every non-Viewer on the workspace, including the actor), creator (task creator, non-Viewer). +- Action: exactly one: send mail (subject from rule, body generated in Rust, English only; optional task details block with Key/Title/Column/Deadline/Assignees). +- Non-status trigger with a column: refused Forbidden (`trigger_of`). Editing a non-status rule always fails and editing an any-column status rule narrows it, because the form pre-selects the first column (bug, section 9). +- Viewers never receive rule mail (excluded in store). The actor is NOT removed from audiences (the module doc in mod.rs claims otherwise; stale). +- Mail rules fire after commit (see section 5). Loop protection is structural only: trigger set is closed and mail-related activity kinds match no trigger. + +### 2.10 Logs and outbox (Admin) + +- `GET /logs` `[admin]`, sections via `?section=`: + - queue: outbox rows (pending and failed) with recipient, subject, state (held / failed / pending / sent / abandoned), attempts, last error, next attempt. Failed and abandoned rows have Retry. + - decisions: rule verdicts grouped by event and task, with outcome chip (owed, already_owed, no_recipients, not_matched, disabled, task_gone) and detail. + - activity: workspace-wide activity feed, newest first. +- Activity filters: actor (`system` or member id), kind (from constant ACTIVITY_KINDS, which omits parented, unparented, reminded, password_reset_*), task key (uppercased), day range (from/to in admin zone, to inclusive), oldest-first toggle (`dir`). +- Keyset pagination with cursor `<RFC3339>~<id>` (`before=`, `after=`); default 50 rows; page size overridable by cookie `iz_rows_<section>` (10 to 200), set by a small script measuring viewport. +- `POST /api/retry_send` `[admin]`: send_id; requeues failed/abandoned (ignores result; always logs send_retried and redirects to `/logs?section=queue`). +- No retention or pruning code exists (ledger and activity grow without limit). + +### 2.11 Settings (all users; sections vary by role) + +- `GET /settings?section=` (`profile` for everyone; `outgoing`, `limits`, `server`, `members`, `message` admin-only, falling back to profile for non-admins; storage card sits under limits). +- Profile (all): identity, theme/ui/language, Connection card (issuer, client id, live stream state, last event age, last pass age). Client id and issuer are read from config (read-only on page). +- Outgoing sender `[admin]` `POST /api/save_sender`: host (required; no whitespace, @, or /), port (1-65535, default 587), username (required), password (required first time; blank keeps stored; cannot be cleared), from name (optional), from address (required, simple address check), workspace public_url (http/https origin, trailing slashes trimmed, empty clears). Save writes sender then public_url (not atomic; second failure shows Unavailable after sender saved). Save spawns a background connection check (15 s). + - `POST /api/check_sender` `[admin]`: connection handshake only (sends nothing; logs sender_checked). + - `POST /api/send_test_mail` `[admin]`: sends a test mail to the admin's own address; requires password and host (logs test_mail_sent). No rate limit. + - Connection chip: Not configured / Unchecked / Connected (time) / Refused (server words). +- Limits `[admin]` `POST /api/save_limits`: attachment_limit_mb (1-500), allowed_file_types (comma/space/newline; lowercased; leading dots stripped; alphanumeric; max 12 chars each; dedupe; empty = all), mail_batch_minutes (0-120), reminder_minutes (u32; server has NO upper bound; UI min 0). +- Storage `[admin]` `POST /api/save_storage` backend = local | in. `in` requires `[storage.in] token` in config and a family service with key `in`; otherwise refused (StorageNotConfigured / StorageNotListed). Card shows service name/URL, connection, usage (used / quota), migration progress (in mode, when local attachments remain), last problem. Note: save_storage does not map to a section in section_of_call (lands on profile). +- Server `[admin]` `POST /api/save_public_url`: app-level public address (`PUBLIC_URL_KEY` setting; read per sign-out; fallback base_url then listen address). +- Members `[admin]` (2.6). Message `[admin]` `POST /api/send_message`: to = everyone (all members except the admin) or one member id (may be self); subject required (HTML 200, no server check); body required (no limit). Each recipient gets a notice (kind notice) queued in the outbox; logs message_sent with subject. +- Settings writes that are logged as activity: limits_saved, sender_saved, sender_checked, test_mail_sent, profile_saved, role_changed, message_sent, rule_*, send_retried. + +### 2.12 Live updates + +- `GET /api/live` `[any signed-in]`: SSE. One connection per tab. 401 if not signed in. Lifetime = `live_seconds` (default 300) then the stream ends and the client reconnects (re-auth point; admin status is fixed at connect time). +- Frames: `{"topic": "<kind>", "id": "<task id if any>", "seq": <u64>}`; no SSE event name. Lag gives `{"topic":"resync"}` (client re-reads). Own-account revoke sends `revoked` then ends the stream. +- Visibility by topic: Board, Task(id), Members, Tags: all readers. Revoked(id): only to that account. Queue, Rules, Settings, Activity: admins only (non-admins never receive the frame). +- Client: opens EventSource once per tab; schedules a morph refresh 200 ms after a relevant frame; revoked redirects to `/`; error triggers `/api/me` probe; 60 s interval refreshes `[data-tick]` elements (deadline labels over midnight). + +### 2.13 Health and family switcher + +- `GET /healthz` (no auth): `200 ok <commit sha>` (IZ_BUILD_SHA). Liveness only; checks no DB, storage or im. The deploy script compares the sha. +- Family switcher (header monogram): reads family list (setting `family`, mirrored from im `/family`), excludes self (key `iz`), probes each sibling `GET {url}/healthz` (2 s timeout, 30 s cache) and shows an on/off dot. Shown only when a family is configured. + +### 2.14 Internationalisation + +- Languages: English (default; unknown codes fall back to English) and Turkish. Per-user `language`. Signed-out and error pages are fixed English. +- 332 message keys; both languages covered by exhaustive match (compile-time check). Mail bodies from iz-core are English only, and the store's activity sentences are rendered in the viewer's language by iz-web. +- `column_name` translates the four seeded column names only. +- Turkish search folding for card search and tag/assignee filters. + +### 2.15 Visual themes + +- `data-ui`: `instrument` (default, dense, cool neutral, 44 px chrome strip, ruled columns, LED-style chips) and `ledger` (warm paper, serif display face Newsreader, mono uppercase keys/dates, hairline rules). Each has light and dark token sets; dark is per user. +- Fonts: IBM Plex Mono and Newsreader from Google Fonts on every page (third-party request). + +--- + +## 3. Cross-app contracts + +### 3.1 im (identity provider, OIDC + extensions) + +Config (`[oidc]` table in config/iz.toml): issuer (required, non-blank; no URL check), client_id (required), client_secret (required; never printed), redirect_uri (optional; default `<listen_url>/auth/callback`; explicit value not validated). + +Endpoints (hard-coded paths relative to issuer; no discovery; issuer must not end with `/`): +| Purpose | Request | Auth | Response used | +|---|---|---|---| +| Authorize | browser 303 `{issuer}/authorize?response_type=code&client_id&redirect_uri&scope=openid profile email&state&nonce&code_challenge&code_challenge_method=S256` | โ€” | โ€” | +| Token | POST `{issuer}/token` form: grant_type=authorization_code, code, redirect_uri, client_id, client_secret, code_verifier | creds in body | JSON `{id_token, app_session?}`; `app_session` is im-specific; absent = not a current im | +| JWKS | GET `{issuer}/jwks.json` | none | keys[] kid, n, e (RSA) | +| Introspect | POST `{issuer}/introspect` form: token, client_id, client_secret | creds in body | `active` (bool, required), `sub`, `email`, `name`, `exp` (i64), `admin` (bool, optional) | +| Logout | browser 303 `{issuer}/logout?back=<public address>` | โ€” | โ€” | +| Family list | GET `{issuer}/family` | HTTP Basic client_id:client_secret | JSON array of `{key, name, url}` | +| Family register | POST `{issuer}/family/register` JSON `{key:"iz", name:"Board", url:<origin>}` | HTTP Basic | 2xx = filed; error body `{error, reason}`; 409 "owned" when key held by another app | +| Directory roster | GET via im-client crate (git rev 2043642), Basic auth; path not visible in this repo | Basic | member records | +| Directory photo | via im-client `directory.photo(sub)` -> (bytes, mime) | Basic | image bytes | +| Directory live stream | GET `{issuer}/directory/live`, SSE, held open with no timeout | Basic | frames: default/`profile` = StreamMember {sub,email,name,admin,photo_version,timezone,disabled}; `revoked` = {sub}; other kinds ignored | + +Auth details: +- PKCE S256: verifier 32 random bytes base64url; state and nonce 16 bytes. +- id_token: RS256 only; kid required; JWKS cached 3600 s and refetched once on unknown kid; iss exact match; aud must be a string equal to client_id; exp > now. nonce checked in exchange. No iat/nbf/azp/kty/alg/use checks. Identity served comes from introspection, not id_token claims. +- Per-request introspection is the revocation mechanism (`active:false`). Session cookie exp is set from the introspected exp at login and never refreshed; introspected exp discarded on later requests. +- Two auth styles are required by im: form-body creds for token/introspect; Basic for family and directory. +- Family beat: every 5 min: roster pass, register family (origin = stored public address, else base_url; skipped with a log line if empty), fetch family and store JSON under setting `family`. Failures keep the previous list. +- Roster pass via `sync_member` also updates photo_version and timezone; a stream frame with disabled toggles user disabled. +- directory_stream: full roster pass then stream; reconnect backoff 1 s doubling to 30 s; each reconnect repeats the full pass. + +### 3.2 in (Files service, attachments) + +Enabled only when `[storage.in] token` is set (bearer token minted for iz). Service URL is read per call from the family row with key `in` (name and url), raw (no trailing-slash trim; a trailing slash yields `//` paths). Without a token, every call is refused before the wire. + +| Call | Request | Auth | Success / body | +|---|---|---|---| +| probe | GET `{url}/healthz` | none | any 2xx | +| status | GET `{url}/api/service/status` | Bearer | JSON `{quota_bytes, used_bytes}` (u64, default 0) | +| put | POST `{url}/api/service/files` multipart: text `external_id` (= iz attachment id), text `name`, part `file` (mime = stored mime) | Bearer | JSON `{"ok": "<file id>"}`; `{"err":"QuotaExceeded"}` = quota; other err string; no status check before parse; idempotent by external_id | +| fetch | GET `{url}/api/service/file/{external_id}` | Bearer | 2xx bytes | +| delete | DELETE `{url}/api/service/file/{external_id}` | Bearer | 2xx | + +Timeouts: connect 5 s, read-silence 10 s, total 10 s for status/probe/delete; put and fetch have no total ceiling (builder failure silently drops all timeouts). +Storage beat every 30 s: probe, status (updates Settings card facts), then if backend `in` and local attachments exist, drains up to 4 per beat (put, mark stored, remove local file). A put that landed but whose local mark failed is re-pushed next beat (idempotent). +Upload to in: put, then add_remote_attachment (row remote_state `stored`); if the DB write fails, best-effort delete remote (a leaked remote file is possible if delete also fails). +Problem words: unreachable, quota, status, store, unlisted (last_problem not cleared on success; known stale-display bug). + +### 3.3 iz-client (what it exposes) + +- `Config { issuer, client_id, client_secret, redirect_uri, logout_back, cookie_name, cookie_key [u8;32] }` (no Debug). +- `IzClient::new(config)`, `family()` -> Option<Vec<FamilyService>>, `register_family(key,name,url)` -> Result<(), String> (only method with String error; inconsistent). +- `FamilyService { key, name, url }`, `User { sub, email, name, admin }`, `Error { Http, Refused, Token }`. +- `mount(builder, config)` registers IzClient as app context and routes `/auth/login`, `/auth/callback`, `/auth/logout` (and `/whoami` under test only). +- `current_user(cx)`. +- Feature `test-seam`: `mint_session_cookie`, `introspect_path`. Example `mint` (requires test-seam): seals a Session cookie for test harnesses (key file must be 32 raw bytes). +- Cookies: `iz_session` (sealed session, HttpOnly, SameSite=Lax, Path=/, Secure iff issuer is https, MaxAge 30 days); flight cookie `iz_session_pkce` (10 min). Sealing: XChaCha20-Poly1305 with 32-byte key from `<db dir>/iz.key`; no AAD or purpose tag; base64url payload. +- Doc claims refresh tokens and silent rotation: code has none (stale doc). + +--- + +## 4. Data model + +All ids are ULID text. Timestamps are RFC 3339 UTC text (iz-core writes 9 fractional digits for text ordering; boot canonicalises legacy stamps). Deadlines are YYYY-MM-DD text. Booleans are INTEGER 0/1. Source: crates/iz-core/migrations/0001..0007 (0001_init.sql is 457 lines per wc). + +Tables (final shape after 0007): + +- workspace: id PK; name; created_at; attachment_limit_bytes INTEGER DEFAULT 26214400 (25 MiB); allowed_file_types TEXT JSON array DEFAULT '[]' (empty = any); mail_batch_minutes INTEGER DEFAULT 5 (0 = send at once); reminder_minutes INTEGER DEFAULT 15 (0 = off); smtp_host, smtp_port, smtp_username, smtp_password (sealed `v1:` ciphertext), smtp_from_name, smtp_from_address; smtp_test_at/ms/error (result of real test mail); smtp_check_at/ms/error (result of handshake; cleared on sender edit); public_url (mail link base). +- user: id PK; workspace_id REF; oidc_sub (unique where not null; claimed on first sign-in by email); email; display_name; role TEXT (admin|member|viewer; no CHECK); disabled DEFAULT 0; timezone DEFAULT 'UTC' (sync'd from im; app shows fixed offsets); theme DEFAULT 'light'; language DEFAULT 'en'; ui DEFAULT 'instrument'; created_at; last_signed_in_at; photo_version DEFAULT 0 (avatar cache stamp from im). +- workspace_owner: singleton PK (one row); user_id; claimed_at. First admin seen claims ownership. +- board: id; workspace_id; name; task_prefix DEFAULT 'DZ' (hard-coded in provisioning; key prefix); created_at. +- board_column: id; board_id; name; position; is_done (finished column). +- tag: id; board_id; name; position; is_default; created_at. Unique: one default per board; unique name per board. +- task: id; board_id; parent_id (self-FK; one level enforced in store); task_key (unique per board; prefix + tail of ULID, retried with longer tails on collision); title; description DEFAULT ''; column_id; tag_id (NOT NULL); deadline (day); clock_at (UTC instant); position REAL (end of column ordering); created_by; created_at; updated_at; done_at (set when moved into is_done column); deleted_at (soft delete). +- task_assignee: (task_id, user_id) PK. +- task_watcher: (task_id, user_id) PK. Table exists; no feature in these files reads or writes it (unverified). +- task_dependency: blocked_task_id; blocking_task_id; created_at; cleared_at (soft-clear; cleared = satisfied); PK (blocked, blocking); CHECK blocked != blocking. +- comment: id; task_id; author_id; body; created_at. Unbounded body; no edit/delete. +- attachment: id; task_id; comment_id (nullable); file_name (label only); mime_type (sniffed); size_bytes; uploaded_by; created_at; remote_state DEFAULT 'local' ('local' = under storage/attachments/<id>; 'stored' = in Files service keyed by id). Note: the store comments are contradictory about 'stored' vs 'local' for files on disk (see section 9). +- transition: id; task_id; from_column (''= created into column); to_column; actor_id; created_at. One per card move. +- freeing: id; board_id; cause_key; cause_title (copied); actor_id; created_at. One per delete that unblocks someone. +- activity: id; task_id (nullable: workspace/account events); actor_id (nullable: system); subject_id (nullable: who assigned/unassigned line is about); kind (no CHECK; includes other kinds: tagged, tag_created, reminded, sender_saved, ...); detail DEFAULT ''; created_at. +- mail_rule: id; board_id; trigger_kind (open set, includes 'status'); trigger_column (nullable; only for status); subject; audience CHECK in (assignees, board, creator); enabled DEFAULT 1; include_task_details DEFAULT 0; created_at. CHECK trigger_column null unless status. +- mail_send (outbox): id; rule_id (FK cascade, nullable); event_id; task_id; recipient; state CHECK in (pending, sent, failed, abandoned); attempts DEFAULT 0; last_error; claimed_at; next_attempt_at (also the lease/due time); sent_at; kind CHECK in (rule, invite, notice, reminder) DEFAULT 'rule'; subject; body. Unique (rule_id, event_id, task_id, recipient) = "the index decides who owns a send". CHECKs tie kind to required columns. +- mail_decision (ledger): id; rule_id (FK cascade); event_id; task_id (no FK; survives deletion); outcome CHECK in (owed, already_owed, no_recipients, not_matched, disabled, task_gone); detail DEFAULT ''; created_at. Unique (rule_id, event_id, task_id). +- setting: key PK; value. Holds `family` (JSON mirror of im family), `public_url` (app address), `storage_backend` (local|in). + +Indexes (selection): user_email_unique (workspace_id, email); user_oidc_sub_unique; tag_one_default; tag_name_unique; tag_by_board; task_key_unique (board_id, task_key); task_by_column; task_by_parent; task_watcher_by_user; task_dependency_by_blocking; comment_by_task; attachment_by_task; transition_by_task; freeing_by_board; activity_by_task; activity_recent; activity_by_subject; mail_send_once; mail_send_owed (next_attempt_at); mail_send_by_rule; mail_send_by_task; mail_decision_once; mail_decision_recent; mail_decision_by_task. +(Pre-collapse fixture has mail_rule_by_board; live schema does not.) + +Dropped in 0003: session, signin_link, auth_attempt tables and password-era user columns (password_hash, invited_by, photo_mime, feed_seen_at); dropped in 0002/0003/0004: rate-limit, session-lifetime, signin-link-lifetime, photo_limit_bytes columns. + +Filesystem layout: `<storage>/attachments/<attachment id>` (0700 dir, 0600 files), `<database dir>/iz.key` (32-byte key, 0600), database file plus -wal/-shm (0600). The `photos/` directory is referenced in comments only (photo bytes now come from im). + +Boot repairs (idempotent, each boot): retire actor-only decisions, retire Viewer assignments, seal plaintext SMTP passwords, canonicalise legacy stamps, re-sniff generic attachment MIME types (zip/octet-stream/OLE; text/plain never refined), sweep orphan files in attachments/ (unknown files deleted; missing files logged only). + +--- + +## 5. Mail engine + +Components: iz-core `mail.rs` (Engine), SMTP client `iz-web/src/smtp.rs` (lettre, outbound only), store ledger (`mail_rule`, `mail_send`, `mail_decision`), iz-web sweep task. + +Triggering (after commit, never inside a move's transaction): +- `on_transition` for card moves (status rules). Crossing into a column owes; a non-matching rule records NotMatched with detail moved:<to>:<watch|any>. A deleted task records task_gone. +- `on_freeing` for deletes that unblock (unblocked rules). Other triggers record not_unblocked. +- `on_activity` for all other activity kinds (created, assigned, unassigned, commented, retitled, linked, unlinked, deleted, deadline_set/cleared, clock_set/cleared). Disabled rule records Disabled. +- Audience resolution: assignees (for assigned/unassigned, only the person named), board (non-Viewers in workspace, including actor), creator. +- Empty audience: decision no_recipients (detail "empty"). +- Each recipient claims a send (unique key). A lost claim records already_owed; a won claim records owed. + +Delivery: +- Sweep task (iz-web main.rs): sleeps until the next due time (idle cap 3600 s, re-check 60 s when a due row was not taken, wakes early on Queue topic), calls deliver_owed(now, 50). Request-side after_activity/after_invite call deliver_owed(now, 8). +- Lease: claimed rows are due again after LEASE = 5 min (crash = late send, possible duplicate; at-least-once). +- Retries: MAX_ATTEMPTS = 5 for retryable refusals; backoff = 5 * 2^(attempts-1) minutes, capped 60 (values reached: 5, 10, 20, 40; the 60 cap is unreachable because the attempt gate stops at 4 retries). Permanent refusal or 5th attempt = abandoned. Otherwise failed with next_attempt_at. +- Held (no sender configured): MailError::unsent, row defers HOLD = 1 min without spending an attempt. +- Quiet window (workspace mail_batch_minutes): rows for same (task, recipient) are grouped into one mail; hold pushes all pending never-attempted rows later, ceiling MAX_HOLD_WINDOWS = 4 windows from oldest row. Holds never pull a leased row back. Window 0 sends immediately. Invites, notices and reminders never batch. +- Batch body: "KEY โ€” title", Column, Deadline, Assignees, when-line, link (+ details block if rule opts in). Single body includes the happened sentence. +- Subject: rule's subject (admin's text, no templates). Invite/notice/reminder carry their own subject and body. +- Body text is composed in Rust (English only); link is `<public_url or listen url>/?task=<id>`. +- Empty subject/body on invite/notice/reminder is sent as-is (unwrap_or_default). + +Kinds: rule (from rules), invite (queued when a member is added; state pending; also "queue_invite" publishes Members), notice (admin message to members), reminder (clock reminders; per recipient; reminder sent writes an activity `reminded` on the task). + +States: pending, sent, failed (retry scheduled), abandoned (no more retries). Decision outcomes: owed, already_owed, no_recipients, not_matched, disabled, task_gone. + +Test mail and connection check: `send_test(to)` (subject "iz test mail", no ledger row, no retry; records sender_test). `check_sender()` = connect, TLS, EHLO, AUTH, NOOP, quit; sends nothing; a pass does not prove deliverability (envelope sender checked per message). + +SMTP client (smtp.rs): +- No listener. Outbound only. +- Port 465 = implicit TLS (relay); any other port = STARTTLS (starttls_relay). UI default port 587. +- Timeouts: transport reply 15 s; probe 15 s whole call. +- Auth: username and password (Credentials). Transport rebuilt when sender config changes. +- From: `"<name> <address>"` or bare address (name not escaped). To parsed as mailbox. Plain text, text/plain, no HTML, no attachments, no size limit set in code. +- Permanent error (parse failure or SMTP permanent code) = abandoned; others retryable. +- Missing sender configuration (host, port, username, from address or password absent/empty, or port out of u16) = unsent (held). + +Inbound mail: NONE. There is no SMTP server, no inbound parsing, no reply-by-mail, no sender verification for inbound. + +Rule-loop protection: structural only (closed trigger set; mail-related activity kinds match no trigger). + +--- + +## 6. Configuration + +File: `config/iz.toml`, path relative to the working directory. No environment variables are read (HOST and PORT deliberately ignored). Missing file: development defaults are written (mode 0600) and the boot stops with "fill in [oidc]" (the "dev" report line is effectively unreachable). The committed repo ignores config/iz.toml (.gitignore); the committed config file shown has database and listen only. + +| Key | Where | Required | Default | Rule | +|---|---|---|---|---| +| database | top level | yes | none | non-empty; resolved absolute; dev template uses "iz.db" | +| storage | top level string, or table [storage.in] | no | `<db parent>/storage` (or "storage") | empty = default; other TOML types invalid; storage and [storage.in] together = duplicate key parse error | +| storage.in.token | [storage.in] | no | absent (in backend unavailable) | empty = absent; never printed | +| listen | top level | no | 127.0.0.1:7654 | must parse as SocketAddr; port 0 allowed; only decides bind address | +| live_seconds | top level | no | 300 | must be nonzero; SSE window | +| base_url | top level | no | empty (derive from listen) | not normalised; used as public URL fallback | +| [oidc] | table | yes | none | must exist | +| oidc.issuer | [oidc] | yes | none | non-blank; no URL validation | +| oidc.client_id | [oidc] | yes | none | non-blank | +| oidc.client_secret | [oidc] | yes | none | non-blank; never printed | +| oidc.redirect_uri | [oidc] | no | `<listen_url>/auth/callback` | explicit value unvalidated | + +Unknown top-level keys and unknown [oidc] keys are reported as ignored (not fatal). Startup report prints database, storage, mail URL, oidc issuer, sender pointer, ignored keys (no secrets). +Config is completed on load: missing optional keys (listen, live_seconds, base_url, storage) are appended (only adds). + +Runtime settings (not in file; in DB, admin-edited): sender (smtp_*), attachment limit, allowed types, mail batch minutes (default 5 in DB; 0 when no workspace yet), reminder minutes (default 15), public URL (workspace and app-level), storage backend (default local), family mirror. + +Build-time: IZ_BUILD_SHA (default "dev"), IZ_STYLE_FINGERPRINT (stylesheet hash guard). + +Boot-time constants: LEASE 5 min; HOLD 1 min; MAX_ATTEMPTS 5; MAX_HOLD_WINDOWS 4; DIRECTORY_SECONDS 300; STORAGE_SECONDS 30; DRAIN_BATCH 4; WIDEST_ATTACHMENT_MB 500; ROWS_PER_PAGE 50 (sheet), COLUMNS_PER_PAGE 12; PROBE timeout 2 s (family), 15 s (sender check); storage connect 5 s / read 10 s; directory backoff 1 s to 30 s; busy_timeout 5000 ms; broadcast capacity 256; live cookie-rows default 50 (10-200). + +CI/deploy: GitHub Actions deploys main to a host over SSH as a systemd user unit (iz.service, WorkingDirectory ~/iz, ExecStart ~/iz/current/iz-web, Restart=on-failure). Health gate on /healthz (must be `ok <sha>`) and served stylesheet hash; automatic rollback to current.previous. + +--- + +## 7. Security mechanisms + +Authentication: +- OIDC with PKCE S256; state and nonce; id_token RS256 + iss + aud + exp; per-request introspection; revocation = `active:false` only. +- Sealed cookies: XChaCha20-Poly1305, key in iz.key beside the DB (lost key = signed out and SMTP password unreadable). +- Cookie flags: HttpOnly, SameSite=Lax, Path=/, Secure iff issuer is https. +- Sign-in return path whitelisted (safe_next). +- Redirects built from Referer are reduced to same-origin path (no open redirect), though the raw Referer is used in some board redirects. + +Authorisation (role matrix; from role.rs and handler guards): +| Capability | Admin | Member | Viewer | +|---|---|---|---| +| Read board, task, files, people, avatars | yes | yes | yes | +| Create/move/edit/delete tasks, subtasks, links, assign, tag a task | yes | yes | no | +| Be assigned, be mailed (rules, reminders) | yes | yes | no | +| Comment | yes | yes | no | +| Upload file | yes | yes (can_comment) | no | +| Delete a file | uploader or admin | uploader | no | +| Administer: members, roles, sender, limits, storage, rules, logs, tags, messages, app public address | yes | no | no | +| Live channel admin topics (queue, rules, settings, activity) | yes | no | no | +| Profile / preferences | yes | yes | yes | +Export: not gated (no export feature found). +Non-admin hitting admin page gets a refusal note (page) or Forbidden (POST). Not-found and cross-workspace both return 404-like "not found" (not forbidden) for tasks, files, profiles. + +CSRF: NO token and NO Origin/Referer check. Only SameSite=Lax on the session cookie stands between a cross-site POST and an action (weak; see section 9). + +Headers: no CSP, X-Frame-Options, nosniff, HSTS, Referrer-Policy, Permissions-Policy. Inline scripts used throughout. Google Fonts loaded from third party on every page. Only Cache-Control no-cache on HTML. + +Secrets: +- SMTP password: write-only in UI, sealed in DB (XChaCha20-Poly1305, `v1:` prefix); never in logs or pages; lost key = "no password set". +- OIDC client secret: never rendered; used only for Basic and form auth. +- Storage bearer token: presence-checked on the page; never printed. +- Config secrets never printed by the startup report. +- Key file written with default umask then chmod 0600 (brief window; unix only). + +Input and limits: +- Upload: 25 MiB default workspace limit (up to 500 MiB), allow-list by extension, bytes sniffed, streamed with per-chunk limit; body cap 500 MiB at /files. +- Download: inline only for safe families; attachment otherwise; nosniff absent. +- Sheet and slide parsing run on spawn_blocking; no zip-bomb limit in slides reader. +- Avatar and file streams have no rate limit; no rate limiting anywhere. +- Live stream: admin topics filtered by role snapshot at connect time. + +Other: +- Viewers excluded from all mail recipients in store queries. +- Disabled accounts cannot sign in (introspection/`disabled` check) and are revoked live. +- Activity log records admin actions and mail verdicts; message bodies and credentials not logged. + +--- + +## 8. UI: pages and what each shows + +| Page | Path | Who | Shows | +|---|---|---|---| +| Sign-in (landing, signed out) | `/` | anyone | Wordmark, sign-in link, auth error line | +| Board | `/` | signed in | Topbar (nav, family switcher, user menu), filter bar (project, assignee, sort, search, overdue/blocked chips, new task), columns of cards, card menus, task modal and new-task modal when open | +| Task modal | `/?task=<id>` | signed in | Masthead (breadcrumb, title, status, close); tabs Task / Subtasks / Files / Comments / Activity / Mail; delete confirmation; in-modal file viewer | +| New task modal | `/?new=1` | writers | Title, column, description, deadline and clock, project, assignees, link | +| File viewer | `/?task=..&file=..` | signed in | Image, video, audio, PDF (present), spreadsheet (paged table, sheet tabs), slides outline | +| Profile (person) | `/people/<id>` | signed in, same workspace | Avatar, name, role, owner chip, email, joined, last seen, counts, recent activity | +| Settings | `/settings` | signed in | Sections: Profile (identity, theme, ui, language, connection), Outgoing (admin: sender, check, test), Limits (admin: attachments, types, batch, reminders, storage), Server (admin: app public address), Members (admin: roles, disable, add), Message (admin: send notice to one or everyone) | +| Mail rules | `/rules` | admin | Rule sentences, enable switch, last sent/fired stamp, edit form, delete; note if no sender | +| Logs | `/logs` | admin | Sections queue / decisions / activity; filters; pagination; retry | +| Tags | `/tags` | admin | New tag form; ordered tag list with card counts, rename, move up/down, delete (disabled for default and in-use tags) | +| Avatars | `/avatar/<id>` | signed in | Image (not a page) | +| Errors | any | any | "nothing at this address" 404 page (signed-out pages in English) | +| Healthz | `/healthz` | any | plain text `ok <sha>` | + +Client-side behaviour: soft navigation (swap body in place, no reload, build-stamp skew reloads once), escape-key priority manager, custom dropdown replacing selects (search when more than 7 options), datepicker popover, card context menu, drag-and-drop card move and file drop zones, live refresh on SSE frames, avatar fallback to initials, audio and PDF helpers. + +--- + +## 9. Oddities, bugs, half-finished and inconsistent items + +Security: +1. Avatar cross-workspace leak: `avatar.rs` fetches any user by id with no workspace comparison (`store.user(id)` is unscoped). Any signed-in user of any workspace can fetch another user's photo if they know the id. Fix: compare workspace_id with viewer. +2. No CSRF token and no Origin/Referer check on any POST; SameSite=Lax only. +3. No CSP or other security headers; inline scripts everywhere; third-party Google Fonts on every page. +4. Download auth failure redirects with `on=upload_file` (wrong refusal tag). +5. Upload: read error on a file stream is reported as FileTooBig. +6. Storage client: stale `last_problem` shown after recovery (never cleared on success). +7. Storage client builder failure silently drops all timeouts. +8. `in_of` uses family URL raw (trailing slash gives `//` paths). +9. set_disabled checks only that target != self; workspace scoping and owner protection rely on store (unverified). set_role in store accepts Admin; handler refuses it, so the Admin refusal exists only at the handler and in add_member. +10. Secret key file created with default permissions, then chmod 0600 (window). Non-unix: no restriction. +11. Downloads and avatars: no rate limiting anywhere. +12. `qsdecode` / `decode_q` slice multibyte text at `%`; can panic on malformed escapes (low impact). +13. Retry endpoint and check_sender have no rate limit; check_sender refusal not shown on the page. + +Data and logic: +14. Reminders go to disabled assignees (recipient query has no disabled filter). +15. Position MAX for new cards includes soft-deleted and done tasks (bug-prone). +16. create_task: column_id not validated against board in store; card is inserted before dependency cycle check, so a cycle refusal leaves a card behind. Same non-atomic risk for assign loops. +17. add_dependency: parent/child check is outside the transaction (race). Dependency edges to soft-deleted blockers still show on the board (dependencies_for_board does not filter blocker deleted_at). +18. Subtask deep nesting not prevented in delete (grandchildren not deleted; orphans possible if nesting ever existed); reminders for deleted subtasks may linger (verify). +19. move_tag can silently do nothing after gaps from delete_tag (no renumbering). +20. Silent no-op updates on wrong workspace id: set_limits, set_public_url, set_setting, set_storage_backend, record_sender_* do not check row count. +21. Rule editing: non-status rule cannot be created unless column select is "Any column" (trigger_of returns Forbidden); editing a non-status rule always fails; editing "any column" status rule narrows it to the first column (form pre-selects first column). +22. Mail actor is not removed from audiences, so people get mail about their own actions (mod.rs doc claims otherwise; stale). +23. Mail backoff cap of 60 min unreachable (attempt gate). +24. Endless re-claim: a send whose rule or event row is missing, or with no task, is never attempted or written off; it is re-claimed every lease pass. +25. Unblocked crossing into a non-done column writes no decision (promise broken). +26. Reconcile (rebuild after schema change) forces user.disabled = 0 for every row (reconcile.rs map), so disabled accounts become enabled after a rebuild. Real bug candidate. +27. Reconcile swap is two renames; a crash between leaves no file at path (only in-process recovery). Every rebuild leaves a full backup file that is never deleted. +28. Mail batch default: DB default 5 minutes vs engine 0 when no workspace row exists. +29. add_member stores untrimmed name and email despite validating the trimmed email. +30. Message to everyone: the admin is excluded; to self is allowed. +31. Clock/reminder: reminder_minutes unbounded on server (u32), while batch is capped at 120. +32. save_sender writes sender then public URL in two non-atomic steps. +33. save_storage not mapped to a settings section (lands on profile). +34. Logs: queue cursor uses next_attempt_at (rows with no next attempt lose the newer/older link at that boundary). retry_send ignores requeue result. +35. Logs: ACTIVITY_KINDS filter omits parented, unparented, reminded, password reset kinds. +36. Logs: no retention or pruning for mail ledger or activity. +37. Logs and refusals on logs_page use English regardless of user language; Refusal for the settings page likewise. +38. Activity writes in tag/file-delete paths swallow errors (let _ =). +39. Turkish-language refusal fallback: BadSender falls back to English by design. +40. Store `task_watcher` table exists with no feature using it (unverified). +41. Board double-load: board page loads twice and applies filters twice. +42. Board: `?task=`/redirect uses raw Referer on some paths (stale refusal params can persist after a later success on board.rs redirects). +43. Direction radio labels in link picker and new-task modal read backwards (values correct). +44. Card deadline shows "done" stamp; detail view does not (inconsistent done rendering). +45. New-task link picker lists all board tasks including subtasks and already linked ones (detail picker filters them). +46. Live stream: admin status fixed at connect (demoted admin keeps admin topics until reconnect, up to live_seconds). +47. Background task handles (sweep, directory, storage) are spawned and not joined: a panic is silent. +48. /healthz checks only the process (no DB/storage/im). +49. Stale names and docs: "in-client" and "im" mixing in comments; files.rs "Ported from iz-web/src/files.rs" self-reference; config.rs doc says relative paths resolve against config/ (they resolve against cwd); `dev` report line unreachable; DZ prefix hard-coded in provisioning; workspace name 'iz' hard-coded; actor "system" sentinel collides with a real id of the same string. +50. Tag names not validated server-side (HTML maxlength 60 only); no length limits on title, description, comment body, subtask title (HTML 200 only), mail subject (rule HTML 120, message HTML 200). +51. Mail From display name not escaped (may fail to parse). +52. Viewer-level delete_file and comment rights: delete_file checks uploader or admin only, not can_comment (a demoted user can delete old own uploads). +53. Dropped `refusal` on successful move keeps stale params in some redirects (see 42). +54. Duplicate queue/dedupe hazards: a crossing and a sweep at the same moment mail once (fixed by unique key); two passes over one owed send send once. +55. Two `Refusal` / message gaps: Refusal::BadPolicy exists in server.rs with no user (may belong to another settings surface). +56. `SubtaskLine` and `DeletionCost` doc comment mix-up in detail.rs. +57. Sheet reader: streamed and whole-workbook paths represent empty rows/cols differently; whole path ignores range start offset. +58. Slides reader: any unknown XML entity fails the whole deck; a relation to a missing slide part fails the whole deck while a sldId without a relation is silently dropped. +59. `sniff`: any unknown ISO-BMFF brand is labelled video/mp4 (M4A audio mislabelled); zip office detection is substring-based over the whole buffer; empty input sniffs as text/plain. +60. No `image/svg+xml` in sniffer, but the inline-render rule depends on that (not enforced in code). +61. Refusal message hard-codes "500 MB" instead of the constant. +62. Live: `/people/` branch in live_script never matches (dead). +63. Dead code: client_label (only tests), DirectoryHealth.opened_at, Outcome enum (turso_store, unused), `file_chip` may_write unused, `#[allow(unused_variables)]` on settings_page and board_page, `may_delete` = `may_write`, sweep_orphan_files loop over one-element array. +64. Test-harness conflict with stated user preferences: crates/iz-web/tests/browser/run.sh and fake-im.mjs use node/npm/npx (user prefers bun). Tests also write to /tmp (reconcile tests use literal /tmp/iz.db and temp_dir; config tests use temp_dir). +65. Config shape drift: storage comment text duplicated between DEVELOPMENT_DEFAULTS and OPTIONAL_KEYS. +66. Mail composition: single and batch bodies repeat key and title; English only; no templates files. + +Data-shape inconsistencies (for rebuild decisions): +- 'stored' vs 'local' attachment semantics: add_attachment writes 'stored'-named paths in comments but local disk; mark_attachment_stored deletes the local file; the meaning of remote_state must be pinned in the rebuild. +- Admin owner: never transferred; no UI to change owner. +- Store doc (mod.rs) says delete_tag moves tasks (stale) versus the real behaviour (refused when cards are on it). + +Disagreements between slice reports (resolved where the code was checked): +- Migration 0001 length: 457 lines (wc) vs 391 (migrations slice; that was the fixture). 457 used here. +- `disabled` on rebuild: reconcile sets 0 for all (reported by reconcile slice; migrations slice did not check). +- Role gates on board/detail handlers: board.rs requires writer; detail.rs requires writer or can_comment per handler; the server slice could not confirm every handler gate. Treat section 2.3 gates as per the detail slice. +- Backoff: mail engine slice (cap unreachable) is correct; the rules slice's "capped at 60" is the formula, not the reachable value. +- Inbound SMTP: none exists (confirmed by smtp and mail slices). + +--- + +## 10. Test inventory (for behaviour reference) + +- http.rs (227 tests) covers: write permissions per role; board and detail behaviour; subtasks and tab routing; files (inline vs download, ranges, viewer, size and type limits, delete rights, cross-workspace not-found); settings (limits, sender validation, probe and test, storage, members and roles, owner protection); mail rules (create, read-back as sentence, enable, delete, foreign ids); logs (queue, retry, message, paging, filters); profile and preferences; avatars and asset cache rules; clock and reminders; tags (permissions, default tag, in-use); search and filters; live channel (topic gating, revoke, reconnect); SSO provisioning and disabled accounts; family switcher; in-service upload/download/delete and quota messages; create-and-move flows. +- store.rs (212 tests) covers: schema and reconcile (including backups, default tag seeding); subtasks; workspace and sender secrets (password not plaintext on disk; file owner-only); users and provisioning (owner claim, email claim, viewer demotion removes assignments, sync announcements); tags; board costs (six queries board, nine queries detail); dependencies and cycles; transitions and Done stamping; mail engine (decisions, claims, retries, batching, holds, reminders, invites, queue ordering); activity paging; files (storage tree, remote rows, resniff at boot); settings announcements. +- browser tests (Playwright; need node/npm and Chromium): soft-nav (no full reload between pages); moment (date+clock picker and card label `Mon DD ยท HH:MM`); photo (avatar renders and survives refresh); drop (file drop zone states and drop targets). Fake im serves introspection and a 1x1 PNG photo. + +--- + +## 11. Rebuild-critical rules (summary) + +- Overdue: one rule everywhere (see 2.4). +- Done/finish: moving into an is_done column stamps done_at; a card with open subtasks cannot enter it. +- Subtasks: one level; a parent with children cannot become a part; deleting parent deletes direct children. +- Dependencies: no cycles over live edges; soft clear; finished blockers stop blocking; delete of a blocker frees dependents and writes a freeing event. +- Viewers: read-only and excluded from mail and assignment. +- Mail: per-recipient claim with unique key; 5 attempts; 5/10/20/40 minute backoff; 1-minute hold without sender; 5-minute lease; batch window per workspace with 4x ceiling; decisions ledger for every verdict. +- Reminders: one per assignee before a clock time; re-derived on every change; abandoned on finish/delete/unassign. +- Live: data-free change notices with a sequence number; client re-reads through normal routes; admin topics admin-only. +- Attachments: sniffed MIME, allow-list by extension, per-workspace size, remote mode via in service with bearer token and external id = attachment id. +- Config: strict on database and oidc; lenient on unknown keys; no env vars.