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: render the journal digest in the context service so the trajectory lib stays import-light

[._.]/ Adam Eivy84c4c05193b5
diff --git a/server/lib/persistentMindTrajectory.js b/server/lib/persistentMindTrajectory.js
index 775ae9fd76..e8ec97cf11 100644
--- a/server/lib/persistentMindTrajectory.js
+++ b/server/lib/persistentMindTrajectory.js
@@ -10,7 +10,6 @@
import { z } from 'zod';
import { comparePersistentMindMemories, persistentMindMemoryProtection } from './persistentMindMemory.js';
import { PERSISTENT_MIND_PROMPT_LIMITS } from './persistentMindPrompt.js';
-import { persistentMindJournalDigest } from './persistentMindJournal.js';
export const PERSISTENT_MIND_ID = 'cos-persistent-mind';
// v2 seals from the decision journal rather than from the raw range, so a v1
@@ -335,7 +334,7 @@ export function assemblePersistentMindContext({
memories = [],
events = [],
rollups = [],
- journal = [],
+ journalDigest = null,
maxChars = PERSISTENT_MIND_TRAJECTORY_LIMITS.maxContextChars,
recentEventLimit = PERSISTENT_MIND_TRAJECTORY_LIMITS.recentContextEvents,
promptVersion = PERSISTENT_MIND_ROLLUP_PROMPT_VERSION,
@@ -412,8 +411,13 @@ export function assemblePersistentMindContext({
PERSISTENT_MIND_TRAJECTORY_LIMITS.maxMemoriesChars
);
// Superseded wording never reaches the prompt: the digest carries only what
- // is still true plus the settled history that explains it.
- const journalSummary = persistentMindJournalDigest(Array.isArray(journal) ? journal : [], mindId);
+ // is still true plus the settled history that explains it. The caller renders
+ // it — this module is reached by ~300 suites for its id/kind constants alone,
+ // so importing the journal renderer here would pull that leaf into every one
+ // of them (server suite import budget, #6156).
+ const journalSummary = journalDigest && typeof journalDigest === 'object'
+ ? journalDigest
+ : { text: '', activeCount: 0, resolvedCount: 0, supersededCount: 0 };
const journalText = bounded(journalSummary.text, PERSISTENT_MIND_TRAJECTORY_LIMITS.maxJournalChars);
const prefix = [
`# Persistent mind identity\nmindId=${mindId}${identityText ? `\n${identityText}` : ''}`,
diff --git a/server/services/persistentMindContext.js b/server/services/persistentMindContext.js
index c032ee6975..6bdfaa2c57 100644
--- a/server/services/persistentMindContext.js
+++ b/server/services/persistentMindContext.js
@@ -33,6 +33,7 @@ import {
extractPersistentMindJournal,
readPersistentMindJournal,
} from './persistentMindJournal.js';
+import { persistentMindJournalDigest } from '../lib/persistentMindJournal.js';
import { PERSISTENT_MIND_CHOSEN_NAME_TAG, persistentMindChooseNameSchema, resolvePersistentMindChosenName } from '../lib/persistentMindChosenName.js';
import * as memoryBackend from './memoryBackend.js';
import {
@@ -331,7 +332,7 @@ export async function preparePersistentMindContext({
memories,
events: history,
rollups,
- journal,
+ journalDigest: persistentMindJournalDigest(journal, mindId),
maxChars,
recentEventLimit,
promptVersion,