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

Function isValidConversationCopyLineage

packages/storage/src/session-store.ts:1086–1112  ·  view source on GitHub ↗
(header: SessionHeader)

Source from the content-addressed store, hash-verified

1084}
1085
1086function isValidConversationCopyLineage(header: SessionHeader): boolean {
1087 const copy = header.conversationCopy;
1088 if (copy === undefined) return true;
1089 if (
1090 !isSessionConversationCopy(copy) ||
1091 !isSafeSessionId(copy.sourceSessionId) ||
1092 copy.sourceSessionId === header.id ||
1093 header.subagentParent !== undefined
1094 ) {
1095 return false;
1096 }
1097 if (copy.kind === 'branch') {
1098 return (
1099 header.parentSessionId === copy.sourceSessionId &&
1100 header.branchOfTurnId === copy.sourceTurnId &&
1101 header.revisionRootSessionId === undefined &&
1102 header.revisionParentSessionId === undefined &&
1103 header.revisionOfTurnId === undefined &&
1104 header.revisionIndex === undefined &&
1105 header.revisionState === undefined
1106 );
1107 }
1108 return (
1109 header.revisionParentSessionId === copy.sourceSessionId &&
1110 header.revisionOfTurnId === copy.sourceTurnId
1111 );
1112}
1113
1114function isValidSubagentSessionLineage(header: SessionHeader): boolean {
1115 if (header.subagentParent === undefined) {

Callers 2

normalizeSessionHeaderFunction · 0.85

Calls 2

isSafeSessionIdFunction · 0.85

Tested by

no test coverage detected