-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscratch_cleanup.go
More file actions
51 lines (44 loc) · 1.08 KB
/
Copy pathscratch_cleanup.go
File metadata and controls
51 lines (44 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//go:build ignore
// +build ignore
// scratch_cleanup.go is a one-off diagnostic script that exercises the
// tool-execution store's AutoCleanup path with a tiny synthetic dataset.
// Excluded from normal builds via the ignore tag; run with:
//
// go run scratch_cleanup.go
package main
import (
"fmt"
"path/filepath"
"os"
"codenerd/internal/store"
)
func main() {
dbPath := filepath.Join(os.TempDir(), "tools_test.db")
os.Remove(dbPath)
s, err := store.NewToolStore(dbPath)
if err != nil {
fmt.Printf("Error creating store: %v\n", err)
return
}
defer s.Close()
exec := store.ToolExecution{
CallID: "c1",
SessionID: "s1",
ResultSize: 60,
SessionRuntimeMs: 1000,
}
if err := s.Store(exec); err != nil {
fmt.Printf("Store failed: %v\n", err)
return
}
cfgSize := store.CleanupConfig{
MaxSizeBytes: 50,
AutoCleanupThreshold: 0.5,
CleanupMode: "size",
}
stats, err := s.AutoCleanup(cfgSize)
if err != nil {
fmt.Printf("AutoCleanup err: %v\n", err)
}
fmt.Printf("ExecutionsDeleted: %d\n", stats.ExecutionsDeleted)
}