chore: remove shadow policy machinery (ADR-0013 step 10)
Deletes shadowPolicies map, getShadowPolicies, setPolicyActive from recommender.ts; removes /api/admin/policies routes from admin.ts; removes getPolicies, togglePolicy, PolicyInfo from admin api.ts; removes the policy toggle section from the ops page. 168 API tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,6 @@ import { requireAdmin } from '../middleware/admin.js';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { bus } from '../events/bus.js';
|
||||
import { config } from '../config.js';
|
||||
import { getShadowPolicies, setPolicyActive } from './recommender.js';
|
||||
import { inspectProfile, rebuildProfile, summarizeProfileFreshness } from '../profile/builder.js';
|
||||
import { spawn } from 'child_process';
|
||||
import { existsSync, readFileSync, unlinkSync } from 'fs';
|
||||
@@ -564,36 +563,6 @@ router.get('/health', async (_req: AuthenticatedRequest, res: Response) => {
|
||||
res.json({ ok: allOk, services, checkedAt: new Date().toISOString() });
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GET /api/admin/policies
|
||||
// POST /api/admin/policies/:name/toggle
|
||||
// ---------------------------------------------------------------------------
|
||||
router.get('/policies', async (_req: AuthenticatedRequest, res: Response) => {
|
||||
res.json({ policies: getShadowPolicies() });
|
||||
});
|
||||
|
||||
router.post('/policies/:name/toggle', async (req: AuthenticatedRequest, res: Response) => {
|
||||
const { name } = req.params as { name: string };
|
||||
const { active } = req.body as { active: boolean };
|
||||
const ok = setPolicyActive(name, active);
|
||||
if (!ok) {
|
||||
res.status(404).json({ error: 'Policy not found' });
|
||||
return;
|
||||
}
|
||||
|
||||
await db.insert(adminActions).values({
|
||||
id: nanoid(),
|
||||
adminId: req.userId!,
|
||||
action: active ? 'enable_policy' : 'disable_policy',
|
||||
targetType: 'policy',
|
||||
targetId: name,
|
||||
detail: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// POST /api/admin/replay-signal
|
||||
// Re-emit a past event on the bus (for testing / backfill).
|
||||
|
||||
@@ -41,23 +41,6 @@ function randomPolicy(candidates: TipCandidate[]): TipCandidate | null {
|
||||
return candidates[Math.floor(Math.random() * candidates.length)];
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Shadow-policy registry — kept for step-10 cleanup; no active shadows.
|
||||
// ---------------------------------------------------------------------------
|
||||
const shadowPolicies = new Map<string, { active: boolean }>([
|
||||
['egreedy-v2-shadow', { active: false }],
|
||||
]);
|
||||
|
||||
export function getShadowPolicies() {
|
||||
return Array.from(shadowPolicies.entries()).map(([name, s]) => ({ name, ...s }));
|
||||
}
|
||||
|
||||
export function setPolicyActive(name: string, active: boolean): boolean {
|
||||
if (!shadowPolicies.has(name)) return false;
|
||||
shadowPolicies.set(name, { active });
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Orchestrator: fetch agent snippets + call ml/serving /recommend
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user