Skip to content

refactor: code quality improvements across llm, config, scheduler, core#3400

Merged
bug-ops merged 3 commits intomainfrom
refactor/code-quality-audit
Apr 25, 2026
Merged

refactor: code quality improvements across llm, config, scheduler, core#3400
bug-ops merged 3 commits intomainfrom
refactor/code-quality-audit

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 25, 2026

Summary

  • RouterState extraction (zeph-llm): 10 shared Arc-wrapped signals extracted from RouterProvider into RouterState; clone cost remains O(1); all field accesses updated from self.field to self.state.field
  • RouterAware sealed trait (zeph-llm): router-specific methods (set_memory_confidence, record_quality_outcome) moved out of LlmProvider into a sealed RouterAware extension trait; silent no-op branches now emit tracing::trace!; tracing::info! added to chat() hot path for turn-level observability
  • Migration registry (zeph-config): Migration trait + LazyLock<Vec<Box<dyn Migration>>> covering all 35 sequential steps; 150-line manual dispatch chain in src/commands/migrate.rs replaced by registry loop; Migration::name() returns &'static str
  • ScheduledTaskRecord (zeph-scheduler): ScheduledTaskInfo/JobStore derive Debug/Clone; src/runner.rs updated to named struct field access
  • Panic audit (zeph-core): bare unwrap() in plan.rs and session_digest.rs initialization paths replaced with descriptive expect("BUG: invariant")
  • Pre-existing clippy fixes (zeph-config, zeph-tools): unnecessary raw string hashes, empty String construction, format string variable

Test plan

  • cargo nextest run --workspace --features full --lib --bins — 8859 passed, 0 failed (net +10 vs main)
  • cargo +nightly fmt --check — clean
  • cargo clippy on all touched crates — no new warnings
  • Security audit: no new unsafe code, RouterAware sealing verified, no new advisories
  • Performance: RouterState clone remains O(1); no hot-path regressions

- Extract RouterState from RouterProvider: moves 10 shared Arc-wrapped
  signals (providers, turn_counter, embed_semaphore, etc.) into a
  dedicated RouterState struct; clone cost remains O(1)
- Add RouterAware sealed extension trait: router-specific methods
  (set_memory_confidence, record_quality_outcome) moved out of the
  main LlmProvider trait into a sealed trait; silent no-op branches
  now emit tracing::trace! for observability; 4 unit tests added
- Add tracing::info! to chat() hot path in router for turn-level
  observability (replaces zero-duration entered span)
- Extend Migration registry to all 35 steps: previously the
  LazyLock<Vec<Box<dyn Migration>>> covered only steps 26-35; now
  covers steps 1-35 with wrapper structs for each free function;
  dispatch in src/commands/migrate.rs replaced 150-line match chain
  with a registry loop; Migration::name() returns &'static str
- Fix misleading test name: registry_has_ten_entries renamed to
  registry_has_thirty_five_entries
- Fix idempotency test: skip comment-only migrations (magic_docs)
  that cannot be idempotent by design
- ScheduledTaskRecord: add Debug+Clone derives to ScheduledTaskInfo,
  Debug to JobStore; fix runner.rs to use named struct fields
- zeph-core panic audit: replace bare unwrap() with descriptive
  expect() in plan.rs and session_digest.rs initialization paths
- Fix pre-existing clippy warnings: unnecessary raw string hashes in
  security.rs, empty String construction in domain_match.rs, format
  string variable in shell/tests.rs
@github-actions github-actions Bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate refactor Code refactoring without functional changes size/XL Extra large PR (500+ lines) labels Apr 25, 2026
@bug-ops bug-ops enabled auto-merge (squash) April 25, 2026 15:12
@bug-ops bug-ops merged commit 10cc40e into main Apr 25, 2026
32 checks passed
@bug-ops bug-ops deleted the refactor/code-quality-audit branch April 25, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) refactor Code refactoring without functional changes rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant