uploads: dual-write uploads to DB, startup backfill, and audit log

Store now indexes every Save into the upload_files table via SetRepo.

DB failures are logged as warnings and do not fail the upload because

.meta.json remains the source of truth and startup backfill recovers.

Add Store.Backfill to walk Root at startup and insert index rows for

any pre-existing .meta.json sidecars, swallowing duplicate-key races.

The upload_file MCP Tool now writes an audit_log entry on success.

Tests cover dual-write args, repo-error non-failure, and backfill

skipping existing rows.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-14 11:30:39 +08:00
co-authored by Claude
parent 1796b5b872
commit 876f1c9edb
7 changed files with 316 additions and 17 deletions
+2
View File
@@ -5,6 +5,7 @@ import (
"time"
"spark-mcp-go/internal/analyzer"
"spark-mcp-go/internal/audit"
"spark-mcp-go/internal/httpclient"
"spark-mcp-go/internal/storage"
"spark-mcp-go/internal/uploads"
@@ -13,6 +14,7 @@ import (
// Deps bundles the dependencies shared by all MCP Tool handlers.
type Deps struct {
Logger *slog.Logger
AuditRepo *audit.Repo
ClusterRepo *storage.ClusterRepo
SparkSubmitTimeout time.Duration
HTTPClient *httpclient.Client