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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([issue-708]): reject unknown personaId on test runs; address review nits
[._.]/ Adam Eivy2d53c65ede92
diff --git a/client/src/components/digital-twin/tabs/TestTab.jsx b/client/src/components/digital-twin/tabs/TestTab.jsxindex f8f31ccb41..139e4b0d70 100644--- a/client/src/components/digital-twin/tabs/TestTab.jsx+++ b/client/src/components/digital-twin/tabs/TestTab.jsx@@ -58,7 +58,7 @@ export default function TestTab({ onRefresh }) {api.getProviders().catch(() => ({ providers: [] })),api.getDigitalTwinTestHistory(5).catch(() => []),api.getBehavioralFeedbackStats().catch(() => null),- api.getDigitalTwinPersonas().catch(() => [])+ api.getDigitalTwinPersonas({ silent: true }).catch(() => [])]);setTests(testsData);diff --git a/server/routes/digital-twin.js b/server/routes/digital-twin.jsindex e141d04627..dc57ff2e4b 100644--- a/server/routes/digital-twin.js+++ b/server/routes/digital-twin.js@@ -52,6 +52,18 @@ import { UUID_RE } from '../lib/fileUtils.js';const router = Router();+/**+ * Assert a persona id (when supplied) resolves to a stored persona, throwing+ * 404 otherwise. A test run with a stale/deleted personaId would otherwise+ * silently fall back to the base twin, mislabeling the result; this makes the+ * contract explicit — mirroring the same guard on PUT /personas/active.+ */+async function assertPersonaExists(personaId) {+ if (personaId && !(await digitalTwinService.getPersonaById(personaId))) {+ throw new ServerError('Persona not found', { status: 404, code: 'NOT_FOUND' });+ }+}+// =============================================================================// STATUS & SUMMARY// =============================================================================@@ -144,6 +156,7 @@ router.get('/tests', asyncHandler(async (req, res) => {*/router.post('/tests/run', asyncHandler(async (req, res) => {const { providerId, model, testIds, personaId } = validateRequest(runTestsInputSchema, req.body);+ await assertPersonaExists(personaId);const result = await digitalTwinService.runTests(providerId, model, testIds, personaId);res.json(result);}));@@ -154,6 +167,7 @@ router.post('/tests/run', asyncHandler(async (req, res) => {*/router.post('/tests/run-multi', asyncHandler(async (req, res) => {const { providers, testIds, personaId } = validateRequest(runMultiTestsInputSchema, req.body);+ await assertPersonaExists(personaId);const io = req.app.get('io');// Run tests for each provider in parallel@@ -207,6 +221,7 @@ router.get('/values-tests', asyncHandler(async (req, res) => {*/router.post('/values-tests/run', asyncHandler(async (req, res) => {const { providerId, model, testIds, personaId } = validateRequest(runTestsInputSchema, req.body);+ await assertPersonaExists(personaId);const result = await digitalTwinService.runValuesAlignmentTests(providerId, model, testIds, personaId);res.json(result);}));diff --git a/server/services/digital-twin-testing.js b/server/services/digital-twin-testing.jsindex 1971670700..61c65fd9ab 100644--- a/server/services/digital-twin-testing.js+++ b/server/services/digital-twin-testing.js@@ -3,10 +3,9 @@ import { existsSync } from 'fs';import { join } from 'path';import { getProviderById } from './providers.js';import { buildPrompt } from './promptService.js';-import { DIGITAL_TWIN_DIR, generateId, now, callProviderAI, parseScorerVerdict } from './digital-twin-helpers.js';+import { DIGITAL_TWIN_DIR, generateId, now, callProviderAI, parseScorerVerdict, resolveTestPersona } from './digital-twin-helpers.js';import { loadMeta, saveMeta, cache, CACHE_TTL_MS } from './digital-twin-meta.js';import { getDigitalTwinForPrompt } from './digital-twin-context.js';-import { resolveTestPersona } from './digital-twin-helpers.js';export async function parseTestSuite() {if (cache.tests.data && (Date.now() - cache.tests.timestamp) < CACHE_TTL_MS) {