Skip to content

Commit 18b2f86

Browse files
authored
Merge branch 'main' into fix/mcp-frontend-recovery
2 parents a215626 + 161df2b commit 18b2f86

90 files changed

Lines changed: 2432 additions & 184 deletions

Some content is hidden

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

‎Makefile.cbm‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ TEST_REPRO_SRCS = \
707707
tests/repro/repro_issue787.c \
708708
tests/repro/repro_issue842.c \
709709
tests/repro/repro_issue964.c \
710+
tests/repro/repro_issue1692.c \
710711
tests/repro/repro_invariant_calls.c \
711712
tests/repro/repro_invariant_graph.c \
712713
tests/repro/repro_invariant_breadth.c \

‎README.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ overwrite user-modified agents.
491491
| Agent | Activation | MCP config | Durable context / augmentation |
492492
|-------|------------|------------|--------------------------------|
493493
| Claude Code | Detected | `~/.claude.json` | Skill + three exact-tool graph agents; `SessionStart`, `SubagentStart`, non-blocking `PreToolUse` for `Grep`/`Glob`/`Bash`, and post-`Read` coverage |
494-
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | `AGENTS.md`, skill, three read-only agents; `SessionStart` + `SubagentStart` |
494+
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart` |
495495
| Gemini CLI | Detected | `.gemini/settings.json` | `GEMINI.md`, three explicit read/graph-tool subagents; `BeforeTool`, `AfterTool` `read_file` coverage, and `SessionStart` |
496496
| Zed | Detected | platform `settings.json` (JSONC) | `AGENTS.md` + shared skill |
497497
| OpenCode | Detected | `$OPENCODE_CONFIG` or resolved global config | `AGENTS.md`, skill, three deny-by-default read-only agents; plugin adds grep/glob graph lookup, post-`read` coverage, first-tool-result session context, and post-compaction reinjection |
@@ -536,6 +536,11 @@ overwrite user-modified agents.
536536
| Oh My Pi (omp) | Detected | Effective agent directory (`OMP_PROFILE` / `PI_CODING_AGENT_DIR`; default `~/.omp/agent/mcp.json`) | Skill and three direct-MCP graph-tool subagents (Scout/Verify/Auditor); preserves user `AGENTS.md` |
537537
| Sourcegraph Cody | Explicit opt-in | Existing `$CBM_CODY_CONFIG_PATH` | MCP only |
538538

539+
For Codex, install keeps only a tiny managed activation pointer in global
540+
`$CODEX_HOME/AGENTS.md`; all detailed behavior lives in the installed `codebase-memory` skill.
541+
Fresh installs create the pointer, upgrades replace the legacy full managed block while preserving
542+
all user-owned bytes, and uninstall removes only the managed pointer.
543+
539544
### Sessions, compaction, and subagents
540545

541546
Hooks installed by this project are fail-open and context-only. Claude Code's

‎internal/cbm/cbm.c‎

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,47 @@ typedef struct {
794794
} cbm_error_regions_t;
795795

796796
static void cbm_error_regions_push(cbm_error_regions_t *acc, TSNode n) {
797+
TSPoint start = ts_node_start_point(n);
798+
TSPoint end = ts_node_end_point(n);
799+
uint32_t start_line = start.row + 1;
800+
uint32_t end_line = end.row + 1;
801+
802+
/* A node that ends at column 0 stopped right after the previous line's
803+
* newline, so it holds no text on the row it points at. Counting that row
804+
* named a line past the end of the file whenever the region ran to EOF:
805+
* scripts/setup-windows.ps1 has 326 lines and reported "245-327". */
806+
if (end.column == 0 && end.row > start.row) {
807+
end_line = end.row;
808+
}
809+
810+
/* One line can carry several error nodes, and repeating the same line range
811+
* says nothing new. Line 113 of scripts/setup-windows.ps1 has two error
812+
* nodes, at columns 25-29 and 31-32, and the report read "113-113,113-113".
813+
* Drop the repeat.
814+
*
815+
* Only an EXACT repeat of the range already open is dropped. Do not merge
816+
* ranges that merely overlap. Each range is judged separately later by
817+
* cbm_region_is_recovered, which asks whether definitions starting inside
818+
* that range cover it. Two ranges with the same numbers always get the same
819+
* verdict, so collapsing them changes nothing. Two DIFFERENT ranges do not:
820+
* merging 3-3 into 2-3 hands the wider range's covering definition to an
821+
* error the definition does not explain, and a real parse failure then
822+
* disappears from the report. tests/test_parse_coverage.c pins that case in
823+
* perl_malformed_source_remains_partial_issue1838.
824+
*
825+
* This runs BEFORE the cap check, so a dropped repeat never counts as a
826+
* range the cap threw away. */
827+
if (acc->count > 0 && start_line == acc->starts[acc->count - 1] &&
828+
end_line == acc->ends[acc->count - 1]) {
829+
return;
830+
}
831+
797832
if (acc->count >= CBM_MAX_ERROR_REGIONS) {
798833
acc->dropped++;
799834
return;
800835
}
801-
acc->starts[acc->count] = ts_node_start_point(n).row + 1;
802-
acc->ends[acc->count] = ts_node_end_point(n).row + 1;
836+
acc->starts[acc->count] = start_line;
837+
acc->ends[acc->count] = end_line;
803838
acc->count++;
804839
}
805840

‎internal/cbm/extract_defs.c‎

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#define MAX_PARAMS_MINUS_1 31
2424
#define MAX_RETURN_TYPES 16
2525
#define MAX_RETURN_TYPES_MINUS_1 15
26+
#define MAX_ATTR_WRAPPERS 16 // stacked C#/PHP attribute_list siblings per declaration (#1692)
27+
#define MAX_ATTR_WRAPPERS_MINUS_1 15
2628

2729
// Tree traversal limits.
2830
enum {
@@ -1323,7 +1325,7 @@ static const char *extract_docstring(CBMArena *a, TSNode node, const char *sourc
13231325
return NULL;
13241326
}
13251327

1326-
static TSNode find_jvm_modifiers(TSNode node, CBMLanguage lang);
1328+
static int find_jvm_modifiers(TSNode node, CBMLanguage lang, TSNode *out, int max);
13271329

13281330
/* HTTP method names recognized in decorator calls (e.g., @router.post → "POST") */
13291331
static const char *decorator_method_name(const char *attr_text) {
@@ -1713,12 +1715,9 @@ static void scan_route_annotations(CBMArena *a, TSNode owner, const char *source
17131715
*out_method = NULL;
17141716
*out_jax_path = NULL;
17151717

1716-
TSNode wrappers[2];
1717-
int wn = 0;
1718-
TSNode modifiers = find_jvm_modifiers(owner, spec->language);
1719-
if (!ts_node_is_null(modifiers)) {
1720-
wrappers[wn++] = modifiers;
1721-
}
1718+
/* MINUS_1: the owner node itself is appended below, after the wrappers. */
1719+
TSNode wrappers[MAX_ATTR_WRAPPERS];
1720+
int wn = find_jvm_modifiers(owner, spec->language, wrappers, MAX_ATTR_WRAPPERS_MINUS_1);
17221721
/* Direct-child annotations (some grammars attach the annotation as a child
17231722
* of the method node rather than under `modifiers`). */
17241723
wrappers[wn++] = owner;
@@ -1872,13 +1871,23 @@ static int count_modifier_annotations(TSNode modifiers, const CBMLangSpec *spec)
18721871
return count;
18731872
}
18741873

1875-
// Find the wrapper child that holds annotations/attributes for languages where
1876-
// they are nested under an intermediate node rather than being a prev-sibling:
1877-
// Java/Kotlin/C#/Swift → `modifiers` (contains annotation/attribute)
1878-
// PHP 8 → `attribute_list` (contains attribute_group)
1879-
// Returns a null node when the language has no such wrapper.
1880-
static TSNode find_jvm_modifiers(TSNode node, CBMLanguage lang) {
1881-
TSNode null_node = {0};
1874+
// Find every wrapper child that holds annotations/attributes for languages
1875+
// where they are nested under an intermediate node rather than being a
1876+
// prev-sibling:
1877+
// Java/Kotlin/Swift → `modifiers` (one node, contains every annotation)
1878+
// C#/PHP 8 → `attribute_list` (contains attribute/attribute_group)
1879+
//
1880+
// C#/PHP attribute stacks are NOT a single wrapper: each bracketed group
1881+
// (`[Foo]`, `[Bar]`, ...) compiles to its own `attribute_list` node, so
1882+
// `[A] [B] [C]` above a declaration produces three separate `attribute_list`
1883+
// siblings among that declaration's children — not one `attribute_list`
1884+
// holding three entries. A field-name lookup (`ts_node_child_by_field_name`)
1885+
// only ever returns the first child registered under a given field, so using
1886+
// it here silently dropped every attribute after the first bracket group
1887+
// (#1692). Scanning all children by kind fixes that for C#/PHP and is a
1888+
// no-op change for Java/Kotlin/Swift, where `modifiers` never repeats.
1889+
// Writes up to `max` wrapper nodes into `out`; returns how many were found.
1890+
static int find_jvm_modifiers(TSNode node, CBMLanguage lang, TSNode *out, int max) {
18821891
const char *wrapper = NULL;
18831892
switch (lang) {
18841893
case CBM_LANG_JAVA:
@@ -1888,19 +1897,12 @@ static TSNode find_jvm_modifiers(TSNode node, CBMLanguage lang) {
18881897
break;
18891898
case CBM_LANG_CSHARP:
18901899
case CBM_LANG_PHP:
1891-
/* C# attributes live in an `attribute_list` child (modifiers like
1892-
* `public` are separate `modifier` nodes); PHP 8 likewise nests
1893-
* `attribute_group` under `attribute_list`. */
18941900
wrapper = "attribute_list";
18951901
break;
18961902
default:
1897-
return null_node;
1898-
}
1899-
TSNode w = ts_node_child_by_field_name(node, wrapper, (uint32_t)strlen(wrapper));
1900-
if (ts_node_is_null(w)) {
1901-
w = cbm_find_child_by_kind(node, wrapper);
1903+
return 0;
19021904
}
1903-
return w;
1905+
return cbm_find_children_by_kind(node, wrapper, out, max);
19041906
}
19051907

19061908
// Count direct children of `node` that are decorator/annotation nodes (used by
@@ -1978,13 +1980,14 @@ static const char **extract_decorators(CBMArena *a, TSNode node, const char *sou
19781980
prev = ts_node_prev_sibling(prev);
19791981
}
19801982

1981-
TSNode modifiers = {0};
1983+
TSNode wrappers[MAX_ATTR_WRAPPERS];
1984+
int wn = 0;
19821985
int mod_count = 0;
19831986
int child_count = 0;
19841987
if (count == 0) {
1985-
modifiers = find_jvm_modifiers(node, lang);
1986-
if (!ts_node_is_null(modifiers)) {
1987-
mod_count = count_modifier_annotations(modifiers, spec);
1988+
wn = find_jvm_modifiers(node, lang, wrappers, MAX_ATTR_WRAPPERS);
1989+
for (int w = 0; w < wn; w++) {
1990+
mod_count += count_modifier_annotations(wrappers[w], spec);
19881991
}
19891992
/* Languages like Scala attach the annotation directly as a child of the
19901993
* definition node (no wrapper, no prev-sibling). */
@@ -2014,8 +2017,8 @@ static const char **extract_decorators(CBMArena *a, TSNode node, const char *sou
20142017
}
20152018
prev = ts_node_prev_sibling(prev);
20162019
}
2017-
if (!ts_node_is_null(modifiers)) {
2018-
idx = collect_modifier_decorators(a, modifiers, source, spec, result, idx, total);
2020+
for (int w = 0; w < wn && mod_count > 0; w++) {
2021+
idx = collect_modifier_decorators(a, wrappers[w], source, spec, result, idx, total);
20192022
}
20202023
if (child_count > 0) {
20212024
idx = collect_child_decorators(a, node, source, spec, result, idx, total);

‎internal/cbm/helpers.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,18 @@ TSNode cbm_find_child_by_kind(TSNode parent, const char *kind) {
466466
return null_node;
467467
}
468468

469+
int cbm_find_children_by_kind(TSNode parent, const char *kind, TSNode *out, int max) {
470+
int n = 0;
471+
uint32_t count = ts_node_child_count(parent);
472+
for (uint32_t i = 0; i < count && n < max; i++) {
473+
TSNode child = ts_node_child(parent, i);
474+
if (strcmp(ts_node_type(child), kind) == 0) {
475+
out[n++] = child;
476+
}
477+
}
478+
return n;
479+
}
480+
469481
/* ── Node-type classification: TSSymbol bitset acceleration ───────────────
470482
* cbm_kind_in_set is called for nearly every AST node (function/class/call/
471483
* import/branching sets), so a linear strcmp over the type-name array is a hot

‎internal/cbm/helpers.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ char *cbm_cpp_out_of_line_parent_class(CBMArena *a, TSNode node, const char *sou
122122
// Find a child node by kind string.
123123
TSNode cbm_find_child_by_kind(TSNode parent, const char *kind);
124124

125+
// Find every child node matching `kind` (unlike cbm_find_child_by_kind,
126+
// which stops at the first match). Writes up to `max` nodes into `out`;
127+
// returns how many were found. Repeated sibling nodes of the same kind are
128+
// common in some grammars (e.g. C#/PHP stack each `[Attr]` as its own
129+
// attribute_list child) — see #1692.
130+
int cbm_find_children_by_kind(TSNode parent, const char *kind, TSNode *out, int max);
131+
125132
/* --- Lisp-family shared gates ---------------------------------------------
126133
* The defs, calls and unified extractors each walk the same generic `list`
127134
* node and must agree on what it means. The predicates below therefore live

0 commit comments

Comments
 (0)