Write the FULL (uncapped) skip list to a per-run logfile — ONLY when >=1 file * was skipped (no logfile on a clean run). Location: * $CBM_INDEX_LOG (override) else /logs/ - .log * Returns true and fills out_path on success. */
| 7203 | * $CBM_INDEX_LOG (override) else <cache_dir>/logs/<project>-<epoch>.log |
| 7204 | * Returns true and fills out_path on success. */ |
| 7205 | static bool write_skip_logfile(const char *project, const cbm_file_error_t *errs, int count, |
| 7206 | char *out_path, size_t out_sz) { |
| 7207 | if (!errs || count <= 0) { |
| 7208 | return false; |
| 7209 | } |
| 7210 | char path[CBM_SZ_1K]; |
| 7211 | const char *override = getenv("CBM_INDEX_LOG"); |
| 7212 | if (override && override[0]) { |
| 7213 | snprintf(path, sizeof(path), "%s", override); |
| 7214 | } else { |
| 7215 | const char *cdir = cbm_resolve_cache_dir(); |
| 7216 | if (!cdir) { |
| 7217 | return false; |
| 7218 | } |
| 7219 | char logdir[CBM_SZ_1K]; |
| 7220 | snprintf(logdir, sizeof(logdir), "%s/logs", cdir); |
| 7221 | cbm_mkdir_p(logdir, 0755); |
| 7222 | snprintf(path, sizeof(path), "%s/%s-%lld.log", logdir, project ? project : "index", |
| 7223 | (long long)time(NULL)); |
| 7224 | } |
| 7225 | FILE *f = cbm_fopen(path, "wb"); |
| 7226 | if (!f) { |
| 7227 | cbm_log_warn("index.logfile_open_fail", "path", path); |
| 7228 | return false; |
| 7229 | } |
| 7230 | int partials = 0; |
| 7231 | for (int i = 0; i < count; i++) { |
| 7232 | if (is_parse_partial(&errs[i])) { |
| 7233 | partials++; |
| 7234 | } |
| 7235 | } |
| 7236 | (void)fprintf(f, "# codebase-memory-mcp index coverage report\n"); |
| 7237 | (void)fprintf(f, "# project=%s skipped=%d parse_partial=%d\n", project ? project : "", |
| 7238 | count - partials, partials); |
| 7239 | (void)fprintf(f, "# columns: phase\treason\tpath\n"); |
| 7240 | for (int i = 0; i < count; i++) { |
| 7241 | (void)fprintf(f, "%s\t%s\t%s\n", errs[i].phase ? errs[i].phase : "", |
| 7242 | errs[i].reason ? errs[i].reason : "", errs[i].path ? errs[i].path : ""); |
| 7243 | } |
| 7244 | (void)fclose(f); |
| 7245 | if (out_path && out_sz) { |
| 7246 | snprintf(out_path, out_sz, "%s", path); |
| 7247 | } |
| 7248 | return true; |
| 7249 | } |
| 7250 | |
| 7251 | /* Build the success portion of the index_repository response. |
| 7252 | * Returns true when status should be "degraded" (#334 plausibility gate). */ |
no test coverage detected