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
address review (claude): survive scorer failures, sentinel-only providers, and explicit default-alignment option
[._.]/ Adam Eivya421c6dcf69c
diff --git a/client/src/components/digital-twin/tabs/PersonalityTab.jsx b/client/src/components/digital-twin/tabs/PersonalityTab.jsxindex 4abec696e3..e149a1f7a7 100644--- a/client/src/components/digital-twin/tabs/PersonalityTab.jsx+++ b/client/src/components/digital-twin/tabs/PersonalityTab.jsx@@ -20,17 +20,35 @@ import useChartColors from '../../../hooks/useChartColors.js';import { timeAgo, formatDateShort } from '../../../utils/formatters';import { filterSelectableModels } from '../../../utils/providers.js';+// Pure helpers are exported for unit tests (PersonalityTab.test.jsx).+// "errorAversion" → "Error Aversion"-const humanizeTrait = (key) =>+export const humanizeTrait = (key) =>key.replace(/([A-Z])/g, ' $1').replace(/^./, (c) => c.toUpperCase()).trim();// Union of trait keys across runs — taxonomy versions may differ per record.-const traitKeyUnion = (runs) => [...new Set(runs.flatMap((r) => Object.keys(r.traits || {})))];+export const traitKeyUnion = (runs) => [...new Set(runs.flatMap((r) => Object.keys(r.traits || {})))];// Unique, readable series label for a run on the radar/table.-const seriesLabel = (run) => `${run.model || run.providerId} · ${formatDateShort(run.timestamp)}`;--const alignmentColor = (score) =>+export const seriesLabel = (run) => `${run.model || run.providerId} · ${formatDateShort(run.timestamp)}`;++// Disambiguate colliding series labels (same model re-tested the same day) by+// suffixing later occurrences with their 1-based position.+export const dedupeSeriesLabels = (bases) =>+ bases.map((base, i) => (bases.indexOf(base) === i ? base : `${base} (${i + 1})`));++// Selectable model chips for a provider. A provider whose list holds only+// configured-default sentinels (e.g. antigravity) still gets one `null` chip —+// "provider default" — which submits no model override and lets the server+// resolve the effective model.+export const providerModelOptions = (provider) => {+ const models = filterSelectableModels(+ provider.models?.length ? provider.models : [provider.defaultModel]+ ).filter(Boolean);+ return models.length ? models : [null];+};++export const alignmentColor = (score) =>score >= 0.7 ? 'text-port-success' : score >= 0.4 ? 'text-port-warning' : 'text-port-error';function TraitRadar({ runs, height = 320 }) {@@ -38,8 +56,7 @@ function TraitRadar({ runs, height = 320 }) {// Keys can differ across taxonomy versions — chart the union.const { data, labels } = useMemo(() => {const keys = traitKeyUnion(runs);- const bases = runs.map(seriesLabel);- const labels = bases.map((base, i) => (bases.indexOf(base) === i ? base : `${base} (${i + 1})`));+ const labels = dedupeSeriesLabels(runs.map(seriesLabel));const data = keys.map((k) => {const row = { trait: humanizeTrait(k) };runs.forEach((r, i) => {@@ -93,6 +110,14 @@ function AlignmentSection({ run }) {</div>);}+ if (run.alignmentError) {+ return (+ <div className="flex items-start gap-2 p-3 rounded bg-port-error/10 text-port-error text-sm">+ <AlertCircle size={16} className="shrink-0 mt-0.5" />+ <span>Alignment check failed: {run.alignmentError}</span>+ </div>+ );+ }if (!run.alignment) return null;const dims = Object.entries(run.alignment.dimensions || {});return (@@ -168,6 +193,7 @@ export default function PersonalityTab() {const [scorerProviderId, setScorerProviderId] = useState('');const [scorerModel, setScorerModel] = useState('');const [historyCap, setHistoryCap] = useState(200);+ const [defaultAlignment, setDefaultAlignment] = useState(true); // the SAVED default, distinct from this run's toggleconst [savingSettings, setSavingSettings] = useState(false);useEffect(() => {@@ -185,6 +211,7 @@ export default function PersonalityTab() {setHistory(Array.isArray(historyData) ? historyData : []);if (settingsData) {setIncludeAlignment(settingsData.defaultIncludeAlignment ?? true);+ setDefaultAlignment(settingsData.defaultIncludeAlignment ?? true);setScorerProviderId(settingsData.scorerProviderId || '');setScorerModel(settingsData.scorerModel || '');setHistoryCap(settingsData.historyCap ?? 200);@@ -213,7 +240,7 @@ export default function PersonalityTab() {setRunning({ current: i + 1, total: selectedProviders.length, model });// The api helper toasts the error; a failed model doesn't abort the rest.const record = await api- .runModelPersonalityTest({ providerId, model, includeAlignment })+ .runModelPersonalityTest({ providerId, ...(model ? { model } : {}), includeAlignment }).catch(() => null);if (record) {setResults((prev) => [...prev, record]);@@ -243,7 +270,7 @@ export default function PersonalityTab() {scorerProviderId: scorerProviderId || null,scorerModel: scorerModel || null,historyCap: Number(historyCap) || 200,- defaultIncludeAlignment: includeAlignment+ defaultIncludeAlignment: defaultAlignment}).catch(() => null);setSavingSettings(false);@@ -296,15 +323,13 @@ export default function PersonalityTab() {<div key={provider.id} className="space-y-2"><div className="text-sm font-medium text-gray-400">{provider.name}</div><div className="flex flex-wrap gap-2">- {filterSelectableModels(- provider.models?.length ? provider.models : [provider.defaultModel]- ).filter(Boolean).map((model) => {+ {providerModelOptions(provider).map((model) => {const isSelected = selectedProviders.some((p) => p.providerId === provider.id && p.model === model);return (<button- key={model}+ key={model ?? '__default__'}onClick={() => toggleProvider(provider.id, model)}className={`px-3 py-2 min-h-[40px] text-sm rounded-lg border transition-colors ${isSelected@@ -312,7 +337,7 @@ export default function PersonalityTab() {: 'border-port-border text-gray-400 hover:text-white hover:border-gray-500'}`}>- {model}+ {model ?? 'provider default'}</button>);})}@@ -414,6 +439,15 @@ export default function PersonalityTab() {/></div></div>+ <label className="flex items-center gap-2 min-h-[44px] cursor-pointer text-sm text-gray-300">+ <input+ type="checkbox"+ checked={defaultAlignment}+ onChange={(e) => setDefaultAlignment(e.target.checked)}+ className="w-5 h-5 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"+ />+ Include the twin alignment check by default on new runs+ </label><buttononClick={saveSettings}disabled={savingSettings}diff --git a/client/src/components/digital-twin/tabs/PersonalityTab.test.jsx b/client/src/components/digital-twin/tabs/PersonalityTab.test.jsxnew file mode 100644index 0000000000..b201b2ee19--- /dev/null+++ b/client/src/components/digital-twin/tabs/PersonalityTab.test.jsx@@ -0,0 +1,60 @@+import { describe, it, expect } from 'vitest';+import {+ humanizeTrait,+ traitKeyUnion,+ seriesLabel,+ dedupeSeriesLabels,+ providerModelOptions,+ alignmentColor+} from './PersonalityTab.jsx';++describe('PersonalityTab helpers', () => {+ it('humanizeTrait splits camelCase and capitalizes', () => {+ expect(humanizeTrait('errorAversion')).toBe('Error Aversion');+ expect(humanizeTrait('humor')).toBe('Humor');+ expect(humanizeTrait('selfCensorship')).toBe('Self Censorship');+ });++ it('traitKeyUnion unions keys across runs and tolerates missing traits', () => {+ const runs = [+ { traits: { humor: { score: 0.5 }, empathy: { score: 0.2 } } },+ { traits: { humor: { score: 0.9 }, dogmatism: { score: 0.1 } } },+ {} // record with no traits map+ ];+ expect(traitKeyUnion(runs)).toEqual(['humor', 'empathy', 'dogmatism']);+ expect(traitKeyUnion([])).toEqual([]);+ });++ it('seriesLabel prefers the model and falls back to providerId', () => {+ const ts = '2026-07-14T12:00:00.000Z';+ expect(seriesLabel({ model: 'm1', providerId: 'p1', timestamp: ts })).toMatch(/^m1 · /);+ expect(seriesLabel({ model: null, providerId: 'p1', timestamp: ts })).toMatch(/^p1 · /);+ });++ it('dedupeSeriesLabels suffixes later collisions and leaves uniques alone', () => {+ expect(dedupeSeriesLabels(['a', 'b', 'a', 'a'])).toEqual(['a', 'b', 'a (3)', 'a (4)']);+ expect(dedupeSeriesLabels(['x', 'y'])).toEqual(['x', 'y']);+ });++ it('providerModelOptions filters sentinel ids and falls back to a null default chip', () => {+ expect(+ providerModelOptions({ models: ['gpt-x', 'codex-configured-default'], defaultModel: 'gpt-x' })+ ).toEqual(['gpt-x']);+ // Sentinel-only provider (e.g. antigravity) → one "provider default" chip.+ expect(+ providerModelOptions({+ models: ['antigravity-configured-default'],+ defaultModel: 'antigravity-configured-default'+ })+ ).toEqual([null]);+ // No models at all → defaultModel fallback.+ expect(providerModelOptions({ models: [], defaultModel: 'm-default' })).toEqual(['m-default']);+ expect(providerModelOptions({ models: [], defaultModel: null })).toEqual([null]);+ });++ it('alignmentColor thresholds match the success/warning/error bands', () => {+ expect(alignmentColor(0.9)).toBe('text-port-success');+ expect(alignmentColor(0.5)).toBe('text-port-warning');+ expect(alignmentColor(0.1)).toBe('text-port-error');+ });+});diff --git a/server/services/modelPersonality.js b/server/services/modelPersonality.jsindex c876e813b3..2312829901 100644--- a/server/services/modelPersonality.js+++ b/server/services/modelPersonality.js@@ -158,7 +158,14 @@ export async function runPersonalityTest({ providerId, model, includeAlignment,};if (wantAlignment) {- Object.assign(record, await scoreAlignment(record, settings));+ // A scorer failure (misconfigured scorer provider, runner cascade+ // exhausted) must not discard the already-completed self-profile — the+ // user paid for call 1. Persist the profile with the error noted instead.+ const alignmentResult = await scoreAlignment(record, settings).catch((err) => {+ console.error(`❌ Alignment scorer failed: ${err.message}`);+ return { alignmentError: err.message };+ });+ Object.assign(record, alignmentResult);}await appendResult(record, settings.historyCap);diff --git a/server/services/modelPersonality.test.js b/server/services/modelPersonality.test.jsindex fd2ec7022b..393aed67c2 100644--- a/server/services/modelPersonality.test.js+++ b/server/services/modelPersonality.test.js@@ -138,6 +138,20 @@ describe('runPersonalityTest', () => {});});+ it('persists the self-profile with alignmentError when the scorer call fails', async () => {+ loadMeta.mockResolvedValue({ traits: { bigFive: { openness: 0.8 } } });+ mockProfileRun({ effectiveModel: 'kept-model' });+ runPromptThroughProvider.mockRejectedValueOnce(new Error('scorer exploded'));++ const record = await svc.runPersonalityTest({ providerId: 'prov-1', includeAlignment: true });++ // Call 1's paid result survives; the failure is recorded, not thrown.+ expect(record.model).toBe('kept-model');+ expect(record.alignment).toBeUndefined();+ expect(record.alignmentError).toBe('scorer exploded');+ expect(await svc.getHistory()).toHaveLength(1);+ });+it('defaults includeAlignment from settings when the caller omits it', async () => {await svc.updateSettings({ defaultIncludeAlignment: false });mockProfileRun();