feat(services): assignment 6 full - form/business key mapping and stream write-back
- fields_registry: FORM_TO_BUSINESS_KEY bidirectional mapping between the graph's six form keys (has_injury...) and the acd business keys (ywrysw...); bjrjs/ywmtc have no form source (set_info only); business_patch_from_form maps graph diffs to whitelisted business keys and filters internal/unknown keys - app_service: chat injection now maps repository business keys back to form keys; both complete() and stream() write back field diffs (FormUpdate events captured in stream, closing the skeleton gap); form keys never leak into the business repository - docs/assignment6-compat.md: mapping table documented, stream write-back backlog item resolved - tests: mapping coverage, write-back mapping end-to-end, reverse mapping injection (bjrjs/ywmtc excluded), stream FormUpdate write-back Verified: 205 unit tests
This commit is contained in:
@@ -21,16 +21,32 @@
|
||||
| `set_info` 未知 key | 任意 key 写入 state 变量 | **拒绝**(500 + "入参不规范:未知或受保护的字段 key") | 白名单保护;任意写入会污染图输入。上线前需审计旧调用方是否依赖任意 key 写入 |
|
||||
| `set_info` 图内部键(`stage_code` 等) | 可写(state 是裸 dict) | **拒绝**(`INTERNAL_FIELD_KEYS` 保护) | 内部状态只允许图自己推进 |
|
||||
| `set_info` 字段值 | 任意字符串原样存 | 按注册表类型解析(bool/int 严格),无法解析拒绝 | 保留 空/False/0/未知 区分,杜绝 `bool("0")` 陷阱 |
|
||||
| 图表单键与业务键 | FastGPT state 为裸 dict,无映射概念 | 建立双向映射(作业 6):表单六键(`has_injury` 等)<-> acd 业务键(`ywrysw` 等);`bjrjs`/`ywmtc` 无表单来源,仅 `set_info` 可写 | 图的表单语义与 get_info 业务分组需要同一份事实 |
|
||||
| LLM 调用 | set/get 走辅助对话 + 事后删记录 | **零 LLM 调用**(测试 spy 保证) | 成本与延迟;删除 race 消失 |
|
||||
| 重复 `delete_session` | FastGPT SDK 行为未固定 | **幂等成功**(业务状态 + checkpoint 均静默容忍缺失) | 行为固定为测试 |
|
||||
| 重复 `delete_session` | FastGPT SDK 行为未固定 | **幂等成功**(业务状态删除天然幂等;checkpoint 清理重复触发但缺失静默容忍) | 行为固定为测试 |
|
||||
|
||||
## 图表单键 <-> 业务键映射(作业 6 建立)
|
||||
|
||||
| 图表单键(accident_fields) | 业务键(acdinfo 分组) |
|
||||
|---|---|
|
||||
| `has_injury` | `ywrysw` |
|
||||
| `has_non_motor_vehicle_hit` | `ywfjdc` |
|
||||
| `is_on_scene` | `sfsgxc` |
|
||||
| `vehicle_count` | `jdcsl` |
|
||||
| `accident_time` | `sgfssj` |
|
||||
| `accident_cause` | `sgyy` |
|
||||
|
||||
- chat 方向:repository 业务键经映射注入图为表单键(图只认表单语义)。
|
||||
- 写回方向:图产出的表单键差量经映射落 repository 业务键,get_info 分组即可读到。
|
||||
- `bjrjs`(报警人是否驾驶员)、`ywmtc`(是否撞摩托车)无表单来源:
|
||||
不进入注入映射,仅支持 set_info 直写、get_info 直读。
|
||||
|
||||
## 待审计项(作业 6-7 要求的后续工作)
|
||||
|
||||
- [ ] 审计现有调用方是否存在对 `set_info` 任意 key 写入的依赖
|
||||
(如动态自定义键)。存在则在注册表补登记或提供逃生口。
|
||||
- [ ] 流式 `chat` 的 `formUpdate` 差量写回 repository:
|
||||
骨架阶段流式原样透传,差量写回仅在非流式 `chat()` 生效;
|
||||
完整版随 FormUpdate 事件捕获补齐(见 `app_service.stream` 注释)。
|
||||
- [x] ~~流式 `chat` 的 `formUpdate` 差量写回 repository~~
|
||||
(完整版已实现:FormUpdate 事件捕获后经映射写回,见 `app_service.stream`)。
|
||||
- [ ] `get_info` 返回值中的敏感字段(证件号/手机号)回显边界:
|
||||
注册表已记录 `SensitiveLevel`,访问控制随作业 9 落地。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user