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
**When to use:** All database reads and writes. Never issue SQLAlchemy queries directly from chain, module, or endpoint code.
113
+
**When to use:** Implementing table-oriented persistence behind an Application-owned
114
+
Protocol. Never issue SQLAlchemy queries or construct Oper objects directly from
115
+
chain, module, endpoint, Agent, scheduler, or workflow code.
114
116
115
117
**Convention:** Each SQLAlchemy model in `app/db/models/` has a corresponding `<Model>Oper` class in `app/db/oper/<model>.py` — the two packages mirror each other file for file, so the module name carries the entity and the package carries the role.
**When to use:** Per-user settings that must survive across sessions but differ by user.
201
227
202
-
**Oper class:**`UserConfigOper` in `app/db/oper/userconfig.py`
228
+
**Host service:**`UserConfigurationService` and
229
+
`get_configured_user_configuration()` in
230
+
`app/application/security/userconfig.py`.
203
231
204
-
Usage mirrors `SystemConfigOper` but scoped to a `user_id`.
232
+
The concrete repository uses `UserConfigOper` behind the service boundary. Host
233
+
callers do not construct it.
205
234
206
235
---
207
236
@@ -212,8 +241,8 @@ Usage mirrors `SystemConfigOper` but scoped to a `user_id`.
212
241
|`module -> chain` coupling | Move orchestration into `chain` and shared logic into its owning canonical package |
213
242
|`module -> module` direct calls | Use `chain` to orchestrate cross-module workflows |
214
243
| Lower-level module importing a chain or manager | Register a callback/resolver from `app/startup/` or move orchestration to `chain`|
215
-
| Raw SQLAlchemy queries in endpoints or chains | Use the corresponding Oper class in `app/db/oper/`|
244
+
| Raw SQLAlchemy queries or Oper construction in host entrypoints | Define/use an Application Protocol or command; implement it in `app/db/adapters/` with an operation-scoped Session/UoW|
216
245
| Raw string keys for SystemConfig | Define and use a `SystemConfigKey` enum entry |
217
246
| HTTP requests via `requests` or `httpx` directly | Host code uses `RequestUtils` from `app/adapters/network/http.py`; plugins use `app.sdk.network`|
Copy file name to clipboardExpand all lines: docs/rules/08-comment-styles.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,7 @@ if not self._initialized:
97
97
98
98
```python
99
99
# 获取订阅列表 ← 这只是在重述代码,不需要
100
-
subscribes =SubscribeOper().list()
100
+
subscribes =repository.list()
101
101
102
102
# 如果 result 为 None 则返回 ← 无意义
103
103
if result isNone:
@@ -139,4 +139,4 @@ When modifying code, update or remove any comment that no longer accurately desc
139
139
| Commented-out dead code | Delete it; git history preserves it |
140
140
| New contract documentation in English inside an otherwise Chinese file | Breaks the repository's default documentation language and local consistency |
**Rule:** Never use raw string literals as `SystemConfig` keys. Always define a new `SystemConfigKey` enum entry first. Raw string key lookups are not searchable and cannot be refactored safely.
0 commit comments