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: preserve standardization target identity (#4921)
Adam Eivy33f98fa15a4a
diff --git a/server/routes/standardize.js b/server/routes/standardize.jsindex e6416f1e80..5994b9fe79 100644--- a/server/routes/standardize.js+++ b/server/routes/standardize.js@@ -63,7 +63,11 @@ async function resolveStandardizeTarget({ repoPath, appId }) {});}- return realTarget;+ // Keep the registered/requested spelling after checking its canonical target.+ // analyzeApp uses the stored repoPath for managed-app identity (including its+ // own-port exemption), so replacing a symlinked path with realTarget would+ // make that app look unrelated and unnecessarily reassign its ports.+ return target;}// POST /api/standardize/analyze - Analyze app and generate standardization plan@@ -87,10 +91,9 @@ router.post('/analyze', asyncHandler(async (req, res) => {// POST /api/standardize/apply - Apply standardization changesrouter.post('/apply', asyncHandler(async (req, res) => {- const { repoPath, appId } = req.body;+ const { repoPath, appId, plan, overwriteEcosystem } = validateRequest(standardizeApplySchema, req.body);const path = await resolveStandardizeTarget({ repoPath, appId });- const { plan, overwriteEcosystem } = validateRequest(standardizeApplySchema, req.body);console.log(`🔧 Applying PM2 standardization to: ${path}`);diff --git a/server/routes/standardize.test.js b/server/routes/standardize.test.jsindex 00b49db08c..7ce34a28bc 100644--- a/server/routes/standardize.test.js+++ b/server/routes/standardize.test.js@@ -32,6 +32,7 @@ import { errorMiddleware } from '../lib/errorHandler.js';import { standardizeRefusalFor, analyzeApp, applyStandardization, createGitBackup } from '../services/pm2Standardizer.js';import { getAppById, updateApp } from '../services/apps.js';import { isWithinAllowedRoots } from '../lib/workspaceRoots.js';+import { realpath } from 'fs/promises';function makeApp() {const app = express();@@ -63,6 +64,7 @@ describe('standardize routes — target resolution and the refusal gate', () =>vi.clearAllMocks();vi.mocked(standardizeRefusalFor).mockReturnValue(null);vi.mocked(isWithinAllowedRoots).mockReturnValue(true);+ vi.mocked(realpath).mockImplementation(async (path) => path);vi.mocked(applyStandardization).mockResolvedValue({ success: true, filesModified: [], backupBranch: null });});@@ -93,7 +95,7 @@ describe('standardize routes — target resolution and the refusal gate', () =>const res = await request(makeApp()).post('/api/standardize/apply')- .send({ appId: 'app-ios', repoPath: '/srv/somewhere-else', plan: {} });+ .send({ appId: 'app-ios', repoPath: '/srv/somewhere-else', plan: validPlan() });expect(res.status).toBe(400);expect(res.body.error?.code ?? res.body.code).toBe('NOT_STANDARDIZABLE');@@ -114,6 +116,17 @@ describe('standardize routes — target resolution and the refusal gate', () =>expect(analyzeApp).toHaveBeenCalledWith('/srv/example-app', undefined);});+ it('preserves a symlinked app path after checking its canonical target', async () => {+ vi.mocked(getAppById).mockResolvedValue({ id: 'app-1', type: 'vite+express', repoPath: '/tmp/example-app' });+ vi.mocked(realpath).mockResolvedValue('/private/tmp/example-app');++ const res = await request(makeApp()).post('/api/standardize/analyze').send({ appId: 'app-1' });++ expect(res.status).toBe(200);+ expect(isWithinAllowedRoots).toHaveBeenCalledWith('/private/tmp/example-app');+ expect(analyzeApp).toHaveBeenCalledWith('/tmp/example-app', undefined);+ });+it('404s an appId with no app record', async () => {vi.mocked(getAppById).mockResolvedValue(null);@@ -180,6 +193,17 @@ describe('standardize routes — target resolution and the refusal gate', () =>expect(applyStandardization).not.toHaveBeenCalled();});+ it('validates malformed target types before resolving filesystem paths', async () => {+ const res = await request(makeApp())+ .post('/api/standardize/apply')+ .send({ repoPath: [], plan: validPlan() });++ expect(res.status).toBe(400);+ expect(res.body.code).toBe('VALIDATION_ERROR');+ expect(realpath).not.toHaveBeenCalled();+ expect(applyStandardization).not.toHaveBeenCalled();+ });+it('rejects a target outside the allowed workspace roots before applying', async () => {vi.mocked(isWithinAllowedRoots).mockReturnValue(false);