Cross-repo workflow grouping: entity, persistence, MCP - #25
Merged
Conversation
A single piece of work often spans sessions across several repositories. Today the only link between them is the operator's memory; there is no object that says 'these sessions are one workflow' and no shared context that survives a session's context being cleared. The design introduces a first-class Workflow entity (Alternative B from the research): it groups sessions across repos and carries a shared WorkflowBrief. It reuses the existing HandoffBrief shape (minus sessionId and writtenAtCommit, which have no meaning above a single session/tree) and the single-writer state model. A session belongs to at most one workflow; a fork offers same-workflow / new-workflow / no-workflow, with the brief linked rather than copied into the seed. An rloop review corrected one critical error: forkedFrom is dead code (never set, SessionManager explicitly says 'No lineage is recorded'), so workflowId inheritance was moved to prepareSuccessorSession where the successor is actually built. Verification: design-only, no code changed. The rloop ran in-session because both subagent models (deepseek and GLM-5.2) aborted on every spawn. Co-Authored-By: Claude <noreply@anthropic.com>
A workflow groups related sessions across repositories and carries a shared brief — the running narrative of the whole effort, written by whichever member session is active and read by the next one opened in any repo. This is the layer above forkedFrom (dead code, never set) and the per-session HandoffBrief (one session's testimony to its in-place successor). Domain: new WorkflowId, WorkflowStatus, WorkflowBrief, and Workflow records. ManagedAgentSession gains an optional workflowId (14th field, at-most-one). ApplicationState gains a workflows list. All follow the existing record/id/with* patterns. Persistence: ApplicationStateCodec encodes/decodes the workflows array and the session workflowId leniently — a missing or malformed workflows array recovers to empty, a missing workflowId recovers to Optional.empty(). No schema version bump, same discipline as forkedFrom/evalMode when they were added. Service: SessionManager gains workflow CRUD (create, rename, archive, delete, write brief, affiliate session, touch). prepareSuccessorSession copies workflowId from the outgoing session alongside the fields it already copies (displayName, namePinned, worktreeRoot, branchCreatedHere, evalMode) — a one-line addition, not riding forkedFrom. MCP: session_handoff gains an optional 'workflow': true flag that writes the calling session's workflow brief instead of its per-session brief. Refused if the session is not a workflow member. No agent-driven workflow creation — naming the effort is a human act, like naming a session. Verification: compileJava + compileTestJava pass. 6 new tests pass (4 codec round-trip: workflow, session-with-workflowId, old-state- without-workflows, old-session-without-workflowId; 2 MCP: workflow- target-writes-workflow-brief, absent-flag-writes-per-session-brief). 1 pre-existing test failure (adoptingARemoteOnlyBranchMintsATrackingLocalBranchAndReportsBothNames) fails on main at 9a1b84b — a git-worktree-add environment issue, unrelated to this change. Not yet implemented: the UI layer (workflow grouping in the rail, archived toggle, brief edit dialog). Co-Authored-By: Claude <noreply@anthropic.com>
jbachorik
marked this pull request as ready for review
August 28, 2026 11:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A single piece of work — a feature, a refactor, a bug hunt — often spans sessions across several repositories. Today the only link between them is the operator's memory; there is no object that says "these sessions are one workflow," and no shared context that survives a session's context being cleared.
This change introduces a first-class Workflow entity that groups related sessions across repositories and carries a shared brief: the running narrative of the whole effort, written by whichever member session is active and read by the next one opened in any repo. It is the layer above
forkedFrom(dead code, never set) and the per-sessionHandoffBrief(one session's testimony to its in-place successor).Domain
New records:
WorkflowId,WorkflowStatus(OPEN | ARCHIVED),WorkflowBrief,Workflow.WorkflowBriefreuses theHandoffBriefshape minussessionId(workflow-scoped, not session-scoped) andwrittenAtCommit(a workflow spans multiple repos and branches, so a single HEAD is meaningless).ManagedAgentSessiongains an optionalworkflowId(14th field, at-most-one workflow per session).ApplicationStategains aworkflowslist. All follow the existing record/id/with*patterns.Persistence
ApplicationStateCodecencodes/decodes theworkflowsarray and the sessionworkflowIdleniently — a missing or malformedworkflowsarray recovers to empty, a missingworkflowIdrecovers toOptional.empty(). No schema version bump, the same discipline used forforkedFrom/evalModewhen they were added.Service
SessionManagergains workflow CRUD:createWorkflow,renameWorkflow,setWorkflowStatus,deleteWorkflow,writeWorkflowBrief,setSessionWorkflow,touchWorkflow,applyAgentWorkflowHandoff.prepareSuccessorSessioncopiesworkflowIdfrom the outgoing session alongside the fields it already copies (displayName, namePinned, worktreeRoot, branchCreatedHere, evalMode) — a one-line addition, not ridingforkedFrom.MCP
session_handoffgains an optionalworkflow: trueflag that writes the calling session's workflow brief instead of its per-session brief. Refused if the session is not a workflow member. No agent-driven workflow creation — naming the effort is a human act, like naming a session.Design decisions
Verification
compileJava+compileTestJavapass. 6 new tests pass: 4 codec round-trip tests (workflow, session-with-workflowId, old-state-without-workflows, old-session-without-workflowId) and 2 MCP tests (workflow-target-writes-workflow-brief, absent-flag-writes-per-session-brief). One pre-existing test failure (adoptingARemoteOnlyBranchMintsATrackingLocalBranchAndReportsBothNames) fails onmainat9a1b84b— agit worktree addenvironment issue, unrelated to this change.Not yet implemented
The UI layer — workflow grouping in the session rail, archived-workflow filter toggle, and workflow brief edit dialog. That is the next chunk of work.
Design doc:
docs/plans/workflow-grouping-design.md.