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([issue-2100]): migrate legacy sessionModules; drop no-op memory module (codex review)

Adam Eivy7ccf91a2ea08
diff --git a/client/src/components/meatspace/post/PostDrillConfig.jsx b/client/src/components/meatspace/post/PostDrillConfig.jsx
index 22c3a8598a..2aae02a0d6 100644
--- a/client/src/components/meatspace/post/PostDrillConfig.jsx
+++ b/client/src/components/meatspace/post/PostDrillConfig.jsx
@@ -6,13 +6,12 @@ import { FormField } from '../../ui/FormField';
import { filterSelectableModels, enabledApiProviderFilter } from '../../../utils/providers';
import { GOAL_DEFS } from './constants';
-// Modules a Full/Quick composed session can draw from (issue #2100). `memory`
-// has no launcher-composed drill yet, so it's listed for forward-compat but is
-// a no-op in composition today.
+// Modules a Full/Quick composed session can draw from (issue #2100). Memory is
+// deliberately absent — it has no launcher-composed drill yet (practice lives in
+// the Memory tab), so offering it here would let a user build an empty session.
const SESSION_MODULE_OPTIONS = [
{ id: 'mental-math', label: 'Mental Math' },
{ id: 'cognitive', label: 'Cognitive' },
- { id: 'memory', label: 'Memory' },
{ id: 'llm-drills', label: 'Wit & Memory (AI)' },
];
@@ -541,7 +540,7 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
// never auto-run without provider-cost consent — check "Wit & Memory" to opt
// them into composed sessions.
const [sessionModules, setSessionModules] = useState(
- () => Array.isArray(config?.sessionModules) ? config.sessionModules : ['mental-math', 'cognitive', 'memory']
+ () => Array.isArray(config?.sessionModules) ? config.sessionModules : ['mental-math', 'cognitive']
);
const [providers, setProviders] = useState([]);
const [saving, setSaving] = useState(false);
diff --git a/scripts/migrations/159-post-session-modules-default.js b/scripts/migrations/159-post-session-modules-default.js
new file mode 100644
index 0000000000..4de1e90b54
--- /dev/null
+++ b/scripts/migrations/159-post-session-modules-default.js
@@ -0,0 +1,67 @@
+/**
+ * Upgrade the legacy POST `sessionModules` default (issue #2100).
+ *
+ * Background:
+ * `sessionModules` in `data/meatspace/post-config.json` was always persisted
+ * (updatePostConfig writes the whole merged config), but nothing ever read it
+ * to compose a session — so every saved config carried the old default value
+ * `['mental-math']`. Issue #2100 wires it into the launcher's Full POST / Quick
+ * composition, which means that stale `['mental-math']` would suddenly restrict
+ * those installs to math-only, silently dropping the cognitive drills they were
+ * getting before.
+ *
+ * This migration rewrites the exact legacy value `['mental-math']` to the new
+ * balanced default `['mental-math', 'cognitive']`. It runs once, on the same
+ * update that ships the new config selector — so no user could yet have
+ * *deliberately* chosen `['mental-math']`, and the upgrade can't clobber a real
+ * choice. Any other value (already the new default, or a user selection made
+ * after this ships) is left untouched, and a missing file is a clean no-op
+ * (fresh installs seed the new default on first write).
+ */
+
+import { readFile, writeFile } from 'fs/promises';
+import { join } from 'path';
+
+const REL_PATH = 'data/meatspace/post-config.json';
+
+// The exact legacy default this migration upgrades, and its replacement. Kept
+// as literals (not imported from the service) so the migration is frozen to the
+// value it shipped for — a later default change must not retroactively alter
+// what this one-time migration rewrites.
+export const LEGACY_SESSION_MODULES = ['mental-math'];
+export const NEW_SESSION_MODULES = ['mental-math', 'cognitive'];
+
+const isLegacy = (mods) =>
+ Array.isArray(mods) && mods.length === 1 && mods[0] === 'mental-math';
+
+export default {
+ async up({ rootDir }) {
+ const configPath = join(rootDir, REL_PATH);
+ const raw = await readFile(configPath, 'utf-8').catch((err) => {
+ if (err.code === 'ENOENT') return null;
+ throw err;
+ });
+ if (raw == null) {
+ console.log(`📄 ${REL_PATH} not present — skipping (fresh installs seed the new default on first write)`);
+ return { updated: 0, reason: 'no-file' };
+ }
+
+ let data;
+ try {
+ data = JSON.parse(raw);
+ } catch (err) {
+ console.log(`⚠️ ${REL_PATH}: invalid JSON, skipping (${err.message})`);
+ return { updated: 0, reason: 'invalid-json' };
+ }
+
+ if (!isLegacy(data?.sessionModules)) {
+ console.log(`✅ ${REL_PATH}: sessionModules already upgraded or customized — no changes`);
+ return { updated: 0, reason: 'not-legacy' };
+ }
+
+ data.sessionModules = [...NEW_SESSION_MODULES];
+ await writeFile(configPath, `${JSON.stringify(data, null, 2)}\n`);
+ console.log(`📝 ${REL_PATH}: upgraded legacy sessionModules ['mental-math'] → ['mental-math','cognitive']`);
+ return { updated: 1 };
+ },
+};
diff --git a/scripts/migrations/159-post-session-modules-default.test.js b/scripts/migrations/159-post-session-modules-default.test.js
new file mode 100644
index 0000000000..a58ed2494a
--- /dev/null
+++ b/scripts/migrations/159-post-session-modules-default.test.js
@@ -0,0 +1,73 @@
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';
+import { tmpdir } from 'os';
+import { join } from 'path';
+
+import migration, { NEW_SESSION_MODULES } from './159-post-session-modules-default.js';
+
+const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');
+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));
+
+describe('migration 159 — upgrade legacy POST sessionModules default', () => {
+ let rootDir;
+ let configPath;
+
+ beforeEach(() => {
+ rootDir = mkdtempSync(join(tmpdir(), 'migration-159-'));
+ mkdirSync(join(rootDir, 'data', 'meatspace'), { recursive: true });
+ configPath = join(rootDir, 'data', 'meatspace', 'post-config.json');
+ });
+
+ afterEach(() => {
+ rmSync(rootDir, { recursive: true, force: true });
+ });
+
+ it('no-ops when the config file is missing', async () => {
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'no-file' });
+ expect(existsSync(configPath)).toBe(false);
+ });
+
+ it('upgrades the exact legacy value and preserves other keys', async () => {
+ writeJson(configPath, { sessionModules: ['mental-math'], adaptive: { enabled: true } });
+ const result = await migration.up({ rootDir });
+ expect(result.updated).toBe(1);
+ const data = readJson(configPath);
+ expect(data.sessionModules).toEqual(NEW_SESSION_MODULES);
+ expect(data.adaptive).toEqual({ enabled: true });
+ });
+
+ it('leaves a customized (non-legacy) sessionModules untouched', async () => {
+ writeJson(configPath, { sessionModules: ['mental-math', 'llm-drills'] });
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'not-legacy' });
+ expect(readJson(configPath).sessionModules).toEqual(['mental-math', 'llm-drills']);
+ });
+
+ it('leaves an already-upgraded config untouched', async () => {
+ writeJson(configPath, { sessionModules: ['mental-math', 'cognitive'] });
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'not-legacy' });
+ });
+
+ it('no-ops when sessionModules is absent', async () => {
+ writeJson(configPath, { adaptive: { enabled: false } });
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'not-legacy' });
+ });
+
+ it('is idempotent across re-runs', async () => {
+ writeJson(configPath, { sessionModules: ['mental-math'] });
+ await migration.up({ rootDir });
+ const afterFirst = readJson(configPath);
+ const second = await migration.up({ rootDir });
+ expect(second).toEqual({ updated: 0, reason: 'not-legacy' });
+ expect(readJson(configPath)).toEqual(afterFirst);
+ });
+
+ it('skips a malformed config file without throwing', async () => {
+ writeFileSync(configPath, '{ not json');
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'invalid-json' });
+ });
+});
diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.js
index a756981a9a..f1394c7887 100644
--- a/server/services/meatspacePost.js
+++ b/server/services/meatspacePost.js
@@ -93,12 +93,16 @@ const DEFAULT_CONFIG = {
}
},
// Default session composition is a balanced, interleaved mix of the free
- // (no-provider) modules — mental math, deterministic cognitive drills, and
- // memory (issue #2100). LLM drills are deliberately excluded from the default:
- // auto-enabling them would queue provider calls the user hasn't consented to
- // (see CLAUDE.md's AI Provider Usage Policy). A user who wants wit/verbal
- // drills in every session adds `llm-drills` here explicitly.
- sessionModules: ['mental-math', 'cognitive', 'memory'],
+ // (no-provider) modules the launcher can actually compose — mental math and
+ // deterministic cognitive drills (issue #2100). LLM drills are deliberately
+ // excluded: auto-enabling them would queue provider calls the user hasn't
+ // consented to (see CLAUDE.md's AI Provider Usage Policy) — a user who wants
+ // wit/verbal drills in every session adds `llm-drills` here explicitly.
+ // `memory` is intentionally NOT a default: memory practice lives in its own
+ // tab and has no launcher-composed drill yet, so including it would only risk
+ // an empty composed session. Legacy installs that persisted the old
+ // `['mental-math']` default are upgraded to this by migration 159.
+ sessionModules: ['mental-math', 'cognitive'],
// Optional practice goals (issue #2100). All fields absent by default so a
// fresh/legacy install shows no goal UI until the user sets one. Bounds are
// enforced by postGoalsSchema (server/lib/postValidation.js).