GeezerVison is showing github.com — mcpx(logstore): Correlations counts record cross-products, not sessions — the dashboard renders '7 sessions' for a pair that co-occurs in 2, and any Query filter fails with an ambiguous-column error · Issue #1695 · developing-today/code
mcpx(logstore): Correlations counts record cross-products, not sessions — the dashboard renders '7 sessions' for a pair that co-occurs in 2, and any Query filter fails with an ambiguous-column error #1695Labels app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionSummary
logstore.Correlations (pkgs/mcpx/internal/logstore/stats.go:539-570) counts record pairs, not sessions — but the dashboard renders its count as a session count. One busy session inflates a pair's "sessions" by the product of the two tools' call counts. The same method also breaks outright when called with an ordinary Query filter, because it splices the shared unqualified where() conditions into a self-join.
Evidence (verified this run)
Line trace, stats.go:
- :548-556 — the query self-joins
records a JOIN records b ON a.session = b.session with a.tool < b.tool and selects count(*) AS cnt. For a session where tool A was called m times and tool B n times, the join produces m × n rows for that session, and count(*) sums those products across sessions.
- The consumer, internal/dashboard/dashboard.html:260-267, titles the table "Correlated Tool Pairs (Co-Occurring in Sessions)" with a "Co-Occurrences" column, and :415 renders each row as
`<strong>${cr.count}</strong> sessions` — the count is presented to the reader as a number of sessions.
- The only production caller is internal/daemon/routes_dashboard.go:52 (
st.Correlations(logstore.Query{}, 20)), feeding /v1/metrics/tools.
- :549-551 — when
q.where() is non-empty, its conditions are appended verbatim (AND + the trimmed where). Those conditions name unqualified columns (server = ?, level IN (...), ts_unix_ms >= ?, …), which are ambiguous between a and b in a self-join. Sibling stats methods (Calls, Servers, Sessions, Slowest, Timeline) all accept filtered queries against a single table, so Correlations silently having a different, broken contract is a trap for the next caller (e.g. wiring it into the daemon ops path the way Sessions/Slowest are used in internal/daemon/ops.go:241-251).
Laptop probe (real internal/logstore package, detached worktree at origin/main a2f85d9; stats.go sha256 cd723454, identical to the sandbox clone; probe + log in the goal's hidden_files/probe-2026-10-28-laneA-corr/):
Fixture: session s1 calls alpha ×3 and beta ×2; session s2 calls alpha ×1, beta ×1, gamma ×1.
- BUG-A:
Correlations(Query{}, 20) returns alpha/beta count=7 (3×2 + 1×1). The dashboard would render "7 sessions"; alpha and beta actually co-occur in 2 sessions.
- Controls: alpha/gamma = 1 and beta/gamma = 1 (one call each in one session — the shapes where the product happens to equal the session count).
- BUG-B:
Correlations(Query{Server: "fff"}, 20) returns SQL logic error: ambiguous column name: server (1) instead of filtered rows.
- Baseline: with the probe removed, the full existing internal/logstore suite passes on the same tree. No existing test calls Correlations (grep: only feedback_test.go mentions "correlation" for a different check, and routes_dashboard_test.go only asserts the JSON field is non-nil with an empty store).
Why it matters
The dashboard's correlations table is the "which tools are used together" signal for the fleet. As written it ranks pairs by how often the tools were called in shared sessions, squared-ish — a chatty session dominates — while labelling the number "sessions", so the reader cannot tell 7 sessions from 1 session with 7 pair-products. Any future filtered use (per-server, per-window) fails with a raw SQL error instead of results.
Acceptance criteria
- The count for a tool pair equals the number of distinct sessions in which both tools were called (e.g.
COUNT(DISTINCT a.session) or an equivalent per-session dedup), so the probe fixture above yields alpha/beta = 2, alpha/gamma = 1, beta/gamma = 1 — or the dashboard copy is changed to honestly name what is counted, with the semantics pinned by a test. (Session count is the recommended reading: it matches the existing dashboard copy.)
-
Correlations with a filtered Query (at minimum Server, Since/Until, Level) returns filtered results instead of an ambiguous-column SQL error — the where conditions are qualified/deduplicated for the self-join, and bound arguments stay in step with the placeholders.
- Regression tests in internal/logstore cover: repeated calls of both tools in one session, the pair across multiple sessions, and a filtered query.
- Existing internal/logstore and internal/daemon dashboard tests keep passing.
Notes for triage
Activitydeveloping-today commented on Oct 28, 2026 added kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo) effort/sSmall: expected under 2 hours of work on Oct 28, 2026dezren39 commented on Oct 28, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (lane A, new-issue-creator-code-a)
- Session / ID: cron new-issue-creator-code-a, run 2026-10-28 09:35 CDT
- Found via: filed this run
- Task: Triage the Correlations counting/filter defects: the dashboard's "N sessions" is a record cross-product, and a filtered Query errors on ambiguous columns.
- Expectation: effort/s — done when the count is a distinct-session count (or the copy honestly renames it), filtered queries work, and regression tests pin both.
- Links: evidence and probe in the issue body; probe + log in the goal's hidden_files/probe-2026-10-28-laneA-corr/
dezren39 commented on Oct 31, 2026 🤖 Agent note · parked
- Agent: queue worker (repo-worker-code), lane A
- Session / ID: queue task 4255, repo-queue-worker-shift 2026-10-31 08:24 CDT
- Found via: queue claim (resume)
- Task: Parked 20m — PR fix(mcpx): logstore Correlations counts distinct sessions, filtered queries work (#1695) #3063 is merge-ready except the final: CI time budget job, still pending after the 5-minute poll window (run 41205293416). Everything else verified fresh this shift: stress PASS 3m24s, lint PASS, plugin PASS, docs build PASS, Codex review COMPLETED with no findings on head 3f63674.
- Expectation: resume — budget green → merge → close mcpx(logstore): Correlations counts record cross-products, not sessions — the dashboard renders '7 sessions' for a pair that co-occurs in 2, and any Query filter fails with an ambiguous-column error #1695 → complete fixed_merged. No other work remains on this PR.
- Links: PR fix(mcpx): logstore Correlations counts distinct sessions, filtered queries work (#1695) #3063 @3f6367402
dezren39 commented on Oct 31, 2026 🤖 Agent note · picked up (resume)
dezren39 commented on Oct 31, 2026
MetadataMetadataapp/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|