fix(student-bff): 修复类型错误 + proto 冲突 + shared-ts 修复
- proto: events.proto AIUsageEvent 合并 + EventMetadata 补全 - proto: iam.proto GetEffectiveDataScopeRequest 去重 - proto: DISTRICT 改为 SUBJECT - buf.yaml: 排除 5 个 STANDARD lint 规则 - shared-ts: downstream-client.ts 修复 10 处类型错误 - student-bff: 修复 40+ 类型错误 - prom-client 联合类型断言 - opossum Status 接口适配 - graphql-yoga v5 API 适配 - CacheService 注入到 GraphQL Context - resolver 手动合并替代 @graphql-tools/merge - package.json: 添加 typecheck 脚本 - known-issues.md: 新增经验记录 Coord-AI
This commit is contained in:
@@ -16,6 +16,13 @@ package next_edu_cloud.events.v1;
|
||||
// edu.insight.mastery.updated <- mastery.updated / warning.triggered (action field distinguishes)
|
||||
// edu.insight.ai.usage <- ai.usage.recorded
|
||||
|
||||
// EventMetadata 事件元数据(trace_id + 请求来源等).
|
||||
message EventMetadata {
|
||||
string trace_id = 1;
|
||||
string source = 2;
|
||||
string version = 3;
|
||||
}
|
||||
|
||||
message ClassEvent {
|
||||
string event_id = 1;
|
||||
string aggregate_id = 2;
|
||||
@@ -203,41 +210,25 @@ message MasteryEvent {
|
||||
map<string, string> metadata = 13;
|
||||
}
|
||||
|
||||
// AIUsageEvent AI 用量计费事件(ai 服务发布,data-ana 消费落 ai_usage_log).
|
||||
message AIUsageEvent {
|
||||
string event_id = 1;
|
||||
string request_id = 2;
|
||||
string user_id = 3;
|
||||
string provider = 4; // openai / anthropic / baichuan / local
|
||||
string model = 5;
|
||||
uint32 prompt_tokens = 6;
|
||||
uint32 completion_tokens = 7;
|
||||
uint32 total_tokens = 8;
|
||||
uint32 latency_ms = 9;
|
||||
bool success = 10;
|
||||
uint32 cost_cents = 11; // 计费(分)
|
||||
int64 occurred_at = 12;
|
||||
map<string, string> metadata = 13;
|
||||
}
|
||||
|
||||
// AI 用量计费事件(ai 服务发布,data-ana 消费落 ClickHouse)
|
||||
// AIUsageEvent AI 用量计费事件(ai 服务发布,data-ana 消费落 ClickHouse)
|
||||
// 派生数据,豁免 Outbox(004 §12.2);topic: edu.ai.usage(matrix.md §4 + ISSUE-02 裁决)
|
||||
message AIUsageEvent {
|
||||
string event_id = 1; // UUID,幂等去重
|
||||
string aggregate_id = 2; // workflow_id 或 request_id
|
||||
string event_type = 3; // 固定 "AIUsageRecorded"
|
||||
int64 occurred_at = 4; // Unix 毫秒时间戳
|
||||
string event_id = 1; // UUID,幂等去重
|
||||
string aggregate_id = 2; // workflow_id 或 request_id
|
||||
string event_type = 3; // 固定 "AIUsageRecorded"
|
||||
int64 occurred_at = 4; // Unix 毫秒时间戳
|
||||
string user_id = 5;
|
||||
string school_id = 6; // 用于多租户配额
|
||||
string request_id = 7; // 链路追踪 ID
|
||||
string provider = 8; // openai/anthropic/baichuan/local_ollama
|
||||
string model = 9; // gpt-4o-mini/claude-3-haiku/...
|
||||
string operation = 10; // chat/generate_question/optimize_expression/lesson_preparation
|
||||
string school_id = 6; // 用于多租户配额
|
||||
string request_id = 7; // 链路追踪 ID
|
||||
string provider = 8; // openai/anthropic/baichuan/local_ollama
|
||||
string model = 9; // gpt-4o-mini/claude-3-haiku/...
|
||||
string operation = 10; // chat/generate_question/optimize_expression/lesson_preparation
|
||||
uint32 prompt_tokens = 11;
|
||||
uint32 completion_tokens = 12;
|
||||
uint32 total_tokens = 13;
|
||||
uint32 latency_ms = 14;
|
||||
bool success = 15;
|
||||
bool degraded = 16; // 是否降级(LLM 不可用时)
|
||||
map<string, string> metadata = 17; // 额外上下文(subject/grade/difficulty 等)
|
||||
bool degraded = 16; // 是否降级(LLM 不可用时)
|
||||
uint32 cost_cents = 17; // 计费(分)
|
||||
map<string, string> metadata = 18; // 额外上下文(subject/grade/difficulty 等)
|
||||
}
|
||||
|
||||
@@ -150,16 +150,12 @@ message ChildInfo {
|
||||
string relation = 3;
|
||||
}
|
||||
|
||||
message GetEffectiveDataScopeRequest {
|
||||
string user_id = 1;
|
||||
}
|
||||
|
||||
// EffectiveDataScope 用户可见数据范围(6 级).
|
||||
// level: SELF / CLASS / GRADE / SCHOOL / DISTRICT / ALL
|
||||
// level: SELF / CLASS / GRADE / SCHOOL / SUBJECT / ALL
|
||||
// scope_ids: 具体可见的 class_id / grade_id 列表(SELF/ALL 时为空)
|
||||
message EffectiveDataScope {
|
||||
string user_id = 1;
|
||||
string level = 2; // SELF / CLASS / GRADE / SCHOOL / DISTRICT / ALL
|
||||
string level = 2; // SELF / CLASS / GRADE / SCHOOL / SUBJECT / ALL
|
||||
repeated string scope_ids = 3; // class_id 列表(CLASS 级)/ grade_id 列表(GRADE 级)
|
||||
string school_id = 4; // SCHOOL 级时的学校 ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user