feat: 审计动作按落库策略分级写入,系统过程动作改写应用日志
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 12m8s

- 审计注册表为可由系统任务、定时任务发起的动作声明落库策略(always/on_success/outcome/log_only/none),未声明按 log_only
- 人工、开放接口、个人客户、外部系统发起的动作始终写审计表
- log_only 写所在服务 app.log(logger=audit),不含快照
- 对接日志不再补写 integration.attempt_started,无上游审计时 audit_event_id 为空
- 新增 audit.persist_overrides 按动作覆盖策略
- 审计覆盖扫描要求机器动作必须声明策略
- 新增 OpenSpec 提案 refactor-audit-log-persistence 与技术方案文档

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
邹进
2026-11-05 18:27:24 +09:00
parent 96ff9c1e35
commit b7a7430cc3
21 changed files with 1720 additions and 4 deletions

View File

@@ -32,6 +32,14 @@ type Config struct {
Worker WorkerConfig `mapstructure:"worker"`
WeCom WeComConfig `mapstructure:"wecom"`
Approval ApprovalConfig `mapstructure:"approval"`
Audit AuditConfig `mapstructure:"audit"`
}
// AuditConfig 统一审计写入配置。
type AuditConfig struct {
// PersistOverrides 按动作覆盖系统任务、定时任务的落库策略,格式 "动作编码=策略,动作编码=策略",
// 策略取值 always、on_success、outcome、log_only、none;为空不覆盖。环境变量:JUNHONG_AUDIT_PERSIST_OVERRIDES
PersistOverrides string `mapstructure:"persist_overrides"`
}
// ServerConfig HTTP 服务器配置

View File

@@ -162,6 +162,11 @@ worker:
# 审计归档、Integration 归档与日留存默认关闭,低峰期按单日推进
audit_archive_tasks_enabled: false
# 统一审计写入配置
audit:
# 按动作覆盖系统任务、定时任务的落库策略,例如 "package_usage.expire=log_only";为空不覆盖
persist_overrides: ""
# 审批新旧入口切换配置
approval:
legacy_refund_manual_enabled: true

View File

@@ -144,6 +144,7 @@ func bindEnvVariables(v *viper.Viper) {
"worker.audit_archive_tasks_enabled",
"approval.legacy_refund_manual_enabled",
"approval.legacy_offline_recharge_pay_enabled",
"audit.persist_overrides",
"wecom.base_url",
"wecom.timeout",
"wechat.official_account.app_id",