Skip to content

Commit df45088

Browse files
committed
feat: add architecture refactor plan document outlining goals, layers, and commit strategy
1 parent 35e4786 commit df45088

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

agent-docs/ARCH_REFACTOR_PLAN.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Architecture Refactor Plan (Clean/Hex, Long-term)
2+
3+
Date: 2026-01-25
4+
5+
This document turns the proposed Clean/Hex refactor into a commit-friendly checklist. Each checkbox is intended to become a small, reviewable PR/commit.
6+
7+
## 0) Goals
8+
9+
- Keep dependencies **one-way**: Domain → Core → Adapters → App (composition only)
10+
- Make plugin registration a **single composition point** (bundle crate)
11+
- Remove “app contains adapters” leakage (e.g. `select` net currently lives in the app crate)
12+
- Maintain behavior + keep the project building between steps
13+
14+
## 1) Target Layers and Responsibilities
15+
16+
- **Domain** (`rd-interface`, `rd-derive`): traits/types/errors/config derive; no concrete implementations.
17+
- **Core** (`rabbit-digger`): runtime/use-cases/orchestration; depends only on Domain.
18+
- **Adapters** (`rd-std`, `protocol/*`): concrete implementations (nets/servers); depend on Domain (and optionally minimal shared libs).
19+
- **App** (`rabbit-digger-pro`): CLI/API/config/storage/schema/telemetry; wires Core + Adapters via a bundle.
20+
21+
## 2) Dependency Rules (must-haves)
22+
23+
- [ ] Domain crates (`rd-interface`, `rd-derive`) must not depend on Core, Adapters, or App crates.
24+
- [ ] Core crate (`rabbit-digger`) must not depend on App crates; avoid depending on Adapters long-term.
25+
- [ ] Adapters (`rd-std`, `protocol/*`) must not depend on Core or App crates.
26+
- [ ] App (`rabbit-digger-pro`) may depend on Core and a _bundle_ crate; avoid direct dependencies on individual protocol crates.
27+
28+
## 3) Commit Plan (step-by-step)
29+
30+
### Milestone A — Stop leaking adapters into App (low risk)
31+
32+
- [ ] Move the `select` net implementation from the app crate to adapters (prefer `rd-std`).
33+
- Acceptance: `select` still appears in registry schema; tests compile.
34+
- [ ] Remove `select` registration from the app’s registry wiring.
35+
36+
### Milestone B — Introduce a single composition point (`rdp-bundle`) (medium risk, high payoff)
37+
38+
- [ ] Create a new workspace crate `rdp-bundle`.
39+
- Purpose: build a `rabbit_digger::Registry` by registering optional plugins.
40+
- [ ] Move protocol plugin registration (`ss`, `trojan`, `rpc`, `raw`, `obfs`) into `rdp-bundle` behind features.
41+
- [ ] Make `rabbit-digger-pro` depend on `rdp-bundle` and call `rdp_bundle::build_registry()`.
42+
- Acceptance: app no longer imports protocol crates directly.
43+
- [ ] Re-map existing features in `rabbit-digger-pro` to enable corresponding features in `rdp-bundle`.
44+
- Acceptance: `cargo build --features ss` etc still works.
45+
46+
### Milestone C — Reduce Core ↔ Adapters coupling (optional, later)
47+
48+
- [ ] Audit `rabbit-digger` builtin loading (`Registry::new_with_builtin`) and plan to move builtin implementations into adapters.
49+
- [ ] Introduce a “core-only registry” constructor (no builtin implementations) and let `rdp-bundle` assemble everything.
50+
- Acceptance: core can be built without `rd-std`.
51+
52+
### Milestone D — Optional App split into infra crates (only if needed)
53+
54+
- [ ] Extract `rdp-storage` from `src/storage/*`.
55+
- [ ] Extract `rdp-config` from `src/config*`.
56+
- [ ] Extract `rdp-api` from `src/api_server/*`.
57+
- [ ] Keep root bin crate thin: CLI + composition.
58+
59+
## 4) Guardrails (recommended)
60+
61+
- [ ] Add CI checks for dependency direction (e.g. `cargo tree -i` patterns or `cargo deny`).
62+
- [ ] Add a short “layer rules” section to README.
63+
- [ ] Prefer `pub(crate)` for app-internal modules; keep Domain/Core public APIs minimal.
64+
65+
## 5) Execution Order (what I will do next)
66+
67+
1. Milestone A: move `select` into `rd-std` and fix registration.
68+
2. Milestone B: add `rdp-bundle`, migrate registration there, and update app features.
69+
3. Run `cargo test` to ensure everything still compiles.

0 commit comments

Comments
 (0)