Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions docs/features/code-index/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@ repository lookup. When several test calls are close together, Loom prefers
examples from different source windows when it can verify their excerpts.
When direct examples are absent, edit context can show tests that reach the
definition through one indexed caller. Such examples carry `evidence:
indirect_call` and a `via` source location.
indirect_call` and a `via` source location. Loom ranks at most 50 candidate call
sites; those in a test module named after the definition's Python module
(`test_app.py` or a `tests/app/` directory for `app.py`) are read first, so a
definition with more test call sites than that keeps its own module's tests among
the candidates.

A definition with no test call site to show carries `tests` and
`test_link_state` in place of `examples`. `tests` holds the first three test
files [`code.test_gate`](#find-the-tests-a-change-obliges) lists for an edit of
that definition, each with its `why`. `test_link_state` is `executed` or
`unexecuted` when a verified coverage run measured the definition, else
`linked` when a call chain links a test to it and `unlinked` when none does.
`unlinked` is not proof that no test runs it.

When an exact call expression such as `convert(row.value)` is absent,
`related_on_miss: true` looks for its qualified argument in the same scope.
Expand Down Expand Up @@ -444,16 +456,19 @@ for row in r.get("co_change_missing", []):
print("usually changes with this diff:", row)
```

The diff shape returns the functions the changed lines sit in, the tests that reach them, and
The diff shape returns the functions the changed lines sit in, the tests linked to them, and
`co_change_missing`; `files` alone treats every function in those files as changed.
`impacted_tests` holds the rows `code.test_gate` lists for the same change at its default
depth, whatever `depth` the radius is walked at, with the same `why` kinds, so the two ops
name the same tests; test-map rows of the impacted paths ride as `test_map` rows.
Both shapes return `owners`: recency-weighted PR authors over the seed paths, with
`exclude_authors` (normally the change's own author) removed. The index holds merged
code, so the diff is read against the branch head; your uncommitted functions resolve
only when they already exist there.

### Check function changes and API contracts

Use `code.impact` to find indexed callers and tests that reach a proposed change.
Use `code.impact` to find indexed callers and the tests linked to a proposed change.
Read `epistemic` and `causes` before treating the result as a complete dependency
list. Dynamic calls and consumers outside the indexed repositories can be missing.

Expand Down
2 changes: 1 addition & 1 deletion docs/features/code-index/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ the [configuration reference](../../reference/configuration.md#code).
A file's language comes from `treesitter.lang_for_path` (C/C++, Python, shell, SQL,
docs, config), then `lang_detect.LANG_BY_EXTENSION` for the lane languages, then
shebangs and shell detection. "Edges" are what `code.callers` / `code.callees` walk.
`code.impact` adds mapped tests and co-change partners, so a language without call edges
`code.impact` adds linked tests and co-change partners, so a language without call edges
still gets file-level impact.

| Language (extensions) | Symbols | Fast-tier edges | Compiler tier |
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/operations/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,9 @@ Symbol-shaped (name/symbol_id) or diff-shaped (files/diff) blast radius.
| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `rev`, `first_written`, `changed_since`, `code_moved` and `supersedes_key`… |
| `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. |
| `impacted_symbols` | `list[dict[str, Any]]` | Each row {qualified_name, path, hop, tier}; a row whose function is a registration function (`REGISTER_FUNCTION(X)`, `registerStorageFoo`) carries `via: "registration"` — the seed is reached through a registry; the key is absent otherwise. |
| `impacted_tests` | `list[dict[str, Any]]` | Tests the test map ties to the seed and impacted paths: {test_path, src_path, confidence}. |
| `impacted_tests` | `list[dict[str, Any]]` | The test files code.test_gate lists for the same change at its default depth (2, whatever `depth` the radius is walked at), at most 30, strongest evidence first: each row as a code.test_gate `tests` row ({test_path, why, evidence, run… |
| `co_change_files` | `list[dict[str, Any]]` | Files changed in the same merged PRs as the seed paths, most often first ({path, prs}, at most 20): the last 10 PRs for the symbol shape, 50 for the diff shape. |
| `blast_radius_score` | `float` | impacted/50 + tests/40, capped at 1. |
| `blast_radius_score` | `float` | impacted/50 + test-map rows/40, capped at 1. |
| `touched_symbols` | `list[dict[str, Any]]` | Diff shape only: the symbols the change touches (the functions its changed lines sit in when a diff was given, else every function in the files), and the files that historically co-change with the touched set but are absent from it — the… |
| `co_change_missing` | `list[dict[str, Any]]` | Diff shape: co-change files absent from the change ({path, prs, of}, at most 5, support at least 4 PRs and 15%); empty for the symbol shape. |
| `owners` | `list[dict[str, Any]]` | Who to ask: {author, share, prs, reviews, last_merged_at} from merged PRs over the seed paths — the PRs a person AUTHORED (`prs`) and the ones they REVIEWED (`reviews`, inline comments), recency-decayed (120-day half-life), share floor, at… |
Expand Down
5 changes: 3 additions & 2 deletions docs/use-cases/code-intelligence.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ placeholders below with your organization, indexed namespace and qualified funct
`arguments: {"org": "<org>", "namespace": "<indexed namespace>", "name": "<qualified function name>", "depth": 1, "per_hop_limit": 20, "explain": true}`.
Look for the checked caller in `impacted_symbols`: `qualified_name`, `path`,
`hop: 1` and `tier`. This request resolves the supplied name; `files` would
seed every function in those files. `impacted_tests` lists mapped tests;
the op does not execute them.
seed every function in those files. `impacted_tests` lists the tests the
index links to the seed, each with the evidence in `why`; the op does not
execute them.
4. Read `epistemic`, `causes`, `counts_floor` and `truncated` on both answers, and
repeat the status request. Compare returned locations with source at the relevant
tier's commit. Missing fields or watermarks, changed watermarks, a missing expected
Expand Down
2 changes: 1 addition & 1 deletion integrations/claude-code-plugin/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "loom",
"displayName": "ClickHouse Loom",
"version": "1.2.83",
"version": "1.2.84",
"description": "Shared long-term memory and code intelligence for Claude Code, self-hosted on ClickHouse. MCP tools to save and recall decisions, preferences and corrections across sessions and teammates; lifecycle hooks that capture each session with no model call; a code index that answers where-is, who-calls and blast-radius questions with line-accurate units instead of whole-file reads.",
"author": {
"name": "ClickHouse"
Expand Down
8 changes: 7 additions & 1 deletion integrations/claude-code-plugin/lib/blast-radius.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export function decideEmit(cache, rel, signature) {
return { emit: true, cache: { sig } };
}

// `why` kinds of an `impacted_tests` row that are about the edited file and say nothing
// about the touched symbols: not tests "reaching" the change.
const FILE_LEVEL_TESTS = new Set(["file_neighbor", "stem_partner"]);

function short(qname) {
// DB::MergeTreeData::renameTempPartAndAdd -> MergeTreeData::renameTempPartAndAdd
const parts = String(qname || "").split("::");
Expand All @@ -73,7 +77,9 @@ export function renderBlast(rel, impact, { maxNames = 5, touchedPaths = [], test
if (!impact) return "";
const touched = (impact.touched_symbols || []).map((s) => short(s.qualified_name)).filter(Boolean);
const impacted = (impact.impacted_symbols || []).filter((s) => s && s.qualified_name);
const tests = namesTests ? (impact.impacted_tests || []).filter((t) => t && t.test_path) : [];
const tests = namesTests
? (impact.impacted_tests || []).filter((t) => t && t.test_path && !FILE_LEVEL_TESTS.has(t.why))
: [];
const already = new Set([rel, ...touchedPaths.map(String)]);
const missing = (impact.co_change_missing || []).filter((m) => m && m.path && !already.has(String(m.path)));
if (!impacted.length && !tests.length && !missing.length) return ""; // owners alone are not a radius
Expand Down
13 changes: 13 additions & 0 deletions integrations/claude-code-plugin/tests/blast-radius.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ test("renderBlast names callers, tests and untouched partners in one line", () =
assert.ok(text.length < 520, `line stays short: ${text.length}`);
});

test("a test file that is only about the edited file is not a test reaching the change", () => {
const rows = [
{ test_path: "tests/test_a.py", why: "static_call", hop: 1 },
{ test_path: "tests/test_b.py", why: "file_neighbor", callees: 3 },
{ test_path: "tests/test_c.py", why: "stem_partner" },
{ test_path: "tests/test_d.py", why: "test_map", src_path: "x", confidence: 0.7 },
];
const text = renderBlast("a.py", { touched_symbols: IMPACT.touched_symbols, impacted_tests: rows });
assert.match(text, /tests reaching it: 2 \(test_a\.py, test_d\.py\)/);
const fileLevel = { touched_symbols: IMPACT.touched_symbols, impacted_tests: rows.slice(1, 3) };
assert.equal(renderBlast("a.py", fileLevel), "");
});

test("beside the test gate's line the radius counts no tests, and tests alone are then no radius", () => {
const text = renderBlast("src/Storages/MergeTree/MergeTreeData.cpp", IMPACT, { tests: false });
assert.match(text, /3 callers in 2 files/);
Expand Down
2 changes: 1 addition & 1 deletion integrations/codex-plugin/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loom",
"version": "1.2.83",
"version": "1.2.84",
"description": "Shared long-term memory and code intelligence for Codex, self-hosted on ClickHouse. MCP tools to save and recall decisions, preferences and corrections across sessions and teammates; lifecycle hooks that capture each session with no model call; a code index that answers where-is, who-calls and blast-radius questions with line-accurate units instead of whole-file reads.",
"author": {
"name": "ClickHouse"
Expand Down
8 changes: 7 additions & 1 deletion integrations/codex-plugin/lib/blast-radius.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export function decideEmit(cache, rel, signature) {
return { emit: true, cache: { sig } };
}

// `why` kinds of an `impacted_tests` row that are about the edited file and say nothing
// about the touched symbols: not tests "reaching" the change.
const FILE_LEVEL_TESTS = new Set(["file_neighbor", "stem_partner"]);

function short(qname) {
// DB::MergeTreeData::renameTempPartAndAdd -> MergeTreeData::renameTempPartAndAdd
const parts = String(qname || "").split("::");
Expand All @@ -73,7 +77,9 @@ export function renderBlast(rel, impact, { maxNames = 5, touchedPaths = [], test
if (!impact) return "";
const touched = (impact.touched_symbols || []).map((s) => short(s.qualified_name)).filter(Boolean);
const impacted = (impact.impacted_symbols || []).filter((s) => s && s.qualified_name);
const tests = namesTests ? (impact.impacted_tests || []).filter((t) => t && t.test_path) : [];
const tests = namesTests
? (impact.impacted_tests || []).filter((t) => t && t.test_path && !FILE_LEVEL_TESTS.has(t.why))
: [];
const already = new Set([rel, ...touchedPaths.map(String)]);
const missing = (impact.co_change_missing || []).filter((m) => m && m.path && !already.has(String(m.path)));
if (!impacted.length && !tests.length && !missing.length) return ""; // owners alone are not a radius
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/loom/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6472,6 +6472,8 @@ class CodeUnit(TypedDict, total=False):
score: NotRequired[float]
recent_prs: NotRequired[list[dict[str, Any]]]
examples: NotRequired[list[dict[str, Any]]]
tests: NotRequired[list[dict[str, Any]]]
test_link_state: NotRequired[str]
lessons: NotRequired[list[dict[str, Any]]]
lessons_unread: NotRequired[bool]
churn: NotRequired[int]
Expand Down
Loading
Loading