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

fix: address claude round 3 — re-read taste record before overlaying interpretation (#2156)

Adam Eivy4f075471e355
diff --git a/server/services/twinEnrichment.js b/server/services/twinEnrichment.js
index c8f5483b3f..3755e0e0f7 100644
--- a/server/services/twinEnrichment.js
+++ b/server/services/twinEnrichment.js
@@ -512,7 +512,12 @@ export async function interpretConsumption({ providerId, model } = {}) {
usedFallback: Boolean(result.usedFallback),
generatedAt: new Date().toISOString(),
};
- const merged = { ...(taste || { source: 'observed', derivedAt: interpretation.generatedAt }), interpretation };
+ // Re-read immediately before the write: the provider call above can take many
+ // seconds, during which a sync-hook or the daily scheduler may have rewritten
+ // this file with fresh rollup numbers. Overlay the interpretation onto the
+ // LATEST record, not the pre-call snapshot, so we don't roll the numbers back.
+ const current = await getTasteEvidence();
+ const merged = { ...(current || { source: 'observed', derivedAt: interpretation.generatedAt }), interpretation };
await ensureDir(DIR);
await atomicWrite(TASTE_OBSERVED_FILE, merged);
console.log(`🧭 Twin interpretation generated via ${interpretation.providerName} (${text.length} chars)`);