refactor(server): move the install audit trail from core to the server (P1.2, UF-040)

Core keeps only shared infrastructure, so InstallAuditStore leaves it and
lives in packages/server/src/local/install-audit.ts. The trail itself stays:
the Audit and Activity tabs, the extend and export routes, and the threat
model entry keep working on the same waggle.db table.

- @waggle/shared gets RecordAuditInput and the narrow InstallAuditRecorder
  (record only), which the agent's skill tools now depend on.
- The server creates the audit table before the one-time legacy copy, which
  no longer constructs it in core.
- UF-040: GET /api/debug/logs called prepare() on the store's private db
  wrapper, which has none, so the support bundle never carried recent
  installs. It now reads them through getRecentSummary().
This commit is contained in:
shumeiko.it
2026-10-25 21:32:38 +01:00
parent 3befcd8e9b
commit 2e08f2ae96
22 changed files with 118 additions and 79 deletions

View File

@@ -12,7 +12,7 @@ import type { ToolDefinition } from './tools.js';
import { SkillRecommender } from './skill-recommender.js';
import { searchCapabilities, validateInstallCandidate, type MarketplaceCandidate } from './capability-acquisition.js';
import { assessTrust, formatTrustSummary } from './trust-model.js';
import type { InstallAuditStore } from '@waggle/core';
import type { InstallAuditRecorder } from '@waggle/shared';
// Type-only import — erased at runtime, so it does NOT reintroduce the
// agent ↔ marketplace runtime cycle that the lazy import below guards against.
import type { SecurityGate, MarketplacePackage } from '@waggle/marketplace';
@@ -50,7 +50,7 @@ export interface SkillToolsDeps {
/** Native tool names (for acquisition search — avoids proposing install when a tool exists) */
nativeToolNames?: string[];
/** Audit store for recording install events (optional — degrades gracefully) */
auditStore?: InstallAuditStore;
auditStore?: InstallAuditRecorder;
/** Optional callback to search the marketplace catalog for capabilities */
searchMarketplace?: (query: string) => Promise<MarketplaceCandidate[]>;
/**

View File

@@ -17,14 +17,14 @@ import * as path from 'node:path';
import { redactSkillContent } from './skill-redaction.js';
import type { SkillInitiator } from './skill-frontmatter.js';
import { parseSkillFrontmatter } from './skill-frontmatter.js';
import type { InstallAuditStore } from '@waggle/core';
import type { InstallAuditRecorder } from '@waggle/shared';
/** Shared deps for every skill-write op. auditStore/onChange degrade gracefully. */
export interface SkillWriteDeps {
/** Directory holding personal-scope SKILL.md files (~/.waggle/skills). */
skillsDir: string;
/** Audit store — when present, every op records an install_audit row. */
auditStore?: InstallAuditStore;
auditStore?: InstallAuditRecorder;
/** Called after a successful write/delete so the caller can hot-reload skills. */
onChange?: () => void;
}