Commit 27c1676f by sunqi02

docs(plan): mark all session persistence tasks as complete

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e26aacb6
......@@ -193,7 +193,7 @@ git commit -m "fix(session): refresh TTL on SessionStore read to keep active ses
**Files:**
- Modify: `app/service/active_session_service.py` (全文重写)
- [ ] **Step 1: 更新 ActiveSessionInfo 和 ActiveSessionService 测试**
- [x] **Step 1: 更新 ActiveSessionInfo 和 ActiveSessionService 测试**
在 `tests/test_session_persistence.py` 添加:
......@@ -237,7 +237,7 @@ class TestActiveSessionServiceSimplified:
assert "room_id" in data
```
- [ ] **Step 2: 运行测试确认失败**
- [x] **Step 2: 运行测试确认失败**
Run:
```bash
......@@ -245,7 +245,7 @@ PYTHONPATH=. python -m pytest tests/test_session_persistence.py::TestActiveSessi
```
Expected: FAIL — `ActiveSessionInfo` 仍有 `user_id` 和 `current_agent_code`。
- [ ] **Step 3: 重写 `app/service/active_session_service.py`**
- [x] **Step 3: 重写 `app/service/active_session_service.py`**
完整文件内容:
......@@ -377,7 +377,7 @@ class ActiveSessionService:
self._db.commit()
```
- [ ] **Step 4: 运行测试确认通过**
- [x] **Step 4: 运行测试确认通过**
Run:
```bash
......@@ -385,7 +385,7 @@ PYTHONPATH=. python -m pytest tests/test_session_persistence.py -v
```
Expected: 所有测试通过(TTL + Simplified 两组)。
- [ ] **Step 5: 确认 test_agent_hub.py 的预期失败**
- [x] **Step 5: 确认 test_agent_hub.py 的预期失败**
Run:
```bash
......@@ -393,7 +393,7 @@ PYTHONPATH=. python -m pytest tests/test_agent_hub.py -v --tb=short
```
Expected: **所有测试失败**,因为 `process_message()` 仍传 `user_id=user_id` 给 `get_or_create_session()`,而新签名已移除该参数,触发 `TypeError`。这是预期的——Task 5 Step 1 会修复调用方。路由测试的断言也需要更新(Task 5 Step 6)。
- [ ] **Step 6: Commit**
- [x] **Step 6: Commit**
```bash
git add app/service/active_session_service.py tests/test_session_persistence.py
......@@ -550,7 +550,7 @@ git commit -m "test(session): add database persistence and recovery tests"
- Modify: `app/main.py` — lifespan 传入 DB session
- Modify: `tests/test_agent_hub.py` — 路由测试更新
- [ ] **Step 1: 修改 `process_message()` — 路由简化**
- [x] **Step 1: 修改 `process_message()` — 路由简化**
在 `app/service/agent_hub.py` 的 `process_message()` 方法中,找到以下代码块(约第 230-260 行):
......@@ -573,7 +573,7 @@ git commit -m "test(session): add database persistence and recovery tests"
)
```
- [ ] **Step 2: 修改路由决策逻辑**
- [x] **Step 2: 修改路由决策逻辑**
找到路由决策块(约第 244-270 行):
......@@ -608,7 +608,7 @@ git commit -m "test(session): add database persistence and recovery tests"
routing_reason = "default"
```
- [ ] **Step 3: 修改消息存储和末尾持久化**
- [x] **Step 3: 修改消息存储和末尾持久化**
找到消息存储和路由更新块(约第 290-300 行):
......@@ -632,7 +632,7 @@ git commit -m "test(session): add database persistence and recovery tests"
self.session_service.save_to_db(session_id)
```
- [ ] **Step 4: 修改 `app/main.py` — lifespan 传入 DB session**
- [x] **Step 4: 修改 `app/main.py` — lifespan 传入 DB session**
在 `app/main.py` 做以下 3 处修改:
......@@ -672,7 +672,7 @@ from app.infrastructure.database import engine, SessionLocal
db.close()
```
- [ ] **Step 5: 运行 test_agent_hub.py 查看剩余失败**
- [x] **Step 5: 运行 test_agent_hub.py 查看剩余失败**
Run:
```bash
......@@ -680,7 +680,7 @@ PYTHONPATH=. python -m pytest tests/test_agent_hub.py -v --tb=short
```
Expected: 非路由测试全部通过。路由测试中,`test_default_routing_to_main` 通过,其他路由测试需更新。
- [ ] **Step 6: 更新路由测试**
- [x] **Step 6: 更新路由测试**
修改 `tests/test_agent_hub.py` 中以下测试:
......@@ -753,7 +753,7 @@ Expected: 非路由测试全部通过。路由测试中,`test_default_routing_
assert result["routing_reason"] == "default"
```
- [ ] **Step 7: 运行全量测试**
- [x] **Step 7: 运行全量测试**
Run:
```bash
......@@ -761,7 +761,7 @@ PYTHONPATH=. python -m pytest tests/test_agent_hub.py tests/test_memory.py tests
```
Expected: 全部通过。
- [ ] **Step 8: Commit**
- [x] **Step 8: Commit**
```bash
git add app/service/agent_hub.py app/main.py tests/test_agent_hub.py
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!