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
feat([issue-708]): run Digital Twin test suites as a selected persona
[._.]/ Adam Eivye9750916873b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 3bf36ce82d..80a1a79843 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -4,6 +4,7 @@- **[issue-708] Digital Twin personas** — give your twin named contexts — Professional, Casual, Family, or your own — each with instructions for how it should modulate voice and behavior. Activate one from the new Personas tab and your CoS agents adopt that context when they act on your behalf, while building your base identity stays unaffected. Create, edit, switch, and clear personas at any time.- **[issue-708] Digital Twin values-alignment tests** — the Digital Twin's Test tab gains a second test mode: instead of only checking whether your twin *sounds* like you, it poses ethical dilemmas and grades whether the twin's choice is consistent with your ranked values. Each dilemma names the values at stake and ships an "aligned" and "misaligned" reference, and runs score against the values hierarchy from your Identity tab — so you can see, per model, where your twin holds your values and where it drifts. Ships a starter dilemma suite you can customize.+- **[issue-708] Test your twin as a persona** — the Digital Twin's Test tab can now run both the behavioral and values-alignment suites *as* a chosen persona instead of only the base twin: pick "Professional", "Casual", or any persona you've created and the suite embodies that context's instructions before answering. Each run is tagged in the history with the persona it used, so you can compare how the same model behaves across contexts. With no personas defined, the picker stays hidden and nothing changes.- **[issue-704] Writers Room synced review** — a new Review view shows a work's prose, its generated script scenes, and the images rendered from them side by side, with the links between them. Click a passage to highlight the scenes and media it became; click a scene to jump back to its source prose and see the image, prompt, and render details. Each media card carries its provenance, and the script is flagged as stale when the draft has changed since it was generated. Pick which of the three panes to show.- **`/claim --issues`** — the claim workflow can now pull its work queue from GitHub issues instead of PLAN.md, auto-picking the oldest open issue filed by the repo owner and filing any major code-review findings as new issues. Developer tooling only — no app-facing change.- **Episode video model picker** — the pipeline's Episode Video stage now lets you choose which video model renders each scene, alongside the aspect-ratio and quality controls. Leave it on "Default model" to follow your video settings, or pin a specific model; the choice is remembered when you restart a render.diff --git a/client/src/components/digital-twin/tabs/TestTab.jsx b/client/src/components/digital-twin/tabs/TestTab.jsxindex a3e08a1f73..c7b60ca99e 100644--- a/client/src/components/digital-twin/tabs/TestTab.jsx+++ b/client/src/components/digital-twin/tabs/TestTab.jsx@@ -30,6 +30,8 @@ export default function TestTab({ onRefresh }) {// Test configurationconst [selectedProviders, setSelectedProviders] = useState([]);const [selectedTests, setSelectedTests] = useState([]);+ const [personas, setPersonas] = useState([]);+ const [selectedPersonaId, setSelectedPersonaId] = useState(''); // '' = base twin (no persona)// Resultsconst [results, setResults] = useState([]);@@ -50,11 +52,12 @@ export default function TestTab({ onRefresh }) {const loadData = async () => {setLoading(true);- const [testsData, providersData, historyData, fbStats] = await Promise.all([+ const [testsData, providersData, historyData, fbStats, personaData] = await Promise.all([api.getDigitalTwinTests().catch(() => []),api.getProviders().catch(() => ({ providers: [] })),api.getDigitalTwinTestHistory(5).catch(() => []),- api.getBehavioralFeedbackStats().catch(() => null)+ api.getBehavioralFeedbackStats().catch(() => null),+ api.getDigitalTwinPersonas().catch(() => [])]);setTests(testsData);@@ -62,6 +65,9 @@ export default function TestTab({ onRefresh }) {setProviders(providersList.filter(p => p.enabled));setHistory(historyData);if (fbStats) setFeedbackStats(fbStats);+ setPersonas(Array.isArray(personaData) ? personaData : []);+ // Drop the persona selection if it no longer exists (e.g. deleted elsewhere)+ setSelectedPersonaId(prev => (prev && (personaData || []).some(p => p.id === prev) ? prev : ''));// Default: select all testssetSelectedTests(testsData.map(t => t.testId));@@ -117,15 +123,16 @@ export default function TestTab({ onRefresh }) {setResults([]);const testIds = selectedTests.length > 0 ? selectedTests : null;+ const personaId = selectedPersonaId || null;if (selectedProviders.length === 1) {// Single provider testconst { providerId, model } = selectedProviders[0];- const result = await api.runSoulTests(providerId, model, testIds);+ const result = await api.runSoulTests(providerId, model, testIds, personaId);setResults([{ providerId, model, ...result }]);} else {// Multi-provider test- const multiResults = await api.runSoulMultiTests(selectedProviders, testIds);+ const multiResults = await api.runSoulMultiTests(selectedProviders, testIds, personaId);setResults(multiResults);}@@ -266,6 +273,29 @@ export default function TestTab({ onRefresh }) {</div></div>+ {/* Persona selector — run the suite as a named persona (P7) or the base twin */}+ {personas.length > 0 && (+ <div className="bg-port-card rounded-lg border border-port-border p-4 flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3">+ <label htmlFor="test-persona" className="text-sm font-medium text-gray-400">+ Embody persona+ </label>+ <select+ id="test-persona"+ value={selectedPersonaId}+ onChange={(e) => setSelectedPersonaId(e.target.value)}+ className="px-3 py-2 min-h-[40px] text-sm rounded-lg border border-port-border bg-port-bg text-white focus:ring-port-accent focus:border-port-accent"+ >+ <option value="">Base twin (no persona)</option>+ {personas.map(p => (+ <option key={p.id} value={p.id}>{p.name}</option>+ ))}+ </select>+ <span className="text-xs text-gray-500">+ Applies to both behavioral and values-alignment runs.+ </span>+ </div>+ )}+{/* Run Button */}<div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-3 sm:gap-4"><button@@ -566,7 +596,14 @@ export default function TestTab({ onRefresh }) {{Math.round(run.score * 100)}%</span><div>- <div className="text-sm text-white">{run.model}</div>+ <div className="text-sm text-white flex items-center gap-2">+ {run.model}+ {run.personaName && (+ <span className="text-xs px-1.5 py-0.5 rounded bg-port-accent/20 text-port-accent">+ {run.personaName}+ </span>+ )}+ </div><div className="text-xs text-gray-500">{run.passed}/{run.total} passed • {timeAgo(run.timestamp)}</div>@@ -630,8 +667,8 @@ export default function TestTab({ onRefresh }) {</div>)}- {/* Values-Alignment Tests (M34 P6) — shares the provider selection above */}- <ValuesAlignmentPanel selectedProviders={selectedProviders} onRefresh={onRefresh} />+ {/* Values-Alignment Tests (M34 P6) — shares the provider + persona selection above */}+ <ValuesAlignmentPanel selectedProviders={selectedProviders} personaId={selectedPersonaId} onRefresh={onRefresh} /></div>);}diff --git a/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsx b/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsxindex 8fd87a1d43..54e240a79b 100644--- a/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsx+++ b/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsx@@ -23,7 +23,7 @@ import { timeAgo } from '../../../utils/formatters';* Reuses the provider/model selection from the parent TestTab via the* `selectedProviders` prop so the two suites share one configuration.*/-export default function ValuesAlignmentPanel({ selectedProviders = [], onRefresh }) {+export default function ValuesAlignmentPanel({ selectedProviders = [], personaId = '', onRefresh }) {const [dilemmas, setDilemmas] = useState([]);const [history, setHistory] = useState([]);const [loading, setLoading] = useState(true);@@ -57,7 +57,7 @@ export default function ValuesAlignmentPanel({ selectedProviders = [], onRefreshconst runResults = await Promise.all(selectedProviders.map(({ providerId, model }) =>- api.runValuesAlignmentTests(providerId, model)+ api.runValuesAlignmentTests(providerId, model, null, personaId || null).then(result => ({ providerId, model, ...result })).catch(err => ({ providerId, model, error: err.message })))@@ -68,7 +68,7 @@ export default function ValuesAlignmentPanel({ selectedProviders = [], onRefresh// to the local list instead of refetching (reactive-update convention).const fresh = runResults.filter(r => !r.error && r.runId)- .map(({ runId, score, aligned, total, timestamp, model }) => ({ runId, score, aligned, total, timestamp, model }));+ .map(({ runId, score, aligned, total, timestamp, model, personaName }) => ({ runId, score, aligned, total, timestamp, model, personaName }));if (fresh.length) setHistory(prev => [...fresh, ...prev].slice(0, 5));setRunning(false);@@ -287,7 +287,14 @@ export default function ValuesAlignmentPanel({ selectedProviders = [], onRefresh{Math.round(run.score * 100)}%</span><div>- <div className="text-sm text-white">{run.model}</div>+ <div className="text-sm text-white flex items-center gap-2">+ {run.model}+ {run.personaName && (+ <span className="text-xs px-1.5 py-0.5 rounded bg-port-accent/20 text-port-accent">+ {run.personaName}+ </span>+ )}+ </div><div className="text-xs text-gray-500">{run.aligned}/{run.total} aligned • {timeAgo(run.timestamp)}</div>diff --git a/client/src/services/apiDigitalTwin.js b/client/src/services/apiDigitalTwin.jsindex 78b7c2c9c1..92d357cd0f 100644--- a/client/src/services/apiDigitalTwin.js+++ b/client/src/services/apiDigitalTwin.js@@ -18,21 +18,21 @@ export const deleteDigitalTwinDocument = (id) => request(`/digital-twin/document// Digital Twin - Testingexport const getDigitalTwinTests = () => request('/digital-twin/tests');-export const runDigitalTwinTests = (providerId, model, testIds = null) => request('/digital-twin/tests/run', {+export const runDigitalTwinTests = (providerId, model, testIds = null, personaId = null) => request('/digital-twin/tests/run', {method: 'POST',- body: JSON.stringify({ providerId, model, testIds })+ body: JSON.stringify({ providerId, model, testIds, personaId })});-export const runDigitalTwinMultiTests = (providers, testIds = null) => request('/digital-twin/tests/run-multi', {+export const runDigitalTwinMultiTests = (providers, testIds = null, personaId = null) => request('/digital-twin/tests/run-multi', {method: 'POST',- body: JSON.stringify({ providers, testIds })+ body: JSON.stringify({ providers, testIds, personaId })});export const getDigitalTwinTestHistory = (limit = 10) => request(`/digital-twin/tests/history?limit=${limit}`);// Digital Twin - Values-Alignment Testing (M34 P6)export const getValuesAlignmentTests = () => request('/digital-twin/values-tests');-export const runValuesAlignmentTests = (providerId, model, testIds = null) => request('/digital-twin/values-tests/run', {+export const runValuesAlignmentTests = (providerId, model, testIds = null, personaId = null) => request('/digital-twin/values-tests/run', {method: 'POST',- body: JSON.stringify({ providerId, model, testIds })+ body: JSON.stringify({ providerId, model, testIds, personaId })});export const getValuesAlignmentTestHistory = (limit = 10) => request(`/digital-twin/values-tests/history?limit=${limit}`);diff --git a/docs/features/digital-twin.md b/docs/features/digital-twin.mdindex 4af4b0b512..46e1dd5e25 100644--- a/docs/features/digital-twin.md+++ b/docs/features/digital-twin.md@@ -116,7 +116,7 @@ traits: {### Phase 7: Twin Personas & Context Switching- Named personas (Professional, Casual, Family, Creative)- Blending rules for trait variation per context-- Per-persona testing+- Per-persona testing — **done**: the Test tab can run the behavioral and values-alignment suites *as* a selected persona (or the base twin), and each run-history entry records which persona it embodied## Success Metricsdiff --git a/server/lib/digitalTwinValidation.js b/server/lib/digitalTwinValidation.jsindex eceb07f3e5..3a5963bf0a 100644--- a/server/lib/digitalTwinValidation.js+++ b/server/lib/digitalTwinValidation.js@@ -52,11 +52,16 @@ export const documentMetaSchema = z.object({weight: z.number().int().min(1).max(10).default(5)});-// Test history entry schema+// Test history entry schema. personaId/personaName are present only when the+// run embodied a persona (P7); older entries predate the field, so both are+// optional — Zod strips unknown keys, so they MUST be declared here or they'd+// be silently dropped on the next loadMeta.export const testHistoryEntrySchema = z.object({runId: z.string().uuid(),providerId: z.string(),model: z.string(),+ personaId: z.string().uuid().optional(),+ personaName: z.string().optional(),score: z.number().min(0).max(1),passed: z.number().int().min(0),failed: z.number().int().min(0),@@ -65,11 +70,13 @@ export const testHistoryEntrySchema = z.object({timestamp: z.string().datetime()});-// Values-alignment run history entry (M34 P6)+// Values-alignment run history entry (M34 P6). Same persona fields as above.export const valuesTestHistoryEntrySchema = z.object({runId: z.string().uuid(),providerId: z.string(),model: z.string(),+ personaId: z.string().uuid().optional(),+ personaName: z.string().optional(),score: z.number().min(0).max(1),aligned: z.number().int().min(0),partial: z.number().int().min(0),@@ -245,11 +252,20 @@ const optionalTestIds = z.preprocess(z.array(z.number().int().min(1)).optional());+// Optional persona to embody for a test run. The UI's "Base twin" choice sends+// '' (or omits it); a specific persona sends its uuid. Treat null/'' as absent+// so a base-twin run validates instead of 400-ing on the sentinel.+const optionalPersonaId = z.preprocess(+ v => (v == null || v === '') ? undefined : v,+ z.string().uuid().optional()+);+// Run tests inputexport const runTestsInputSchema = z.object({providerId: z.string().min(1),model: z.string().min(1),- testIds: optionalTestIds+ testIds: optionalTestIds,+ personaId: optionalPersonaId});// Run multi-model tests input@@ -258,7 +274,8 @@ export const runMultiTestsInputSchema = z.object({providerId: z.string().min(1),model: z.string().min(1)})).min(1).max(10),- testIds: optionalTestIds+ testIds: optionalTestIds,+ personaId: optionalPersonaId});// Enrichment question inputdiff --git a/server/lib/digitalTwinValidation.test.js b/server/lib/digitalTwinValidation.test.jsindex a27c60997b..af385901a5 100644--- a/server/lib/digitalTwinValidation.test.js+++ b/server/lib/digitalTwinValidation.test.js@@ -4,7 +4,9 @@ import {runMultiTestsInputSchema,createPersonaInputSchema,setActivePersonaInputSchema,- digitalTwinSettingsSchema+ digitalTwinSettingsSchema,+ testHistoryEntrySchema,+ valuesTestHistoryEntrySchema} from './digitalTwinValidation.js';// Regression guard: the client API wrappers default `testIds` to `null` for a@@ -38,6 +40,74 @@ describe('runTestsInputSchema testIds null-tolerance', () => {});});+// Per-persona testing (M34 P7): a test run may embody a persona. The UI's+// "Base twin" choice sends '' (or omits it); a specific persona sends its uuid.+describe('runTestsInputSchema personaId (per-persona testing)', () => {+ const uuid = '22222222-2222-4222-8222-222222222222';++ it('treats empty-string personaId as base twin (normalized away)', () => {+ const parsed = runTestsInputSchema.parse({ providerId: 'p', model: 'm', personaId: '' });+ expect(parsed.personaId).toBeUndefined();+ });++ it('treats null/omitted personaId as base twin', () => {+ expect(runTestsInputSchema.parse({ providerId: 'p', model: 'm', personaId: null }).personaId).toBeUndefined();+ expect(runTestsInputSchema.parse({ providerId: 'p', model: 'm' }).personaId).toBeUndefined();+ });++ it('accepts a uuid persona id', () => {+ expect(runTestsInputSchema.parse({ providerId: 'p', model: 'm', personaId: uuid }).personaId).toBe(uuid);+ });++ it('rejects a malformed persona id', () => {+ expect(runTestsInputSchema.safeParse({ providerId: 'p', model: 'm', personaId: 'nope' }).success).toBe(false);+ });++ it('carries personaId on the multi-model schema too', () => {+ const parsed = runMultiTestsInputSchema.parse({+ providers: [{ providerId: 'p', model: 'm' }],+ personaId: uuid+ });+ expect(parsed.personaId).toBe(uuid);+ });+});++// Run-history entries persist which persona they embodied. Zod strips unknown+// keys, so the persona fields MUST survive a parse round-trip or loadMeta would+// silently drop them — while older (persona-free) entries still validate.+describe('history-entry schemas preserve persona attribution', () => {+ const uuid = '33333333-3333-4333-8333-333333333333';+ const baseBehavioral = {+ runId: '44444444-4444-4444-8444-444444444444',+ providerId: 'p', model: 'm', score: 0.8,+ passed: 4, failed: 1, partial: 0, total: 5,+ timestamp: '2026-06-03T00:00:00.000Z'+ };+ const baseValues = {+ runId: '55555555-5555-4555-8555-555555555555',+ providerId: 'p', model: 'm', score: 0.6,+ aligned: 3, partial: 1, misaligned: 1, total: 5,+ timestamp: '2026-06-03T00:00:00.000Z'+ };++ it('keeps personaId/personaName on a behavioral entry', () => {+ const parsed = testHistoryEntrySchema.parse({ ...baseBehavioral, personaId: uuid, personaName: 'Professional' });+ expect(parsed.personaId).toBe(uuid);+ expect(parsed.personaName).toBe('Professional');+ });++ it('keeps personaId/personaName on a values entry', () => {+ const parsed = valuesTestHistoryEntrySchema.parse({ ...baseValues, personaId: uuid, personaName: 'Casual' });+ expect(parsed.personaId).toBe(uuid);+ expect(parsed.personaName).toBe('Casual');+ });++ it('still validates persona-free (legacy) entries', () => {+ expect(testHistoryEntrySchema.parse(baseBehavioral).personaName).toBeUndefined();+ expect(valuesTestHistoryEntrySchema.parse(baseValues).personaName).toBeUndefined();+ });+});+// Personas (M34 P7) — validate the create/active input contracts and that the// settings schema accepts the activePersonaId pointer (including null = clear).describe('persona input schemas', () => {diff --git a/server/routes/digital-twin.js b/server/routes/digital-twin.jsindex 09840c9bb7..e141d04627 100644--- a/server/routes/digital-twin.js+++ b/server/routes/digital-twin.js@@ -143,8 +143,8 @@ router.get('/tests', asyncHandler(async (req, res) => {* Run behavioral tests against a single provider/model*/router.post('/tests/run', asyncHandler(async (req, res) => {- const { providerId, model, testIds } = validateRequest(runTestsInputSchema, req.body);- const result = await digitalTwinService.runTests(providerId, model, testIds);+ const { providerId, model, testIds, personaId } = validateRequest(runTestsInputSchema, req.body);+ const result = await digitalTwinService.runTests(providerId, model, testIds, personaId);res.json(result);}));@@ -153,13 +153,13 @@ router.post('/tests/run', asyncHandler(async (req, res) => {* Run behavioral tests against multiple providers/models*/router.post('/tests/run-multi', asyncHandler(async (req, res) => {- const { providers, testIds } = validateRequest(runMultiTestsInputSchema, req.body);+ const { providers, testIds, personaId } = validateRequest(runMultiTestsInputSchema, req.body);const io = req.app.get('io');// Run tests for each provider in parallelconst results = await Promise.all(providers.map(async ({ providerId, model }) => {- const result = await digitalTwinService.runTests(providerId, model, testIds).catch(err => ({+ const result = await digitalTwinService.runTests(providerId, model, testIds, personaId).catch(err => ({providerId,model,error: err.message@@ -206,8 +206,8 @@ router.get('/values-tests', asyncHandler(async (req, res) => {* response against the user's stored values hierarchy*/router.post('/values-tests/run', asyncHandler(async (req, res) => {- const { providerId, model, testIds } = validateRequest(runTestsInputSchema, req.body);- const result = await digitalTwinService.runValuesAlignmentTests(providerId, model, testIds);+ const { providerId, model, testIds, personaId } = validateRequest(runTestsInputSchema, req.body);+ const result = await digitalTwinService.runValuesAlignmentTests(providerId, model, testIds, personaId);res.json(result);}));diff --git a/server/services/digital-twin-helpers.js b/server/services/digital-twin-helpers.jsindex a4e6d00502..8bbca5586e 100644--- a/server/services/digital-twin-helpers.js+++ b/server/services/digital-twin-helpers.js@@ -52,6 +52,22 @@ export function parseScorerVerdict(response, verdicts, fallback = 'partial') {return { result, reasoning };}+/**+ * Resolve a persona id (as passed to a test runner) into the fields stamped on+ * a test-history entry, so a run can be attributed to the persona it embodied.+ * Returns `{}` when no persona id is given or it doesn't match a stored persona+ * — leaving the history entry persona-free (the base-twin run). `personas` is+ * `meta.personas`; mirrors how `resolvePersona` in digital-twin-context.js maps+ * an id to a persona for the prompt itself.+ */+export function resolveTestPersona(personas, personaId) {+ if (!personaId) return {};+ const list = Array.isArray(personas) ? personas : [];+ const persona = list.find(p => p.id === personaId);+ if (!persona) return {};+ return { personaId: persona.id, personaName: persona.name };+}+/*** Ensure a document entry exists in meta.documents. If absent, push it.* Mutates meta in place; caller must saveMeta() after.diff --git a/server/services/digital-twin-helpers.test.js b/server/services/digital-twin-helpers.test.jsnew file mode 100644index 0000000000..ea01a99515--- /dev/null+++ b/server/services/digital-twin-helpers.test.js@@ -0,0 +1,32 @@+import { describe, it, expect } from 'vitest';+import { resolveTestPersona } from './digital-twin-helpers.js';++// resolveTestPersona maps a persona id (as passed to a test runner) into the+// `{ personaId, personaName }` fields stamped on a run-history entry, so a run+// can be attributed to the persona it embodied. No id (or an unknown id) yields+// `{}` — the base-twin run, which leaves the history entry persona-free.+describe('resolveTestPersona', () => {+ const personas = [+ { id: 'p1', name: 'Professional', instructions: '...' },+ { id: 'p2', name: 'Casual', instructions: '...' }+ ];++ it('returns the id + name for a matching persona', () => {+ expect(resolveTestPersona(personas, 'p2')).toEqual({ personaId: 'p2', personaName: 'Casual' });+ });++ it('returns {} for a base-twin run (no persona id)', () => {+ expect(resolveTestPersona(personas, null)).toEqual({});+ expect(resolveTestPersona(personas, undefined)).toEqual({});+ expect(resolveTestPersona(personas, '')).toEqual({});+ });++ it('returns {} when the id does not match a stored persona', () => {+ expect(resolveTestPersona(personas, 'ghost')).toEqual({});+ });++ it('tolerates a missing/non-array personas list', () => {+ expect(resolveTestPersona(undefined, 'p1')).toEqual({});+ expect(resolveTestPersona(null, 'p1')).toEqual({});+ });+});diff --git a/server/services/digital-twin-testing.js b/server/services/digital-twin-testing.jsindex ac12ce1af3..1971670700 100644--- a/server/services/digital-twin-testing.js+++ b/server/services/digital-twin-testing.js@@ -6,6 +6,7 @@ import { buildPrompt } from './promptService.js';import { DIGITAL_TWIN_DIR, generateId, now, callProviderAI, parseScorerVerdict } 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) {@@ -40,9 +41,12 @@ export async function parseTestSuite() {return tests;}-export async function runTests(providerId, model, testIds = null) {+export async function runTests(providerId, model, testIds = null, personaId = null) {const tests = await parseTestSuite();- const soulContext = await getDigitalTwinForPrompt();+ // When a persona is selected the embodied context is flavored with that+ // persona's instructions, so the suite measures how the twin behaves *as*+ // that persona (P7 "per-persona testing"); with none it tests the base twin.+ const soulContext = await getDigitalTwinForPrompt(personaId ? { personaId } : {});const provider = await getProviderById(providerId);if (!provider || !provider.enabled) {@@ -66,11 +70,14 @@ export async function runTests(providerId, model, testIds = null) {else if (result.result === 'partial') partial++;}- // Save to history+ const meta = await loadMeta();++ // Save to history (attributed to the persona it embodied, if any)const historyEntry = {runId: generateId(),providerId,model,+ ...resolveTestPersona(meta.personas, personaId),score: testsToRun.length > 0 ? (passed + partial * 0.5) / testsToRun.length : 0,passed,failed,@@ -79,7 +86,6 @@ export async function runTests(providerId, model, testIds = null) {timestamp: now()};- const meta = await loadMeta();meta.testHistory.unshift(historyEntry);meta.testHistory = meta.testHistory.slice(0, 50); // Keep last 50 runsawait saveMeta(meta);diff --git a/server/services/digital-twin-values-testing.js b/server/services/digital-twin-values-testing.jsindex 706f7b489d..6bccd9fdae 100644--- a/server/services/digital-twin-values-testing.js+++ b/server/services/digital-twin-values-testing.js@@ -18,7 +18,7 @@ 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';@@ -98,9 +98,11 @@ export function formatValuesHierarchy(traits) {.join('\n');}-export async function runValuesAlignmentTests(providerId, model, testIds = null) {+export async function runValuesAlignmentTests(providerId, model, testIds = null, personaId = null) {const dilemmas = await parseValuesAlignmentSuite();- const twinContext = await getDigitalTwinForPrompt();+ // A persona flavors the embodied identity so the dilemmas measure values+ // alignment *as* that persona (P7); none tests the base twin.+ const twinContext = await getDigitalTwinForPrompt(personaId ? { personaId } : {});const provider = await getProviderById(providerId);if (!provider || !provider.enabled) {@@ -130,6 +132,7 @@ export async function runValuesAlignmentTests(providerId, model, testIds = null)runId: generateId(),providerId,model,+ ...resolveTestPersona(meta.personas, personaId),score: toRun.length > 0 ? (aligned + partial * 0.5) / toRun.length : 0,aligned,partial,