{"record":{"id":"136be849d9423e4d","repo":"jackwener/OpenCLI","slug":"verify-command-returned-no-metric-for-baseline","errorCode":null,"errorMessage":"Verify command returned no metric for baseline","messagePattern":"Verify command returned no metric for baseline","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"autoresearch/engine.ts","lineNumber":183,"sourceCode":"    ];\n    return hints[Math.min(discards - 5, hints.length - 1)];\n  }\n\n  /** Run the main loop */\n  async run(): Promise<IterationResult[]> {\n    const results: IterationResult[] = [];\n\n    // Phase 0: Preconditions\n    this.log('Phase 0: Precondition checks...');\n    this.checkPreconditions();\n\n    // Initialize logger\n    this.logger.init(this.config);\n\n    // Baseline measurement\n    this.log('Measuring baseline...');\n    const baseline = this.runVerify();\n    if (baseline == null) throw new Error('Verify command returned no metric for baseline');\n    this.bestMetric = baseline;\n    this.currentMetric = baseline;\n\n    const baselineCommit = exec('git rev-parse --short HEAD');\n    const baselineResult: IterationResult = {\n      iteration: 0,\n      commit: baselineCommit,\n      metric: baseline,\n      delta: 0,\n      guard: this.config.guard ? (this.runGuard() ? 'pass' : 'fail') : '-',\n      status: 'baseline',\n      description: `initial state — ${this.config.metric} ${baseline}`,\n    };\n    this.logger.append(baselineResult);\n    results.push(baselineResult);\n    this.log(`Baseline: ${this.config.metric} = ${baseline}`);\n\n    // Main loop","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/autoresearch/engine.ts#L165-L201","documentation":"pruneTraceArtifactsBestEffort in src/observation/artifact.ts wraps pruneTraceArtifacts in try/catch and, on failure, only logs '[trace] Failed to prune trace artifacts: <message>' via log.warn. This is intentionally best-effort: pruning old trace artifacts after exportObservationSession must never fail the export, so any error (permissions, missing dirs, locked files) is downgraded to a warning carrying the underlying error message.","triggerScenarios":"exportObservationSession calls pruneTraceArtifacts with a retention policy and protectedTraceDir, and the pruning step throws — e.g. the tracesDir doesn't exist, files are read-only, or the OS denies deletion.","commonSituations":"Running the daemon under a user without write/delete permission on the traces directory; tracesDir on a read-only or removed volume; another process holding trace files open (Windows file locks); a corrupted or partially deleted trace directory from a previous crash.","solutions":["Check the log's embedded message (err.message) to identify the underlying fs error (ENOENT, EACCES, EBUSY, etc.).","Verify the traces directory exists and the process user has write/delete permissions on it and its contents.","Close other processes/locks holding trace files open, then re-run the export/prune.","If pruning is optional for your workflow, treat the warning as non-fatal — the observation session export itself succeeded; manually clean old trace dirs as needed."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import { accessSync, constants } from 'fs';\ntry {\n  accessSync(tracesDir, constants.W_OK);\n} catch {\n  log.warn(`[trace] tracesDir ${tracesDir} not writable — pruning will be skipped`);\n}","typeGuard":"function canPrune(tracesDir: string): boolean {\n  try { accessSync(tracesDir, constants.W_OK); return true; } catch { return false; }\n}","tryCatchPattern":"// the library already swallows this; on your side treat it as non-fatal:\ntry {\n  await exportObservationSession(session);\n} catch (err) {\n  throw err; // pruning failures do NOT surface here — only as '[trace] Failed to prune...' warnings\n}\n// match on the log warning if you want to schedule manual cleanup","preventionTips":["Ensure the daemon/service runs as a user with write and delete permissions on the traces directory.","Keep tracesDir off read-only or ephemeral volumes if you rely on retention pruning.","On Windows, avoid other processes locking trace files during export windows.","Monitor logs for the '[trace] Failed to prune' warning and alert on repeated occurrences to prevent unbounded disk growth."],"tags":["filesystem","trace","best-effort","retention"],"backgroundTag":"file-cleanup-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}