refactor: remove KVARK, enterprise packs and the compliance subsystem (P1.4, P1.6)
KVARK is the commercial enterprise product and is not part of the community edition. The agent's KVARK tools were never wired into the server, so removing them changes no runtime behaviour beyond the routes listed here. - agent: delete kvark-tools; CombinedRetrieval and formatCombinedResult now merge workspace and personal memory only (no KVARK lane, no source conflict note); connector substrate is always 'waggle' - agent: promote_skill stops at workspace scope; team and enterprise scopes answer "not available in this edition" instead of an upgrade prompt - server: delete src/kvark and GET /api/marketplace/enterprise-packs - marketplace: delete ENTERPRISE_PACKS - compliance (EU AI Act dashboard, its templates and the KVARK template seeded on every boot): delete core/src/compliance, the /api/compliance/* routes, agent compliance-pdf and the Cockpit compliance panel. The ai_interactions table lives in the memory substrate and goes with P1.5.
This commit is contained in:
@@ -10,7 +10,7 @@ import Fastify, { type FastifyInstance, type FastifyRequest } from 'fastify';
|
||||
import cors from '@fastify/cors';
|
||||
import fastifyStatic from '@fastify/static';
|
||||
import websocket from '@fastify/websocket';
|
||||
import { MindDB, MultiMind, MultiMindCache, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, FrameStore, SessionStore, SuppressionStore, InstallAuditStore, CronStore, AwarenessLayer, VaultStore, SkillHashStore, OptimizationLogStore, ImprovementSignalStore, HarvestSourceStore, ClaudeCodeAdapter, reconcileIndexes, TeamSync, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore, EvolutionRunStore, ComplianceTemplateStore, harvestSetHash, type WorkspaceConfig } from '@waggle/core';
|
||||
import { MindDB, MultiMind, MultiMindCache, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, FrameStore, SessionStore, SuppressionStore, InstallAuditStore, CronStore, AwarenessLayer, VaultStore, SkillHashStore, OptimizationLogStore, ImprovementSignalStore, HarvestSourceStore, ClaudeCodeAdapter, reconcileIndexes, TeamSync, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore, EvolutionRunStore, harvestSetHash, type WorkspaceConfig } from '@waggle/core';
|
||||
import { corsOriginAllowed } from './cors-config.js';
|
||||
import { getBoundTeamServer } from './team-server-binding.js';
|
||||
import { fetchTeamServer } from './team-server-egress.js';
|
||||
@@ -172,7 +172,6 @@ import { identityRoutes } from './routes/identity.js';
|
||||
import { agentRunRoutes } from './routes/agent-run.js';
|
||||
import { agentRunsRoutes } from './routes/agent-runs.js';
|
||||
import { localInferenceRoutes } from './routes/local-inference.js';
|
||||
import { complianceRoutes } from './routes/compliance.js';
|
||||
import { OfflineManager } from './offline-manager.js';
|
||||
import { listOllamaChatModelIds } from './model-availability.js';
|
||||
import { log, createLogger } from './logger.js';
|
||||
@@ -528,17 +527,6 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
|
||||
const auditStore = new InstallAuditStore(multiMind.personal);
|
||||
server.decorate('auditStore', auditStore);
|
||||
|
||||
// M-06: seed the built-in KVARK enterprise template on first boot.
|
||||
// Idempotent — subsequent boots see the row and no-op.
|
||||
try {
|
||||
const templateStore = new ComplianceTemplateStore(multiMind.personal);
|
||||
templateStore.seedKvarkTemplateIfMissing();
|
||||
} catch (err) {
|
||||
// Non-fatal: users can create the template manually from the UI if the
|
||||
// seed fails (disk full, schema drift, etc.).
|
||||
server.log.warn({ err }, 'Failed to seed KVARK compliance template');
|
||||
}
|
||||
|
||||
// Cron store — SQLite-backed schedule persistence for Solo
|
||||
const cronStore = new CronStore(multiMind.personal);
|
||||
server.decorate('cronStore', cronStore);
|
||||
@@ -2890,7 +2878,6 @@ Return ONLY the improved system prompt text. No commentary, no markdown fences,
|
||||
await server.register(agentRunRoutes);
|
||||
await server.register(agentRunsRoutes);
|
||||
await server.register(localInferenceRoutes);
|
||||
await server.register(complianceRoutes);
|
||||
|
||||
// ── Static file serving for web mode ──────────────────────────
|
||||
// When WAGGLE_FRONTEND_DIR is set, serve the React frontend as static files.
|
||||
|
||||
@@ -1,312 +0,0 @@
|
||||
/**
|
||||
* Compliance Routes — AI Act compliance API endpoints.
|
||||
*
|
||||
* GET /api/compliance/status — get compliance status
|
||||
* POST /api/compliance/export — generate audit report
|
||||
* GET /api/compliance/interactions — list recent interactions
|
||||
* POST /api/compliance/interactions — record an interaction (internal use)
|
||||
*/
|
||||
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
InteractionStore, ComplianceStatusChecker, ReportGenerator,
|
||||
HarvestSourceStore, ComplianceTemplateStore,
|
||||
type RecordInteractionInput, type AuditReportRequest,
|
||||
type CreateComplianceTemplateInput, type UpdateComplianceTemplateInput,
|
||||
type AIActRiskLevel,
|
||||
} from '@waggle/core';
|
||||
import { renderComplianceReportPdf, type PdfTemplateOverrides } from '@waggle/agent';
|
||||
|
||||
/**
|
||||
* M-03: the `/export` and `/export-pdf` routes accept three optional template-
|
||||
* sourced overrides on the request body. They do not change section selection
|
||||
* (which is already merged client-side into `include`) — they only affect how
|
||||
* the PDF renders org name, footer text, and the risk-classification label.
|
||||
*/
|
||||
interface TemplateOverrideFields {
|
||||
templateOrgName?: string | null;
|
||||
templateFooterText?: string | null;
|
||||
templateRiskClassification?: AIActRiskLevel | null;
|
||||
}
|
||||
|
||||
function extractPdfOverrides(body: unknown): PdfTemplateOverrides | undefined {
|
||||
if (!body || typeof body !== 'object') return undefined;
|
||||
const b = body as TemplateOverrideFields;
|
||||
if (b.templateOrgName == null && b.templateFooterText == null && b.templateRiskClassification == null) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
orgName: b.templateOrgName ?? null,
|
||||
footerText: b.templateFooterText ?? null,
|
||||
riskClassification: b.templateRiskClassification ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
const sectionsSchema = z.object({
|
||||
interactions: z.boolean(),
|
||||
oversight: z.boolean(),
|
||||
models: z.boolean(),
|
||||
provenance: z.boolean(),
|
||||
riskAssessment: z.boolean(),
|
||||
fria: z.boolean(),
|
||||
});
|
||||
|
||||
const riskSchema = z.enum(['minimal', 'limited', 'high-risk', 'unacceptable']);
|
||||
|
||||
const createTemplateSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
description: z.string().nullable().optional(),
|
||||
sections: sectionsSchema,
|
||||
riskClassification: riskSchema.nullable().optional(),
|
||||
orgName: z.string().nullable().optional(),
|
||||
footerText: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
const updateTemplateSchema = z.object({
|
||||
name: z.string().min(1).optional(),
|
||||
description: z.string().nullable().optional(),
|
||||
sections: sectionsSchema.optional(),
|
||||
riskClassification: riskSchema.nullable().optional(),
|
||||
orgName: z.string().nullable().optional(),
|
||||
footerText: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export async function complianceRoutes(fastify: FastifyInstance) {
|
||||
// GET /api/compliance/status — evaluate current compliance
|
||||
fastify.get<{ Querystring: { workspaceId?: string } }>('/api/compliance/status', async (_request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) {
|
||||
return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
}
|
||||
|
||||
const store = new InteractionStore(personalDb);
|
||||
const checker = new ComplianceStatusChecker(store);
|
||||
const workspaceId = _request.query?.workspaceId;
|
||||
return checker.check(workspaceId || undefined);
|
||||
});
|
||||
|
||||
// POST /api/compliance/export — generate audit report
|
||||
fastify.post('/api/compliance/export', async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) {
|
||||
return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
}
|
||||
|
||||
const body = request.body as AuditReportRequest;
|
||||
if (!body.from || !body.to) {
|
||||
return reply.code(400).send({ error: 'from and to dates are required' });
|
||||
}
|
||||
|
||||
const interactionStore = new InteractionStore(personalDb);
|
||||
const harvestStore = new HarvestSourceStore(personalDb);
|
||||
const wsManager = fastify.workspaceManager;
|
||||
const generator = new ReportGenerator({
|
||||
interactionStore,
|
||||
harvestStore,
|
||||
getWorkspaceName: (id) => wsManager?.get(id)?.name ?? id,
|
||||
getWorkspaceRisk: (id) => wsManager?.get(id)?.riskLevel ?? 'minimal',
|
||||
getWorkspaceRiskClassifiedAt: (id) => wsManager?.get(id)?.riskClassifiedAt ?? null,
|
||||
});
|
||||
|
||||
const report = generator.generate({
|
||||
workspaceId: body.workspaceId,
|
||||
from: body.from,
|
||||
to: body.to,
|
||||
format: body.format ?? 'json',
|
||||
include: body.include ?? {
|
||||
interactions: true,
|
||||
oversight: true,
|
||||
models: true,
|
||||
provenance: true,
|
||||
riskAssessment: true,
|
||||
fria: false,
|
||||
},
|
||||
});
|
||||
|
||||
return report;
|
||||
});
|
||||
|
||||
// GET /api/compliance/interactions — list recent interactions
|
||||
fastify.get('/api/compliance/interactions', async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) {
|
||||
return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
}
|
||||
|
||||
const store = new InteractionStore(personalDb);
|
||||
const { limit, workspaceId } = request.query as { limit?: string; workspaceId?: string };
|
||||
const parsedLimit = Math.min(Number(limit) || 20, 100);
|
||||
|
||||
if (workspaceId) {
|
||||
return { interactions: store.getByWorkspace(workspaceId) };
|
||||
}
|
||||
return { interactions: store.getRecent(parsedLimit) };
|
||||
});
|
||||
|
||||
// POST /api/compliance/interactions — record an AI interaction
|
||||
fastify.post('/api/compliance/interactions', async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) {
|
||||
return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
}
|
||||
|
||||
const body = request.body as RecordInteractionInput;
|
||||
if (!body.model || !body.provider) {
|
||||
return reply.code(400).send({ error: 'model and provider are required' });
|
||||
}
|
||||
|
||||
const store = new InteractionStore(personalDb);
|
||||
const entry = store.record(body);
|
||||
return entry;
|
||||
});
|
||||
|
||||
// POST /api/compliance/export-pdf — M-02: renders the same AuditReport
|
||||
// shape as /export through the compliance-pdf module and returns a PDF
|
||||
// binary. Body accepts the full AuditReportRequest, identical to /export,
|
||||
// so the UI can reuse its existing "which sections should we include"
|
||||
// state. Returns application/pdf with a Content-Disposition hint so
|
||||
// browsers trigger a Save dialog.
|
||||
fastify.post('/api/compliance/export-pdf', async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) {
|
||||
return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
}
|
||||
|
||||
const body = request.body as AuditReportRequest;
|
||||
if (!body.from || !body.to) {
|
||||
return reply.code(400).send({ error: 'from and to dates are required' });
|
||||
}
|
||||
|
||||
const interactionStore = new InteractionStore(personalDb);
|
||||
const harvestStore = new HarvestSourceStore(personalDb);
|
||||
const wsManager = fastify.workspaceManager;
|
||||
const generator = new ReportGenerator({
|
||||
interactionStore,
|
||||
harvestStore,
|
||||
getWorkspaceName: (id) => wsManager?.get(id)?.name ?? id,
|
||||
getWorkspaceRisk: (id) => wsManager?.get(id)?.riskLevel ?? 'minimal',
|
||||
getWorkspaceRiskClassifiedAt: (id) => wsManager?.get(id)?.riskClassifiedAt ?? null,
|
||||
});
|
||||
|
||||
const report = generator.generate({
|
||||
workspaceId: body.workspaceId,
|
||||
from: body.from,
|
||||
to: body.to,
|
||||
format: body.format ?? 'json',
|
||||
include: body.include ?? {
|
||||
interactions: true,
|
||||
oversight: true,
|
||||
models: true,
|
||||
provenance: true,
|
||||
riskAssessment: true,
|
||||
fria: false,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const pdfBuffer = await renderComplianceReportPdf(report, extractPdfOverrides(body));
|
||||
const filename = `ai-act-compliance-${body.from.slice(0, 10)}-to-${body.to.slice(0, 10)}.pdf`;
|
||||
return reply
|
||||
.header('Content-Type', 'application/pdf')
|
||||
.header('Content-Disposition', `attachment; filename="${filename}"`)
|
||||
.send(pdfBuffer);
|
||||
} catch (err) {
|
||||
return reply.code(500).send({
|
||||
error: err instanceof Error ? err.message : 'PDF generation failed',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// GET /api/compliance/models — get model inventory
|
||||
fastify.get('/api/compliance/models', async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) {
|
||||
return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
}
|
||||
|
||||
const store = new InteractionStore(personalDb);
|
||||
const { from, to, workspaceId } = request.query as { from?: string; to?: string; workspaceId?: string };
|
||||
return { models: store.getModelInventory(from, to, workspaceId) };
|
||||
});
|
||||
|
||||
// ── M-03: Compliance templates CRUD ──
|
||||
// Templates are stored on the personal mind (same DB as ai_interactions) so a
|
||||
// single "My templates" list is visible across all workspaces. Sections merge
|
||||
// with the runtime /export body's `include` flags (union semantics); the
|
||||
// merge happens in the UI layer before the POST, not here, so the /export
|
||||
// and /export-pdf routes stay template-agnostic.
|
||||
|
||||
fastify.get('/api/compliance/templates', async (_request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
const store = new ComplianceTemplateStore(personalDb);
|
||||
return { templates: store.list() };
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id: string } }>(
|
||||
'/api/compliance/templates/:id',
|
||||
async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
const id = Number(request.params.id);
|
||||
if (!Number.isFinite(id)) return reply.code(400).send({ error: 'Invalid id' });
|
||||
const store = new ComplianceTemplateStore(personalDb);
|
||||
const template = store.getById(id);
|
||||
if (!template) return reply.code(404).send({ error: 'Template not found' });
|
||||
return { template };
|
||||
},
|
||||
);
|
||||
|
||||
fastify.post('/api/compliance/templates', async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
const parsed = createTemplateSchema.safeParse(request.body);
|
||||
if (!parsed.success) {
|
||||
return reply.code(400).send({ error: 'Invalid template body', detail: parsed.error.issues });
|
||||
}
|
||||
const store = new ComplianceTemplateStore(personalDb);
|
||||
try {
|
||||
const template = store.create(parsed.data as CreateComplianceTemplateInput);
|
||||
return reply.code(201).send({ template });
|
||||
} catch (err) {
|
||||
return reply.code(400).send({ error: err instanceof Error ? err.message : 'Create failed' });
|
||||
}
|
||||
});
|
||||
|
||||
fastify.patch<{ Params: { id: string } }>(
|
||||
'/api/compliance/templates/:id',
|
||||
async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
const id = Number(request.params.id);
|
||||
if (!Number.isFinite(id)) return reply.code(400).send({ error: 'Invalid id' });
|
||||
const parsed = updateTemplateSchema.safeParse(request.body);
|
||||
if (!parsed.success) {
|
||||
return reply.code(400).send({ error: 'Invalid template patch', detail: parsed.error.issues });
|
||||
}
|
||||
const store = new ComplianceTemplateStore(personalDb);
|
||||
try {
|
||||
const template = store.update(id, parsed.data as UpdateComplianceTemplateInput);
|
||||
if (!template) return reply.code(404).send({ error: 'Template not found' });
|
||||
return { template };
|
||||
} catch (err) {
|
||||
return reply.code(400).send({ error: err instanceof Error ? err.message : 'Update failed' });
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
fastify.delete<{ Params: { id: string } }>(
|
||||
'/api/compliance/templates/:id',
|
||||
async (request, reply) => {
|
||||
const personalDb = fastify.multiMind?.personal;
|
||||
if (!personalDb) return reply.code(503).send({ error: 'Personal mind not available' });
|
||||
const id = Number(request.params.id);
|
||||
if (!Number.isFinite(id)) return reply.code(400).send({ error: 'Invalid id' });
|
||||
const store = new ComplianceTemplateStore(personalDb);
|
||||
const deleted = store.delete(id);
|
||||
if (!deleted) return reply.code(404).send({ error: 'Template not found' });
|
||||
return { deleted: true };
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import type { FastifyInstance, FastifyReply } from 'fastify';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { homedir } from 'os';
|
||||
import { MarketplaceDB, MarketplaceInstaller, MarketplaceSync, SecurityGate, ENTERPRISE_PACKS, PACKAGE_CATEGORIES, recategorizeAll, isCiscoScannerAvailable, resolveSkillSource, SkillSourceError, createMarketplaceMcpProvenance } from '@waggle/marketplace';
|
||||
import { MarketplaceDB, MarketplaceInstaller, MarketplaceSync, SecurityGate, PACKAGE_CATEGORIES, recategorizeAll, isCiscoScannerAvailable, resolveSkillSource, SkillSourceError, createMarketplaceMcpProvenance } from '@waggle/marketplace';
|
||||
import type { InstallationType, SearchSort, ScanResult, MarketplacePackage, MarketplaceMcpProvenance, MarketplaceApprovalIdentity, FetchFn } from '@waggle/marketplace';
|
||||
import { validateSkillMd } from '@waggle/sdk';
|
||||
import { safeFetch, assertUrlAllowed, scanForInjection } from '@waggle/agent';
|
||||
import { getKvarkConfig } from '../../kvark/kvark-config.js';
|
||||
import { emitNotification } from './notifications.js';
|
||||
import { loadMcpConfig, removeMcpServerEntry } from '../mcp-config.js';
|
||||
import { enqueueHeldAction } from '../held-action-executor.js';
|
||||
@@ -182,30 +181,6 @@ export async function marketplaceRoutes(fastify: FastifyInstance) {
|
||||
return result;
|
||||
});
|
||||
|
||||
// ── GET /api/marketplace/enterprise-packs ─────────────────────────────
|
||||
// Returns enterprise packs that require KVARK. Only populated when
|
||||
// KVARK credentials are configured in the vault.
|
||||
|
||||
fastify.get('/api/marketplace/enterprise-packs', async (request, reply) => {
|
||||
const vault = fastify.vault;
|
||||
const kvarkConfigured = vault ? getKvarkConfig(vault) !== null : false;
|
||||
|
||||
if (!kvarkConfigured) {
|
||||
return {
|
||||
packs: [],
|
||||
total: 0,
|
||||
kvarkRequired: true,
|
||||
hint: 'Enterprise packs require a KVARK connection. Configure KVARK credentials in the vault to unlock.',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
packs: ENTERPRISE_PACKS,
|
||||
total: ENTERPRISE_PACKS.length,
|
||||
kvarkRequired: false,
|
||||
};
|
||||
});
|
||||
|
||||
// ── POST /api/marketplace/install ───────────────────────────────────
|
||||
// Install a package from the marketplace with SecurityGate pre-scan.
|
||||
// Severity-based gating:
|
||||
|
||||
@@ -319,8 +319,6 @@ const UNSAFE_WORKSPACE_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);
|
||||
*/
|
||||
const VIEWER_READ_ONLY_POST_EXEMPT_PATHS = new Set([
|
||||
'/api/export',
|
||||
'/api/compliance/export',
|
||||
'/api/compliance/export-pdf',
|
||||
'/api/automations/test',
|
||||
'/api/command/interpret',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user