elenchus_clear_cache
Clear cached verification results to force fresh adversarial code analysis using the Verifier-Critic debate loop. Requires explicit confirmation.
Instructions
Clear all cached verification results. Requires confirm: true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confirm | Yes | Confirm cache clear operation |
Implementation Reference
- src/tools/cache-tools.ts:46-65 (handler)The clearCacheTool handler function that executes the tool logic. It checks the 'confirm' argument, and if true, calls clearCache() from the cache module and returns a success response. Otherwise returns an error message.
export async function clearCacheTool( args: z.infer<typeof ClearCacheSchema> ): Promise<{ success: boolean; message: string; }> { if (!args.confirm) { return { success: false, message: 'Cache clear not confirmed. Set confirm: true to proceed.' }; } await clearCache(); return { success: true, message: 'Cache cleared successfully' }; } - src/tools/schemas.ts:252-254 (schema)The ClearCacheSchema validation schema using Zod, requiring a 'confirm' boolean field.
export const ClearCacheSchema = z.object({ confirm: z.boolean().describe('Confirm cache clear operation') }); - src/tools/cache-tools.ts:71-82 (registration)Registration of the 'elenchus_clear_cache' tool in the cacheTools object, mapping it to the ClearCacheSchema and clearCacheTool handler.
export const cacheTools = { elenchus_get_cache_stats: { description: 'Get cache statistics including hit rate, total entries, and token savings.', schema: GetCacheStatsSchema, handler: getCacheStatsTool }, elenchus_clear_cache: { description: 'Clear all cached verification results. Requires confirm: true.', schema: ClearCacheSchema, handler: clearCacheTool } }; - src/tools/index.ts:41-54 (registration)The composed 'tools' export that includes all cacheTools (including elenchus_clear_cache) via spread operator.
export const tools = { ...sessionLifecycleTools, ...issueManagementTools, ...mediatorTools, ...roleTools, ...reverifyTools, ...diffTools, ...cacheTools, ...pipelineTools, ...safeguardsTools, ...optimizationTools, ...dynamicRoleTools, ...llmEvalTools, }; - src/cache/store.ts:211-234 (helper)The clearCache helper function that deletes all .json cache files from disk and resets the in-memory cache index and stats.
export async function clearCache(config: CacheConfig = DEFAULT_CACHE_CONFIG): Promise<void> { const cacheDir = config.storagePath || DEFAULT_CACHE_DIR; try { const files = await fs.readdir(cacheDir); for (const file of files) { if (file.endsWith('.json')) { await fs.unlink(path.join(cacheDir, file)); } } cacheIndex.clear(); stats = { totalEntries: 0, hitCount: 0, missCount: 0, hitRate: 0, averageAge: 0, totalTokensSaved: 0, storageSize: 0 }; } catch (error) { console.error('[Elenchus Cache] Error clearing:', error); } }