Skip to content

Language Tutorials

These tutorials start from recognizable source code and show the same query in Rune Query Language and canonical JSON CodeQuery. Bifrost’s integration tests run every marked fixture, query, and expected result on the language pages, Library Integration, Typed Set Composition, Reference Traversal, and Receiver Traversal. Some explanatory blocks on Reference Traversal show a query form without a fixture or expected result. Import Traversal shows templates with a <language> placeholder and has no expected results.

Each page builds from a broad structural query to narrower filters and exclusions. Import Traversal covers direct project-file edges, Typed Set Composition combines those edges with union, intersection, and subtraction, Reference Traversal follows exact indexed declarations to source sites and semantic users, and Receiver Traversal exercises bounded values and exact members through the shared adapter-neutral contract. Every language cookbook also executes supertypes, subtypes, members, and owner, with bounded and transitive hierarchy examples distributed across the suite. The receiver cookbook does not claim whole-program points-to, general alias, control-flow, taint, or data-flow reasoning.

Hierarchy recipes return only declarations indexed by the fixture’s analyzer. Real projects may expose usages of library types whose declarations are not indexed; those library declarations remain outside the query result until library indexing can be targeted explicitly.

Library Integration is the odd one out: instead of teaching more query vocabulary, it runs one canonical query through the Rust and Python libraries and shows how an embedder reads the result’s completeness signals.

Each page that has fixtures is marked with the date of its last successful end-to-end verification.

Some results name an entity by a public id: a 256-bit hash of the source content together with the semantic environment, which includes the language adapter version and the semantic IR schema version. Those ids rotate on every adapter or schema bump while the behavior a page teaches stays the same, so a page that embedded one would silently go stale and master would redden after a routine version bump.

These pages therefore spell every such id as <public-id> and assert the stable fields instead: the range, provenance, proof, event counts, kinds, paths, symbols and text. The checked-in golden expectations keep the exact ids and cover their derivation; re-bless those with BIFROST_BLESS=1 after a version bump. The elision is implemented in tests/suite_cross_language/code_query_tutorials.rs.

query_code works with a public language-neutral vocabulary, not raw tree-sitter grammar node names. The completed tutorial suite exercises every normalized kind and role from that public vocabulary, including abstract subtype-aware queries such as callable, declaration, and literal. The aggregate integration test fails if a future vocabulary addition is not taught here.

The pages deliberately spread the vocabulary across languages: calls and assignments appear in every adapter, decorators are demonstrated where the grammar exposes them, kwargs appears in Python, PHP, Scala, C#, Ruby, and Kotlin, and C/C++ share the cpp adapter. For the kinds and roles that each language supports, see language support.