Skip to content

Commit 26530b5

Browse files
westgatewestgate
authored andcommitted
S204: deep debt evolution — safety docs, hardcoded→constants, dep hygiene, mock isolation, lint reason, deny cleanup
Phase 1: Add // SAFETY comments to all 13 unsafe blocks in ffi_loader.rs Phase 2: Replace hardcoded toadstool-main/toadstool-primary with INSTANCE_ID/PRIMAL_NAME constants; mDNS duplicate → TOADSTOOL_SERVICE_TYPE Phase 3: Unify serde_yaml_ng to workspace=true (5 crates); remove unused humantime-serde from CLI; align rustix 1.0→1.1 in secure_enclave; fix stale WASM/zstd comment Phase 4: Gate InMemoryAgentBackend + AgentBackendDispatch::InMemory + with_inmemory behind #[cfg(any(test, feature = "test-mocks"))] Phase 5: Convert bare #[allow] to #[allow(reason)] in 9 crate lib.rs + 1 struct Phase 6: Remove stale BSD-3-Clause-Clear license allow; activate zstd-sys ban; document ring clarify as defensive 7,832 lib tests, 0 failures, clippy clean, fmt clean. Made-with: Cursor
1 parent d2a327b commit 26530b5

30 files changed

Lines changed: 133 additions & 50 deletions

File tree

DEBT.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
# Active Technical Debt Register
22

3-
**Date**: April 2026 — S177
3+
**Date**: April 2026 — S204
44
**Philosophy**: Math is universal, precision is silicon. Workarounds are
55
short-term solutions that increase debt. We aim to solve deep debt over
66
iterations, evolving toward vendor-agnostic, capability-based solutions—
77
with production stubs surfacing typed configuration errors and capability
88
guidance, and auth policy driven by explicit environment configuration
99
where applicable.
1010

11+
**S204 (Deep Debt Evolution)**: Resolved **D-SAFETY-DOCS** (13 `// SAFETY`
12+
comments added to `ffi_loader.rs` — last file without them), **D-HARDCODED-IDS**
13+
(`toadstool-main`/`toadstool-primary``INSTANCE_ID`/`PRIMAL_NAME` constants;
14+
mDNS duplicate `"_toadstool._tcp.local."``TOADSTOOL_SERVICE_TYPE`),
15+
**D-DEP-HYGIENE** (`serde_yaml_ng` unified to `workspace = true` in 5 crates;
16+
unused `humantime-serde` removed from CLI; `rustix` aligned 1.0→1.1 in
17+
secure\_enclave; stale WASM/zstd comment corrected), **D-MOCK-ISOLATION**
18+
(`InMemoryAgentBackend` + `AgentBackendDispatch::InMemory` +
19+
`AgentDeploymentManager::with_inmemory` gated behind `#[cfg(any(test,
20+
feature = "test-mocks"))]`), **D-LINT-EVOLUTION** (bare `#[allow]` blocks
21+
in 9 crate roots + 1 struct → `#[allow(..., reason = "...")]`),
22+
**D-DENY-CLEANUP** (stale `BSD-3-Clause-Clear` license removed; `zstd-sys`
23+
ban uncommented/active; `ring` clarify documented as defensive).
24+
7,832 lib tests, 0 failures, clippy and fmt clean.
25+
1126
**S177 (Deep Debt Evolution)**: Resolved **D-PROD-STUBS** (StubRuntimeEngine
1227
`ToadStoolError::configuration` with capability guidance; `NoopCryptoProvider`
1328
unchanged), **D-AUTH-OVERSTEP** (JWT issuer from `TOADSTOOL_AUTH_ISSUER` with

DOCUMENTATION.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ToadStool Documentation Hub
22

3-
**Last Updated**: April 2026 — S177
3+
**Last Updated**: April 2026 — S204
44

55
---
66

@@ -30,11 +30,11 @@ These root documents were **fully resolved** and **fossilized** in wateringHole
3030

3131
---
3232

33-
## Current State (S177 — April 2026)
33+
## Current State (S204 — April 2026)
3434

3535
**Post-budding, dependency-sovereign, IPC-first, fully concurrent, capability-based.** barraCuda is a separate primal at `ecoPrimals/barraCuda/`. ToadStool is the hardware infrastructure layer — GPU/NPU/CPU discovery, capability probing, workload orchestration, and shader dispatch.
3636

37-
- **20,000+ tests** (7,789 lib-only S177), 0 failures, 0 clippy warnings, 0 fmt diffs. Full workspace concurrent test suite.
37+
- **20,000+ tests** (7,832 lib-only S204), 0 failures, 0 clippy warnings, 0 fmt diffs. Full workspace concurrent test suite.
3838
- **65 JSON-RPC methods** (incl. `compute.execute` direct route S203f). Wire Standard L3 (partial): `cost_estimates`, `operation_dependencies`. IPC compliant (`health.liveness``{"status":"alive"}`, `health.readiness` → ready+version, `health.check` full envelope, `capabilities.list`, `identity.get`).
3939
- **Dual-socket IPC**`compute.sock` (JSON-RPC primary, biomeOS routes here) + `compute-tarpc.sock` (tarpc hot-path). Override: `TOADSTOOL_SOCKET` / `TOADSTOOL_TARPC_SOCKET`. Family: `compute-{fid}.sock` / `compute-{fid}-tarpc.sock`.
4040
- **Pipeline dispatch**`compute.dispatch.pipeline.submit` + `.status` for ordered multi-stage workloads (DAG, topological sort, result forwarding). Resolves neuralSpring PG-05.
@@ -44,7 +44,7 @@ These root documents were **fully resolved** and **fossilized** in wateringHole
4444
- **BTSP Phase 2 + JSON-line relay (S176)** — Handshake enforced on every UDS accept path; auto-detects plain-text clients (primalSpring) and degrades gracefully. JSON-line BTSP auto-detection on `0x7B` path routes `"protocol":"btsp"` to `relay_json_line_handshake()` (4-step BearDog IPC relay). Family seed loading via `load_family_seed_for_btsp()` (env→file cascade).
4545
- **async-trait DEPRECATED** (S203r) — fully removed and banned in `deny.toml`. All ~91 annotations evolved to manual `Pin<Box<dyn Future>>` (dyn-dispatched) or native AFIT (non-dyn), and subsequently enum dispatch + RPITIT (S203s). Zero runtime behavior change. Transitive only via axum/config/wiggle.
4646
- **`deny.toml` ring ban active** — ecoBin v3 compliant. `ring` absent from lockfile.
47-
- **46 unsafe blocks (all in hw-safe/GPU/VFIO/display containment crates)**; all SAFETY-documented with `debug_assert!` pre-conditions. Workspace `unsafe_code = "deny"`, **41 crates `forbid`** + 5 hw crates with narrow `#[allow]`.
47+
- **49 unsafe blocks (all in hw-safe/GPU/VFIO/display/plugin containment crates)**; all SAFETY-documented (S204: ffi\_loader.rs gap closed). Workspace `unsafe_code = "deny"`, **41 crates `forbid`** + 5 hw crates with narrow `#[allow]`.
4848
- **Edge discovery evolved (S203m)** — USB via `/sys/bus/usb/devices/`, Bluetooth via sysfs adapter enumeration, IPv6 via `/proc/net/if_inet6`. All gracefully degrade on non-Linux.
4949
- **Scheduler queuing (S203m)**`schedule_job``UniversalJobQueue::add_job` inserts into per-priority queues (was metadata-only). `schedule_local_job` logs post-enqueue telemetry.
5050
- **Hardcoding sweep (S203m–p)** — sysfs/procfs paths centralized to `platform_paths`; all `TOADSTOOL_*` env var literals interned to `socket_env` constants (~55 new in S203p). `env_overrides` subsystem fully converted.

NEXT_STEPS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ToadStool -- Next Steps
22

3-
**Updated**: April 2026 — S177 (Deep Debt Evolution)
4-
**Status**: Production-grade | Rust edition **2024** (MSRV 1.85) | **AGPL-3.0-or-later** | **All quality gates green** | **7,789 lib-only** tests verified (20,000+ workspace, 0 failures) | **~65 JSON-RPC methods** | Wire Standard L3 (partial) | Zero C FFI deps (ecoBin v3.0) | Zero production unwraps | IPC-first | workspace `unsafe_code = "deny"`, **41 crates `forbid`** | **46 unsafe blocks** (all in hw containment) | **0 production TODOs** | **rustix 1.x workspace-wide** | **capability-based primal references (no hardcoded names)** | **`async-trait` DEPRECATED** (banned in `deny.toml`) | **`deny.toml` ring + async-trait bans active** | **env centralized via config structs** | **real Linux sandbox (rustix)** | **real resource metrics (cgroup v2/proc)** | **plugin loading (libloading)** | **binary tarpc framing (MessagePack)** | **BTSP JSON-line relay (Phase 45c)**
5-
**Latest**: S177 — Deep Debt Evolution: production stubs → `ToadStoolError::configuration` + capability guidance; JWT issuer`TOADSTOOL_AUTH_ISSUER` (BEARDOG default); workspace `base64` unified; ~20 stale feature flags removed; OpenCL stub files + deprecated discovery variants removed; `deny.toml` tightened. **7,789 lib-only** tests, 0 failures, clippy clean, fmt clean.
3+
**Updated**: April 2026 — S204 (Deep Debt Evolution)
4+
**Status**: Production-grade | Rust edition **2024** (MSRV 1.85) | **AGPL-3.0-or-later** | **All quality gates green** | **7,832 lib-only** tests verified (20,000+ workspace, 0 failures) | **~65 JSON-RPC methods** | Wire Standard L3 (partial) | Zero C FFI deps (ecoBin v3.0) | Zero production unwraps | IPC-first | workspace `unsafe_code = "deny"`, **41 crates `forbid`** | **49 unsafe blocks** (all in hw containment, all SAFETY-documented) | **0 production TODOs** | **rustix 1.x workspace-wide** | **capability-based primal references (no hardcoded names)** | **`async-trait` DEPRECATED** (banned in `deny.toml`) | **`deny.toml` ring + async-trait + zstd-sys bans active** | **env centralized via config structs** | **real Linux sandbox (rustix)** | **real resource metrics (cgroup v2/proc)** | **plugin loading (libloading)** | **binary tarpc framing (MessagePack)** | **BTSP JSON-line relay (Phase 45c)** | **Display Phase 2 (petalTongue IPC)**
5+
**Latest**: S204 — Deep Debt Evolution: ffi\_loader.rs SAFETY docs (13 blocks); hardcoded IDsconstants (`INSTANCE_ID`, `PRIMAL_NAME`, `TOADSTOOL_SERVICE_TYPE`); `serde_yaml_ng` workspace unified (5 crates); unused `humantime-serde` removed; `rustix` aligned; `InMemoryAgentBackend` gated to test-only; bare `#[allow]``#[allow(reason)]` in 10 sites; `deny.toml` stale entries cleaned. **7,832 lib-only** tests, 0 failures, clippy clean, fmt clean.
66

77
---
88

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Nest = Tower + Storage <- storage
4242
| `cargo fmt --all -- --check` | 0 diffs |
4343
| `cargo clippy --workspace --all-targets -- -D warnings` | 0 warnings |
4444
| `cargo doc --workspace --no-deps` (RUSTDOCFLAGS="-D warnings") | 0 warnings |
45-
| `cargo test --workspace` | **20,000+ tests, 0 failures** (7,789 lib-only verified S177), **~93** ignored (hardware-gated); full workspace ~3m30s |
45+
| `cargo test --workspace` | **20,000+ tests, 0 failures** (7,832 lib-only verified S204), **~93** ignored (hardware-gated); full workspace ~3m30s |
4646
| Doctests | All passing (common, core, server, cli, testing, display) |
4747
| Standalone clone test | Pull to any machine, `cargo test` works (GPU-optional, CPU fallback, device-lost resilient) |
4848
| `unsafe` blocks | **46 actual** (all in hw-safe/GPU/VFIO/display containment crates); SAFETY-documented with `debug_assert!` pre-conditions; workspace `unsafe_code = "deny"`, **41 crates `forbid`** + 5 hw crates with narrow `#[allow(unsafe_code, reason)]` |
@@ -247,7 +247,7 @@ toadStool/
247247
| Clippy pedantic warnings | 0 (workspace-wide `clippy::pedantic` clean; `#[expect]` evolution S131+) |
248248
| Doc warnings | 0 |
249249
| Build warnings | 0 |
250-
| Workspace tests | **20,000+**, 0 failures (7,789 lib-only S177) |
250+
| Workspace tests | **20,000+**, 0 failures (7,832 lib-only S204) |
251251
| Lib-only line coverage | ~83.6% |
252252
| Full workspace test time | ~3m30s (unlimited parallelism, `cfg!(test)` fast timeouts; GPU crates have NVK resilience wrappers) |
253253
| `unsafe` blocks | **46 actual** (all in hw-safe/GPU/VFIO/display containment crates); SAFETY-documented with `debug_assert!` pre-conditions; workspace `unsafe_code = "deny"`, **41 crates `forbid`** + 5 hw crates with narrow `#[allow(unsafe_code, reason)]` |
@@ -381,7 +381,7 @@ See [DEBT.md](DEBT.md) for full register and evolution paths.
381381

382382
---
383383

384-
**Last Updated**: April 2026 — S177 (Deep Debt Evolution). **20,000+** workspace tests, 0 failures (7,789 lib-only). ~83.6% lib-only line coverage (target 90%). **65 JSON-RPC methods** (direct) + semantic registry with **Wire Standard L3** (cost_estimates + operation_dependencies). AGPL-3.0-or-later. Zero C FFI deps (ecoBin v3.0). **46 unsafe blocks** (all in hw-safe/GPU/VFIO/display containment crates); SAFETY-documented with `debug_assert!`; workspace `unsafe_code = "deny"`, **41 crates `forbid`** + 5 hw crates with narrow `#[allow(unsafe_code, reason)]`. IPC-first JSON-RPC (dual-socket: `compute.sock` + `compute-tarpc.sock`). Rust 1.85+ (edition 2024, MSRV). **async-trait DEPRECATED** — fully removed, banned in `deny.toml`. **env_overrides fully interned** (socket_env). Real monitoring (sysmon + statvfs). **BTSP Phase 2 + JSON-line relay** (primalSpring Phase 45c). **Capability-based discovery compliant** per `CAPABILITY_BASED_DISCOVERY_STANDARD.md` v1.2.
384+
**Last Updated**: April 2026 — S204 (Deep Debt Evolution). **20,000+** workspace tests, 0 failures (7,832 lib-only). ~83.6% lib-only line coverage (target 90%). **65 JSON-RPC methods** (direct) + semantic registry with **Wire Standard L3** (cost_estimates + operation_dependencies). AGPL-3.0-or-later. Zero C FFI deps (ecoBin v3.0). **49 unsafe blocks** (all in hw-safe/GPU/VFIO/display/plugin containment crates); all SAFETY-documented (S204: ffi\_loader.rs gap closed); workspace `unsafe_code = "deny"`, **41 crates `forbid`** + 5 hw crates with narrow `#[allow(unsafe_code, reason)]`. IPC-first JSON-RPC (dual-socket: `compute.sock` + `compute-tarpc.sock`). Rust 1.85+ (edition 2024, MSRV). **async-trait DEPRECATED** — fully removed, banned in `deny.toml`. **env_overrides fully interned** (socket_env). Real monitoring (sysmon + statvfs). **BTSP Phase 2 + JSON-line relay** (primalSpring Phase 45c). **Display Phase 2** (petalTongue IPC: `display.present`, `display.subscribe_input`, `display.poll_events`). **Capability-based discovery compliant** per `CAPABILITY_BASED_DISCOVERY_STANDARD.md` v1.2.
385385

386386
---
387387

crates/cli/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@ toadstool-display = { path = "../runtime/display" }
4141
toadstool-config = { path = "../core/config" }
4242
toadstool-distributed = { path = "../distributed" }
4343
toadstool-server = { path = "../server" } # UniBin Phase 2: Server library integration (library compiles!)
44-
humantime-serde = "1.1"
45-
4644
# Runtime engines
4745
toadstool-runtime-container = { path = "../runtime/container" }
4846
toadstool-runtime-native = { path = "../runtime/native" }
4947
# EVOLVED: toadstool-runtime-python removed — pyo3 FFI violates ecoBin v3.0
50-
toadstool-runtime-wasm = { path = "../runtime/wasm", optional = true } # Optional: has zstd C dependency
48+
toadstool-runtime-wasm = { path = "../runtime/wasm", optional = true } # Optional: pure Rust (wasmi)
5149
wasmi = { version = "1.0", features = ["std"], optional = true } # For WASM execution when wasm feature enabled
5250
toadstool-runtime-gpu = { path = "../runtime/gpu", optional = true }
5351

@@ -68,7 +66,7 @@ tracing-subscriber = { workspace = true }
6866
# Serialization (rc for Arc<str> zero-copy in metadata)
6967
serde = { workspace = true, features = ["rc"] }
7068
serde_json = { workspace = true }
71-
serde_yaml_ng = "0.10"
69+
serde_yaml_ng = { workspace = true }
7270
toml = { workspace = true }
7371
bytes = { workspace = true }
7472

crates/client/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// SPDX-License-Identifier: AGPL-3.0-or-later
22
#![forbid(unsafe_code)]
33
#![warn(missing_docs)]
4-
#![allow(clippy::missing_errors_doc)]
4+
#![allow(
5+
clippy::missing_errors_doc,
6+
reason = "client API: error docs covered in module-level docs"
7+
)]
58

69
//! # ToadStool Client Library
710
//!

crates/core/common/src/constants/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ pub use network::{
2525
DEFAULT_HOSTNAME, HTTP_PROTOCOL, HTTPS_PROTOCOL, LOCALHOST_IPV4, LOCALHOST_IPV6,
2626
UNIX_SOCKET_URL_PREFIX, UNIX_SOCKET_URL_SCHEME,
2727
};
28-
pub use primal_identity::{CAPABILITY_DOMAIN, PRIMAL_NAME};
28+
pub use primal_identity::{CAPABILITY_DOMAIN, INSTANCE_ID, PRIMAL_NAME};

crates/core/common/src/constants/primal_identity.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
/// should reference this constant.
3838
pub const PRIMAL_NAME: &str = "toadstool";
3939

40+
/// Default instance identifier for this primal's primary/singleton instance.
41+
///
42+
/// Used in `UniversalPrimalProvider::instance_id()` and display capability
43+
/// advertisements. Must start with `PRIMAL_NAME`.
44+
pub const INSTANCE_ID: &str = "toadstool-main";
45+
4046
/// Primary capability domain per `PRIMAL_SELF_KNOWLEDGE_STANDARD.md` v1.1.
4147
///
4248
/// Socket files use the domain stem, not the primal name:
@@ -132,6 +138,11 @@ mod tests {
132138
assert!(capability::STORAGE_PROVIDER.contains('.'));
133139
}
134140

141+
#[test]
142+
fn instance_id_starts_with_primal_name() {
143+
assert!(INSTANCE_ID.starts_with(PRIMAL_NAME));
144+
}
145+
135146
#[test]
136147
fn audience_self_matches_identity() {
137148
assert_eq!(audience::SELF_AUDIENCE, PRIMAL_NAME);

crates/core/common/src/universal_adapter/discovery_engine/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,14 @@ impl DiscoverySource for MDnsSource {
218218
}
219219
};
220220

221-
let service_type = "_toadstool._tcp.local.";
222-
let receiver = match mdns.browse(service_type) {
221+
let receiver = match mdns.browse(crate::primal_discovery_mdns::TOADSTOOL_SERVICE_TYPE) {
223222
Ok(rx) => rx,
224223
Err(e) => {
225-
tracing::debug!("mDNS browse failed for {}: {}", service_type, e);
224+
tracing::debug!(
225+
"mDNS browse failed for {}: {}",
226+
crate::primal_discovery_mdns::TOADSTOOL_SERVICE_TYPE,
227+
e
228+
);
226229
let _ = mdns.shutdown();
227230
return Ok(vec![]);
228231
}
@@ -263,7 +266,7 @@ impl DiscoverySource for MDnsSource {
263266
}
264267
}
265268

266-
let _ = mdns.stop_browse(service_type);
269+
let _ = mdns.stop_browse(crate::primal_discovery_mdns::TOADSTOOL_SERVICE_TYPE);
267270
let _ = mdns.shutdown();
268271

269272
tracing::debug!("mDNS discovery found {} providers", providers.len());

0 commit comments

Comments
 (0)