FinClaw V1 Sub-Packet: ProfileConsent 实现
状态:Pending / 等待 Engineering 启动信号 日期:2026-05-16 Lane:Engineering Owner:Engineering Agent A(agent/ + api/)+ Frontend Agent D(web/)协作 Parent Packet:v1-engineering-implementation-task-packet.md 对齐 Action Item:AL-1(v1-governance-engineering-alignment.md §9.AL-1)
1. 目标
把 v1-product-object-and-schema-design.md §8.2 ProfileConsent schema 在工程仓库 fin-claw 中落地为可运行的 opt-in consent 流程,覆盖:
- 后端
ProfileConsent数据模型与持久化; - REST API(grant / revoke / list);
- Onboarding ConsentDialog 与 Profile Settings 撤回 UI;
- 端到端测试:grant → revoke → audit。
本 sub-packet 不实现 SensitiveInputHandling(由 sub-2 承接)也不实现 TrainingAssetCandidate 治理状态(由 sub-3 承接);只覆盖 consent 这一对象。
2. 允许读取
见 frontmatter must_read / reference_only。
3. 禁止范围
- 不引入数据库(V1 阶段坚持文件持久化,与 CognitionStore 一致;如果未来需要 DB,CRUD 层抽象足够);
- 不实现完整 GDPR 合规字段(按 D-12 复核延后但不豁免,本 sub-packet 只确保字段足以承接后续法务复核);
- 不在 ConsentDialog 中收集除 ConsentScope 外的额外字段(不要趁机扩 onboarding);
- 不绕过 Boundary Guard 写入 forbidden execution fields;
- 不在 Labs 内测期间收集多语言 consent text(D-01 简化)。
4. Acceptance Criteria
| AC ID | 验收项 |
|---|---|
| AC-1 | ProfileConsent Pydantic v2 模型字段完整:consent_id、context_ref、save_to_profile、save_to_thread、training_use_allowed、de_identified、retention_scope、delete_or_revoke_available、confirmed_at、consent_version、revoke_path |
| AC-2 | POST /v1/consent/grant 与 DELETE /v1/consent/revoke endpoints 可工作;返回 schema 与 v1-product-object-and-schema-design.md §8.2 一致 |
| AC-3 | 撤回 consent 后 instrumentation 停止上报(与 sub-6 / cs sub-2 的事件 sink 隔离) |
| AC-4 | Onboarding ConsentDialog 显示 4 类 ConsentScope checkbox + 明确「不提供执行能力」边界文案 |
| AC-5 | Profile Settings 中可独立撤回 consent;撤回成功后 UI 即时反映状态 |
| AC-6 | 单测覆盖 grant / revoke / list / expiry / file persistence 共 ≥ 12 case,全部通过 |
| AC-7 | 持久化路径:data/consents/<user_id>.yaml(与 CognitionStore 一致的文件持久化模式) |
| AC-8 | 与 V1 PRD §10.1「待实现验收项」中的「轻量用户画像确认」对齐:未确认不得长期保存任何金融上下文 |
5. 回写位置
- 代码 → 工程仓库
fin-claw(feature branchfeature/profile-consent); - 完成后立即刷新 v1-governance-engineering-alignment.md §2 / §9.AL-1 状态由
missing→aligned-initial; - Hand-off anchor →
handoff-anchors/v1-eng-impl-sub-1-profile-consent.yaml; - 解除依赖:sub-3(TrainingAssetCandidate 与 ProfileConsent 的关联)、cs sub-2(Consent Gate)。
6. 风险与裁决项
- 风险 R-1:Consent 字段命名漂移导致前后端不一致 → 必须在 PR 描述中粘贴 schema diff;
- 风险 R-2:Onboarding 弹窗增加摩擦影响 trial cohort 上手 → D-01 已限定 3 人内测,可接受;公开扩展前需重测 conversion;
- 裁决项 J-1:
consent_version当前固定为"v1.0";trial 期间是否随 D-12 法务复核版本递增由项目发起人裁决。
7. 与其他 Sub-Packet 的关系
- 解除:sub-3(依赖 ProfileConsent 模型)、cs sub-2(依赖
consent_for_trial_data字段); - 并行无冲突:sub-4 / sub-5(前端 web/ 文件不重叠);
- 共享文件需协调:
server/agent/models.py(与 sub-2 / sub-3 协调;本 sub-packet 只新增,不修改其他对象字段)。