MCPcopy Create free account
hub / github.com/apache/maka / createRevisionSession

Method createRevisionSession

packages/runtime/src/session-manager.ts:4926–4995  ·  view source on GitHub ↗
(
    sessionId: string,
    sourceView: RuntimeReadModelSessionView,
    copied: StoredMessage[],
    input: ReviseBeforeTurnInput,
  )

Source from the content-addressed store, hash-verified

4924 }
4925
4926 private async createRevisionSession(
4927 sessionId: string,
4928 sourceView: RuntimeReadModelSessionView,
4929 copied: StoredMessage[],
4930 input: ReviseBeforeTurnInput,
4931 ): Promise<SessionSummary> {
4932 const plan = await this.prepareConversationRuntimeLedgerClone(sessionId, sourceView, copied);
4933 const [header, boundary] = await Promise.all([
4934 this.deps.store.readHeader(sessionId),
4935 this.deps.store.readExecutionBoundary(sessionId),
4936 ]);
4937 const revisionRootSessionId = header.revisionRootSessionId ?? sessionId;
4938 const family = (await this.deps.store.list()).filter(
4939 (candidate) =>
4940 candidate.id === revisionRootSessionId ||
4941 candidate.revisionRootSessionId === revisionRootSessionId,
4942 );
4943 const revisionIndex =
4944 Math.max(1, ...family.map((candidate) => candidate.revisionIndex ?? 1)) + 1;
4945 const next = await this.deps.store.create(
4946 {
4947 cwd: header.cwd,
4948 ...(header.projectId !== undefined ? { projectId: header.projectId } : {}),
4949 backend: header.backend,
4950 llmConnectionSlug: header.llmConnectionSlug,
4951 model: header.model,
4952 thinkingLevel: header.thinkingLevel,
4953 permissionMode: header.permissionMode,
4954 collaborationMode: header.collaborationMode,
4955 orchestrationMode: header.orchestrationMode ?? 'default',
4956 name: header.name,
4957 labels: header.labels,
4958 // A revision of a real branch remains in that branch's conversation
4959 // slot; revision lineage itself must not create a branch banner.
4960 parentSessionId: header.parentSessionId,
4961 branchOfTurnId: header.branchOfTurnId,
4962 revisionRootSessionId,
4963 revisionParentSessionId: sessionId,
4964 revisionOfTurnId: input.sourceTurnId,
4965 revisionIndex,
4966 revisionState: 'preparing',
4967 status: 'active',
4968 },
4969 boundary,
4970 );
4971 try {
4972 const rewritten = await this.cloneConversationRuntimeLedger(next.id, copied, plan);
4973 if (rewritten.length > 0) await this.deps.store.appendMessages(next.id, [...rewritten]);
4974 await this.deps.store.appendMessage(next.id, {
4975 type: 'system_note',
4976 id: this.deps.newId(),
4977 ts: this.deps.now(),
4978 kind: 'session_start',
4979 data: {
4980 revisionRootSessionId,
4981 revisionParentSessionId: sessionId,
4982 revisionOfTurnId: input.sourceTurnId,
4983 revisionIndex,

Callers 1

reviseBeforeTurnMethod · 0.95

Calls 13

headerToSummaryFunction · 0.85
readHeaderMethod · 0.65
readExecutionBoundaryMethod · 0.65
listMethod · 0.65
createMethod · 0.65
appendMessagesMethod · 0.65
appendMessageMethod · 0.65
newIdMethod · 0.65
nowMethod · 0.65

Tested by

no test coverage detected