Skip to content

refactor(epic-1977): tighten abstraction boundaries — agent accessors, OpenAI fix, builder warnings#2017

Merged
bug-ops merged 2 commits intomainfrom
abs-level-improvements
Mar 19, 2026
Merged

refactor(epic-1977): tighten abstraction boundaries — agent accessors, OpenAI fix, builder warnings#2017
bug-ops merged 2 commits intomainfrom
abs-level-improvements

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 19, 2026

Summary

Epic #1977: Abstraction Level Improvements — Phase 1. Tighten abstraction boundaries, reduce public API surface, and improve encapsulation.

Changes

ABS-04: Created Agent state-group accessor methods (msg(), memory_state(), runtime(), session_config(), metrics() + mutable variants). Enables encapsulation without breaking existing code. Incremental migration of 835 field accesses across 24 files (Phase 1 covers 340 high-traffic accesses in 4 files).

ABS-05 (bug fix): Fixed OpenAI convert_messages_structured() silently dropping internal MessagePart variants (Recall, CodeContext, Summary, CrossSession). Now correctly converts to plain text using existing as_plain_text() method. Added regression test validating all internal variants are preserved. LLM serialization gate: 2 live OpenAI sessions, no 400/422 errors.

ABS-07: Added builder validation — tracing::warn! when context_budget() == 0, debug_assert! for max_active_skills > 0.

Testing

  • ✅ 5933/5933 tests pass (--features full, all validators)
  • ✅ New regression test: convert_messages_structured_preserves_internal_variants
  • ✅ LLM serialization gate: live Claude + OpenAI sessions both pass
  • cargo +nightly fmt --check — PASS
  • cargo clippy --workspace --features full -- -D warnings — PASS

Deferred to Phase 2+

  • ABS-01: AgentSessionConfig pub→pub(crate) + accessors
  • ABS-02/03: Low-ROI re-export cleanup
  • ABS-08: LLM provider builder patterns
  • ABS-09: Other(String) enum replacements
  • Full field-access migration (800+ remaining accesses)

Related

Closes epic #1977 (Phase 1 only)


Validation team handoffs:

  • Architect (revised v2): Design addressing all critic feedback (CRIT-01/02/03)
  • Critic: All critical issues resolved, approved design
  • Developer: Phase 1 implementation complete, local checks pass
  • Tester: 5933 tests pass, LLM gate passed, no regressions
  • Security: GO verdict, no state leaks, as_plain_text() correctly sanitizes
  • Impl-Critic: GO with conditions (doc comment fixed, PR documented)
  • Reviewer: GO verdict, all gates pass, CHANGELOG updated

…x, builder warnings

ABS-04: Add state-group accessor methods to Agent<C> (accessors.rs) for all sub-structs.
Accessors are pub(super), named identically to fields, enabling incremental migration
without breaking existing direct field access. Migration pattern: self.msg.x -> self.msg().x.

ABS-05: Fix convert_messages_structured() in OpenAI provider to preserve Recall,
CodeContext, Summary, CrossSession variants in tool-use messages. Previously, the
MessagePart::Text-only filter on assistant messages and the wildcard `_ => {}` on
user messages silently dropped these internal variants. Both arms now use as_plain_text()
which handles all text-like variants uniformly. Add regression test.

ABS-07: Add tracing::warn in with_context_budget() when budget_tokens == 0.
Add debug_assert in Agent::new_with_registry_arc() for max_active_skills > 0.
@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/L Large PR (201-500 lines) labels Mar 19, 2026
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/L Large PR (201-500 lines)

Projects

None yet

1 participant