Skip to content

EPIC: Type Safety and Generics Improvements #1974

@bug-ops

Description

@bug-ops

Problem

Multiple opportunities exist to leverage Rust's type system more aggressively:

  • Unnecessary dyn Trait usage where static dispatch suffices
  • Runtime type checks (type_name) duplicated across 3 LLM providers
  • No compile-time enforcement of Agent state boundaries
  • Boolean flag state machines instead of proper enums
  • Duplicated BoxFuture type aliases

Goal

Improve type safety, reduce dynamic dispatch overhead, and make invalid states unrepresentable.

Audit Reference

.local/audit/002-type-safety-opportunities.md

Key Issues

  • TYPE-01: Replace unnecessary dyn Trait with static dispatch (3 locations)
  • TYPE-02: Consolidate BoxFuture type alias (3 definitions)
  • TYPE-03: Extract shared type_name schema helper for LLM providers
  • TYPE-04: Agent state accessor boundaries (long-term)
  • TYPE-05: Type-state pattern for Agent lifecycle (evaluation)
  • TYPE-06: Compaction enum state machine (replace boolean flags)
  • TYPE-07..09: GAT evaluation for VectorStore and ToolExecutor

Acceptance Criteria

  • No unnecessary Box in hot paths
  • Single BoxFuture definition shared across zeph-memory
  • Shared schema_prompt helper in zeph-llm
  • CompactionState enum replaces 4 boolean flags
  • All tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitecture improvementsepicMilestone-level tracking issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions