From 090dfd148e1da6a99a8fafab4c0d849e5856ef10 Mon Sep 17 00:00:00 2001 From: Shanu Date: Tue, 18 Aug 2026 17:45:03 +0530 Subject: [PATCH] =?UTF-8?q?Stop=20a=20durable-namespace=20drift,=20and=20s?= =?UTF-8?q?hed=20a=20web=20framework=20(#18=20=C2=A7B2/=C2=A7D2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three findings, all in this crate, none touching another repo. §B2 -- the sync-state KV namespace was declared twice ----------------------------------------------------- `core/src/engine/sync.rs` held pub const HOST_SYNC_STATE_NAMESPACE: &str = "composio-sync-state"; while the engine holds `tinycortex::memory::sync::state::STATE_NAMESPACE` with the same literal. Host and engine therefore agreed only by coincidence of the string. Change either one and they read and write *different* KV namespaces, stranding every persisted Composio sync cursor -- with no error anywhere, because both sides are individually valid. Now a re-export, so they agree by construction. A test additionally pins the value, because the namespace is durable: changing it is a data migration, and that should fail loudly here rather than surface later as a sync that silently restarts from the beginning. §D2 -- `regex` was never used by this crate -------------------------------------------- The only apparent usage was a *local module* named `regex` (`pub mod regex { pub use crate::engine::backend::score::extract::regex::extract; }`), not the crate. No `use regex::`, no `Regex::new`, nothing. Honest classification: this is a redundant declaration, not a shed. `cargo tree -i regex` still reaches it through tinycortex; only core's false claim to need it is gone. §D2 -- `axum` was a test-only dependency in the normal graph ------------------------------------------------------------ All four references are inside `mod tests` (from line 726), where `store::factories`' tests stand up a throwaway HTTP server to exercise the embedder's failure paths. Declared as a normal dependency, it put a web framework into every build that links this crate. This one is a real shed, measured: tinymemory-tinycortex (default) 169 -> 154 tinymemory-tinycortex --features memory-git 173 -> 158 `cargo tree -p tinymemory-tinycortex -e normal -i axum` now reports no match at all. Checked and deliberately left alone: `rand` and `walkdir` are genuinely production (`new_summary_id`, `engine/persona.rs`). A first pass misread `rand` as test-only because an unrelated `#[cfg(test)]` sits above the `pub fn` that uses it. cargo fmt --all -- --check: clean cargo clippy --workspace --all-targets --all-features: clean cargo test --workspace: 1207 passed, 0 failed (core 798 -> 799) (cherry picked from commit 00006503f60bceda83df6d18d26fe7d6a7ccda8c) --- Cargo.lock | 1 - core/Cargo.toml | 8 +++++-- core/src/engine/sync.rs | 11 +++++++++- .../src/sync/composio/providers/sync_state.rs | 22 +++++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c5ca9c..ffe877c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1855,7 +1855,6 @@ dependencies = [ "log", "parking_lot", "rand 0.8.7", - "regex", "reqwest", "rusqlite", "serde", diff --git a/core/Cargo.toml b/core/Cargo.toml index d876807..9410c4b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -42,7 +42,6 @@ async-trait = "0.1" # tinycortex's major — which `links = "git2"` turns into a hard cargo error # rather than a warning. # `store/factories.rs` exposes a tiny health router for the embedded provider. -axum = { version = "0.8", default-features = false, features = ["http1", "json", "tokio", "query", "ws", "macros"] } chrono = { version = "0.4", features = ["serde"] } # `tinycortex/persona.rs` resolves the user's home directory for the obsidian # vault default. @@ -55,7 +54,6 @@ parking_lot = "0.12" rand = "0.8" reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] } tracing = "0.1" -regex = "1.10" rusqlite = { version = "=0.40.0", features = ["bundled"] } serde = { version = "1", features = ["derive"] } serde_json = "1" @@ -70,6 +68,12 @@ walkdir = "2" # `TestHostConfig` — the concrete `MemoryHostConfig` the extracted test suites # build, since `Config` is a trait object and cannot be `Default`ed. tinymemory-api = { path = "../api", features = ["test-support"] } +# Test-only. `store::factories`' tests stand up a throwaway HTTP server to +# exercise the embedder's failure paths — the four `axum` references in this +# crate are all inside `mod tests`. It was declared as a normal dependency, +# which put a web framework in the normal graph of every build linking this +# crate (#18 §D2). +axum = { version = "0.8", default-features = false, features = ["http1", "json", "tokio", "query", "ws", "macros"] } tempfile = "3" tokio = { version = "1", features = ["test-util"] } diff --git a/core/src/engine/sync.rs b/core/src/engine/sync.rs index 54aa871..c72553c 100644 --- a/core/src/engine/sync.rs +++ b/core/src/engine/sync.rs @@ -14,7 +14,16 @@ use crate::sources::{MemorySourceEntry, SourceKind}; use crate::store::MemoryClientRef; use crate::Config; -pub const HOST_SYNC_STATE_NAMESPACE: &str = "composio-sync-state"; +/// The KV namespace Composio sync state is persisted under. +/// +/// Re-exported from the engine rather than re-declared. It was a second +/// `const` holding the same literal as +/// `tinycortex::memory::sync::state::STATE_NAMESPACE`, so the host and the +/// engine agreed only by coincidence of the string: change either and the two +/// would silently read and write *different* namespaces, stranding every +/// persisted sync cursor with no error anywhere. A duplicated literal is a +/// drift hazard precisely when the thing it names is durable (#18 §B2). +pub use tinycortex::memory::sync::state::STATE_NAMESPACE as HOST_SYNC_STATE_NAMESPACE; pub use tinycortex::memory::sync::{ RawCoverage, RawFileRef, RealCostAccumulator, RebuildOutcome, SyncAuditEntry, }; diff --git a/core/src/sync/composio/providers/sync_state.rs b/core/src/sync/composio/providers/sync_state.rs index 4e33f91..d931f25 100644 --- a/core/src/sync/composio/providers/sync_state.rs +++ b/core/src/sync/composio/providers/sync_state.rs @@ -17,3 +17,25 @@ pub fn extract_item_id(item: &serde_json::Value, paths: &[&str]) -> Option