refactor: structural code organization — EPIC-01 through 06#1966
Merged
refactor: structural code organization — EPIC-01 through 06#1966
Conversation
…lities - Add new zeph-common crate (Layer 0, no zeph-* deps) with: - text: truncate_to_bytes, truncate_to_bytes_ref, truncate_chars, truncate_to_chars - net: is_private_ip (canonical SSRF defense, covers IPv4/IPv6/CGNAT/BiDi) - sanitize: strip_control_chars, strip_null_bytes - Consolidate 3 truncate_to_bytes duplicates (zeph-mcp, zeph-memory x2) into zeph-common - Consolidate 2 is_private_ip duplicates (zeph-tools, zeph-a2a) into zeph-common - zeph-tools/src/net.rs re-exports from zeph-common - zeph-a2a/src/client.rs uses zeph-common directly - Remove same-layer violation: zeph-tools no longer depends on zeph-index (#1963) - Inline language detection and grammar/query setup in search_code.rs using tree-sitter directly - Add zeph-common to workspace Cargo.toml - All 6161 tests pass; clippy clean with --features full Closes #1962, #1963
…2, 03, 05, 06)
EPIC-02 - Agent Struct Decomposition:
- Extract InstructionState, ExperimentState, CompressionState, MessageState,
SessionState sub-structs from Agent<C>
- Move all sub-struct definitions to agent/state/mod.rs
- Update all field accesses across 20+ files (msg.messages, session.env_context, etc.)
EPIC-03 - Agent Module File Splits:
- tool_execution/mod.rs: 4,502 → 622 lines; tests → tool_execution/tests.rs
- context/mod.rs: 4,320 → 94 lines; tests → context/tests.rs
EPIC-04 - LLM Provider Consolidation (already included in branch):
- claude.rs, openai.rs, gemini.rs split into mod/request/response/tests/cache
EPIC-05 - Memory Module Cleanup:
- graph/store.rs (3,886 lines) → graph/store/{mod,tests}.rs
- graph/resolver.rs (2,021 lines) → graph/resolver/{mod,tests}.rs
- sqlite/messages.rs (1,559 lines) → sqlite/messages/{mod,tests}.rs
EPIC-06 - Tool Module Improvements:
- filter/declarative.rs (2,852 lines) → filter/declarative/{mod,tests,default-filters.toml}
- shell.rs (2,459 lines) → shell/{mod,tests}.rs
- Update snapshot source paths for insta tests
All 6161 tests pass. No behavioral changes.
Bundle check CI jobs (chat/ide/server) compile without context-compression feature, causing dead_code error on the compression field. Gate the struct definition, field declaration, initialization, and import with #[cfg(feature = "context-compression")] to match the original per-field gating pattern.
This was referenced Mar 18, 2026
bug-ops
added a commit
that referenced
this pull request
Mar 18, 2026
…E, group Agent fields, add state tests (#1972) * docs(zeph-common): add README.md — closes #1969 * refactor(zeph-core): consolidate text module into zeph-common — closes #1967 Add zeph-common as zeph-core dependency, delete duplicate text.rs, re-export via pub use zeph_common::text so existing crate::text:: paths remain valid. * refactor(zeph-common): extract shared tree-sitter queries behind 'treesitter' feature — closes #1968 Add zeph-common::treesitter module with 5 shared symbol query constants (RUST/PYTHON/JS/TS/GO_SYM_Q), compile_query helper, and lang_for_ext. Feature-gated behind 'treesitter'. zeph-tools and zeph-index now import from zeph-common::treesitter instead of maintaining their own copies. Lang enum and method queries remain in zeph-index. * refactor(zeph-core): group loose Agent fields into FeedbackState, move rate_limiter into RuntimeConfig — closes #1971 Add FeedbackState { detector, judge } grouping feedback_detector and judge_detector. Move rate_limiter into RuntimeConfig alongside other runtime policy fields. Update all ~30 call sites across mod.rs, builder.rs, and tool_execution/native.rs. * test(zeph-core): add unit tests for agent state sub-structs — closes #1970 Add agent/state/tests.rs with construction and field access tests for InstructionState, ExperimentState, MessageState, SessionState, RuntimeConfig (including rate_limiter), FeedbackState, and CompressionState (#[cfg(feature = "context-compression")]). ExperimentState has cfg-gated field tests behind #[cfg(feature = "experiments")]. Tests pass both without extra features (1940 tests) and with experiments,context-compression (2098 tests). * style: fix nightly fmt and clippy must_use on treesitter::compile_query * chore: update CHANGELOG for batch #1967-#1971
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zeph-commoncrate (Layer 0) consolidates shared utilities:truncate_to_bytes,is_private_ip,strip_control_chars. Eliminates 3 independent copies of truncation and 2 copies of SSRF-check logic.Agent<C>struct decomposition — extracts 5 new named sub-structs (InstructionState,ExperimentState,CompressionState,MessageState,SessionState). All sub-struct definitions moved toagent/state/mod.rs.tool_execution/mod.rs(4,502 → 622 lines) andcontext/mod.rs(4,320 → 94 lines); tests extracted to siblingtests.rsfiles.claude.rs,openai.rs,gemini.rssplit into{mod,request,response,tests,cache}.rs;SchemaVisitortrait for OpenAI/Gemini normalization extracted toschema.rs.graph/store.rs(3,886),graph/resolver.rs(2,021),sqlite/messages.rs(1,559) each split intomod.rs+tests.rs.filter/declarative.rs(2,852) andshell.rs(2,459) each split intomod.rs+tests.rs.Closes #1741
Closes #1962
Closes #1963
Closes #1964
Closes #1965
Test plan
cargo +nightly fmt --checkpassescargo clippy --workspace --features full -- -D warningspassescargo nextest run --workspace --features full --lib --bins— 6161 tests passFollow-up issues