Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 7 additions & 30 deletions cmd/context-guru-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"net/http"
"os"
"os/signal"
"path/filepath"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -206,11 +205,15 @@ func main() {
"hosted mode: max in-flight requests per tenant (0 = unlimited)")
cheapConcurrent = flag.Int("cheap-model-concurrent", envInt("CHEAP_MODEL_CONCURRENT", 4),
"process-wide cap on concurrent compaction-model calls, so one tenant's extract_llm cannot stall everyone's agents (0 = unlimited)")

dashBench = flag.String("dashboard-bench-dirs", envOr("DASHBOARD_BENCH_DIRS", ""),
"comma-separated directories of benchmark runs (each with summary.json + rows-*.json) to ingest")
// The Benchmarks tab is gone. The flag stays as a no-op so an existing unit file or
// environment that still passes it starts instead of exiting on an unknown flag.
dashBenchIgnored = flag.String("dashboard-bench-dirs", envOr("DASHBOARD_BENCH_DIRS", ""),
"deprecated and ignored: the dashboard no longer has a Benchmarks tab")
)
flag.Parse()
if *dashBenchIgnored != "" {
slog.Warn("--dashboard-bench-dirs / DASHBOARD_BENCH_DIRS is ignored: the dashboard no longer has a Benchmarks tab")
}

// --version before anything else: an installer asks a binary what it is, and it must be
// able to ask without starting a server or needing a config. buildinfo.Version was already
Expand Down Expand Up @@ -327,7 +330,6 @@ func main() {
QueueSize: *dashQueue,
LifecycleSignals: *dashLifecycle,
TrustedCIDRs: splitComma(*dashCIDRs),
BenchDirs: splitComma(*dashBench),

DiskHighWatermark: *dashDiskHigh,
DiskLowWatermark: *dashDiskLow,
Expand Down Expand Up @@ -379,31 +381,6 @@ func main() {
} else {
slog.Info("dashboard: recovered session recency across the restart", "sessions", n)
}
if runs, tasks := rec.DB().IngestBenchRoots(opts.BenchDirs); runs > 0 {
slog.Info("dashboard: ingested benchmark runs", "runs", runs, "tasks", tasks)
} else if len(opts.BenchDirs) > 0 {
// Asked to ingest and found nothing. Say so: ingestion runs ONCE at startup,
// so a silent zero means the Benchmarks tab stays empty forever with no clue
// why, and the most likely cause is invisible from inside the process.
//
// That cause is PrivateTmp. The shipped unit sets PrivateTmp=true, so the
// service gets its OWN empty /tmp — a directory that plainly exists in the
// operator's shell is simply not there for this process. Pointing
// DASHBOARD_BENCH_DIRS at /tmp/<anything> therefore looks correct, changes
// nothing, and reports nothing. Naming the path we actually looked at is what
// makes that diagnosable in one glance at the log.
hint := ""
for _, d := range opts.BenchDirs {
if strings.HasPrefix(filepath.Clean(d), "/tmp/") {
hint = "a /tmp path is NOT visible to this process when the unit sets " +
"PrivateTmp=true; copy the run directory somewhere readable " +
"(e.g. under the state dir) and point DASHBOARD_BENCH_DIRS there"
break
}
}
slog.Warn("dashboard: no benchmark runs ingested; the Benchmarks tab will be empty",
"dirs", strings.Join(opts.BenchDirs, ","), "hint", hint)
}
slog.Info("dashboard enabled", "url", "http://"+addr+"/dashboard/", "db", rec.DB().Path(),
"content_capture", *dashContent)
}
Expand Down
45 changes: 5 additions & 40 deletions dash/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"net"
"net/http"
Expand Down Expand Up @@ -333,7 +334,10 @@ func (a *API) serveJSON(w http.ResponseWriter, r *http.Request, c *jsonCache, ke
// Detaching it means the result is always cached even if nobody is left to receive it, so the
// next reader gets a hit rather than starting again. Each caller still gets its own deadline
// from the handler timeout, which is what bounds THEIR wait; this bounds the WORK.
v, err, _ := a.jsonInflight.Do(key, func() (any, error) {
// The flight key names the CACHE as well as the entry: /api/stats and /api/tools, for one account and
// the same filters, have the same entry key, and two concurrent requests for them collapsed onto one
// computation, so /api/stats answered with the tools report.
v, err, _ := a.jsonInflight.Do(fmt.Sprintf("%p\x00%s", c, key), func() (any, error) {
ctx, cancel := context.WithTimeout(context.Background(), dashComputeTimeout)
defer cancel()
body, err := compute(a.rec.DB().WithContext(ctx))
Expand Down Expand Up @@ -651,8 +655,6 @@ func (a *API) routes() []route {
{"GET /api/breakdown", scopeTenant, a.breakdown},
{"GET /api/facets", scopeTenant, a.facets},
{"GET /api/config", scopeManager, a.config},
{"GET /api/benchmarks", scopeManager, a.benchmarks},
{"GET /api/benchmarks/{id}/tasks", scopeManager, a.benchmarkTasks},
{"GET /api/capture", scopeTenant, a.capture},
{"GET /api/whoami", scopePublic, a.whoamiHandler},
{"GET /api/archive", scopeTenant, a.archive},
Expand Down Expand Up @@ -1586,43 +1588,6 @@ func (a *API) config(w http.ResponseWriter, r *http.Request) {
writeJSON(w, body)
}

// benchmarks lists ingested harbor runs. A MANAGER view in hosted mode: the runs are
// the operator's own eval history, not any tenant's traffic — and ?refresh=1 walks the
// filesystem and inserts rows, which unauthenticated is a writer denial of service
// anyone can repeat.
func (a *API) benchmarks(w http.ResponseWriter, r *http.Request) {
if !a.requireManager(w, r, "benchmark runs") {
return
}
if r.URL.Query().Get("refresh") == "1" {
// The DIRS go back with the counts. Without them a re-scan of a mistyped path and a
// correct scan of an empty directory are the same response — and the UI reported both
// as "nothing happened" because it discarded the body entirely.
dirs := a.rec.Opts().BenchDirs
runs, tasks := a.db(r).IngestBenchRoots(dirs)
writeJSON(w, map[string]any{"ingested_runs": runs, "ingested_tasks": tasks, "dirs": dirs})
return
}
runs, err := a.db(r).BenchRuns()
if err != nil {
httpErr(w, http.StatusInternalServerError, err.Error())
return
}
writeJSON(w, map[string]any{"runs": runs})
}

func (a *API) benchmarkTasks(w http.ResponseWriter, r *http.Request) {
if !a.requireManager(w, r, "benchmark runs") {
return
}
rows, err := a.db(r).BenchTasks(atoi64(r.PathValue("id")), r.URL.Query().Get("arm"))
if err != nil {
httpErr(w, http.StatusInternalServerError, err.Error())
return
}
writeJSON(w, map[string]any{"tasks": rows})
}

// capture reports the capture pipeline's own health, drops included. Exposed as a
// first-class endpoint (and rendered in the UI) because a dashboard that hides its
// own coverage gaps cannot be trusted about anything else.
Expand Down
Loading
Loading