feat(discover): user-defined extension→language mappings (C port)#73
feat(discover): user-defined extension→language mappings (C port)#73halindrome wants to merge 3 commits intoDeusData:mainfrom
Conversation
QA Round 1 |
QA Round 1 — Fixes AppliedAddressed all confirmed findings from the Opus QA review. Commit: b439f0e Fixed[Critical] Early-return userconfig leak in cbm_pipeline_run — the [Major] alloc failure leak in global config parse — [Major] Compound extension matching broken — |
QA Round 2 —
|
QA Round 2 — Fixes Applied (commit eb4e996)[Minor] cbm_pipeline_free missing userconfig cleanup — added defensive |
QA Round 3 — Final ReviewReviewer: Claude (senior C engineer) Previous Fix VerificationAll fixes from Rounds 1 and 2 are confirmed present and correct:
Code Analysis — No Critical or Major Issues FoundMemory safety (userconfig.c):
Extension matching (language.c):
Pipeline integration (pipeline.c):
CLI --project flag (cli.c):
Test coverage (test_userconfig.c):
Minor Observations (Informational, Not Blocking)
VerdictPASS — Ready for merge. All Round 1 and Round 2 fixes are correctly applied. No critical, major, or moderate issues remain. The code is well-structured, memory-safe, and properly tested. |
|
Thanks for the thorough work here — the 3-round QA process and the compound extension handling are impressive. We'd like to merge the extension→language mapping feature, but could you split this into two PRs? Feature 1 (extension mappings) — the Feature 2 ( The extension mapping part looks ready — if you can split it out we'll review and merge quickly. Thanks! |
|
Yeah I don't know how that happened. I think I had some worktree confusion. I will rebase this and re-run the qa round. |
…ig files
Read extra_extensions from ~/.config/codebase-memory-mcp/config.json
(global) and {repo}/.codebase-memory.json (project), merging them with
project config taking precedence. Unknown language values warn and skip.
Missing files are silently ignored (fail-open).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- pipeline.c: inline userconfig cleanup on early-exit paths (discover failure and cancel check) so userconfig is always freed, fixing the resource leak when pipeline exits before reaching the cleanup label - userconfig.c: free partially-built entries array on global config parse failure to fix alloc-failure memory leak - language.c: probe user config for compound extensions (e.g. ".blade.php") by scanning from the first dot to the last, falling back to built-in single-extension lookup — preserves built-in behavior while correctly resolving user-defined compound extensions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Defensively free p->userconfig in cbm_pipeline_free in case run() was never called (e.g. pipeline created but not executed before free) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Rebased to drop the |
eb4e996 to
57e08e6
Compare
Summary
src/discover/userconfig.c/userconfig.h: readsextra_extensionsfrom two optional JSON config files (global XDG + per-repo.codebase-memory.json), merging them with project config taking precedencecbm_language_for_extension()via a process-global pointer set before indexing starts; clears and frees it in the pipeline cleanup pathcbm_log_warn) and are silently skipped — fail-openThis is a direct C port of the Go feature from PR #60.
Config format
Global (
$XDG_CONFIG_HOME/codebase-memory-mcp/config.json, fallback~/.config/…):{"extra_extensions": {".blade.php": "php", ".mjs": "javascript"}}Project (
{repo_root}/.codebase-memory.json):{"extra_extensions": {".blade.php": "php"}}Project overrides global for conflicting keys.
Test plan
userconfig_project_basic— project config loaded,.blade.php→PHP,.mjs→JSuserconfig_global_via_env— global config read viaXDG_CONFIG_HOMEuserconfig_project_wins_over_global— project.xyz→rust beats global.xyz→pythonuserconfig_unknown_lang_skipped—"klingon"skipped, valid entry still worksuserconfig_missing_files_ok— non-existent repo → empty config, no crashuserconfig_integration_override—cbm_set_user_lang_config+cbm_language_for_extensionround-tripuserconfig_free_null— NULL-safe free🤖 Generated with Claude Code