Skip to content

Create GlobalSessionRegistry for centralized session storage#766

Closed
cyrusagent wants to merge 3 commits intomainfrom
cypack-725
Closed

Create GlobalSessionRegistry for centralized session storage#766
cyrusagent wants to merge 3 commits intomainfrom
cypack-725

Conversation

@cyrusagent
Copy link
Copy Markdown
Contributor

@cyrusagent cyrusagent commented Jan 16, 2026

Summary

Implements Phase 1 of CYPACK-724 architectural refactor. Creates a new GlobalSessionRegistry class that centralizes session storage across all repositories, enabling cross-repository session lookups for orchestrator workflows.

Currently, sessions are stored per-repository in AgentSessionManager. When a parent orchestrator in Repository A creates a child issue in Repository B, the child cannot find the parent session because sessions are siloed. The GlobalSessionRegistry solves this by owning ALL CyrusAgentSession objects globally.

Implementation

Core Features

  • Session CRUD operations: createSession, getSession, updateSession, deleteSession, getAllSessions
  • Entry management: addEntry, getEntries, updateEntry for conversation history
  • Parent-child mapping: setParentSession, getParentSessionId, getChildSessionIds for orchestrator workflows
  • EventEmitter lifecycle events: sessionCreated, sessionUpdated, sessionCompleted
  • Serialization: serializeState, restoreState with v3.0 format for persistence
  • Cleanup: cleanup(maxAgeMs) to remove old sessions

Data Structures

  • sessions: Map<string, CyrusAgentSession> - all sessions keyed by session ID
  • entries: Map<string, CyrusAgentSessionEntry[]> - all entries keyed by session ID
  • childToParentMap: Map<string, string> - child session ID → parent session ID

Testing

Comprehensive unit tests with 45 test cases covering:

  • Session CRUD operations (15 tests)
  • Entry management (10 tests)
  • Parent-child mapping (6 tests)
  • Serialization/deserialization (5 tests)
  • Cleanup functionality (5 tests)
  • Edge cases (4 tests)

All tests passing ✅

Files Changed

  • Created: packages/edge-worker/src/GlobalSessionRegistry.ts - Main implementation
  • Created: packages/edge-worker/test/GlobalSessionRegistry.test.ts - Comprehensive tests
  • Modified: packages/edge-worker/src/index.ts - Export GlobalSessionRegistry and types
  • Modified: CHANGELOG.internal.md - Document internal changes

Migration Notes

This is Phase 1 of the refactor - introducing the class with full functionality and tests. Future phases will:

  1. Integrate GlobalSessionRegistry with EdgeWorker
  2. Update AgentSessionManager to use GlobalSessionRegistry
  3. Remove per-repository session storage

No breaking changes in this PR - the new class is isolated and not yet integrated.

Closes CYPACK-725

cyrusagent and others added 2 commits January 15, 2026 22:13
…YPACK-725)

Implements Phase 1 of CYPACK-724 architectural refactor. Creates new
GlobalSessionRegistry class that centralizes session storage across all
repositories, enabling cross-repository session lookups for orchestrator
workflows.

Key features:
- Session CRUD operations (create, get, update, delete, getAll)
- Entry management (add, get, update entries)
- Parent-child session mapping for orchestrator workflows
- EventEmitter with lifecycle events (sessionCreated, sessionUpdated, sessionCompleted)
- Serialization/deserialization (v3.0 format)
- Cleanup method for removing old sessions
- Comprehensive unit tests (45 tests)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add changelog entry for GlobalSessionRegistry implementation with PR link.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@cyrusagent cyrusagent marked this pull request as ready for review January 16, 2026 06:15
Fix TypeScript error in updateEntry method by ensuring type and content
fields are never undefined when applying partial updates.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@cyrusagent
Copy link
Copy Markdown
Contributor Author

Closing - work merged into final PR #773

@cyrusagent cyrusagent closed this Jan 16, 2026
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.

1 participant