feat(channels): 非消息事件接入(notice 归一化 + 传入前审查,fail-safe 静默)与入站脱敏帧日志/日志轮转
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- notice:adapter 归一化 seam + 结构化分类 + 净化(ANSI/控制/零宽/双向字符、200 runes 截断)
  + fail-safe 写死为「静默」(未装配审查/超时/失败 ⇒ 仅登记、不驱动 loop)
- 身份面零改动:notice 发送者恒 RoleSystem + SenderID=system
- 复用策略四的同一个审查模型(Options.Review),未另造第二套
- 入站帧脱敏 DEBUG(post_type/message_type/sub_type/self_id/user_id/sender_id/group_id/段类型/at 目标)
- ctrl.bat 启动前归档轮转(保留 20 份)+ bash 侧改追加(不再重启即截断)
This commit is contained in:
AskaEth committed 2026-10-05 11:55:05 +08:00
1 parent 85abb90067
commit 5139945bfe
15 files changed
+1604 -21

No files matched your search

+22 -9
View File
@@ -179,22 +179,35 @@ func (a *Adapter) readConn(ctx context.Context, conn *wsConn) {
}
// handlePayload parses a text frame, converting message events into normalized
// UnifiedMessage and dispatching them.
// UnifiedMessage and dispatching them. notice(系统通知)上报同样被归一化后投递
// ——它们带 ContentType=ContentAction 的结构化标记,由 channelbridge 的「传入前
// 审查」决定是否 / 如何进入她的上下文(design/12 §6 策略一补充);其余非 message
// 上报(message_sent 回声、meta_event 心跳等)一律丢弃。丢弃前一律留一条**脱敏结构
// DEBUG**(logInboundFrame):上游到底有没有把这一帧推过来,是排障时最先要回答的问题,
// 而「被丢弃」与「从未到达」在日志里必须能分开。
func (a *Adapter) handlePayload(ctx context.Context, payload []byte) {
ev, err := parseEvent(payload)
if err != nil {
a.log.Debug("non-event payload ignored", "err", err)
return
}
if ev.PostType != "message" {
return
a.logInboundFrame(ev)
switch ev.PostType {
case postTypeMessage:
msg := a.toUnified(ev, payload)
if err := msg.Validate(); err != nil {
a.log.Warn("invalid unified message dropped", "err", err)
return
}
a.dispatch(ctx, msg)
case postTypeNotice:
msg := a.toNoticeMessage(ev, payload)
if err := msg.Validate(); err != nil {
a.log.Warn("invalid notice event dropped", "err", err)
return
}
a.dispatch(ctx, msg)
}
msg := a.toUnified(ev, payload)
if err := msg.Validate(); err != nil {
a.log.Warn("invalid unified message dropped", "err", err)
return
}
a.dispatch(ctx, msg)
}
// dispatch routes an inbound message to the registered push handler, falling