API-INFO-010 P0 | 事件校验、去重、activeSecondsDelta 处理 【status:todo】 #110
Closed
opened 2026-06-07 11:03:39 +08:00 by wangdl
·
2 comments
Labels
Clear labels
area:activity
活动/统计
area:admin
管理后台
area:admin-api
area:ai
AI/RAG
area:ai-runtime
AI Runtime / AI 分析体系相关
area:analytics
area:api
API 接口
area:auth
认证与授权
area:cos
对象存储
area:database
数据库/Migration
area:import
文件导入/解析
area:knowledge
知识库/知识点
area:learning-info
area:learning-session
area:quiz
测验/自测
area:reading-event
area:reading-progress
area:review
复习系统
area:security
安全相关
audit:api-admin-info
audit:api-info
audit:planned
已完成宏观规划,尚未代码审查
audit:reviewed
blocked-by:api-info-aggregation
blocked-by:api-info-core
blocked-by:api-info-ops
blocked-by:api-info-schema
blocked-by:processor
blocked-by:schema
priority:p0
最高优先级,阻塞发布
priority:p1
高优先级,里程碑必需
priority:p2
中优先级,后续版本
repo:api
API 仓库 Issue
status:blocked
被阻塞
status:done
已完成
status:partial
status:todo
type:aggregation
type:bug
缺陷修复
type:design
设计
type:docs
文档
type:feature
新功能
type:migration
type:refactor
重构
type:test
work:admin-api
work:aggregation
work:api
work:artifact
题目/卡片产物
work:audit
work:circuit-breaker
熔断
work:contract
work:design
架构/协议设计工作
work:docs
work:export
work:extend-existing
work:internal-api
Runtime 内部接口
work:job
Job 调度相关
work:new-module
work:new-table
work:ops
work:query
work:quota
额度/限流
work:schema
Prisma Schema 设计
work:security
work:service
Service 层实现
work:snapshot
Snapshot 构建
work:test
No Label
Milestone
No items
No Milestone
M8:学习信息收集与基础分析闭环
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: wangdl/api-server#110
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
目标
统一事件校验和幂等处理。
规则
详见设计文档 API-INFO-000。
API-INFO-005 P0 | 实现 ReadingEvent 去重与校验to API-INFO-010 P0 | 实现事件校验、去重、activeSecondsDelta 处理API-INFO-010 P0 | 实现事件校验、去重、activeSecondsDelta 处理to API-INFO-010 P0 | 事件校验、去重、activeSecondsDelta 处理 【status:todo】审查结论:当前 API 项目学习信息收集体系基本为全新建设。可复用:JWT Guard、LearningSession 基础表/CRUD、DailyLearningActivity 基础表、ActivityController 部分接口、LearningRecord schema。其余 ReadingEvent/TemporaryMaterial/Progress/批量上报/Processor/聚合/查询接口/错误码/去重/权限/测试/文档均不存在或仅部分存在。
本 Issue: 代码不存在。activeSecondsDelta=0合法、>300截断、<0拒绝。
标签: audit:reviewed audit:api-info status:todo work:api
完成报告
交付
reading-event.service.ts—processBatch()完整 7 步校验管线:1. Required fields — eventId / clientSessionId / materialId 缺失 → failed
2. Type validation — readingTargetType 必须为 knowledge_source | temporary_file,eventType 必须为 5 种之一
3. Delta validation — =0 ✅ / <0 ❌ INVALID_ACTIVE_SECONDS / >300 ✅ 截断 + ACTIVE_SECONDS_CAPPED warning
4. Timestamp validation — 无效/负数 ❌ INVALID_TIMESTAMP / >5min 未来 ⚠️ CLIENT_TIMESTAMP_SKEWED
5. Dedup check — userId+eventId 查重,已存在 → DUPLICATE_EVENT + 跳过写入 + 跳过聚合
6. Position validation — 检查 type 字段属于 6 种 ReadingPosition variant,无效 → POSITION_IGNORED + 不更新 progress
7. Persist — create(非 upsert!先查重再写入),status=processed
代码证据