Skip to content

refactor(core): Phase 1 mechanical cleanup — unify alloc imports, logging shim, delete dead API, drop vestigial tokio dep #132

@lxsaah

Description

@lxsaah

Context

The remaining mechanical items from Phase 1 of docs/design/034-technical-debt-review.md (§3.1.2, §3.1.3, §3.8, §3.10). Sibling of #129 (DbError unification). Every item is independent, low-risk, and zero-behavior-change — they can be picked individually and reviewed as separate PRs against this issue.

Breaking changes are acceptable (dead-API deletion is wanted, not deprecated).

Tasks

1. Unify std/alloc imports (~25 sites in aimdb-core)

#[cfg(not(feature = "std"))]
use alloc::{boxed::Box, sync::Arc};
#[cfg(feature = "std")]
use std::{boxed::Box, sync::Arc};

std::sync::Arc is a re-export of alloc::sync::Arc — one unconditional use alloc::... works on every target (the crate has an unconditional extern crate alloc). Replace all dual-import headers. (The fully duplicated RuntimeContext impl blocks in context.rs are handled by #131; skip that file if #131 lands first.)

2. Internal logging macros instead of 62 per-call-site cfg gates

Add crate-private log_debug!/log_info!/log_warn!/log_error! macros that forward to tracing when the feature is on and expand to nothing otherwise; delete every #[cfg(feature = "tracing")] attribute that exists only to guard a single log statement.

3. Delete dead API surface

  • Database<A> (aimdb-core/src/database.rs, 140 lines) — thin wrapper over AimDb, referenced only by…
  • TokioDatabase / EmbassyDatabase type aliases — used nowhere in the workspace.
  • .link() on RecordRegistrar — deprecated since 0.2.0, workspace is at 1.1.0.

4. Drop the vestigial tokio dependency from aimdb-core

[dependencies] tokio (with net, io-util, sync, time) is enabled by the std feature, but since the session-engine refactor the only tokio:: references in aimdb-core/src are inside #[cfg(test)] modules — covered by the existing dev-dependency. Remove it from [dependencies] and from the std feature list.

5. Struct-ify OutboundRoute

builder.rs defines it as a 5-tuple type alias; every connector destructures it positionally. Make it a struct with named fields (topic, consumer, serializer, config, topic_provider) and update the connectors.

6. Small opportunistic fixes

Acceptance criteria

  • grep -rn "use std::{" aimdb-core/src and dual-import pairs return nothing (std-only modules like error.rs io imports excepted)
  • grep -rn 'cfg(feature = "tracing")' aimdb-core/src only hits the macro definition site
  • Database, TokioDatabase, EmbassyDatabase, .link() gone; changelog notes the removals
  • cargo tree -p aimdb-core shows no tokio outside dev-dependencies
  • No behavior change: make check and make examples pass

See docs/design/034-technical-debt-review.md Phase 1 for context. Related: #129, #130, #131.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions