Expand description
AQL engine: parse, index, query, and validate code annotations.
All domain logic lives here. Surface crates (CLI, MCP server, WASM) are thin shims that call into this crate.
Modules§
- meta
- Project identity constants and accessors — single source of truth for all crates.
Structs§
- Annotation
- A single annotation entry from an
.aqmfile. - Annotation
Store - In-memory index of annotation sidecar files.
- Annotation
Summary - Summary of an annotation attached to a code element.
- AqlError
- Error type for AQL operations.
- AqlSymbol
- A symbol extracted from an
.aqmfile for editor outline/navigation. - Attr
Definition - Definition of a tag attribute.
- Attr
Name - Attribute key in metadata maps.
- Attr
Summary - Statistical summary of an attribute across annotation instances.
- Batch
Mutation Result - Result of a batch mutation across multiple files.
- Bench
Case - A single benchmark scenario comparing multiple baselines against AQL.
- Bench
Config - Parsed benchmark configuration from
.config/aql.bench. - Bench
Request - Input for a single bench run. Shims construct this from their input format.
- Bench
Response - Output from a bench run.
- Bench
Result - Result of running a single benchmark case.
- Binding
- Annotation-to-code join key.
- Code
Cache - Per-file cache of parsed
CodeElementtrees with mtime invalidation. - Code
Element - A node in the universal code element tree.
- Code
Element Name - Name of a code construct.
- Code
Element Summary - Summary of a matched code element.
- Colocated
Locator - Default strategy: sidecar lives next to its source file with
.aqmextension.src/api.ts→src/api.aqm - Compound
Selector - A single compound selector: optional tag + zero or more attribute predicates.
- Compression
Result - Compression measurement result from in-memory data.
- Declare
Attr - Attribute definition within a
DeclareTag. - Declare
Config - User-facing config for
declare(). All fields have sensible defaults. - Declare
Extractor - Extractor definition within a
DeclareConfig. - Declare
Tag - Tag definition within a
DeclareConfig. - Delta
- What is unique about a specific annotation relative to the pattern.
- Detected
Stacks - Result of stack detection.
- Diff
Change - An annotation that changed between baseline and current.
- Diff
Entry - A single annotation in a diff.
- Diff
Result - Summary of annotation changes between two states.
- Directory
Locator - Centralized strategy: all sidecars live under a single directory,
mirroring the source tree structure.
With
base = ".annotations":src/api.ts→.annotations/src/api.aqm - Express
Extractor - Built-in Express route/middleware extractor.
- Extractor
Config - Configuration for a single extractor, parsed from the manifest.
- Extractor
Registry - Registry of built-in extractors indexed by name.
- Extractor
Result - Result of running a single extractor.
- File
Compression - Per-file compression detail.
- File
Coverage - Per-file annotation coverage entry.
- File
Diff Coverage - Per-file coverage for a specific set of files (diff-aware).
- File
Entry - Input format for loading annotations: a file path and its XML content.
- File
Summary - Detailed single-file annotation summary.
- GoHttp
Extractor - Built-in Go HTTP route/middleware extractor.
- GoResolver
- Go source file resolver using tree-sitter.
- GoStructure
Extractor - General-purpose Go structure extractor.
- GoTest
Extractor - Built-in Go test/benchmark extractor.
- Manifest
- A parsed AQL manifest from
.config/aql.schema. - Measured
Output - Measured output from one approach.
- Mutation
Request - A single mutation to apply to a source file node.
- Mutation
Result - Result of a mutation operation.
- NavResult
- Result of a navigation operation that returns nodes.
- Node
Kind - tree-sitter AST node kind identifier.
- NodeRef
- A self-contained reference to a node in a source file.
- Pattern
- Common structure across all annotations of a tag.
- Pattern
Result - Result of pattern extraction: the common pattern and per-instance deltas.
- Predicate
- A predicate expression:
name,name=value,name^=value, etc. - Project
Root - Absolute path to the project root directory.
- Project
Stats - Aggregate project statistics for token burn reporting.
- Query
Context - Context passed to each middleware.
- Query
Options - Options applied to query and select result sets after matching.
- Query
Pipeline - Builder and runner for AQL queries.
- Query
Pipeline Builder - Builder for
QueryPipeline. - Query
Result - Enriched query result.
- React
Extractor - Built-in React component/hook extractor.
- Relative
Path - Source file path relative to project root.
- Repair
Suggestion - A suggested fix for a broken annotation binding.
- Resolver
Registry - Registry of Code Resolvers by file extension. Uses an FxHashMap for O(1) extension lookup instead of linear scan.
- Rust
Resolver - Rust source file resolver using tree-sitter.
- Rust
Structure Extractor - General-purpose Rust structure extractor.
- Scope
- Query scope prefix (directory, file, or empty).
- Selector
Ast - Parsed selector AST — a chain of compound selectors.
- Selector
Str - Raw selector string before parsing.
- Sidecar
Edit - A text edit to apply to an
.aqmsidecar file. - Source
Entry - A source file entry for in-memory benchmarking.
- Source
Location - Location of a code element in a source file.
- Spot
Check Failure - A single binding that failed the spot check.
- Spot
Check Result - Result of spot-checking annotation bindings against code elements.
- TagDefinition
- Definition of an annotation tag.
- TagName
- Annotation or code element tag name.
- Test
Extractor - Built-in test framework extractor.
- Transaction
Result - Result of a successfully committed transaction.
- Type
Script Resolver - TypeScript/JavaScript source file resolver using tree-sitter.
- Type
Script Structure Extractor - General-purpose TypeScript/JavaScript structure extractor.
- Validation
Result - A validation result.
Enums§
- AqlDef
- AQL approach definition.
- Attr
Type - Attribute type enumeration.
- Baseline
Def - Baseline approach definition.
- Combinator
- Combinator between compound selectors.
- Insert
Position - Position relative to a target node for insertion.
- Mutation
Op - Mutation operation to perform on a node.
- Predicate
Op - Comparison operator.
- Predicate
Value - Typed predicate value.
- Stack
- Detected project stack.
- Transaction
Condition - A condition evaluated against the in-memory buffer during a transaction.
- Transaction
Op - A single operation within a transaction.
- Validation
Level - Severity level.
Constants§
- BUILTIN_
ATTRS - Built-in attributes available on all tags without manifest definition.
- CLI_
ONLY - Operations exposed only by
amql-cli(no MCP equivalent required).mcpis a transport command that starts the MCP server itself. - MCP_
ONLY - Operations exposed only by
amql-mcp-server(no CLI equivalent required). Entries here must NOT appear inSURFACE. - NON_
GENERATED_ BUILTINS - Built-in attributes that are never generated (human/agent-authored only).
- SCHEMA_
VERSION - Current AQL schema version.
- SOURCE_
EXTENSIONS - Source extensions the engine’s resolver registry handles.
- SURFACE
- Operations that MUST be exposed by both
amql-cli(as aCommandvariant) andamql-mcp-server(as anaql_{op}tool function). Names are lowercase snake_case.
Traits§
- Builtin
Extractor - A built-in extractor that discovers annotations from source code.
- Code
Resolver - A Code Resolver resolves source files into universal CodeElement trees.
- Matchable
- A matchable node — works for both annotations and code elements.
- Query
Middleware - A middleware that can transform query results after AQL runs them.
- Sidecar
Locator - Strategy for locating
.aqmsidecar files relative to source files.
Functions§
- apply_
edits - Apply edits to XML content. Edits must be sorted descending by
start_byte. - auto_
detect_ cases - Auto-generate benchmark cases by scanning the project.
- batch_
mutate - Execute multiple mutations in parallel across files.
- batch_
query - Run multiple selectors in parallel against the same scope.
- count_
source_ files - Count source files in a project.
- declare_
config - Validate a
DeclareConfigand produce aManifest. - detect_
stacks - Detect project stacks from marker files in the given directory.
- diff_
annotations - Compute the diff between baseline annotations and current annotations.
- diff_
file_ coverage - Annotation coverage for a specific set of files (diff-aware).
- diff_
from_ pattern - Given a pattern and a specific annotation, return only what is unique.
- execute_
bench_ request - Execute a bench request end-to-end: validate, build cases, run, return results.
- execute_
transaction - Execute a declarative transaction: apply
opsto an in-memory buffer, then flush to disk only if all ops succeed. On error nothing is written. - expand
- Return the parent node, or the nearest ancestor matching an optional selector.
- expand_
node - Expand: return parent or nearest ancestor matching selector.
- extract_
aql_ symbols - Extract symbols from
.aqmdocument text for editor features (outline, go-to). - extract_
bind_ from_ line - Extract the
bind="..."value from a single line of AQL XML. - extract_
pattern - Analyze all annotations of a tag and return the common pattern.
- file_
coverage - Per-file annotation coverage report.
- file_
summary - Detailed single-file annotation summary.
- filter_
by_ selector - Filter an array of flat nodes by a selector AST. Returns indices into the input slice for matched nodes.
- filter_
by_ selector_ indexed - Filter nodes using parent indices for combinator matching.
parent_indices[i]is the index of node i’s parent innodes, orNone. - find_
project_ root - Walk up from
start_dirlooking for.config/aql.schema. Returns the project root directory (parent of.config/), orNone. - format_
bench_ table - generate_
schema - Generate a
.config/aql.schemaXML string for the detected stacks. - glob_
annotation_ files - Backward-compatible alias for
glob_aql_files. - glob_
aql_ files - Glob for
.aqmfiles in a project, using theignorecrate for.gitignore-aware walking. Uses parallel walking for performance. - glob_
source_ files - Glob source files within a scope, filtered to resolver-supported extensions.
Reuses
ignore::WalkBuilderpattern fromglob_annotation_files. - init_
project - Run
aql init: detect stacks and write.config/aql.schema. - insert
- Insert source text relative to a target node. Writes back to disk.
- insert_
source - Insert source text relative to a target node.
- json_
value_ to_ string - Shared utility: convert a JSON value to a string representation.
Returns
Cow::Borrowedfor theStringvariant to avoid allocation. - load_
manifest - Load and parse a manifest from
project_root/.config/aql.schema. - matches_
compound - Test if a single node matches a compound selector (tag + attributes).
- measure_
compression - Measure compression from pre-loaded source files and annotations.
- move_
node - Move a node to a new position relative to a target. Both must be in the same file. Writes back to disk.
- move_
node_ in_ source - Move a node to a new position relative to a target. Both nodes must be in the same file (same source text).
- nav_
select - Select nodes matching a structural selector within a scope.
- next
- Return the next named sibling, or the next sibling matching a selector.
- next_
node - Next: return next named sibling matching selector.
- parse_
bench_ config - Parse a benchmark config from a raw XML string.
- parse_
manifest - Parse a manifest from a raw XML string.
- parse_
selector - Parse a selector string into an AST.
- pattern_
with_ deltas - Extract the pattern and compute deltas for every instance of a tag.
- prev
- Return the previous named sibling, or the previous sibling matching a selector.
- prev_
node - Prev: return previous named sibling matching selector.
- project_
name - Derive a project name from the project root directory.
- project_
stats - Compute project statistics from loaded stores.
- read_
source - Read the source text of a node.
- remove
- Remove a node from its source file. Returns the modified source and detached text.
- remove_
node - Remove a node from the source text, returning the modified source and the detached node’s text.
- replace
- Replace a node’s source text. Writes back to disk.
- replace_
node - Replace a node’s source text with new content.
- resolve_
bind_ name - Resolve qualified bindings:
Foo.bar→bar. - run_
all_ extractors - Run all extractors defined in the manifest and collect results.
- run_
bench - Execute all benchmark cases and collect results.
- run_
extractor - Run a single extractor as a subprocess and parse its JSON output.
- select_
nodes - Select all named descendants matching a selector within a scope.
- shrink
- Return the first child matching an optional selector, or all direct children.
- shrink_
node - Shrink: return children matching selector, or all named children.
- sidecar_
for_ colocated - Derive the colocated sidecar path from a source path.
src/api.ts→src/api.aqm - source_
candidates - Candidate source paths for a sidecar. Inverse of
sidecar_for_colocated. - spot_
check_ bindings - Spot-check annotation bindings against parsed code elements.
- suggest_
repairs - Find annotations with bindings that look potentially broken
and suggest repairs based on other annotations and code element names.
If
code_cacheis provided, code element names are included in the known names set. - suggest_
repairs_ from_ annotations - Suggest repairs using only annotation data (no code cache).
- sync_
sidecar - Compute minimal edits to sync an
.aqmsidecar with new annotations. - unified_
query - Main query entry point.
- validate
- Validate all loaded annotations against the manifest.
Parallelizes per-file validation via rayon when the
fsfeature is enabled.
Type Aliases§
- AttrOp
- Alias for
PredicateOp(backwards compatibility). - Attr
Predicate - Alias for
Predicate(backwards compatibility). - File
Lock Manager - Per-file lock manager keyed by
RelativePath. - FxHash
Map - Type alias for a hash map that uses the Fx hashing algorithm.