From 189bd22b46197e6420ebf983ff625bcded6ad7cb Mon Sep 17 00:00:00 2001 From: ajianaz Date: Thu, 15 Oct 2026 16:12:17 +0700 Subject: [PATCH] build: enforce the unsafe_code lint in every crate (#1456) --- .agents/skills/uteke-memory/SKILL.md | 4 ++-- CHANGELOG.md | 1 + Cargo.toml | 2 +- crates/docgen/Cargo.toml | 3 +++ crates/uteke-cli/Cargo.toml | 3 +++ crates/uteke-cli/assets/uteke-memory-skill.md | 4 ++-- crates/uteke-cli/src/config.rs | 1 + crates/uteke-cli/src/main.rs | 1 + crates/uteke-core/Cargo.toml | 3 +++ crates/uteke-core/src/embed/ort_init.rs | 1 + crates/uteke-core/src/lib.rs | 2 ++ crates/uteke-mcp/Cargo.toml | 3 +++ crates/uteke-server/Cargo.toml | 3 +++ 13 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.agents/skills/uteke-memory/SKILL.md b/.agents/skills/uteke-memory/SKILL.md index eba1e4d8..304f8bb6 100644 --- a/.agents/skills/uteke-memory/SKILL.md +++ b/.agents/skills/uteke-memory/SKILL.md @@ -5,7 +5,7 @@ description: "Persistent memory engine for AI agents via the uteke CLI — remem # Uteke Memory Skill Persistent memory engine for AI agents via the `uteke` CLI. -Version: **0.21.1** — SQLite + HNSW vector index (usearch default, or vecq) + FTS5 hybrid search (RRF k=60); `fusion` (weighted RRF of the vector and hybrid rankings) is the default recall strategy since 0.16.0. `unsafe_code = "forbid"` workspace-wide. +Version: **0.21.1** — SQLite + HNSW vector index (usearch default, or vecq) + FTS5 hybrid search (RRF k=60); `fusion` (weighted RRF of the vector and hybrid rankings) is the default recall strategy since 0.16.0. `unsafe_code = "deny"` workspace-wide (only test modules that change env vars opt out). > This skill ships with each release — its version tracks the CLI version > (a CI gate fails when they drift, see `skill-version-parity` test). @@ -211,7 +211,7 @@ Version: **0.21.1** — SQLite + HNSW vector index (usearch default, or vecq) + - **Embedding:** ONNX EmbeddingGemma Q4 (768d), auto-downloaded - **Tiered memory:** Hot (<7d, +0.1 boost), Warm (<30d), Cold (>30d) - **Schema versioning:** Integer counter, auto-migration on upgrade -- **`unsafe_code = "forbid"`** at the workspace level +- **`unsafe_code = "deny"`** at the workspace level, inherited by every crate (test modules that mutate the environment allow it) - **Project-scoped stores:** `uteke --store .uteke remember "..."` ## Usage Patterns diff --git a/CHANGELOG.md b/CHANGELOG.md index 390be883..208abe6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changed - **`tools/list` for a read-only token lists only the tools it can call (#1446)** - MCP over HTTP advertised every tool to read-only callers, which then failed at call time. A read-only caller now sees exactly the read tools; full-access callers, the stdio transport and `tools/call` are unchanged. Contract: uteke-cloud#203 (approved by the owner). +- **`unsafe_code` is now enforced (#1456)** - the workspace declared `unsafe_code = "forbid"` but no crate inherited it, so nothing was enforced. Every crate now has `[lints] workspace = true` and the level is `deny`: production code cannot contain `unsafe`, and only the five test modules that call `std::env::set_var`/`remove_var` (edition 2024) opt out with `#[allow(unsafe_code)]`. `forbid` cannot be used because it cannot be relaxed per module. ## [0.21.1] - 2026-10-15 diff --git a/Cargo.toml b/Cargo.toml index 9e06b787..b67c906b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ readme = "README.md" homepage = "https://uteke.dev" [workspace.lints.rust] -unsafe_code = "forbid" +unsafe_code = "deny" [profile.release] opt-level = 3 diff --git a/crates/docgen/Cargo.toml b/crates/docgen/Cargo.toml index 56314e35..ff0a3775 100644 --- a/crates/docgen/Cargo.toml +++ b/crates/docgen/Cargo.toml @@ -15,3 +15,6 @@ uteke-core = { path = "../uteke-core" } schemars = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" + +[lints] +workspace = true diff --git a/crates/uteke-cli/Cargo.toml b/crates/uteke-cli/Cargo.toml index c9916d59..59de7ade 100644 --- a/crates/uteke-cli/Cargo.toml +++ b/crates/uteke-cli/Cargo.toml @@ -45,3 +45,6 @@ minisign-verify = "0.3.0" [dev-dependencies] serial_test = "3" + +[lints] +workspace = true diff --git a/crates/uteke-cli/assets/uteke-memory-skill.md b/crates/uteke-cli/assets/uteke-memory-skill.md index eba1e4d8..304f8bb6 100644 --- a/crates/uteke-cli/assets/uteke-memory-skill.md +++ b/crates/uteke-cli/assets/uteke-memory-skill.md @@ -5,7 +5,7 @@ description: "Persistent memory engine for AI agents via the uteke CLI — remem # Uteke Memory Skill Persistent memory engine for AI agents via the `uteke` CLI. -Version: **0.21.1** — SQLite + HNSW vector index (usearch default, or vecq) + FTS5 hybrid search (RRF k=60); `fusion` (weighted RRF of the vector and hybrid rankings) is the default recall strategy since 0.16.0. `unsafe_code = "forbid"` workspace-wide. +Version: **0.21.1** — SQLite + HNSW vector index (usearch default, or vecq) + FTS5 hybrid search (RRF k=60); `fusion` (weighted RRF of the vector and hybrid rankings) is the default recall strategy since 0.16.0. `unsafe_code = "deny"` workspace-wide (only test modules that change env vars opt out). > This skill ships with each release — its version tracks the CLI version > (a CI gate fails when they drift, see `skill-version-parity` test). @@ -211,7 +211,7 @@ Version: **0.21.1** — SQLite + HNSW vector index (usearch default, or vecq) + - **Embedding:** ONNX EmbeddingGemma Q4 (768d), auto-downloaded - **Tiered memory:** Hot (<7d, +0.1 boost), Warm (<30d), Cold (>30d) - **Schema versioning:** Integer counter, auto-migration on upgrade -- **`unsafe_code = "forbid"`** at the workspace level +- **`unsafe_code = "deny"`** at the workspace level, inherited by every crate (test modules that mutate the environment allow it) - **Project-scoped stores:** `uteke --store .uteke remember "..."` ## Usage Patterns diff --git a/crates/uteke-cli/src/config.rs b/crates/uteke-cli/src/config.rs index 784020e3..c43ff9e2 100644 --- a/crates/uteke-cli/src/config.rs +++ b/crates/uteke-cli/src/config.rs @@ -1058,6 +1058,7 @@ fn set_namespace_in_toml(content: &str, namespace: &str) -> String { // ── Tests ─────────────────────────────────────────────────────────────────── +#[allow(unsafe_code)] #[cfg(test)] mod tests { use super::*; diff --git a/crates/uteke-cli/src/main.rs b/crates/uteke-cli/src/main.rs index ab02a279..cfac3678 100644 --- a/crates/uteke-cli/src/main.rs +++ b/crates/uteke-cli/src/main.rs @@ -306,6 +306,7 @@ pub(crate) fn resolve_namespace(cli: &Cli, config: &Config) -> String { "default".to_string() } +#[allow(unsafe_code)] #[cfg(test)] mod resolve_store_tests { use super::*; diff --git a/crates/uteke-core/Cargo.toml b/crates/uteke-core/Cargo.toml index 0dbd0469..e267d537 100644 --- a/crates/uteke-core/Cargo.toml +++ b/crates/uteke-core/Cargo.toml @@ -52,3 +52,6 @@ sha2 = { version = "0.11" } [dev-dependencies] tempfile = "3" serial_test = "3" + +[lints] +workspace = true diff --git a/crates/uteke-core/src/embed/ort_init.rs b/crates/uteke-core/src/embed/ort_init.rs index 66e86570..d7070da0 100644 --- a/crates/uteke-core/src/embed/ort_init.rs +++ b/crates/uteke-core/src/embed/ort_init.rs @@ -365,6 +365,7 @@ pub fn init_ort_environment() -> Result { Ok(info) } +#[allow(unsafe_code)] #[cfg(test)] mod tests { use super::*; diff --git a/crates/uteke-core/src/lib.rs b/crates/uteke-core/src/lib.rs index 693229aa..31dc2619 100644 --- a/crates/uteke-core/src/lib.rs +++ b/crates/uteke-core/src/lib.rs @@ -2769,6 +2769,7 @@ fn restrict_dir_permissions(dir: &Path) { let _ = dir; } +#[allow(unsafe_code)] #[cfg(test)] mod tests { /// #1166: `open()` must not request a backend the build cannot @@ -4476,6 +4477,7 @@ mod documents_fts_heal_tests { } } +#[allow(unsafe_code)] #[cfg(test)] mod fallback_settings_tests { //! #1355 step A — one env-override implementation for `[embed_fallback]`. diff --git a/crates/uteke-mcp/Cargo.toml b/crates/uteke-mcp/Cargo.toml index c56ac77a..efa1b854 100644 --- a/crates/uteke-mcp/Cargo.toml +++ b/crates/uteke-mcp/Cargo.toml @@ -38,3 +38,6 @@ uuid = "1" [dev-dependencies] uuid = { version = "1", features = ["v4"] } chrono = "0.4" + +[lints] +workspace = true diff --git a/crates/uteke-server/Cargo.toml b/crates/uteke-server/Cargo.toml index f13bcc40..4ce946e8 100644 --- a/crates/uteke-server/Cargo.toml +++ b/crates/uteke-server/Cargo.toml @@ -40,3 +40,6 @@ ctrlc = "3" uuid = "1" sha2 = "0.11" chrono = { version = "0.4", default-features = false, features = ["serde", "clock"] } + +[lints] +workspace = true