GeezerVison is showing github.com — Event store: one table for every statistic, from any source · Issue #1850 · developing-today/code
Event store: one table for every statistic, from any source #1850DescriptionRelocated from dezren39/darwin-nix#6 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).
Parent: #181
Idea
Record everything mcpx and its harness learn as events in one table, so that
any statistic is a query rather than a new code path.
Today mcpx stats has seven dimensions and mcpx stats --opencode has six,
each a hand-written query against a differently-shaped source. Adding a source
— a REST API, a hosted mcpx, a second harness — means writing that set again.
Shape
CREATE TABLE event (
id INTEGER PRIMARY KEY,
ts_unix_ms INTEGER NOT NULL,
kind_id INTEGER NOT NULL REFERENCES kind(id),
idset_id INTEGER REFERENCES idset(id), -- who/what this concerns
source TEXT NOT NULL, -- mcpx, opencode, rest, tui
value REAL, -- the number, when there is one
data TEXT -- the rest, as JSON
);
Identifier sets
The repeated shape is "this event concerns session X, whose parent is Y, in
worktree Z". Those combinations recur constantly, so interning them is both a
large space saving and what makes GROUP BY idset_id mean something.
CREATE TABLE idset (id INTEGER PRIMARY KEY, fingerprint TEXT UNIQUE);
CREATE TABLE idset_member (idset_id INTEGER, key TEXT, value TEXT,
PRIMARY KEY (idset_id, key, value));
MCPX_TRACE_IDS already carries exactly this, as pairs, with variadic entries
for aliases. The set is the natural landing place for it.
Kinds
A kind is a declared event type, so a writer cannot invent a field shape and a
reader cannot guess one.
CREATE TABLE kind (
id INTEGER PRIMARY KEY,
name TEXT UNIQUE, -- mcp.call, harness.tool, session.start
unit TEXT, -- ms, tokens, usd, count
schema TEXT -- JSON Schema for `data`
);
Open questions
- Is the schema table worth it? The variadic/required/optional machinery
sketched in the original note is a type system. It may be more than this
needs; JSON Schema on data gets most of the value for none of the design.
- Retention. Events are smaller than log lines but there are more of them.
Probably the same age-and-count rotation, but per kind.
- Does it replace
records, or sit beside it? Beside, initially. The log
index answers "what happened"; the event store answers "how much, over
time". Merging them means one of the two questions gets a worse answer.
Gap semantics (owns #181 collision 13)
Owns #181 collision 13: what a consumer of a bounded event history is told when it misses events. The
live bus (internal/events) has this problem today and the store will inherit it; #81's hooks consume
whatever is decided here rather than inventing their own.
What exists at 05c78b2:
| way to miss events |
what happens |
where |
reconnect with a since older than the retained history |
gap=true; /v1/events sends event: gap with {since, latest} in-band |
internal/events/events.go:185-187, internal/daemon/server.go:838-842 |
| a live subscriber that is not reading |
its 256-slot channel fills, the event is dropped and Dropped is incremented -- nothing outside internal/events reads Dropped, so the gap is silent |
events.go:177, :224-231, :144-147 |
| a replay longer than the channel |
SubscribeFrom replays under the bus lock into the same 256-slot channel before anyone drains it, so ?since=0 (or a Last-Event-ID more than 256 matching events back) keeps the oldest 256, silently drops the rest, then continues live |
events.go:176-199; history is events.history, default 1024 (internal/defaults/defaults.json:52, declared at internal/settings/wire.go:225, wired at server.go:165) |
The third row is a defect in shipped code, not only a design question: docs/story.md:2203-2214
("Lossless reconnection": "?since=0 replays everything retained") and the New comment
(events.go:124-129, "lets a reconnecting subscriber miss nothing") promise a reconnecting subscriber
misses nothing or is told so, and past 256 matching events it is neither. Found in the 2026-09-30 issues pass, not reproduced by running it.
A -- raise the limits. Bigger history, bigger channel. Cheap, and it moves the cliff rather than
removing it; memory grows with every subscriber and a hook pool that saturates still loses events silently.
B -- back-pressure. Let a hook subscriber block the publisher. Nothing is lost, and one slow hook stalls
every tool call, which is exactly what Publish's "never blocks" rule (events.go:203-206) exists to
prevent. Not for a bus that sits on the call path.
C -- recommended: one gap contract, three triggers. Every consumer has a seq watermark. Whenever
delivery skips -- reconnect past history, live overflow, replay truncation -- the consumer receives the same
explicit marker the SSE path already sends for the first case (gap {since, latest}), and Dropped is
reported (in the marker and per subscription in /v1/status). A consumer that sees a gap resynchronises
from state instead of trusting the stream. Replay should drain history in order without the fixed-size
channel (or mark the truncation). For #81, a hook whose worker queue overflows is a consumer with a gap and
is told so the same way; "replay hooks over history" then works from the watermark. Recommended because it
is the only option where a consumer can always tell a complete stream from an incomplete one, and it reuses
a marker that already ships.
Why it is filed rather than built
The value is entirely in having several sources to query uniformly, and there
are currently two. Building the general mechanism now means designing against
imagined sources, which is how a schema acquires fields nothing fills. Worth
doing when the third source exists and its shape is known.
The gap contract above is the exception: it is small, #81 depends on it, and one of its three cases is a
live defect, so it should not wait for the third source.
Ease · Impact · Related
Ease S for the gap contract (collision 13); M-L for the store. Impact med-high for the gap contract
(every /v1/events consumer and every #81 hook depends on it); med for the store until a third source exists.
Related: #193 (the live bus already loses replayed events past 256 without a gap marker -- the first consumer of the gap contract), #81 (hooks consume the gap contract; the store is their history), #87 (expiry events belong here),
#86 (a browser EventSource is a reconnecting subscriber), #85 (a remote TUI lives on /v1/events).
Security/auth deferred; see tracker. Activitydezren39 commented on Oct 28, 2026 History carried over from dezren39/darwin-nix#6 (verbatim, oldest first):
@dezren39 · 2026-09-30T07:28:29Z
Integration pass -- cross-theme collision. Surfaced only when the themes were put side by side; the authors of these issues could not see each other's work. Recorded at the root in #181.
events.history already answers #81's open question, and changes its design
#81 asks what keep is today. It is events.history, default 1024 (internal/defaults/defaults.json:52, wired at internal/daemon/server.go:165). That means a saturated hook pool is gapped, not merely slow, which the seq-watermark design has to handle explicitly.
Also on: #81. Nobody currently owns this.
@dezren39 · 2026-09-30T07:28:37Z
Integration pass. This issue has no category tracker -- it predates the build-out and is a dependency of several parts of it. Placed in the proposed order at #181.
@dezren39 · 2026-09-30T11:05:38Z
Collision ownership (issues pass, 2026-09-30, at 05c78b2). #181 listed these cross-theme collisions with no owner. Each now has one:
| #181 row |
Collision |
Owner |
What the owner decides |
| 13 |
events.history (default 1024) already answers #81's open question |
#6 |
A bounded history means a saturated consumer is gapped, not slow. That is a property of the event store, so #6 defines gap semantics (a seq watermark and an explicit gap marker); #81's hooks consume them. |
Where this issue is the owner, the decision is made here; where it is not, it adopts the owner's decision rather than making its own.
@dezren39 · 2026-09-30T12:11:58Z
Issues pass (2026-09-30, at 05c78b2).
- Added
Parent: #181, a footer (Ease S for the gap contract / M-L for the store; Impact med-high / med) and Related links.
- New section Gap semantics (owns Phase 3: sync, blob gate, and relays #181 collision 13). It has a table of the three ways a consumer can miss events today and A/B/C options. The recommendation is one explicit gap marker (the
event: gap {since, latest} that already ships) for all three triggers, plus a per-consumer seq watermark. chore(deps): bump stefanzweifel/git-auto-commit-action from 4 to 5 #81 consumes it.
- New defect found (not reproduced by running):
SubscribeFrom replays history under the bus lock into a 256-slot channel before anyone drains it (internal/events/events.go:176-199). A replay of more than 256 matching events therefore keeps the oldest 256 and silently drops the rest. With the default events.history of 1024, ?since=0 can lose 768 events with no marker, contradicting docs/story.md:2203-2214 and the New comment. Live overflow is also silent: Dropped is counted and never read. This is flagged to the ISSUES architect as a possible separate bug issue.
- Added the
design label.
@dezren39 · 2026-09-30T12:16:49Z
Issues pass (2026-09-30, architect follow-up). Related adds #193: /v1/events replay already loses events past a 256-slot buffer without emitting a gap (internal/events/events.go:176-199), so the gap contract this issue owns (collision 13) has a first consumer and a live bug.
@dezren39 · 2026-10-28T20:37:22Z
Triage verdict (lane A, task 2029, 2026-10-28): CONFIRMED, but deferred-by-design and no longer routable from this repo — kept open under #181.
Evidence at current HEAD:
- The mcpx source left this repo on 2026-10-19:
pkgs/mcpx was deleted (lab-ops-hub container crawler accepts inet_aton IPv4 spellings (127.1, 2130706433, 0x7f.1) — loopback SSRF bypass in validate_crawl_url #468) per planning/plans/mcpx-extraction.md; dezren39/nix now only builds mcpx from the pinned mcpx-src input (developing-today/code). No code this issue designs against exists here to cite or change.
- In the owning repo (developing-today/code @ bfcfc15) the premise still holds exactly: there is no unified
event/kind/idset table in pkgs/mcpx (tables are records, files, token_telemetry, interactions, tasks, artifacts, elicitations, …), and mcpx stats is still hand-written per dimension — CmdStats in internal/cli/logs.go with statsCalls/statsServers/statsInstances/statsErrors/statsSessions/statsVolume/statsSlowest, plus a separate statsOpencode path in internal/cli/opencode.go.
Routing:
developing-today commented on Oct 28, 2026 dezren39 commented on Oct 29, 2026 dezren39 commented on Oct 29, 2026 🤖 Agent note · done
Dedupe (explicit):
- The event store itself: no covering issue. pm stack: one cross-stack event log (actions, orchestration, sessions, comments in a single chronological stream) #1739 / design(aggregator): one activity river — a unified, filterable audit timeline across GitHub, Kaneo, sessions, and dashboard actions #1261 / External-system observability: unified PM + queue + quota attribution (webhooks, hot list, session IDs, projections) #2072 are PM-stack/aggregator-side streams, not the mcpx-internal statistics store; 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 is a logstore Correlations bug. Scope is not shrunk.
- The embedded gap-semantics defect (replay past the 256-slot channel silently drops events, contradicting the "lossless reconnection" promise): already tracked as mcpx: /v1/events replay drops everything past 256 events without a gap marker, though reconnection is documented as lossless #1914 (replay drops past 256 without a gap marker) and mcpx(events): the /v1/events resume contract silently breaks at since=0 and on a malformed since — a trimmed history reports no gap, and a bad cursor is coerced to 0 or MaxUint64 #1679 (since=0 / malformed cursor). A cross-reference comment was posted on mcpx: /v1/events replay drops everything past 256 events without a gap marker, though reconnection is documented as lossless #1914; this issue's store must consume whatever gap semantics is decided there, not invent its own.
Scope confirmed at current main (82b019a0): pkgs/mcpx/internal/events/events.go and internal/logstore/ (incl. hand-written stats.go) exist exactly as the issue describes; no event/kind/idset store exists (no matches in code search).
Routing: enqueued task 3062 — first slice only: an internal/eventstore package beside logstore (not replacing it, per the issue's own lean), event/kind/idset tables as sketched, kind registration with JSON Schema on data, idset interning, and one existing stats dimension re-expressed as a query over the store as proof. Retention, the remaining dimensions, and source adapters remain on this issue. #1850 stays open, labels reset to queue/queued.
dezren39 commented on Nov 8, 2026 🤖 Agent note · handed off
developing-today commented on Nov 8, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 8, 2026 🤖 Agent note · triage verdict (queue task 11977, lane bf419306-c4ef-470f-a553-beabf93239de, 2026-11-08)
Verdict: REAL, CURRENT, AND STILL GATED — no follow-up packet filed
Worked directly by the opencode claimant this time (the previous lanes handed task 11977 off without binding; this lane is the claimant and drives it to a terminal state).
Re-verified fresh at origin/main cc09dd4f5f. This confirms and refreshes the 2026-11-03 triage (task 7740, comment 6611814100) rather than overturning it.
What has landed
- Slice 1 — PR feat(mcpx): event store skeleton — tables, writer API, calls dimension as a query (#1850 slice 1) #2449 (merge
207b0ee3): pkgs/mcpx/internal/eventstore/ with the kind/event/idset/idset_member tables, RegisterKind JSON-Schema validation, InternIDs, Write, and CallStats() as the proof dimension.
- Gap semantics (owns Phase 3: sync, blob gate, and relays #181 collision 13) — DONE. PR mcpx: /v1/events replay drops everything past 256 events without a gap marker, though reconnection is documented as lossless #1914 (
5b472809ae, "tell a live /v1/events subscriber what it missed") shipped all three triggers: reconnect past history, live overflow, and replay truncation. daemon/server.go:1686-1700 emits event: gap with {since, latest, dropped} and /v1/status reports per-subscription Dropped. The replay-truncation defect is fixed at events.go:246-252 (channel sized for the replay, loss flagged if it ever happens). Nothing here needs re-deciding for chore(deps): bump stefanzweifel/git-auto-commit-action from 4 to 5 #81.
What has not changed (the gate)
- The store still has no producer and no consumer.
grep -rn 'internal/eventstore' --include='*.go' outside the package returns zero hits — eventstore.Open is called nowhere in shipped code. Every row in the table comes from package tests. It is not broken; it is unwired.
- Still only two stats sources: the
mcpx logstore and --opencode (cli/logs.go:442, dimensions at :478-492). No REST/hosted ingest, no TUI stats source.
- The issue's own gate is explicit: "Worth doing when the third source exists and its shape is known." A retention policy or adapter set for a table nothing writes to would be designed against no data — the exact failure mode the issue says it is avoiding.
Scoped path when the gate opens (unchanged, restated for the next pass)
- Producer first — one adapter writing real events (the
mcpx log ingest path, logstore/ingest.go, is the obvious first), behind a flag, so the schema is exercised by varying data.
- Retention/rotation — only after (1) shows the write volume; mirror logstore's age-and-count rotation, per kind.
- Remaining dimensions one at a time —
servers, instances, errors, sessions, volume, slowest, each replacing a logstore query and each proven equal on shared fixtures the way CallStats was.
Routing
No fix packet filed. Nothing in the remainder is implementable under the issue's own gate, and filing one would create work that cannot be verified. The issue stays OPEN as the tracker; priority/low and effort/l stand. Resume condition: the day a third writer appears (REST/hosted ingest or a TUI stats source), slice 1 gets a producer and steps 2-3 follow.
dezren39 commented on Nov 17, 2026 🤖 Agent note · triaged — duplicate; gate re-verified still closed (task 18144, queue repo-health-code-pilot, lane code-a)
- Pickup: claimed task 18144 this shift; fresh revalidation of issue Event store: one table for every statistic, from any source #1850 below. No held, user/owned, do-not-merge, or do-not-auto-edit labels.
- Verdict: DUPLICATE of task 11977's triage (2026-11-08, comment 6726354530, itself confirming task 7740) — REAL, CURRENT, AND STILL GATED; no follow-up packet filed, for the same reason.
- Landed (unchanged): Slice 1 — PR feat(mcpx): event store skeleton — tables, writer API, calls dimension as a query (#1850 slice 1) #2449:
pkgs/mcpx/internal/eventstore/ with the kind/event/idset/idset_member tables, RegisterKind JSON-Schema validation, InternIDs, Write, and CallStats() as the proof dimension. Gap semantics — PR mcpx: /v1/events replay drops everything past 256 events without a gap marker, though reconnection is documented as lossless #1914, all three triggers shipped.
- Gate re-checked fresh this shift (2026-11-17): the issue's own gate is "worth doing when the third source exists and its shape is known." A fresh code search for
internal/eventstore across developing-today/code returns only the package's own test file and a testing-inventory doc — the store still has no producer and no consumer in shipped code (eventstore.Open is called nowhere outside the package), and the stats sources are still the same two (the mcpx logstore and mcpx stats --opencode). No REST/hosted ingest and no TUI stats source has appeared. The gate is still closed, by the issue's own terms — a retention policy or adapter set for a table nothing writes to would be designed against no data.
- Scoped path when the gate opens (from task 11977's verdict, stands): (1) producer first — one adapter writing real events (the
mcpx log ingest path is the obvious first), behind a flag; (2) retention/rotation only after (1) shows the write volume; (3) remaining dimensions one at a time, each proven equal on shared fixtures the way CallStats was.
- Routing: no fix packet — nothing in the remainder is implementable under the issue's own gate, and filing one would create unverifiable work. Issue Event store: one table for every statistic, from any source #1850 stays OPEN as the tracker; priority/low and effort/l stand. Resume condition: the day a third writer appears (REST/hosted ingest or a TUI stats source), slice 1 gets a producer and steps 2–3 follow.
dezren39 commented on Nov 17, 2026 agent-note:v1
state: triaged
task 19590 (repo-health-code-pilot, OpenChamber scheduled lane)
Fresh repeat-triage verification, 2026-11-17: #1850 remains OPEN. rg -n "internal/eventstore|eventstore\\.Open\\(" pkgs/mcpx --glob "*.go" finds only the eventstore package tests; there is still no shipped producer or consumer. The current stats surface remains the two already recorded by task 18144. The issue’s own third-source gate remains closed, so the existing staged path and resume condition from task 18144 (#1850 (comment)) stand. No follow-on packet is implementable or needed today; this is duplicate intake, not a new scope.
Completing task 19590 as triaged; issue remains open as the gated tracker. dezren39 commented on Nov 24, 2026 🤖 Agent note · second-pass verify-and-route (task 21758, lane oc-code-04)
Fresh verification (2026-11-24 ~09:05Z): #1850 OPEN, labels enhancement + priority/low + effort/l + epic/pm-stack, no hard-stop labels. Slice 1 (PR #2449) and gap semantics (PR #1914) still landed and unchanged. Fresh code search: internal/eventstore is referenced only by the package's own test file — still no shipped producer or consumer (eventstore.Open called nowhere in shipped code). Stats sources still the same two (mcpx logstore, --opencode). The issue's own third-source gate is still closed.
Verdict: duplicate of triages 11977 / 18144 / 19590 — REAL, CURRENT, AND STILL GATED. No new packet. Issue stays OPEN as tracker; resume when a third writer appears.
developing-today-fleet commented on Nov 26, 2026 🤖 Agent note · coverage-triage refresh (task 24939, lane code-f)
Fresh check (2026-11-26): #1850 remains OPEN and the latest substantive triage (task 21758, 2026-11-24) still matches current HEAD. confirms the only calls in shipped Go sources are in ; the store still has no production producer or consumer. PR #2449 delivered only the first slice, and the gap-semantics defect is separately resolved by #1914/#1679. The issue's own gate—wait until a third statistics source exists—remains the stated resume condition; existing triage also records the producer → retention → remaining dimensions order.
Verdict: duplicate coverage intake; no new fix packet or duplicate queue work is warranted while that gate remains closed. Keep #1850 open as the tracker and resume when a third writer/source appears. No code changed.
developing-today-fleet commented on Nov 26, 2026 🤖 Agent note · correction to coverage-triage refresh (task 24939, lane code-f)
The previous comment's shell quoting stripped the inline-code spans; the intended finding is: as of 2026-11-26, #1850 remains OPEN and the latest substantive triage (task 21758, 2026-11-24) still matches current HEAD. git grep confirms the only eventstore.Open calls in shipped Go sources are in internal/eventstore/eventstore_test.go; the store still has no production producer or consumer. PR #2449 delivered only the first slice, and the gap-semantics defect is separately resolved by #1914/#1679. The issue's own gate—wait until a third statistics source exists—remains the stated resume condition; existing triage also records the producer → retention → remaining dimensions order.
Verdict: duplicate coverage intake; no new fix packet or duplicate queue work is warranted while that gate remains closed. Keep #1850 open as the tracker and resume when a third writer/source appears. No code changed.
developing-today-fleet commented on Nov 27, 2026
Triage verdict (lane any-o, task 25441): duplicate coverage intake; no new implementation packet. The latest revalidation on #1850 (task 24939, 2026-11-27) confirms the prior substantive triage (task 21758) still matches: eventstore.Open has no production producer/consumer; PR #2449 delivered only the first slice; gap semantics are handled separately by #1914/#1679. The issue's own gate remains closed until a third statistics source/writer exists. Keep #1850 OPEN as the tracker and resume when that gate changes. No code changes or duplicate packet created.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|