You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every SeaORM entity file in the workspace contains two identical structural boilerplate blocks: an impl Related<T> for Entity that always calls Relation::X.def(), and an empty impl ActiveModelBehavior for ActiveModel {}. Across 13 entity files these are copy-pasted verbatim with only the type names changing. A pair of macro_rules! helpers in agentd-common would collapse each into a single expressive line.
Current State
All 13 entity files follow this closing pattern (example from crates/communicate/src/entity/message.rs:53-59 and crates/orchestrator/src/entity/dispatch.rs:32-39):
Entities with multiple relations (belongs-to + has-many) may need multiple sea_orm_related! calls — that is fine.
The impl ActiveModelBehavior for ActiveModel {} is always empty in this codebase; if a future entity needs custom behavior, the macro call is simply replaced with a manual impl.
Overview
Every SeaORM entity file in the workspace contains two identical structural boilerplate blocks: an
impl Related<T> for Entitythat always callsRelation::X.def(), and an emptyimpl ActiveModelBehavior for ActiveModel {}. Across 13 entity files these are copy-pasted verbatim with only the type names changing. A pair ofmacro_rules!helpers inagentd-commonwould collapse each into a single expressive line.Current State
All 13 entity files follow this closing pattern (example from
crates/communicate/src/entity/message.rs:53-59andcrates/orchestrator/src/entity/dispatch.rs:32-39):All 13 entity files across
communicate,orchestrator,notify, andmemoryrepeat this exact structure.Desired State
Two
macro_rules!macros exported fromagentd-common::sea_orm_helpers(behind asea-ormfeature flag) reduce each entity file's tail to:Macro definitions in
crates/common/src/macros.rs:Affected Files
crates/common/src/macros.rs— new file with the twomacro_rules!definitionscrates/common/src/lib.rs— addpub mod macros;(or inline with#[macro_export])crates/common/Cargo.toml— add optionalsea-ormdependency gated on asea-ormfeature flagcommunicate,orchestrator,notify,memory— replace boilerplate with macro callsEntity files:
crates/communicate/src/entity/message.rscrates/communicate/src/entity/room.rscrates/communicate/src/entity/participant.rscrates/orchestrator/src/entity/dispatch.rscrates/orchestrator/src/entity/workflow.rscrates/notify/src/entity/notification.rscrates/memory/src/entity/memory_entry.rsAcceptance Criteria
sea_orm_related!andsea_orm_active_model_behavior!macros defined and#[macro_export]-ed fromagentd-commonsea-ormCargo feature inagentd-commonto avoid pullingsea-orminto crates that do not use itcargo buildsucceeds for all affected cratescargo testpasses with no regressionscargo clippyproduces no new warningsNotes
macro_rules!(declarative macros), not proc-macros — no new crate needed.crates/macrosproc-macro crate is created as part of refactor(macros): create agentd-macros proc-macro crate with ApiIntoResponse derive #768, consider whether these declarative macros belong there or remain inagentd-common. Declarative macros are simpler and have no compile overhead, soagentd-commonis the better home.sea_orm_related!calls — that is fine.impl ActiveModelBehavior for ActiveModel {}is always empty in this codebase; if a future entity needs custom behavior, the macro call is simply replaced with a manual impl.