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: reject unparseable prompts in scoreDrill, remove mirror test logic
Adam Eivy041ad7c1b4c3
diff --git a/server/services/meatspaceAlcohol.test.js b/server/services/meatspaceAlcohol.test.jsindex fda0cf8064..9ffd4e7d08 100644--- a/server/services/meatspaceAlcohol.test.js+++ b/server/services/meatspaceAlcohol.test.js@@ -265,71 +265,5 @@ describe('computeRollingAverages', () => {});});-// =============================================================================-// CUSTOM DRINK BUTTON LOGIC TESTS (inline logic mirroring service functions)-// =============================================================================--describe('custom drink button logic', () => {- // Mirrors loadCustomDrinks normalization- function normalizeCustomDrinks(data) {- if (!data) return { drinks: [] };- if (!Array.isArray(data.drinks)) data.drinks = [];- return data;- }-- it('normalizes null data to empty drinks array', () => {- const result = normalizeCustomDrinks(null);- expect(result).toEqual({ drinks: [] });- });-- it('normalizes data without drinks key', () => {- const result = normalizeCustomDrinks({ something: 'else' });- expect(result.drinks).toEqual([]);- });-- it('normalizes non-array drinks to empty array', () => {- const result = normalizeCustomDrinks({ drinks: 'invalid' });- expect(result.drinks).toEqual([]);- });-- it('preserves valid drinks array', () => {- const drinks = [{ name: 'Beer', oz: 12, abv: 5 }];- const result = normalizeCustomDrinks({ drinks });- expect(result.drinks).toEqual(drinks);- });-- it('preserves empty drinks array', () => {- const result = normalizeCustomDrinks({ drinks: [] });- expect(result.drinks).toEqual([]);- });-- // Mirrors index bounds checking in update/remove/reorder- function isValidIndex(index, length) {- return Number.isInteger(index) && index >= 0 && index < length;- }-- it('rejects NaN index', () => {- expect(isValidIndex(NaN, 5)).toBe(false);- });-- it('rejects float index', () => {- expect(isValidIndex(1.5, 5)).toBe(false);- });-- it('rejects negative index', () => {- expect(isValidIndex(-1, 5)).toBe(false);- });-- it('rejects out-of-bounds index', () => {- expect(isValidIndex(5, 5)).toBe(false);- });-- it('accepts valid index', () => {- expect(isValidIndex(0, 5)).toBe(true);- expect(isValidIndex(4, 5)).toBe(true);- });-- it('rejects any index for empty list', () => {- expect(isValidIndex(0, 0)).toBe(false);- });-});+// Custom drink normalization and index validation are covered by meatspaceCustomDrinks.test.js+// which exercises the actual service exports (getCustomDrinks, updateCustomDrink, etc.)diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.jsindex d9113b02d1..3df4a6f312 100644--- a/server/services/meatspacePost.js+++ b/server/services/meatspacePost.js@@ -277,9 +277,9 @@ export function scoreDrill(type, questions, timeLimitMs, config = {}) {// Recompute expected from the prompt server-side — never trust client-provided expectedconst recomputed = questions.map(q => {- const expected = computeExpectedFromPrompt(q.prompt) ?? q.expected;+ const expected = computeExpectedFromPrompt(q.prompt);let correct;- if (q.answered == null) {+ if (expected == null || q.answered == null) {correct = false;} else if (type === 'estimation') {const tolerance = ((config.tolerancePct ?? 10) / 100);