Skip to content

feat: Session Bus — real-time cross-session heartbeat registry#470

Closed
creandoaldia wants to merge 1 commit into
Gentleman-Programming:mainfrom
creandoaldia:main
Closed

feat: Session Bus — real-time cross-session heartbeat registry#470
creandoaldia wants to merge 1 commit into
Gentleman-Programming:mainfrom
creandoaldia:main

Conversation

@creandoaldia

Copy link
Copy Markdown

What

Adds a Session Bus layer for real-time cross-session awareness. Sessions send periodic heartbeats with task descriptions, and Engram tracks active sessions with a 2-minute staleness window.

How it works

Each coding session sends a heartbeat on every tool call (throttled to 30s):
\
POST /sessions/{id}/heartbeat → returns list of other active sessions
\\

Other sessions can query the bus:
\
GET /sessions/active?project=X → all sessions with recent heartbeats
\\

Stale sessions (no heartbeat in 2 min) are auto-cleaned on every read.

Changes

Store (store.go)

  • \session_heartbeats\ table (session_id, project, current_task, status_blob, last_seen)
  • \ActiveSession\ struct
  • 5 methods: \UpsertHeartbeat, \UpdateSessionStatus, \CleanStaleHeartbeats, \ActiveSessions\

MCP (mcp.go) — 3 new tools (agent profile, 22 total)

  • \mem_session_heartbeat\ — send heartbeat + receive active sessions list
  • \mem_session_status\ — store detailed JSON status blob
  • \mem_active_sessions\ — read-only list of active sessions

HTTP (server.go) — 3 new endpoints

  • \POST /sessions/{id}/heartbeat\
  • \POST /sessions/{id}/status\
  • \GET /sessions/active?project=X\

Dependencies

Zero. No new imports, no new services, no Redis, no WebSocket. Pure SQLite + existing REST API.

Companion PRs

Add Session Bus layer for inter-session awareness:
- session_heartbeats table in SQLite (session_id, project, current_task,
  status_blob, last_seen) with 2-min staleness window
- 3 new MCP tools: mem_session_heartbeat, mem_session_status,
  mem_active_sessions (agent profile, 22 total tools)
- 3 HTTP endpoints: POST /sessions/{id}/heartbeat,
  POST /sessions/{id}/status, GET /sessions/active
- ActiveSession struct and 5 store methods (UpsertHeartbeat,
  UpdateSessionStatus, CleanStaleHeartbeats, ActiveSessions)
- Heartbeats auto-cleaned on every read via datetime('now', '-120 seconds')

Enables sessions to know what other sessions are working on in real time.
No new dependencies. Fully Go-first, zero external services.
@Alan-TheGentleman

Copy link
Copy Markdown
Collaborator

Closing this because it introduces a new Session Bus architecture without an approved issue or design discussion. This changes Engram's runtime coordination model through store tables, MCP tools, and HTTP endpoints, so it needs a real proposal first. Open an issue describing the problem, the intended contract, and the tradeoffs, then we can discuss whether this belongs in Engram before any PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants