Commit 50fbc08
committed
protocol: reorganize brain-protocol by business domain, drop requests/responses split
The wire-direction folder split (requests/ + responses/) was a leaky
taxonomy — working on a feature meant jumping between two mirror files,
and the audit found that requests/entity.rs reached backward into
responses/entity.rs while EvidenceRefWire lived under statement on the
request side but was imported by relation on both sides.
The crate is now organized by capability. Each business domain owns one
file with its request, response, and view types side by side. Wire
plumbing, the dispatch enum, error taxonomy, connection-lifecycle ops,
and cross-cutting shared types each live in their own focused module.
Final layout (36 files down from 49):
crates/brain-protocol/src/
├── lib.rs crate root + flat re-exports
├── error.rs ErrorCategory / ErrorCode / ProtocolError
├── codec/ bytes-on-the-wire plumbing
│ ├── header.rs 32-byte frame header
│ ├── frame.rs Frame envelope (encode/decode)
│ ├── crc.rs CRC32C helpers
│ ├── rkyv.rs rkyv pipeline (was rkyv_codec.rs)
│ └── opcode.rs Opcode enum + namespace helpers
├── envelope/ dispatch + ERROR frame + conversions
│ ├── request.rs RequestBody + WireUuid/MemoryId/ContextId
│ ├── response.rs ResponseBody
│ ├── error.rs ErrorResponse + ErrorDetails (was responses/error.rs)
│ └── convert.rs MemoryKind/EdgeKind ↔ wire bridges
├── connection/ connection-lifecycle ops
│ ├── handshake.rs HELLO/WELCOME/AUTH/AUTH_OK + negotiate
│ └── stream.rs CANCEL_STREAM / PING / PONG / SERVER_PING / BYE
├── shared/ cross-cutting wire types
│ ├── primitives.rs MemoryKindWire, EdgeKindWire, PlanStrategy, PlanState, ForgetMode (was requests/types.rs)
│ └── enums.rs EventType, StageKind, RetrieverNameWire, ErrorCodeWire, etc. (was responses/types.rs)
├── schema/ schema DSL parser + wire ops in one module
│ ├── ast.rs, parser.rs, validator.rs, parse_error.rs (unchanged)
│ └── ops.rs SCHEMA_UPLOAD/GET/LIST/VALIDATE req+resp
└── ops/ per-domain wire ops
├── memory.rs ENCODE/RECALL/PLAN/REASON/FORGET/LINK/UNLINK/ENCODE_VECTOR_DIRECT
├── procedural.rs MATERIALIZE_PROCEDURAL
├── subscribe.rs SUBSCRIBE/UNSUBSCRIBE + SubscriptionEvent + KnowledgeEventPayload
├── txn.rs TXN_BEGIN/COMMIT/ABORT
├── admin.rs substrate admin ops
├── entity.rs typed-graph entity ops + EntityView
├── statement.rs typed-graph statement ops + StatementView + EvidenceRefWire family
├── relation.rs typed-graph relation ops + RelationView + TraversalPathWire
├── query.rs hybrid query ops + TimeRangeWire/RetrieverWire/FusionConfigWire
└── extractor.rs EXTRACTOR_LIST/DISABLE/ENABLE
Moves preserved git history via `git mv` (21 renames in this commit's
status). The requests/ + responses/ directories are gone.
Public API surface: every name reachable as `brain_protocol::X` before
is reachable as `brain_protocol::X` now. lib.rs uses `pub use crate::
ops::<module>::*;` plus targeted re-exports for codec/envelope/
connection/shared/schema items.
Downstream caller updates (per-crate count of edited import lines):
- brain-ops, brain-server, brain-workers, brain-metadata, brain-extractors,
brain-planner (glommio-dependent; not buildable on macOS but source
updated and the rewrite passes ran)
- brain-sdk-rust, brain-shell, brain-explore, brain-cli, brain-llm,
brain-http, brain-embed, brain-core, brain-protocol (all pass
`cargo check` on macOS)
Cross-ref sweeps applied:
- `brain_protocol::requests::X::Y` → flat `brain_protocol::Y`
- `brain_protocol::responses::X::Y` → flat `brain_protocol::Y`
- `brain_protocol::responses::types::EventType` → `brain_protocol::EventType` (and similar for RetrieverNameWire, ErrorCodeWire, InferenceKind, TransitionKind, StageKind)
- `brain_protocol::requests::statement::EvidenceRefWire` → `brain_protocol::EvidenceRefWire`
- `brain_protocol::responses::error::ErrorResponse` → `brain_protocol::ErrorResponse`
- Internal `use crate::header::` / `frame::` / `crc::` / etc. → `use crate::codec::`
- `use crate::handshake::` → `use crate::connection::handshake::`
- `use crate::request::`/`response::` → `use crate::envelope::*::`
- `use crate::requests::*` / `use crate::responses::*` → `use crate::ops::*::`
Test + clippy results:
- cargo test -p brain-protocol --lib → 205 passed (no change)
- cargo test -p brain-protocol --test '*' → 37 passed (no change)
- cargo clippy -p brain-protocol -- -D warnings → clean
- Per-crate macOS-buildable check: clean
Three deviations from the plan, all benign:
- envelope/{request,response}.rs use bulk `pub use crate::ops::<mod>::*`
instead of the plan's enumerated lists. Equivalent surface, less churn.
- Three merged files (procedural, query, statement) had a test module
in both halves. Renamed to `tests_req` + `tests_resp` so both run.
- Downstream callers used singular `brain_protocol::request::` /
`::response::` / `::header::` / `::handshake::` / `::opcode::` paths
in addition to the deep nested ones. Added these to the sweep map
so callers stay compiling.
Zero hits on `brain_protocol::(requests|responses)::` across the
workspace. The reorg is complete.1 parent 0434935 commit 50fbc08
197 files changed
Lines changed: 2377 additions & 2386 deletions
File tree
- crates
- brain-cli/src/commands/extract
- brain-core/src/nodes
- brain-explore
- src/render
- tests
- brain-ops
- src
- handlers
- state
- writer
- write
- tests
- brain-planner/src
- executor
- planner
- plan
- brain-protocol
- src
- codec
- connection
- envelope
- ops
- requests
- responses
- schema
- tests
- brain-sdk-rust
- examples
- src
- client
- config
- ops
- pool
- proto
- tests
- common
- brain-server
- src
- admin/handlers
- metrics
- network
- shard
- tests
- support_harness
- brain-shell
- src
- commands
- parser
- tests
- brain-workers
- src/workers
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
640 | | - | |
| 640 | + | |
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
| |||
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
656 | | - | |
657 | | - | |
658 | | - | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
| 723 | + | |
724 | 724 | | |
725 | | - | |
726 | | - | |
727 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| |||
735 | 735 | | |
736 | 736 | | |
737 | 737 | | |
738 | | - | |
| 738 | + | |
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
| |||
1376 | 1376 | | |
1377 | 1377 | | |
1378 | 1378 | | |
1379 | | - | |
| 1379 | + | |
1380 | 1380 | | |
1381 | 1381 | | |
1382 | 1382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
212 | | - | |
| 211 | + | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
0 commit comments