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

Function nextTaskKey

packages/storage/src/task-ledger-store.ts:705–717  ·  view source on GitHub ↗
(tasks: readonly Task[], parent: Task | undefined)

Source from the content-addressed store, hash-verified

703}
704
705function nextTaskKey(tasks: readonly Task[], parent: Task | undefined): string {
706 const siblings = tasks.filter((task) => task.parentId === parent?.id);
707 const prefix = parent ? `${parent.key}.` : 'T';
708 const used = new Set(siblings.map((task) => task.key));
709 let index = 1;
710 while (used.has(`${prefix}${index}`)) index += 1;
711 const key = `${prefix}${index}`;
712 if (!isTaskKey(key))
713 throw new Error(
714 `Task hierarchy is too deep to allocate a stable key under ${parent?.key ?? 'root'}`,
715 );
716 return key;
717}
718
719function assertChildTaskOwner(
720 owner: TaskOwner,

Callers 1

createMethod · 0.85

Calls 2

isTaskKeyFunction · 0.90
hasMethod · 0.65

Tested by

no test coverage detected