Skip to content

Commit 3353465

Browse files
authored
Merge branch 'main' into fix/1954-uninstall-symlinked-config
2 parents 91c63be + 9b85dd3 commit 3353465

49 files changed

Lines changed: 3697 additions & 248 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/_lint.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ jobs:
6868
- name: Install build deps
6969
run: sudo apt-get update && sudo apt-get install -y zlib1g-dev
7070

71-
- name: Install LLVM 22 (pinned analyzer toolchain)
71+
- name: Install LLVM 21 (pinned analyzer toolchain)
7272
run: |
7373
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
74-
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-22 main" | sudo tee /etc/apt/sources.list.d/llvm-22.list
74+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" | sudo tee /etc/apt/sources.list.d/llvm-21.list
7575
sudo apt-get update
76-
sudo apt-get install -y clang-tidy-22
76+
sudo apt-get install -y clang-tidy-21
7777
7878
- name: Memory-analyzer gate
79-
run: scripts/ci/lint-mem.sh clang-tidy-22
79+
run: scripts/ci/lint-mem.sh clang-tidy-21

‎.github/workflows/_test.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ jobs:
227227
- name: Install deps
228228
run: sudo apt-get update && sudo apt-get install -y zlib1g-dev ccache
229229

230-
- name: Install LLVM 22 (pinned diagnostic toolchain)
230+
- name: Install LLVM 21 (pinned diagnostic toolchain)
231231
run: |
232232
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
233-
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-22 main" | sudo tee /etc/apt/sources.list.d/llvm-22.list
233+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" | sudo tee /etc/apt/sources.list.d/llvm-21.list
234234
sudo apt-get update
235-
sudo apt-get install -y clang-22
235+
sudo apt-get install -y clang-21
236236
237237
- name: Compiler cache (content-verified, restore)
238238
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
@@ -247,11 +247,11 @@ jobs:
247247
# lane: stack-use-after-return, stack-use-after-scope, and strict string
248248
# checks. Mirrors `make -f Makefile.cbm diag`, including its reasoning
249249
# for leaving detect_invalid_pointer_pairs out.
250-
- name: Test (clang-22, ASan+UBSan + off-by-default ASan checks)
250+
- name: Test (clang-21, ASan+UBSan + off-by-default ASan checks)
251251
env:
252252
ASAN_OPTIONS: "detect_stack_use_after_return=1:strict_string_checks=1:detect_stack_use_after_scope=1"
253253
run: |
254-
scripts/test.sh CC=clang-22 CXX=clang++-22 \
254+
scripts/test.sh CC=clang-21 CXX=clang++-21 \
255255
SANITIZE="-fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls"
256256
257257
- name: Compiler cache (save)

‎internal/cbm/cbm.c‎

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,42 @@ static const char *cbm_string_read(void *payload, uint32_t byte, TSPoint point,
213213

214214
// --- Parse timeout callback ---
215215

216+
/* Budget for the tree-sitter progress callback. The PRIMARY gate is per-thread
217+
* CPU time: a worker descheduled under CI contention burns WALL time but not
218+
* CPU, so a starved-but-parseable file must NOT be abandoned merely because the
219+
* 5 s budget elapsed in wall-clock against near-zero CPU. That false "parse
220+
* timeout" silently dropped a file's defs and, with them, every cross-file edge
221+
* those defs anchored (e.g. a Celery.send_task definition backing an ASYNC_CALLS
222+
* edge). A generous WALL ceiling stays as a backstop so a genuinely
223+
* stuck/spinning parse still terminates in bounded time. */
224+
#define CBM_PARSE_WALL_CEILING_FACTOR 12ULL /* ~60 s ceiling for the 5 s CPU budget */
225+
226+
typedef struct {
227+
uint64_t cpu_deadline_ns; // trip once this thread's CPU time passes it
228+
uint64_t wall_ceiling_ns; // hard wall backstop for a spinning/stuck parse
229+
} CBMParseBudget;
230+
231+
#ifdef CBM_ENABLE_TEST_SEAMS
232+
/* Deterministic RED-repro seam (armed by CBM_TEST_WALL_STALL_ON in
233+
* cbm_extract_file_ex): when set, the timeout callback reads the WALL clock this
234+
* many ns ahead of reality while CPU time is untouched — emulating a worker
235+
* descheduled long enough for the old wall-only budget to elapse against
236+
* near-zero CPU. With the CPU-time budget the parse still completes; a wall-only
237+
* / tight-ceiling budget drops the file. Thread-local so it cannot leak across
238+
* worker threads. Compiled only into seam-enabled test artifacts. */
239+
static CBM_TLS uint64_t tl_parse_wall_seam_offset_ns = 0;
240+
#endif
241+
242+
/* tree-sitter's TSProgressCallback mandates a non-const TSParseState*; a const
243+
* parameter here would not match the opts.progress_callback assignment below. */
244+
// cppcheck-suppress constParameterCallback
216245
static bool cbm_timeout_cb(TSParseState *state) {
217-
uint64_t deadline = *(uint64_t *)state->payload;
218-
return now_ns() > deadline;
246+
const CBMParseBudget *budget = (const CBMParseBudget *)state->payload;
247+
uint64_t wall = now_ns();
248+
#ifdef CBM_ENABLE_TEST_SEAMS
249+
wall += tl_parse_wall_seam_offset_ns;
250+
#endif
251+
return cbm_thread_cpu_time_ns() > budget->cpu_deadline_ns || wall > budget->wall_ceiling_ns;
219252
}
220253

221254
// --- Thread-local parser pool ---
@@ -1620,11 +1653,26 @@ static CBMFileResult *extract_file_ex_body(const char *source, int source_len, C
16201653
};
16211654

16221655
TSParseOptions opts = {0};
1623-
uint64_t deadline_ns = 0; // cppcheck-suppress unreadVariable
1656+
CBMParseBudget budget = {0}; // cppcheck-suppress unreadVariable
16241657
if (timeout_micros > 0) {
1625-
deadline_ns = t0 + ((uint64_t)timeout_micros * USEC_TO_NSEC);
1626-
opts.payload = &deadline_ns;
1658+
uint64_t budget_ns = (uint64_t)timeout_micros * USEC_TO_NSEC;
1659+
// Descheduling burns wall time but not CPU: gate on this thread's CPU
1660+
// time so a starved-but-parseable file is not abandoned, with a generous
1661+
// wall ceiling as a backstop against a genuinely spinning/stuck parse.
1662+
budget.cpu_deadline_ns = cbm_thread_cpu_time_ns() + budget_ns;
1663+
budget.wall_ceiling_ns = t0 + budget_ns * CBM_PARSE_WALL_CEILING_FACTOR;
1664+
opts.payload = &budget;
16271665
opts.progress_callback = cbm_timeout_cb;
1666+
#ifdef CBM_ENABLE_TEST_SEAMS
1667+
tl_parse_wall_seam_offset_ns = 0;
1668+
const char *stall_on = getenv("CBM_TEST_WALL_STALL_ON");
1669+
if (stall_on && stall_on[0] && rel_path && strstr(rel_path, stall_on)) {
1670+
// Push the wall reading past the 1x budget (the old wall-only budget
1671+
// trips) but well under the generous ceiling (the CPU-time budget
1672+
// survives): budget + 1 s, deterministic, no real timing involved.
1673+
tl_parse_wall_seam_offset_ns = budget_ns + NSEC_PER_SEC;
1674+
}
1675+
#endif
16281676
}
16291677

16301678
TSTree *tree = ts_parser_parse_with_options(parser, NULL, ts_input, opts);

‎src/cli/agent_profiles.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,17 @@ static bool render_profile_text(profile_buffer_t *buffer, cbm_graph_profile_dial
547547
}
548548
return true;
549549
case CBM_GRAPH_DIALECT_OPENCODE:
550+
if (!profile_buffer_append(buffer, "---\ndescription: ") ||
551+
!profile_buffer_append(buffer, description) ||
552+
!profile_buffer_append(
553+
buffer, "\nmode: subagent\npermission:\n \"*\": deny\n read: allow\n grep: "
554+
"allow\n glob: allow\n tool_search: allow\n tool_search_regex: "
555+
"allow\n") ||
556+
(direct && !append_permission_mcp_tools(buffer, dialect, tier)) ||
557+
!profile_buffer_append(buffer, "---\n") || !profile_buffer_append(buffer, prompt)) {
558+
return false;
559+
}
560+
return true;
550561
case CBM_GRAPH_DIALECT_KILO:
551562
if (!profile_buffer_append(buffer, "---\ndescription: ") ||
552563
!profile_buffer_append(buffer, description) ||

0 commit comments

Comments
 (0)