---
id: 10726
title: Disconnect-triggered summarization wiring
state: CLOSED
labels:
  - enhancement
  - ai
  - architecture
assignees:
  - neo-gemini-pro
createdAt: '2026-05-04T22:13:51Z'
updatedAt: '2026-05-15T12:46:10Z'
githubUrl: 'https://github.com/neomjs/neo/issues/10726'
author: neo-gemini-pro
commentsCount: 0
parentIssue: 10721
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking: []
closedAt: '2026-05-05T06:59:02Z'
---
# Disconnect-triggered summarization wiring

## Context
For the Shared Deployment MVP (#10721), the summarization coordinator primitive (`claimSummarizationJob`) was shipped in #10693. However, the automated trigger that invokes this coordinator when a client disconnects is missing.

## The Problem
Without a disconnect trigger, session summarization relies on manual invocation or out-of-band cron jobs. To provide a seamless team-shared deployment, the Memory Core must automatically queue and process session summaries when an agent disconnects (indicating session completion or suspension).

## The Architectural Reality
This requires bridging MCP client-disconnect events and the `claimSummarizationJob` coordinator. It necessitates introducing a "session completion" marker concept (a data shape, a writer, and a detector) to safely transition sessions from active to summarizable.

## The Fix
Wire the MCP disconnect event to a trigger mechanism. Define the "session completion" marker data shape. Implement the detector that invokes the `claimSummarizationJob` coordinator upon detecting a completion/disconnect marker. The coordinator handles concurrency; this task provides the missing trigger.

## Contract Ledger Matrix

| Target Surface | Source of Authority | Proposed Behavior | Fallback | Docs | Evidence |
|---|---|---|---|---|---|
| Disconnect Trigger | MCP Server Lifecycle | Write "session completion" marker on client disconnect and queue summarization job. | If write fails, rely on standard periodic sweep (if implemented) or manual purge. | Update `learn/agentos/SharedDeployment.md` | L3 (Integration test verifying summarization queued on disconnect event) |

## Acceptance Criteria
- [ ] Define and implement "session completion" marker data shape.
- [ ] Wire MCP client-disconnect event to write the completion marker.
- [ ] Implement detector that triggers `claimSummarizationJob` upon marker write.
- [ ] Coordinate cleanly with `SummarizationJobs` primitive (#10693) without re-architecting it.

## Out of Scope
- Modifying the underlying TTL-lease and atomic SQLite transactions of the coordinator (already shipped).

## Avoided Traps
- **Rejected: Immediate synchronous summarization on disconnect.** Summarization can be slow. The trigger must queue the job for the asynchronous coordinator rather than blocking the disconnect lifecycle.

## Related
- Parent Epic: #10721
- Substrate primitive: #10693

Origin Session ID: 79042442-bebc-431d-8968-8a2e7d7a1151
Retrieval Hint: `query_raw_memories(query="Disconnect-triggered summarization wiring claimSummarizationJob marker")`

## Timeline

- 2026-05-04T22:13:52Z @neo-gemini-pro added the `enhancement` label
- 2026-05-04T22:13:52Z @neo-gemini-pro added the `ai` label
- 2026-05-04T22:13:53Z @neo-gemini-pro added the `architecture` label
- 2026-05-04T22:14:08Z @neo-gemini-pro added parent issue #10721
- 2026-05-04T22:20:06Z @neo-gemini-pro assigned to @neo-gemini-pro
- 2026-05-04T22:49:47Z @neo-gemini-pro cross-referenced by PR #10731
- 2026-05-04T22:55:09Z @neo-gemini-pro referenced in commit `29dba69` - "fix(memory-core): respect autoSummarize config gate for queueSummarizationJob (#10726)"
- 2026-05-04T23:08:14Z @neo-gemini-pro referenced in commit `dc7a84c` - "style(memory-core): fix trailing whitespaces and add missing JSDocs (#10726)"
- 2026-05-04T23:08:14Z @neo-gemini-pro referenced in commit `bdf43be` - "test(memory-core): add test coverage for onSessionClosed (#10726)

Adds unit tests for Server.onSessionClosed to ensure SessionService.queueSummarizationJob is properly invoked.
Also protects the setupRequestHandlers method against cases where the MCP Server instance was destroyed during async boot."
- 2026-05-04T23:14:16Z @neo-gemini-pro referenced in commit `ffe8b86` - "test(memory-core): add trigger-path test and fix trailing whitespace (#10726)

Includes documentation updates and JSDoc summaries."
- 2026-05-04T23:25:18Z @neo-gemini-pro referenced in commit `617f016` - "test(memory-core): add trigger-path test and fix trailing whitespace (#10726)

Includes documentation updates and JSDoc summaries."
- 2026-05-04T23:30:53Z @neo-gemini-pro referenced in commit `12eaeef` - "test(memory-core): add trigger-path test and fix trailing whitespace (#10726)

Includes documentation updates and JSDoc summaries."
- 2026-05-05T06:59:02Z @tobiu referenced in commit `11d0f13` - "feat(memory-core): wire disconnect-triggered summarization (#10726) (#10731)

* feat(memory-core): wire disconnect-triggered summarization (#10726)

* fix(memory-core): respect autoSummarize config gate for queueSummarizationJob (#10726)

* style(memory-core): fix trailing whitespaces and add missing JSDocs (#10726)

* test(memory-core): add test coverage for onSessionClosed (#10726)

Adds unit tests for Server.onSessionClosed to ensure SessionService.queueSummarizationJob is properly invoked.
Also protects the setupRequestHandlers method against cases where the MCP Server instance was destroyed during async boot.

* test(memory-core): add trigger-path test and fix trailing whitespace (#10726)

Includes documentation updates and JSDoc summaries.

---------

Co-authored-by: neo-gemini-pro <neo-gemini-pro@users.noreply.github.com>"
- 2026-05-05T06:59:02Z @tobiu closed this issue
- 2026-05-05T07:06:29Z @neo-opus-ada cross-referenced by PR #10730
- 2026-05-05T18:15:00Z @neo-gpt cross-referenced by #10721
- 2026-05-05T18:15:46Z @neo-gpt cross-referenced by #10724

