Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

docs(pipeline): CBM_EXTRACT_BUDGET is a CPU-time parse budget, not bytes (#2311)

Martin Vogelf3754d6197b6
diff --git a/internal/cbm/cbm.h b/internal/cbm/cbm.h
index a00192a18..5a9de600b 100644
--- a/internal/cbm/cbm.h
+++ b/internal/cbm/cbm.h
@@ -729,9 +729,6 @@ const char *cbm_index_quarantine_phase(const char *rel_path);
void cbm_index_mark_start(const char *rel_path);
void cbm_index_mark_done(const char *rel_path);
-// Extract all data from one file. Caller must call cbm_free_result().
-// source must remain valid for the duration of the call.
-// timeout_micros: per-file parse timeout in microseconds (0 = no timeout).
/* Compact a finished result: copy everything reachable from it -- every
* record array at exact count, every string once (interned by content within
* the file), the retained source -- into one exact-size arena, and destroy the
@@ -767,6 +764,11 @@ void cbm_work_arena_keep_begin(void);
/* Free the compaction scratch this thread kept (cbm_work_arena_release calls it). */
void cbm_result_compact_release_thread(void);
+// Extract all data from one file. Caller must call cbm_free_result().
+// source must remain valid for the duration of the call.
+// timeout_micros: per-file tree-sitter parse budget in microseconds of the
+// calling thread's CPU time, with a wall-clock backstop of
+// CBM_PARSE_WALL_CEILING_FACTOR x the budget (0 = no budget).
CBMFileResult *cbm_extract_file(const char *source, int source_len, CBMLanguage language,
const char *project, const char *rel_path, int64_t timeout_micros,
const char **extra_defines, // NULL-terminated, or NULL
diff --git a/src/pipeline/pipeline_internal.h b/src/pipeline/pipeline_internal.h
index e7782adef..727a5e5ec 100644
--- a/src/pipeline/pipeline_internal.h
+++ b/src/pipeline/pipeline_internal.h
@@ -23,7 +23,10 @@
/* ── Shared pipeline constants ─────────────────────────────────── */
-/* Maximum byte budget for tree-sitter extraction per file */
+/* Per-file tree-sitter parse budget, in MICROSECONDS of this thread's CPU time
+ * (5 s). Passed as cbm_extract_file*()'s timeout_micros; a generous wall-clock
+ * ceiling (CBM_PARSE_WALL_CEILING_FACTOR x, ~60 s) backstops a stuck parse.
+ * It is a time budget, not a byte budget. */
#define CBM_EXTRACT_BUDGET 5000000
/* Route node QN buffer size (must fit __route__METHOD__/full/url/path) */