Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): document active-only embedding-coverage scope; deterministic neighbor tiebreak

[._.]/ Adam Eivyd841dd0ff877
diff --git a/server/services/brainGraph.js b/server/services/brainGraph.js
index 60679298fa..c02a8fce91 100644
--- a/server/services/brainGraph.js
+++ b/server/services/brainGraph.js
@@ -260,9 +260,11 @@ export async function getBrainGraphNeighborhood({ focusId, limit } = {}) {
if (w >= SHARED_TAG_MIN_JACCARD) consider(id, 'shared_tag', w);
}
- // Rank candidates and take the top `cap` neighbors.
+ // Rank candidates and take the top `cap` neighbors. Final tiebreak on id keeps
+ // which neighbors survive the cap deterministic when priority+weight are equal
+ // (e.g. many identically-tagged neighbors at Jaccard 1.0).
const neighborIds = [...candidates.entries()]
- .sort((a, b) => (b[1].priority - a[1].priority) || (b[1].weight - a[1].weight))
+ .sort((a, b) => (b[1].priority - a[1].priority) || (b[1].weight - a[1].weight) || a[0].localeCompare(b[0]))
.slice(0, cap)
.map(([id]) => id);
diff --git a/server/services/brainMemoryBridge.js b/server/services/brainMemoryBridge.js
index ab009f33b2..268fa20df3 100644
--- a/server/services/brainMemoryBridge.js
+++ b/server/services/brainMemoryBridge.js
@@ -380,8 +380,10 @@ export async function syncAllBrainData({ dryRun = false, refresh = false, onlyMi
* Count how many active brain records lack an embedding — the headline number
* for the "N memories missing embeddings · Embed missing" affordance on the
* graph. A record is "missing" when it's unmapped OR its mapped memory has a
- * NULL embedding. Read-only; walks the same stores as the onlyMissing sync so
- * the count matches what "Embed missing" would actually process.
+ * NULL embedding — scoped to ACTIVE memories, since getMemoryIdsMissingEmbedding
+ * only reports active rows (an archived/non-active mapped memory is treated as
+ * embedded and is not a backfill target). Read-only; walks the same stores as
+ * the onlyMissing sync so the count matches what "Embed missing" would process.
*/
export async function getEmbeddingCoverage() {
const map = await loadBridgeMap();