Skip to content

Add find_circuit_paths (VFBquery#114) - #23

Merged
Robbie1977 merged 2 commits into
mainfrom
circuit-paths
Nov 25, 2026
Merged

Robbie1977 merged 2 commits into
mainfrom
circuit-paths

Conversation

@Clare72

@Clare72 Clare72 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Adds find_circuit_paths, which calls VFBquery's /circuit_paths (VirtualFlyBrain/VFBquery#114, VirtualFlyBrain/VFBquery#147). It returns the strongest multi-hop pathways from one neuron class (or neuron) to another, searched separately in each connectome from the class graphs built with each release.

Changes

  • src/circuitPaths.ts builds the request. Unit tests are in tests/circuitPaths.test.js (7 tests).
    • Ids only (FBbt classes or VFB neurons), one or several per end. Labels are refused before the request, with a pointer to search_terms, because the endpoint reports a label as "not found in any searched dataset", which reads like "no connection".
    • k (max 20), min_synapses, min_inprop (0–1), normalise (input/output) and instance_k (max 10) are checked against the endpoint's limits.
    • If exclude_dbs is left out, the endpoint's default (hb, fafb) applies. [] searches every dataset.
  • src/index.ts:
    • The tool definition. Its description covers the scoring (product of input proportions), leaf-class assignment, and why the figures differ from query_connectivity with group_by_class.
    • The handler has a 1-minute timeout and passes the response through as compact JSON.
    • A 503 (graphs not loaded) is reported as "temporarily unavailable", not as an empty result.
    • VFBQUERY_CIRCUIT_BASE points the tool at another circuit server, e.g. a local one or p3.
  • Docs:
    • LLM_GUIDANCE.md: a routing rule for "how does X reach Y?", a summary-table row, a section on calling it and reading the result, and a follow-up offer.
    • README.md and TECHNICAL.md: the tool and the endpoint.

Testing

  • npm test: 40 pass.
  • The stdio server was tested against a local VFBquery circuit server (FlyWire and L1EM build of 18 Nov):
    • class paths (LC12 → giant fiber);
    • a broad term with instance_graph (Kenyon cell → MBON01);
    • a label refused;
    • an unknown exclude_dbs name passed back as the endpoint's error;
    • the 503 message;
    • an unreachable host.

Before merging

  • Tested against the live 20261115 graphs (see comment).
  • Version bump and release as usual.

🤖 Generated with Claude Code

Ranked multi-hop pathways between neuron classes or neurons, per
connectome, from the class graphs built with each release. Ids only
(labels are refused with a pointer to search_terms), numeric options
range-checked, 503 reported as unavailable rather than empty.
VFBQUERY_CIRCUIT_BASE points it at another circuit server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Clare72
Clare72 requested a review from Robbie1977 November 18, 2026 20:23
@Clare72

Clare72 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Tested against the live service (release 20261115) with VFBQUERY_CIRCUIT_BASE unset, so the tool used v3-cached:

Query Time Response Top paths
ORN_DA1 → MBON01 0.75 s 10 KB BANC, FlyWire and male CNS; one class path shared
LC12 → giant fiber, exclude_dbs: [], instance_graph 3.2 s 6 KB LC12 → PVLP100 → DNp01 in FlyWire, male CNS and hemibrain; BANC via PVLP025 → PVLP151
Kenyon cell → MBON01, normalise: "output" 0.27 s 6 KB KCg-s1 and KCg-m lead in every dataset

Responses are small, so compact JSON with no paging is fine.

ORN_DA1 → MBON01 also shows what connectome-curation#2 costs. In male CNS the top route is ORN_DA1 → DA1_lPN → KCg-m → MBON01 (0.002). FlyWire's DA1 lPNs also carry a female fruitless type, so they are left out, and FlyWire's best route goes via TC-LN → VA1d_adPN at 0.0001.

Ready for review.

@Clare72
Clare72 marked this pull request as ready for review November 18, 2026 21:54
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Clare72

Clare72 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Tested against the live 20261115 graphs (VFBQUERY_CIRCUIT_BASE unset), through the stdio server:

Case Result
LC12 → giant fiber (default datasets) 0.8 s. BANC, FlyWire and male CNS class paths; top LC12 > PVLP100 > DNp01 (BANC: LC12 > PVLP025 > PVLP151 > DNp01)
Same, exclude_dbs: [] 0.6 s. Adds hemibrain
Kenyon cell → MBON01, instance_graph, k=2 8.6 s. Expands to KCg-m > MBON01 in 3 datasets, 3 example neuron chains each
VFB_fw005285 → giant fiber 1.7 s. FlyWire neuron-level paths
Labels Refused, pointing to search_terms
Unknown exclude_dbs Endpoint's 400 message passed back

I've also added a line to the tool description, README and LLM_GUIDANCE about neurons outside the class graph. In neuron-level paths they have class: null, and from the next VFBquery release (with VirtualFlyBrain/VFBquery#151) also status and types. Ready for review.

@Robbie1977 Robbie1977 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and tests look good (40 pass, builds; id validation, the 503 message and the v3-cached routing all work). Tested against the live 20261115 graphs, one thing needs changing before merge: instance_graph is much slower than the description says.

  • LC12 → giant fibre: class paths 1.5 s; instance_graph=true with defaults 22.5 s; at the tool's maximums (k=20, instance_k=10) it hadn't finished after 90 s, past the handler's 60 s timeout.
  • The server keeps computing after the client gives up: that request was still using a full CPU on one vfbquery-circuit pod afterwards. With two workers per pod, a few such calls can tie up the whole service.

Could you:

  1. Change the description to say instance_graph can take tens of seconds on the large connectomes, and to use it only when the user asks about individual neurons.
  2. Cap k at 5 and instance_k at 3 when instance_graph is true, until the server has a time limit.

On the server side (VFBquery#114) we need a time budget per search, or cancellation when the client disconnects. I'll raise that separately.

@Robbie1977
Robbie1977 merged commit d4f3b9f into main Nov 25, 2026
2 checks passed
@Clare72

Clare72 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Both done in cfa4a78:

  1. The description, parameter text, README and LLM_GUIDANCE now say instance_graph takes tens of seconds on the large connectomes and should only be used when the user asks about individual neurons. The old "about a second" and "well under a few seconds" wording is gone.
  2. With instance_graph=true, k above 5 or instance_k above 3 is refused before the request, with a message saying why and to call again without instance_graph for more class paths. Without it, k still goes to 20. The limits are constants in src/circuitPaths.ts, with a note to lift them once the server has a time limit. There's a new test, and 41 pass.

Agreed on a per-search time budget or cancellation on disconnect for VFBquery#114.

Clare72 added a commit that referenced this pull request Nov 25, 2026
instance_graph takes tens of seconds on the large connectomes, and the
server keeps working after the client times out. Say so in the
description and guidance, and refuse k > 5 or instance_k > 3 with it
until the server has a time limit (review on #23).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants