refactor: remove sessionRepositories and activitySinks maps; add issueTrackers TODOs (CYPACK-968)#992
refactor: remove sessionRepositories and activitySinks maps; add issueTrackers TODOs (CYPACK-968)#992cyrusagent wants to merge 7 commits into
Conversation
…K-968) Delete the redundant sessionRepositories: Map<string, string> from EdgeWorker, replacing all ~14 usage sites with direct reads from session.repositories[0]?.repositoryId. The reverse-lookup in repo deletion now uses session.repositories.some() which is more correct for multi-repo sessions. Also adds TODO comments documenting: - activitySinks multi-workspace limitation for cross-workspace sessions - issueTrackers composite key needed for multi-platform support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…PACK-968) Change activitySinks from Map<repoId, sink> to Map<workspaceId, sink>. This eliminates redundant sink instances (one per workspace instead of one per repo), decouples the lookup from which repo is "primary", and makes the data model honest about what it represents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
LinearActivitySink is a thin, stateless wrapper around IIssueTrackerService. Instead of maintaining a pre-built map, create sinks on-the-fly at session registration time via createActivitySink() helper. Falls back to NoopActivitySink when no issue tracker is available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| const allActiveSessions = this.agentSessionManager.getActiveSessions(); | ||
| const activeSessions = allActiveSessions.filter( | ||
| (s) => this.sessionRepositories.get(s.id) === repo.id, | ||
| const activeSessions = allActiveSessions.filter((s) => | ||
| s.repositories.some((r) => r.repositoryId === repo.id), | ||
| ); |
There was a problem hiding this comment.
This is also wrong now that CYPACK-911 has been merged. There is no longer a requirement for sessions to be linked to repos, now that we have support for surfaces like Slack. This will also need to be changed once multi-repo support is added
| const repoId = this.sessionRepositories.get(childSessionId); | ||
| const childSession = | ||
| this.agentSessionManager.getSession(childSessionId); | ||
| const repoId = childSession?.repositories[0]?.repositoryId; |
There was a problem hiding this comment.
This will need to change once multi-repo session support is added. handleResumeParentSession should not require the repo now that CYPACK-911 has been merged. I presume it's needed to build the allowed tools for the session, but the repo config itself should not be passed to this method.
| const repoId = this.sessionRepositories.get(sessionId); | ||
| const repoId = session.repositories[0]?.repositoryId; |
There was a problem hiding this comment.
Same thing with this.
| const repoId = this.sessionRepositories.get(sessionId); | ||
| const repoId = session.repositories[0]?.repositoryId; |
|
@cyrusagent look at the comments left on this PR as review and address them |
|
This repository is not configured with Cyrus. Please add it at https://app.atcyrus.com/repos to start using Cyrus here. |
1 similar comment
|
This repository is not configured with Cyrus. Please add it at https://app.atcyrus.com/repos to start using Cyrus here. |
|
I can't connect to your local environment because the Cyrus process isn't running. Run |
|
This repository is not configured with Cyrus. Please add it at https://app.atcyrus.com/repos to start using Cyrus here. |
1 similar comment
|
This repository is not configured with Cyrus. Please add it at https://app.atcyrus.com/repos to start using Cyrus here. |
…internally (CYPACK-968) Move repo resolution out of event handler callbacks and into the handler methods themselves via a new resolveSessionRepo helper. This removes the requirement for sessions to be linked to repos at the call site, aligning with CYPACK-911 where sessions can exist without repos (e.g. Slack surfaces). Also adds multi-repo TODOs for removeDeletedRepositories and the helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pushed. Here's a summary of the changes addressing all 4 review comments:
All changes use a new |
| @@ -363,21 +346,12 @@ export class EdgeWorker extends EventEmitter { | |||
| this.agentSessionManager.on( | |||
| "validationLoopIteration", | |||
| async ({ sessionId, session, fixerPrompt, iteration, maxIterations }) => { | |||
| const repoId = this.sessionRepositories.get(sessionId); | |||
|
@cyrusagent merge main into this and then find out which of the changes we were trying to make in this PR are still relevant |
|
I aborted the merge attempt — it would require substantial rework rather than mechanical conflict resolution. Here's the assessment: Merge outcome13 conflicts in PR's 3 stated goals — still relevant
But the implementation is staleOf the 6 PR commits, 4 touched code that main deleted in CYPACK-996 (PR #1018, skills refactor):
Related work already on mainCommit RecommendationClose this PR and redo the refactor fresh against current main. The goals still hold, but >50% of the diff targets deleted code, and the new code on main (push webhooks, issue-state-change, GitLab, warm sessions) has its own Want me to proceed with a fresh refactor commit on this branch, or close the PR? |
Resolves conflicts in CHANGELOG.internal.md (kept both CYPACK-968 and CYPACK-1101 entries) and EdgeWorker.ts. EdgeWorker.ts conflict resolution: - Preserved the PR's core refactor: removed sessionRepositories and activitySinks maps, added issueTrackers composite-key TODO, added resolveSessionRepo helper, on-the-fly createActivitySink - Discarded PR edits to handleSubroutineTransition, handleValidationLoopFixer, and handleValidationLoopRerun (those handlers were deleted by CYPACK-996) - Adopted main's updateLinearWorkspaceTokens, removed obsolete legacy issue tracker construction and workspace cleanup, adopted CYPACK-969 rename
|
Merged Still relevant (kept):
Became obsolete (discarded):
Already on main (no-op):
Also adopted main's |
|
Merged |
|
@cyrusagent update the PR description |
| // TODO (multi-repo): When multi-repo session support is added, sessions may span | ||
| // multiple repos. Instead of stopping the entire session, we should detach only the | ||
| // removed repo and keep the session alive if it still has other repos. Sessions | ||
| // without any repos (e.g. Slack surfaces) are unaffected by repo removal. |
There was a problem hiding this comment.
@cyrusagent since we have multi repo now what should we think about doing here?
Summary
sessionRepositories: Map<string, string>from EdgeWorker — it was a lossy cache ofsession.repositories[0].repositoryIdthat only stored the primary repoactivitySinks: Map<string, IActivitySink>entirely —LinearActivitySinkis a stateless wrapper aroundIIssueTrackerService, so sinks are now created on-the-fly viacreateActivitySink()helper at session registration timeissueTrackers(in both EdgeWorker.ts and CLAUDE.md) noting composite key needed for multi-platform supportImplementation approach
sessionRepositories removal
Each
sessionRepositories.get(sessionId)call was replaced based on context:sessionfrom the event payload directlythis.agentSessionManager.getSession(id)to fetch the session firstfirstSession.repositories[0]?.repositoryIds.repositories.some()for correct multi-repo matchingactivitySinks deletion
createActivitySink(workspaceId)helper that looks up issueTracker and createsLinearActivitySinkon-the-fly, falling back toNoopActivitySinkcreateActivitySink()instead of map lookupTesting
Links