Rotation exclusions: config rotationExcludeIds - excluded positions are never offered as the company-rotation target but their subtree is still traversed (founders reserving #4's slot for an incoming team)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-19 17:09:44 -05:00
parent 02290f1200
commit b9ab55a156
2 changed files with 8 additions and 4 deletions
+5 -2
View File
@@ -686,13 +686,16 @@ function memberIdByAccount(address) {
// Company-rotation pick: breadth-first (matrix order, left→right) first
// position under `rootId` that still needs directs — the "next open team
// position" for the public rotation when publicRotationMode==='chain'.
function nextOpenPosition(rootId) {
function nextOpenPosition(rootId, exclude) {
if (!state || !state.snapshotAt) return null;
const skip = exclude || new Set();
const q = [rootId]; const seen = new Set();
while (q.length) {
const id = q.shift(); if (seen.has(id)) continue; seen.add(id);
const m = state.members[id]; if (!m) continue;
if ((m.directCount || 0) < 2) return { id, directCount: m.directCount || 0, level: levelName(m.level || 1) };
// excluded positions are never offered as the target, but their subtree
// is still traversed (founders can reserve a position's open slots)
if (!skip.has(id) && (m.directCount || 0) < 2) return { id, directCount: m.directCount || 0, level: levelName(m.level || 1) };
if (m.l) q.push(m.l); if (m.r) q.push(m.r);
}
return null;