MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / flowSequence

Function flowSequence

graph-ui/src/pseudocode/flow-model.ts:305–345  ·  view source on GitHub ↗
(rootLabel: string, nodes: readonly FlowNode[])

Source from the content-addressed store, hash-verified

303 * set of arrows starting nowhere.
304 */
305export function flowSequence(rootLabel: string, nodes: readonly FlowNode[]): FlowSequence {
306 const participants: string[] = [];
307 const seen = new Set<string>();
308 const add = (label: string): void => {
309 if (!seen.has(label)) {
310 seen.add(label);
311 participants.push(label);
312 }
313 };
314 const root = sanitizeLabel(rootLabel) || 'root';
315 add(root);
316
317 /** The lifeline each depth is currently drawn at. Undefined where a cap cut the branch. */
318 const callerAt: (string | undefined)[] = [root];
319 const interactions: FlowInteraction[] = [];
320 let omitted = 0;
321
322 for (const node of nodes) {
323 if (node.depth < 1) {
324 continue;
325 }
326 const caller = callerAt[node.depth - 1];
327 const callee = moduleLabel(node);
328 const room = seen.has(callee) || seen.size < SEQUENCE_PARTICIPANT_CAP;
329 if (caller === undefined || interactions.length >= SEQUENCE_INTERACTION_CAP || !room) {
330 omitted += 1;
331 callerAt[node.depth] = undefined;
332 continue;
333 }
334 add(callee);
335 interactions.push({
336 from: caller,
337 to: callee,
338 message: sanitizeLabel(node.ref.name) || callee,
339 cycle: node.badges.cycle === true,
340 });
341 callerAt[node.depth] = callee;
342 }
343
344 return { participants, interactions, omitted };
345}
346
347/** The lifeline one node is drawn on: its file, or its own name when it has no file. */
348export function moduleLabel(node: FlowNode): string {

Callers 2

flow-model.test.tsFile · 0.90
buildFlowViewFunction · 0.90

Calls 4

sanitizeLabelFunction · 0.85
addFunction · 0.70
moduleLabelFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected