CyberStrikeAI/internal/database
Sycun 470eb5ead1
feat: add runtime storage cleanup with per-category retention (#310) (#313)
Runtime artifacts (agent workspaces, tool-output spill, C2 payloads, chat
uploads, workflow checkpoints, diagnostic logs) previously accumulated
without bound: most were only removed when a conversation or project was
deleted, and tmp/c2 plus workflow checkpoints were never removed at all.

Add a storage cleaner with named per-category tasks (Gitea-style), a
settings page tab, and a background sweep that is off by default so
upgrading never deletes existing data.

Safety properties, since mis-deleting live task data costs far more than
the disk saved:
- dry-run is the default; a real cleanup requires dry_run=false together
  with confirm=true at the API layer, not just a frontend dialog
- sessions active within active_grace_hours are always skipped, and a
  failed activity lookup skips conservatively (fail closed)
- directories whose conversation/project no longer exists are reclaimed
  as orphans after orphan_grace_days
- scanners never follow symlinks and every candidate path is confined to
  its category root; deletion renames to a .tmp-for-deletion marker first
  so a crash leaves recoverable residue instead of a half-deleted dir
- storage:* permissions are admin-only; without the grantSystemRolePermissions
  skip the default branch would have given operators an irreversible
  file-deletion right

Also fix two confirmed leaks: DeleteConversation left chat_uploads files
on disk (their rows already vanished via ON DELETE CASCADE), and workflow
checkpoints had no deletion path at all.

Co-authored-by: Parallels <parallels@kali-linux-2025-2.localdomain>
2026-09-25 14:46:23 +08:00
..
asset.go Add files via upload 2026-08-18 20:34:53 +08:00
asset_test.go Add files via upload 2026-08-18 20:34:53 +08:00
attackchain.go Add files via upload 2026-08-18 20:34:53 +08:00
audit.go Add files via upload 2026-08-18 20:34:53 +08:00
audit_time_test.go Add files via upload 2026-08-18 20:34:53 +08:00
batch_hitl_test.go feat: add batch task approval settings and fix modal dropdown scrolling 2026-09-13 18:02:43 +08:00
batch_task.go feat: add batch task approval settings and fix modal dropdown scrolling 2026-09-13 18:02:43 +08:00
blocked_execution_test.go feat: add configurable tool call blocking and monitoring 2026-09-08 09:44:32 +08:00
c2.go Add files via upload 2026-08-18 20:34:53 +08:00
c2_payload.go Add files via upload 2026-08-18 20:34:53 +08:00
chat_upload.go Add files via upload 2026-08-18 20:34:53 +08:00
conversation.go feat: add runtime storage cleanup with per-category retention (#310) (#313) 2026-09-25 14:46:23 +08:00
conversation_cleanup_test.go feat: add runtime storage cleanup with per-category retention (#310) (#313) 2026-09-25 14:46:23 +08:00
conversation_create_meta.go Add files via upload 2026-08-18 20:34:53 +08:00
conversation_project_filter_test.go Add files via upload 2026-08-18 20:34:53 +08:00
conversation_turn_test.go Add files via upload 2026-08-18 20:34:53 +08:00
conversation_vulnerability_test.go Add files via upload 2026-08-18 20:34:53 +08:00
database.go feat: add runtime storage cleanup with per-category retention (#310) (#313) 2026-09-25 14:46:23 +08:00
hitl_logs.go Add files via upload 2026-08-18 20:34:53 +08:00
hitl_logs_test.go Add files via upload 2026-08-18 20:34:53 +08:00
model_token_usage.go Add token usage tracking and UI refinements 2026-08-24 00:05:05 +08:00
model_token_usage_test.go Add token usage tracking and UI refinements 2026-08-24 00:05:05 +08:00
monitor.go feat: add configurable tool call blocking and monitoring 2026-09-08 09:44:32 +08:00
monitor_reconcile_test.go Add files via upload 2026-08-18 20:34:53 +08:00
monitor_retention_test.go Add files via upload 2026-08-18 20:34:53 +08:00
monitor_summary_test.go Add files via upload 2026-08-18 20:34:53 +08:00
plantask.go Add files via upload 2026-08-18 20:34:53 +08:00
plantask_test.go Add files via upload 2026-08-18 20:34:53 +08:00
process_detail_dedupe.go Add files via upload 2026-08-18 20:34:53 +08:00
process_details_summary_test.go Fix finalization cleanup for pending tool executions 2026-08-23 19:57:17 +08:00
project.go Add files via upload 2026-08-18 20:34:53 +08:00
project_dashboard.go Add files via upload 2026-08-18 20:34:53 +08:00
project_fact_edges.go Add files via upload 2026-08-18 20:34:53 +08:00
project_fact_upsert_test.go Add files via upload 2026-08-18 20:34:53 +08:00
project_search_test.go Add files via upload 2026-08-18 20:34:53 +08:00
project_stats.go Add files via upload 2026-08-18 20:34:53 +08:00
project_time_test.go Add files via upload 2026-08-18 20:34:53 +08:00
rbac.go feat: add runtime storage cleanup with per-category retention (#310) (#313) 2026-09-25 14:46:23 +08:00
rbac_access_test.go Remove conversation grouping feature 2026-08-26 15:00:09 +08:00
robot_identity.go Add files via upload 2026-08-18 20:34:53 +08:00
robot_identity_test.go Add files via upload 2026-08-18 20:34:53 +08:00
robot_session.go Add files via upload 2026-08-18 20:34:53 +08:00
skill_stats.go Add files via upload 2026-08-18 20:34:53 +08:00
sqltime.go Add files via upload 2026-08-18 20:34:53 +08:00
storage_activity.go feat: add runtime storage cleanup with per-category retention (#310) (#313) 2026-09-25 14:46:23 +08:00
tool_execution_args_lookup.go Add files via upload 2026-08-18 20:34:53 +08:00
tool_guard_migration.go feat: add configurable tool call blocking and monitoring 2026-09-08 09:44:32 +08:00
vulnerability.go Add files via upload 2026-08-18 20:34:53 +08:00
vulnerability_alert.go Add files via upload 2026-08-18 20:34:53 +08:00
vulnerability_alert_test.go Add files via upload 2026-08-18 20:34:53 +08:00
webshell.go Add files via upload 2026-08-18 20:34:53 +08:00
workflow.go Add files via upload 2026-08-18 20:34:53 +08:00
workflow_package.go Add files via upload 2026-08-18 20:34:53 +08:00
workflow_package_test.go Add files via upload 2026-08-18 20:34:53 +08:00