WeKnora/internal/application/repository
wizardchen ff1f03ce0d feat(rbac): daily retention sweep for audit_logs (default 90 days)
The audit_logs table grows monotonically until something purges it.
PR 6 explicitly listed retention as out of scope for v1; this picks
that up.

Adds an `audit.retention_days` config (default 90, 0 disables) and a
small background goroutine `AuditLogRetentionRunner` that fires once
~10 minutes after boot and then every 24h, calling
`AuditLogService.Purge` which DELETEs rows older than the cutoff in a
single statement. The dependency surface is intentionally minimal —
no robfig/cron, no asynq, no migration — because retention has no
wall-clock alignment requirement.

Wiring is the same shape as the existing data source scheduler:
container `Provide(NewAuditLogRetentionRunner)`, an `Invoke` that
calls `Start`, and a `ResourceCleaner.RegisterWithName` for graceful
shutdown.

Defaults preserve operator intent:
  - `audit:` section omitted from YAML  -> retention_days=90.
  - explicit `audit.retention_days: 0` in YAML  -> purge disabled.
  - `WEKNORA_AUDIT_RETENTION_DAYS=N` env override (incl. N=0).
  - `retention_days < 0` is rejected by ValidateConfig.

Tests cover the service Purge contract (no-op when disabled, cutoff
math, error propagation) and the runner lifecycle (Start no-op when
disabled, idempotent Start/Stop, ticker cadence, runOnce swallows
errors). 10 new tests, all green.

docs/rbac.md updated with the new YAML / env / behaviour.

Refs: #1303
2026-05-18 17:28:58 +08:00
..
memory/neo4j fix: revert to neo4j v6 and workaround Go 1.24 Windows compiler bug with -p=1 2026-04-11 22:08:02 +08:00
retriever chore(deps): update dependencies in /docreader and adjust dependabot configuration 2026-05-12 14:58:52 +08:00
agent_share.go feat(rbac): lift org membership from per-user to per-tenant (Plan 3, #1303) 2026-05-18 17:28:58 +08:00
audit_log.go feat(rbac): daily retention sweep for audit_logs (default 90 days) 2026-05-18 17:28:58 +08:00
chunk.go fix(faq): correct PostgreSQL cast precedence in FAQ search 2026-05-12 16:42:21 +08:00
chunk_sqlite_test.go fix: SQLite/Lite mode compatibility for FAQ import and chunk operations 2026-04-15 20:37:10 +08:00
custom_agent.go refactor: 调整智能体配置,增强智能体选择与状态管理 2025-12-26 21:31:02 +08:00
datasource_repo.go refactor(datasource): remove WeCom document integration and related components 2026-03-30 20:46:07 +08:00
kbshare.go feat(rbac): lift org membership from per-user to per-tenant (Plan 3, #1303) 2026-05-18 17:28:58 +08:00
knowledge.go feat(knowledge-base): document list filters and explicit batch-management UX 2026-05-12 18:29:47 +08:00
knowledgebase.go feat(knowledge-base): validate vector store bindings on create, copy, and delete 2026-05-18 15:58:46 +08:00
knowledgebase_sqlite_test.go feat(rbac): add tenant_members schema and auth wiring (PR 1 of 3, #1303) 2026-05-18 17:28:58 +08:00
mcp_service.go feat: add built-in MCP service support 2026-03-05 21:57:01 +08:00
mcp_tool_approval_repository.go fix(agent): 加固 MCP 工具人审批的跨实例与并发语义 2026-05-10 22:57:12 +08:00
message.go feat(datasource): implement data source management functionality 2026-03-30 20:46:07 +08:00
model.go refactor: Update function signatures across multiple files to improve readability by adding context parameters and enhancing code structure 2025-11-28 16:17:52 +08:00
organization.go feat(rbac): lift org membership from per-user to per-tenant (Plan 3, #1303) 2026-05-18 17:28:58 +08:00
session.go fix(session): scope session access by user 2026-05-14 15:56:43 +08:00
session_test.go fix(session): scope session access by user 2026-05-14 15:56:43 +08:00
tag.go feat(datasource): implement data source management functionality 2026-03-30 20:46:07 +08:00
task_queue.go perf(wiki-ingest): scale to 4w-doc KBs + generic task queue / dead-letter 2026-05-10 00:01:06 +08:00
task_queue_test.go perf(wiki-ingest): scale to 4w-doc KBs + generic task queue / dead-letter 2026-05-10 00:01:06 +08:00
tenant.go refactor(rbac): address PR 1 review feedback 2026-05-18 17:28:58 +08:00
tenant_disabled_shared_agent.go feat(agent): enhance agent and skill management features 2026-02-09 11:40:25 +08:00
tenant_member.go fix(rbac): address PR 3 + leave-endpoint review feedback 2026-05-18 17:28:58 +08:00
tenant_test.go fix(tenant): prevent api_key encryption loss on tenant settings update 2026-03-25 21:25:21 +08:00
user.go fix(rbac): address PR 3 + leave-endpoint review feedback 2026-05-18 17:28:58 +08:00
vectorstore.go feat: add VectorStore service layer with types and connection testing 2026-04-13 22:57:17 +08:00
web_search_provider.go feat(web-search): refactor web search provider 2026-03-31 20:22:34 +08:00
wiki_log_entry.go perf(wiki): move ingest log to event table and index to on-demand API 2026-05-08 21:48:52 +08:00
wiki_log_entry_test.go perf(wiki): move ingest log to event table and index to on-demand API 2026-05-08 21:48:52 +08:00
wiki_page.go fix(wiki-ingest,asynqdl): review fixups for PR #1241 2026-05-10 00:01:06 +08:00
wiki_page_test.go perf(wiki): move ingest log to event table and index to on-demand API 2026-05-08 21:48:52 +08:00