Skip to content

Commit abdd281

Browse files
committed
Merge origin/main into fix/2388-extraction-remaining-fixed-size-tsnode-w
Signed-off-by: Martin Vogel <[email protected]>
2 parents 50ed9c3 + 83109dd commit abdd281

61 files changed

Lines changed: 2761 additions & 293 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/pr-acknowledgement.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,25 @@ jobs:
5151
run: |
5252
set -euo pipefail
5353
MESSAGE_FILE=.github/pr-acknowledgement.md
54+
BODY_FILE="$RUNNER_TEMP/pr-acknowledgement-body.md"
5455
5556
if [ ! -f "$MESSAGE_FILE" ]; then
5657
echo "No $MESSAGE_FILE in the base tree — acknowledgements are off."
5758
exit 0
5859
fi
5960
60-
# An empty or whitespace-only file is the documented off switch.
61-
if [ -z "$(tr -d '[:space:]' < "$MESSAGE_FILE")" ]; then
62-
echo "$MESSAGE_FILE is blank — acknowledgements are off."
61+
# HTML comments in the template are notes for maintainers. Posted
62+
# verbatim they become text a reader cannot see but a tool can, and
63+
# our own PR screening holds every comment that carries hidden text.
64+
# Strip them (an unterminated one runs to the end, as GitHub renders
65+
# it) so the posted body is exactly what the contributor sees.
66+
perl -0777 -pe 's/<!--.*?(?:-->|\z)[ \t]*\n?//gs' "$MESSAGE_FILE" > "$BODY_FILE"
67+
68+
# A body with no visible text is the documented off switch.
69+
if [ -z "$(tr -d '[:space:]' < "$BODY_FILE")" ]; then
70+
echo "$MESSAGE_FILE has no visible text — acknowledgements are off."
6371
exit 0
6472
fi
6573
66-
gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file "$MESSAGE_FILE"
74+
gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file "$BODY_FILE"
6775
echo "Acknowledged PR #${PR_NUMBER}."

‎README.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,14 +695,14 @@ overwrite user-modified agents.
695695
| Agent | Activation | MCP config | Durable context / augmentation |
696696
|-------|------------|------------|--------------------------------|
697697
| Claude Code | Detected | `~/.claude.json` | Skill + three exact-tool graph agents; `SessionStart`, `SubagentStart`, non-blocking `PreToolUse` for `Grep`/`Glob`/`Bash`, and post-`Read` coverage |
698-
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart` |
698+
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart`, `PreToolUse` graph lookup for `Bash` searches |
699699
| Gemini CLI | Detected | `.gemini/settings.json` | `GEMINI.md`, three explicit read/graph-tool subagents; `BeforeTool`, `AfterTool` `read_file` coverage, and `SessionStart` |
700700
| Zed | Detected | platform `settings.json` (JSONC) | `AGENTS.md` + shared skill |
701701
| 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 |
702702
| Antigravity | Detected | `.gemini/config/mcp_config.json` | `.gemini/GEMINI.md` |
703703
| Aider | Detected | none | `CONVENTIONS.md` via `.aider.conf.yml` |
704704
| KiloCode | Detected | `.config/kilo/kilo.jsonc` | Rule + three graph-tool subagents with deny-by-default permissions |
705-
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart` |
705+
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
706706
| Cursor | Detected | `.cursor/mcp.json` | Skill + three read-only parent-handoff agents; context hooks withheld because session injection races and `readonly` blocks MCP |
707707
| Windsurf | Detected | `~/.codeium/windsurf/mcp_config.json` | Always-on `global_rules.md` |
708708
| Augment / Auggie | Detected | `~/.augment/settings.json` | Rule, three read-only handoff subagents, `SessionStart` + post-`view` coverage |
@@ -714,7 +714,7 @@ overwrite user-modified agents.
714714
| Cline | Detected | `~/.cline/mcp.json` + `${CLINE_DATA_DIR:-~/.cline/data}/settings/cline_mcp_settings.json` | Rule + skill; automatic file hooks withheld because they auto-activate and their output is not reliably consumed; child agents cannot use MCP |
715715
| Warp | Detected, skill only | UI, Warp Drive, or per invocation (manual) | Shared `~/.agents/skills/codebase-memory/SKILL.md` |
716716
| Qwen Code | Detected | `.qwen/settings.json` | `QWEN.md`, skill, three explicit read/graph-tool agents; `SessionStart`, `SubagentStart`, and post-`ReadFile` coverage |
717-
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart` |
717+
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
718718
| Factory Droid | Detected | `.factory/mcp.json` | `AGENTS.md`, skill, three droids with exact per-tier graph-tool lists (without additive whole-server exposure); `SessionStart` + post-`Read` coverage on macOS/Linux, withheld on Windows |
719719
| Crush | Detected | `.config/crush/crush.json` | Managed context path with explicit parent-to-child handoff |
720720
| Goose | Detected | `.config/goose/config.yaml` | `.goosehints` |
@@ -751,7 +751,11 @@ Hooks installed by this project are fail-open and context-only. Claude Code's
751751
`PreToolUse` observes `Grep`/`Glob`/`Bash` and injects matching graph symbols as
752752
`additionalContext`; `PostToolUse` on `Read` adds targeted coverage context when
753753
the graph could not fully parse or index that file. It never denies or replaces
754-
the requested tool call.
754+
the requested tool call. Codex CLI's `PreToolUse` on `Bash` gives its shell
755+
searches the same context. GitHub Copilot CLI and VS Code's Copilot runtime get
756+
it after the search: their `preToolUse` can only decide permissions, so a
757+
`PostToolUse` entry for `Bash`, `Grep` and `Glob` appends the graph symbols to
758+
the tool result.
755759

756760
Claude Code, Codex CLI, Qwen Code, GitHub Copilot CLI, and VS Code's Copilot
757761
runtime receive paired session/subagent context where the vendor exposes a

‎install.ps1‎

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,28 @@ try {
277277

278278
# Validate the zip namespace before extraction. Windows paths are
279279
# case-insensitive, so two entries that differ only in case are ambiguous and
280-
# must never be allowed to overwrite each other. The official five entries are
280+
# must never be allowed to overwrite each other. The official four entries are
281281
# required at the archive root with their exact release names.
282+
#
283+
# Two failure classes are reported differently (both still exit 1; nothing is
284+
# relaxed). An unsafe entry path or a duplicate/case-conflicting entry is a
285+
# hostile archive shape. A well-formed archive whose root file SET differs from
286+
# $WindowsArchiveNames already passed checksum verification above, so it is
287+
# the published artifact for $BaseUrl -- the usual cause is this script being
288+
# newer or older than that release (e.g. install.ps1 run from main ahead of
289+
# the latest release, #1218). Calling that "unsafe" sends the user hunting for
290+
# tampering that is not there. Every entry is screened for the hostile class
291+
# BEFORE any layout verdict, so a bad path can never hide behind a layout
292+
# message just because an unexpected entry happened to come first.
293+
$LayoutMismatch = $false
282294
try {
283295
Add-Type -AssemblyName System.IO.Compression.FileSystem
284296
$zip = [System.IO.Compression.ZipFile]::OpenRead("$TmpDir\$Archive")
285297
try {
286298
$seen = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase)
287299
$archiveCounts = @{}
288300
foreach ($archiveName in $WindowsArchiveNames) { $archiveCounts[$archiveName] = 0 }
301+
$layoutProblem = $null
289302
foreach ($entry in $zip.Entries) {
290303
$entryName = $entry.FullName.Replace('\', '/')
291304
$isDirectory = $entryName.EndsWith('/')
@@ -304,10 +317,16 @@ try {
304317
throw "duplicate or case-conflicting zip entry: $($entry.FullName)"
305318
}
306319
if (-not ($WindowsArchiveNames -ccontains $entryName) -or $isDirectory) {
307-
throw "archive contains an unexpected root entry: $($entry.FullName)"
320+
if ($null -eq $layoutProblem) {
321+
$layoutProblem = "archive contains an unexpected root entry: $($entry.FullName)"
322+
}
323+
continue
308324
}
309325
$archiveCounts[$entryName] = $archiveCounts[$entryName] + 1
310326
}
327+
# Every entry passed the hostile-shape checks; only now judge the layout.
328+
$LayoutMismatch = $true
329+
if ($null -ne $layoutProblem) { throw $layoutProblem }
311330
foreach ($archiveName in $WindowsArchiveNames) {
312331
if ($archiveCounts[$archiveName] -ne 1) {
313332
throw "archive must contain exactly one $archiveName"
@@ -316,11 +335,21 @@ try {
316335
if ($seen.Count -ne $WindowsArchiveNames.Count) {
317336
throw "archive does not match the exact Windows release allowlist"
318337
}
338+
$LayoutMismatch = $false
319339
} finally {
320340
$zip.Dispose()
321341
}
322342
} catch {
323-
Write-Host "error: unsafe or incomplete release archive: $_" -ForegroundColor Red
343+
if ($LayoutMismatch) {
344+
Write-Host "error: release archive layout does not match this installer: $_" -ForegroundColor Red
345+
Write-Host " The archive matched the checksum published with it at $BaseUrl, so it is"
346+
Write-Host " the genuine release artifact, built for a different installer version."
347+
Write-Host " This installer expects: $($WindowsArchiveNames -join ', ')"
348+
Write-Host " Fix: run the install.ps1 shipped inside that same release archive, or"
349+
Write-Host " re-run this script after the next release is published."
350+
} else {
351+
Write-Host "error: unsafe release archive: $_" -ForegroundColor Red
352+
}
324353
Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue
325354
exit 1
326355
}

‎internal/cbm/extract_channels.c‎

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,42 @@ static void elixir_emit_second_arg(CBMExtractCtx *ctx, TSNode call, TSNode args,
901901
}
902902
}
903903

904-
static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
904+
/* tree-sitter-elixir gives a call's arguments node NO field name — its whole
905+
* field set is key, left, operand, operator, quoted_start, quoted_end, right,
906+
* target and value — so the generic field lookup is always null here and every
907+
* channel below was silently skipped. extract_defs.c has carried the same
908+
* positional fallback for the definition side since Elixir was added. */
909+
static TSNode elixir_channel_call_args(TSNode call) {
910+
TSNode args = ts_node_child_by_field_name(call, TS_FIELD("arguments"));
911+
if (ts_node_is_null(args) && ts_node_child_count(call) > 1) {
912+
args = ts_node_child(call, 1);
913+
}
914+
return args;
915+
}
916+
917+
/* The callee of an Elixir `call`. The grammar labels it `target`; child(0) is
918+
* the same node and is what extract_defs.c reads, so accept either. */
919+
static TSNode elixir_channel_call_target(TSNode call) {
905920
TSNode target = ts_node_child_by_field_name(call, TS_FIELD("target"));
921+
if (ts_node_is_null(target) && ts_node_child_count(call) > 0) {
922+
target = ts_node_child(call, 0);
923+
}
924+
return target;
925+
}
926+
927+
/* Elixir def* macros. `def`/`defp` cover Phoenix channel callbacks; the macro
928+
* forms are included because `handle_in` is generated by macros in some
929+
* libraries. */
930+
static bool elixir_channel_is_def_macro(const char *macro) {
931+
if (!macro) {
932+
return false;
933+
}
934+
return strcmp(macro, "def") == 0 || strcmp(macro, "defp") == 0 ||
935+
strcmp(macro, "defmacro") == 0 || strcmp(macro, "defmacrop") == 0;
936+
}
937+
938+
static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
939+
TSNode target = elixir_channel_call_target(call);
906940
if (ts_node_is_null(target)) {
907941
return;
908942
}
@@ -911,7 +945,7 @@ static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
911945
return;
912946
}
913947

914-
TSNode args = ts_node_child_by_field_name(call, TS_FIELD("arguments"));
948+
TSNode args = elixir_channel_call_args(call);
915949

916950
if (strstr(target_text, "PubSub.broadcast") || strstr(target_text, "PubSub.local_broadcast")) {
917951
elixir_emit_second_arg(ctx, call, args, "phoenix_pubsub", CBM_CHANNEL_EMIT);
@@ -927,18 +961,39 @@ static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
927961
}
928962
}
929963

930-
/* Detect handle_in("event", payload, socket) — Phoenix Channel listener */
931-
static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode func_def) {
932-
TSNode name_node = ts_node_child_by_field_name(func_def, TS_FIELD("name"));
933-
if (ts_node_is_null(name_node)) {
964+
/* Detect handle_in("event", payload, socket) — Phoenix Channel listener.
965+
* `def_call` is the `call` node of a def* macro. Elixir has no `def` node type
966+
* and no `name`/`parameters` fields: a definition is a call whose first
967+
* argument is the head, itself a call of name(params) — wrapped in a `when`
968+
* binary_operator when the clause carries a guard. */
969+
static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode def_call) {
970+
TSNode args = elixir_channel_call_args(def_call);
971+
if (ts_node_is_null(args) || ts_node_named_child_count(args) == 0) {
972+
return;
973+
}
974+
TSNode head = ts_node_named_child(args, 0);
975+
if (strcmp(ts_node_type(head), "binary_operator") == 0) {
976+
TSNode op = ts_node_child_by_field_name(head, TS_FIELD("operator"));
977+
TSNode left = ts_node_child_by_field_name(head, TS_FIELD("left"));
978+
if (!ts_node_is_null(op) && !ts_node_is_null(left) &&
979+
ts_node_end_byte(op) - ts_node_start_byte(op) == 4 &&
980+
strncmp(ctx->source + ts_node_start_byte(op), "when", 4) == 0) {
981+
head = left;
982+
}
983+
}
984+
if (strcmp(ts_node_type(head), "call") != 0 || ts_node_child_count(head) == 0) {
985+
return;
986+
}
987+
TSNode name_node = ts_node_child(head, 0);
988+
if (ts_node_is_null(name_node) || strcmp(ts_node_type(name_node), "identifier") != 0) {
934989
return;
935990
}
936991
char *name = cbm_node_text(ctx->arena, name_node, ctx->source);
937992
if (!name || strcmp(name, "handle_in") != 0) {
938993
return;
939994
}
940995
/* First parameter is the event name pattern */
941-
TSNode params = ts_node_child_by_field_name(func_def, TS_FIELD("parameters"));
996+
TSNode params = elixir_channel_call_args(head);
942997
if (ts_node_is_null(params)) {
943998
return;
944999
}
@@ -952,7 +1007,7 @@ static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode func_def) {
9521007
val = literal_from_first_child(ctx, first_param);
9531008
}
9541009
if (val) {
955-
push_channel(ctx, val, "phoenix_channel", CBM_CHANNEL_LISTEN, func_def);
1010+
push_channel(ctx, val, "phoenix_channel", CBM_CHANNEL_LISTEN, def_call);
9561011
}
9571012
}
9581013

@@ -964,10 +1019,18 @@ static void extract_channels_elixir(CBMExtractCtx *ctx) {
9641019
while (stack.count > 0) {
9651020
TSNode node = ts_nstack_pop(&stack);
9661021
const char *kind = ts_node_type(node);
1022+
/* Everything in Elixir is a `call`, including `def`. The old dispatch
1023+
* tested for a "def" node type the grammar does not have, so the
1024+
* handle_in listener branch was unreachable. */
9671025
if (strcmp(kind, "call") == 0) {
968-
elixir_process_call(ctx, node);
969-
} else if (strcmp(kind, "def") == 0) {
970-
elixir_process_function_def(ctx, node);
1026+
TSNode target = elixir_channel_call_target(node);
1027+
char *macro =
1028+
ts_node_is_null(target) ? NULL : cbm_node_text(ctx->arena, target, ctx->source);
1029+
if (elixir_channel_is_def_macro(macro)) {
1030+
elixir_process_function_def(ctx, node);
1031+
} else {
1032+
elixir_process_call(ctx, node);
1033+
}
9711034
}
9721035
uint32_t count = ts_node_child_count(node);
9731036
for (int i = (int)count - SKIP_ONE; i >= 0; i--) {

‎internal/cbm/lsp/py_lsp.c‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static void py_register_instance_field(PyLSPContext *ctx, const char *class_qn,
245245
static void py_bind_for_target(PyLSPContext *ctx, TSNode left, const CBMType *elem_type);
246246
static void py_register_lambda(PyLSPContext *ctx, const char *name, TSNode lambda_node);
247247
static void py_register_dict_literal(PyLSPContext *ctx, const char *name, TSNode dict_node);
248-
static TSNode py_lookup_lambda(PyLSPContext *ctx, const char *name);
248+
static int py_lookup_lambda(PyLSPContext *ctx, const char *name);
249249
static const char *py_lookup_dict_dispatch(PyLSPContext *ctx, const char *var, const char *key);
250250
static void py_process_function(PyLSPContext *ctx, TSNode func_node, const char *container_qn);
251251
static void py_process_class(PyLSPContext *ctx, TSNode class_node);
@@ -895,19 +895,21 @@ static void py_register_lambda(PyLSPContext *ctx, const char *name, TSNode lambd
895895
}
896896
ctx->lambdas[ctx->lambda_count].name = cbm_arena_strdup(ctx->arena, name);
897897
ctx->lambdas[ctx->lambda_count].lambda_node = lambda_node;
898+
ctx->lambdas[ctx->lambda_count].expanding = false;
898899
ctx->lambda_count++;
899900
}
900901

901-
static TSNode py_lookup_lambda(PyLSPContext *ctx, const char *name) {
902-
TSNode null_node = {0};
902+
/* Registry index of the lambda bound to `name`, or -1. An index, not a
903+
* pointer: the registry array is replaced when it grows. */
904+
static int py_lookup_lambda(PyLSPContext *ctx, const char *name) {
903905
if (!ctx || !name)
904-
return null_node;
906+
return -1;
905907
for (int i = 0; i < ctx->lambda_count; i++) {
906908
if (ctx->lambdas[i].name && strcmp(ctx->lambdas[i].name, name) == 0) {
907-
return ctx->lambdas[i].lambda_node;
909+
return i;
908910
}
909911
}
910-
return null_node;
912+
return -1;
911913
}
912914

913915
/* Helper for stripping quotes from a tree-sitter `string` node text. */
@@ -3157,12 +3159,18 @@ static void py_emit_call_for(PyLSPContext *ctx, TSNode call_node) {
31573159
/* These legacy entries have no lexical frame identity. During class
31583160
* execution, leave lambda replay unresolved instead of bypassing a
31593161
* local shadow or running the lambda against class locals. */
3160-
TSNode lambda_node =
3161-
ctx->class_body_outer_scope ? (TSNode){0} : py_lookup_lambda(ctx, fname);
3162-
if (!ts_node_is_null(lambda_node)) {
3162+
int lambda_idx = ctx->class_body_outer_scope ? -1 : py_lookup_lambda(ctx, fname);
3163+
if (lambda_idx >= 0) {
3164+
TSNode lambda_node = ctx->lambdas[lambda_idx].lambda_node;
31633165
TSNode params = ts_node_child_by_field_name(lambda_node, "parameters", 10);
31643166
TSNode body = ts_node_child_by_field_name(lambda_node, "body", 4);
31653167
TSNode args = ts_node_child_by_field_name(call_node, "arguments", 9);
3168+
// A lambda that reaches itself again (directly or through another
3169+
// lambda) would re-walk its body once per nesting level up to the
3170+
// walk-depth cap, and two such calls in one body double the work
3171+
// per level. Walk each body at most once per chain.
3172+
if (ctx->lambdas[lambda_idx].expanding)
3173+
return;
31663174
CBMScope *saved = ctx->current_scope;
31673175
ctx->current_scope = py_scope_push_checked(ctx);
31683176
// Bind each lambda param to the call-site arg's type.
@@ -3195,7 +3203,9 @@ static void py_emit_call_for(PyLSPContext *ctx, TSNode call_node) {
31953203
ctx->enclosing_func_qn = cbm_arena_sprintf(ctx->arena, "%s.<lambda>",
31963204
prev_func ? prev_func : ctx->module_qn);
31973205
if (!ts_node_is_null(body)) {
3206+
ctx->lambdas[lambda_idx].expanding = true;
31983207
py_resolve_calls_in(ctx, body);
3208+
ctx->lambdas[lambda_idx].expanding = false;
31993209
}
32003210
ctx->enclosing_func_qn = prev_func;
32013211
py_scope_restore(ctx, saved);

‎internal/cbm/lsp/py_lsp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
typedef struct {
1414
const char *name; // bound name, e.g. "fn"
1515
TSNode lambda_node; // the lambda AST node
16+
bool expanding; // body is being re-walked for a call site right now
1617
} CBMLambdaEntry;
1718

1819
// Function-as-dict-value entry. When `funcs = {"a": foo, "b": bar}` is

0 commit comments

Comments
 (0)