Skip to content

[ponytail] Web server: delete dead SSE subsystem, route map, graph-queries dedupe #122

Closed

Description

@devinmlowe

Cut

Server-side half of the visualizer: routing, data queries and the dead SSE subsystem.

Findings

  • delete: the whole SSE subsystem. No page opens an EventSource; all four views poll /api/diff every 1.5 s (verified with rg EventSource across the repo: only a comment in auth-gate.ts, the unit test and a phase-4 plan doc). Drop src/interfaces/web/routes/sse.ts, handleGraphEvents, the two /api/events routes, getSseClientCount and the broadcastUpdate(db) call in the WAL watcher; keep the watcher for its two cache resets (~75 lines). Update the "Real-time SSE updates" lines in CLAUDE.md and README.md.
  • stdlib: the 138-line if (pathname === ... || pathname === ...) chain plus seven one-line handler modules that all do writeHead(200, JSON_HEADERS); end(JSON.stringify(fn(db))) (src/interfaces/web/server.ts:118, routes/graph.ts:17, routes/words.ts:9). A Map<string, (db, url) => unknown> for JSON routes and a Map<string, string> for pre-rendered pages with one generic responder (~100 lines).
  • delete: route aliases nothing requests: /api/diff, /depth/api/diff, /depth/api/threshold, /api/dream/status, /api/dream/start, /api/words, /words/api/words, /graph/api/health (verified by rg over every fetch(, Invoke-* and curl in the repo). Keep the prefixes the templates call plus /api/health for the supervisor probe (~14 lines). Re-verify scripts/*.ps1 and scripts/*.sh health probes before removing any /health alias.
  • shrink: getGraphData is getDepthGraphData minus lastActive / bridgeScore (src/interfaces/web/data/graph-queries.ts:69). Serve the depth payload everywhere; consumers ignore extra fields and terminal/graph.html.ts already reads the two fields it never receives (~50 lines).
  • shrink: getGraphDiff runs the same six-column SELECT twice with a different predicate (graph-queries.ts:215, ~20 lines).
  • shrink: computeOptimalThreshold's fallback re-runs both count queries (graph-queries.ts:190, ~16 lines).
  • delete: isDreamRunning (src/interfaces/web/routes/dream.ts:33), zero importers.
  • yagni: src/interfaces/web/paths.ts (returns loadConfig().dbPath), src/interfaces/web/bind.ts (two-key env lookup) and resolveDreamLogPath in routes/dream.ts:23 (identical to src/dream/daemon.ts:50, with a contract test asserting the copies agree). Inline the first two, import the daemon's function for the third and delete that contract test (~40 lines).

Verification

npm run build and npm run test:run green before and after. Start the server on a spare port with the real database read-only and curl every route the four page templates and the terminal pages call; every one returns the same status and JSON shape as before (capture before, diff after).

Activity

  1. added
    sub-issueChild task of a parent issue
    ponytailOver-engineering audit cut (2026-09-20)
    on Sep 21, 2026
  2. devinmlowe commented on Sep 21, 2026

    @devinmlowe
    OwnerAuthor

    PR: #131 (branch ponytail/web-server, origin/main merged in).

    Tests: main baseline 134 files / 1750 tests → 132 / 1744. Removed: tests/core/sse-broadcast.test.ts (1), tests/core/server-bind.test.ts (4), and the web-route/web-server cases of tests/contracts/data-paths.test.ts (1; the daemon-resolver cases stay). Build clean.

    All eight findings implemented; nothing skipped. /depth/api/graph (unlisted sibling of the two listed /depth/api/* aliases, also unreferenced) went too. Route capture before/after on port 3199 against the real DB is in the PR: every template-called route is byte-identical in status and key shape except /graph/api/graph and /api/graph, which now carry the depth payload's bridgeScore / lastActive (intended); the ten unrequested aliases return 404.

  3. added a commit that references this issue on Sep 21, 2026
  4. devinmlowe commented on Sep 21, 2026

    @devinmlowe
    OwnerAuthor

    Merged PR #131 into main with --no-ff (commit 549ba8f). Post-merge on main: build clean, 132 test files / 1744 tests passing (was 134 / 1750; the 6 dropped cases covered the deleted SSE, bind and web-path code). Live visualizer on 3001 still runs the previous build; restart it when convenient to pick up the route changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ponytailOver-engineering audit cut (2026-09-20)sub-issueChild task of a parent issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions