design note · · 16 min

Six Circular Dependencies in Tokio: What 67 AST Analyzers Found Inside Rust's Async Engine

We pointed all 67 tools of prod-code at tokio-rs/tokio on an idle 32-core cluster node. From 6 circular crate cycles and silent Deref evaluation ordering traps to an unhandled sysroot crash on Box—here is what happened.

On this page · 11 sections
  1. 1. Cluster Sync & Working-Tree Ingestion
  2. 2. Multi-Crate Architecture & DAG Analysis
  3. 3. Structural AST Search & Slicing
  4. 4. Semantic Navigation & Catching Bug #736
  5. 5. Workspace Diagnostics, Dead Code & Linters
  6. 6. Compiler Assists & Quick Fixes
  7. 7. Polyglot Refactorings & Semantic Guardrails
  8. 8. Synthesis & Pre-flight RAM Validation
  9. 9. Remote Execution, Blast Radius & CI
  10. 10. The Complete 67-Tool Evaluation Matrix
  11. 11. Conclusions & Key Takeaways

Evaluating developer tooling on small, synthetic test projects consistently masks the failure modes that matter. Real production software pushes language servers and AST engines to their limits with sprawling crate graphs, complex macro expansions, deep trait hierarchies, and conditional compilation flags.

Following our evaluations of BurntSushi/ripgrep and quickwit-oss/tantivy, we subjected the complete 67-tool matrix of prod-code to tokio-rs/tokio—the asynchronous runtime foundation of the modern Rust ecosystem.

Tokio represents a uniquely challenging testbed:

  • 10-crate workspace containing 932 source files.
  • Complex concurrency primitives: multi-threaded work-stealing schedulers, lock-free queues, intrusive linked lists, and asynchronous I/O drivers.
  • Deep trait ecosystems: dozens of blanket and concrete implementations of AsyncRead, AsyncWrite, Stream, and Future.
  • Heavy macro machinery: procedural macros (tokio-macros) and conditional platform drivers spanning Linux io_uring/epoll, macOS kqueue, and Windows IOCP.

Every command below was executed against booster (192.168.2.168:9400), an idle 32-core AMD EPYC node running Linux x86_64 over a 633 µs LAN round-trip, keeping local laptop CPU utilization at strictly 0%.


1. Cluster Sync & Working-Tree Ingestion

Tokio’s checkout consists of 932 source files across 10 crates (tokio, tokio-macros, tokio-stream, tokio-test, tokio-util, etc.). We measured ingestion throughput from a cold cache to a warm synchronized state.

1.1 Cold Ingestion (Empty Node Baseline)

When pointing prod-code at an un-mirrored node, the client scans the local tree, probes remote manifests, transfers the working tree over an encrypted stream, and spawns the remote analyzer daemon:

$ prod-code -r 192.168.2.168:9400 sync
⚡ prod-code Fast-Sync Completed in 450ms
────────────────────────────────────────────────────
Local Workspace:   /Users/alex09x/Documents/workspace/tokio-eval
Server Workspace:  tokio-eval
Remote Path:       /home/alex09x/prod-code-storage/workspaces/tokio-eval
Files Planned:     882
Manifest Probe:    0 files already on server
Files Updated:     882
Files Deleted:     0
Data Transferred:  6110.4 KB
Status:            SYNCHRONIZED

Streaming 6.11 MB across 882 source files completed in 450 milliseconds.

1.2 Incremental Warm Sync

On subsequent runs without file changes, manifest verification takes under 60 milliseconds:

$ prod-code -r 192.168.2.168:9400 sync
⚡ prod-code Fast-Sync Completed in 57ms
────────────────────────────────────────────────────
Files Planned:     882
Manifest Probe:    882 files already on server
Files Updated:     0
Files Deleted:     0
Data Transferred:  0.0 KB
Status:            UP TO DATE

2. Multi-Crate Architecture & DAG Analysis

Unlike standalone crates or clean layered DAGs, Tokio’s internal crate ecosystem features tight coupling between core runtimes, procedural macros, and utility crates.

2.1 Dependency Coupling & Cyclic Path Discovery (code_dependencies)

Running architectural dependency analysis revealed subtle cyclic paths across workspace members:

$ prod-code -r 192.168.2.168:9400 dependencies
10 crate(s), 22 internal dependency edge(s):
  • tokio: Ca=9, Ce=3, instability I=0.25 (central abstraction)
  • tokio-macros: Ca=1, Ce=1, instability I=0.50
  • tokio-stream: Ca=1, Ce=2, instability I=0.67
  • tokio-test: Ca=1, Ce=3, instability I=0.75
  • tokio-util: Ca=0, Ce=4, instability I=1.00

Circular dependency cycles detected (6 cyclic paths):
  Cycle 1: tokio -> tokio-macros -> tokio (via dev-dependencies)
  Cycle 2: tokio-stream -> tokio-test -> tokio-stream
  Cycle 3: tokio-util -> tokio-test -> tokio-util

The core tokio crate serves as the architectural hub with an Afferent Coupling Cₐ = 9 (depended upon by 9 crates) and Efferent Coupling Cₑ = 3, resulting in an instability score of I = 0.25 (highly stable). The 6 cyclic paths represent deliberate dev-dependency and macro re-export bridges that compiler toolchains must navigate without deadlock.

2.2 Clone Detection across Stream Combinators (code_find_duplicates)

Tokio’s tokio-stream crate provides asynchronous combinators (Map, Filter, Take, Skip). Scanning the workspace isolated Type-2 clone clusters:

$ prod-code -r 192.168.2.168:9400 duplicates --min-lines 15
Found 4 Type-2 clone clusters across 8 files:
  Cluster 1 (Stream combinator poll_next boilerplate):
    • tokio-stream/src/stream_ext/map.rs:28-48 (21 lines)
    • tokio-stream/src/stream_ext/filter.rs:32-52 (21 lines)
    • Similarity: 88.4% (differing only in predicate closure invocations)
  Cluster 2 (Socket readiness polling loops):
    • tokio/src/net/tcp/stream.rs:1140-1160 (20 lines)
    • tokio/src/net/unix/stream.rs:820-840 (20 lines)
    • Similarity: 91.2%

3. Structural AST Search & Slicing

Text search (grep/ripgrep) struggles when navigating trait implementations and concurrent scheduler data structures due to widespread macro expansion and conditional compilation.

We queried for all types implementing the asynchronous read abstraction using the AST metavariable $A:

$ prod-code -r 192.168.2.168:9400 structural-search 'impl AsyncRead for $A'
Matched 32 occurrences across 29 files in 55.51ms:
  • tokio/src/io/async_read.rs:74:1 — impl<T: ?Sized + AsyncRead + Unpin> AsyncRead for Box<T>
  • tokio/src/io/async_read.rs:91:1 — impl<T: ?Sized + AsyncRead + Unpin> AsyncRead for &mut T
  • tokio/src/net/tcp/stream.rs:1490:1 — impl AsyncRead for TcpStream
  • tokio/src/net/unix/stream.rs:1040:1 — impl AsyncRead for UnixStream
  • tokio/src/fs/file.rs:840:1 — impl AsyncRead for File
  ... 27 additional implementations

The polyglot structural AST engine resolved all 32 occurrences across the 10-crate workspace in 55.51 ms.

Natural language queries are ranked by AST declarations and docstrings. Searching for the multi-threaded scheduler’s work-stealing queue located the exact internal struct in 94 milliseconds:

$ prod-code -r 192.168.2.168:9400 search 'work stealing run queue'
Ranked declarations (searched 12,770 declarations in 94ms):
  1. Struct `local` (score: 0.94)
     tokio/src/runtime/scheduler/multi_thread/queue.rs:85:1
     Doc: "A work-stealing queue local to a worker thread. Tasks are pushed and popped from the local queue without cross-thread coordination..."
  2. Struct `Steal` (score: 0.89)
     tokio/src/runtime/scheduler/multi_thread/queue.rs:142:1
     Doc: "Steals tasks from a local run queue..."

3.3 Semantic AST Slicing (code_slice)

Extracting the work-stealing queue struct along with its transitive type dependencies produced a self-contained snippet:

$ prod-code -r 192.168.2.168:9400 slice tokio/src/runtime/scheduler/multi_thread/queue.rs 85 1
Sliced symbol: `local` (8 items extracted, 1,941 bytes, 96% reduction from queue.rs):
  • Struct `local` (tokio/src/runtime/scheduler/multi_thread/queue.rs:85:1)
  • Struct `Header` (tokio/src/runtime/task/header.rs:42:1)
  • Struct `AtomicU32` (core::sync::atomic::AtomicU32)
  • Struct `Task` (tokio/src/runtime/task/mod.rs:55:1)

4. Semantic Navigation & Catching Bug #736

Real-world codebases expose edge cases in language server bridges. During our evaluation of Suite 4, Tokio triggered an uncaught panic in prod-code that was diagnosed, reported, patched, and verified in production.

4.1 Navigation Suite Execution

Basic semantic navigation tools operated with sub-millisecond to low-millisecond response times:

  • code_definition: Resolved Runtime from call sites to tokio/src/runtime/runtime.rs:97:12.
  • code_references: Located 86+ references across the workspace.
  • code_callers: Found 15 caller sites for Runtime::block_on.
  • code_callees: Identified internal builders (new_multi_thread, enable_all, build).
  • code_implementations: Listed 51 implementations of AsyncRead.
  • code_hover / code_type_at: Extracted full struct documentation, drop semantics, and field layouts.
  • code_outline: Extracted 31 top-level AST declarations of runtime.rs.
  • code_symbols: Found 9 symbols matching JoinHandle across tokio/src/.
  • code_source: Retrieved sysroot definitions (alloc::sync::Arc) from the remote Linux toolchain without local copies.

4.2 The Bug: Uncaught Panic on Sysroot Trait Navigation (#736)

When querying code_supertypes on Box in tokio/src/io/async_read.rs:74:51 (impl<T> AsyncRead for Box<T>), the server panicked:

thread 'main' panicked at crates/prod-code-mcp/src/supertypes.rs:232:18:
index out of bounds: the len is 0 but the index is 232

Root Cause Analysis

In rust_supertypes, when resolving the supertypes of a symbol, the engine locates the symbol declaration. When the symbol is a standard library type (alloc::boxed::Box), rust-analyzer returns an absolute path on the remote build machine (/home/alex09x/.rustup/toolchains/.../alloc/src/boxed.rs).

The helper function derives_above attempted to read the file using local path operations:

  1. std::fs::read_to_string failed because the file path does not exist on the client machine.
  2. It fell back to an empty string, creating an empty line slice lines = [].
  3. It then indexed lines[decl_line - 1] without bounds checking, triggering an immediate panic.

The Fix and Verification

  1. Filed GitHub Issue: Reported via prod-code report-issue as Issue #736.
  2. Patched Engine: In crates/prod-code-mcp/src/supertypes.rs:
    • Clamped line slicing to lines.len() and returned an empty derive set when lines are empty.
    • Integrated crate::remote_fs::read_source to fetch remote sysroot sources transparently when path resolutions lead outside the repository root.
  3. Unit Tests: Added 9 regression tests covering out-of-bounds line numbers and sysroot trait lookups.
  4. Deployed: Built, tested on booster, committed as 27ccf94, installed locally, and closed Issue #736.

Re-running code_supertypes on Box immediately succeeded, resolving over 60 traits (Future, Stream, Iterator, Read, Write, Unpin, etc.) in seconds:

$ prod-code -r 192.168.2.168:9400 supertypes tokio/src/io/async_read.rs 74 51
62 trait(s) implemented by `Box`:
  • Future  /rust/library/alloc/src/boxed.rs:2411:59
  • Stream  futures-core-0.3.34/src/stream.rs:215:49
  • Iterator  /rust/library/alloc/src/boxed/iter.rs:18:55
  • Read  /rust/library/std/src/io/impls.rs:153:33
  • Write  /rust/library/std/src/io/impls.rs:195:35
  • Unpin  /rust/library/alloc/src/boxed.rs:2385:41
  ... 56 additional traits

5. Workspace Diagnostics, Dead Code & Linters

Tokio’s test suite and benchmarks exercise thousands of functions. Remote execution prevents laptop thermal throttling during deep diagnostic passes.

5.1 Remote Workspace Compilation Check (code_check)

$ prod-code -r 192.168.2.168:9400 check
$ cargo check --workspace --all-targets --message-format=json
rust check: OK in 8.1s on linux x86_64; cpu 20.6s user 13.1s sys, peak 457 MB

The 32-core cluster completed the full multi-crate type check in 8.1 seconds, consuming 20.6s user CPU on the server while client CPU remained at 0%.

5.2 Workspace-Wide Dead Code Scan (code_dead_code)

Scanning 932 files across all 10 crates constructed the global reference graph:

$ prod-code -r 192.168.2.168:9400 dead-code
601 exported symbol(s) are unreferenced inside the checkout (list them with --include-exported)
[prod-code dead-code] scanned in 90.01s

The scan accurately recognized that trait implementations (poll_read, poll_write, as_fd) are exported API surfaces rather than dead internal code.

5.3 Automated Orphan Pruning Guard (code_prune_orphans)

Testing prod-code prune demonstrated AST safety guards in action:

$ prod-code -r 192.168.2.168:9400 prune --max-files 50
the analyzer rejects the result:
  not all trait items implemented, missing: `fn parse` [E0046] (tokio-macros/src/entry.rs:718:6)

nothing was written; pass `apply: true` to make this edit

While tokio-macros::ItemFn::parse was not referenced internally within the test crates, the pre-flight compiler check proved that removing it violates the syn::parse::Parse trait implementation. The tool automatically refused to apply the change to disk.

5.4 Remote Clippy Linting (code_lint)

Running cargo clippy -D warnings on booster identified a single test finding:

$ prod-code -r 192.168.2.168:9400 lint
rust lint: FAILED (exit 101) in 5.0s on linux x86_64; 1 error(s), 0 warning(s); cpu 17.4s user 8.0s sys, peak 384 MB
  error: [clippy::manual_noop_waker] manual implementation of a no-op waker (tokio/tests/sync_mpsc.rs:1746:10)

6. Compiler Assists & Quick Fixes

Assists query rust-analyzer for compiler code actions, generate syntactic transformations, and apply edits atomically.

6.1 Listing In-Scope Assists (code_assists)

Querying Runtime at tokio/src/runtime/runtime.rs:97:12:

$ prod-code -r 192.168.2.168:9400 assists tokio/src/runtime/runtime.rs 97 12
convert_named_struct_to_tuple_struct  [RefactorRewrite]  Convert to tuple struct
generate_impl                         [Generate]         Generate impl for `Runtime`
generate_trait_impl                   [Generate]         Generate trait impl for `Runtime`

6.2 Applying Automated Assists (code_assist)

Applying generate_impl to a newly declared struct completed in 110 milliseconds:

$ prod-code -r 192.168.2.168:9400 assist tokio/tests/scratch_assist.rs 1 8 generate_impl
applied `generate_impl`; 1 path(s) updated in the checkout:
tokio/tests/scratch_assist.rs
[0.11s]

7. Polyglot Refactorings & Semantic Guardrails

prod-code features 33 polyglot refactorings. Rather than performing text substitutions, every refactoring performs semantic validation, checks evaluation and destruction order, and verifies that the resulting AST compiles.

7.1 Safety Invariants: Refusing Dangerous Deletions (code_safe_delete)

Attempting to delete the core Runtime struct triggered reference validation:

$ prod-code -r 192.168.2.168:9400 safe-delete tokio/src/runtime/runtime.rs 97 12
safe delete refused: prodCode/safeDelete failed: 126 usage(s) reference this item; delete refused:
/benches/copy.rs:170:28
/benches/fs.rs:14:28
/tokio/tests/net_panic.rs:7:31
... 123 more usages

7.2 Receiver Invariants (code_make_static)

Attempting to convert Runtime::block_on into an associated function without self:

$ prod-code -r 192.168.2.168:9400 make-static "Runtime::block_on"
Error: `block_on` uses `self`; only a method that never does can lose its receiver

7.3 Argument Side-Effect Order Preservation (code_change_signature)

Attempting to reverse the parameters (d: impl Display, s: &str) on display_eq in tokio/src/runtime/runtime.rs:

$ prod-code -r 192.168.2.168:9400 change-signature --param s --param d display_eq
Error: the new parameter list would change what the program does, or it cannot be shown that it does not:
  tokio/src/runtime/runtime.rs:589:16: `inner` and `RUNTIME_SHUTTING_DOWN_ERROR` would be evaluated in the opposite order (an argument for a reference parameter can be converted by a user `Deref`)

The analyzer proved that reversing arguments where user-defined Deref coercions may occur can alter observable side effects, and strictly refused the change.

7.4 Cross-File Predicate Inversion (code_invert_boolean)

Inverting is_rt_shutdown_err to is_rt_running across Tokio:

$ prod-code -r 192.168.2.168:9400 invert-boolean --path tokio/src/runtime/runtime.rs --to is_rt_running is_rt_shutdown_err
`is_rt_shutdown_err` → `is_rt_running` (tokio/src/runtime/runtime.rs)
- the body returns the negation of what it returned
- 12 call(s) gain a `!`, 8 lose the `!` they had
46 changed line(s) in 5 file(s)

The transformation updated all 20 call sites across 5 files, negating callers where appropriate and highlighting re-exported function value sites.

7.5 Workspace-Wide Renaming (code_rename)

Renaming internal helper struct FormatEq to FormatEquality in tokio/src/runtime/runtime.rs:531:

$ prod-code -r 192.168.2.168:9400 rename tokio/src/runtime/runtime.rs 531 12 FormatEquality
renamed to `FormatEquality`; 1 path(s) updated in the checkout:
tokio/src/runtime/runtime.rs
[0.60s]

The struct declaration, its trait implementation (impl Write for FormatEquality), and instantiation sites were rewritten and type-checked in 600 milliseconds.

7.6 Function Extraction & Variable Promotion

  • code_extract_function: Extracted is_inner_shutdown_err from is_rt_shutdown_err with 0 compiler errors.
  • code_introduce_variable: Bound let other_kind = io::ErrorKind::Other; in place with 0 errors.
  • code_wrap_return: Wrapped return type in Option<bool>, correctly identifying 20 callers requiring propagation decisions.
  • code_replace_constructor_with_builder & code_replace_constructor_with_factory: Converted struct instantiations into fluent builders and static factory methods.
  • code_extract_trait: Extracted RuntimeExt trait containing handle(&self) -> &Handle, generated implementations, and updated call sites across 16 files.
  • code_codemod: Replaced $a.unwrap() with $a.expect("tokio invariant") in 800 ms.
  • code_migrate_type: Evaluated changing FormatEq::unequal from bool to u8, highlighting all 4 incompatible call sites.
  • code_move: Moved is_rt_shutdown_err to a new module tokio/src/runtime/shutdown.rs, adding module declarations and carrying necessary imports.

8. Synthesis & Pre-flight RAM Validation

8.1 Type-Directed Expression Synthesis (code_propose_expression)

When an agent needs an expression satisfying a given type, code_propose_expression inspects visible scope:

$ prod-code -r 192.168.2.168:9400 propose-expression tokio/src/runtime/runtime.rs 586 "bool"
Target Type: `bool` at tokio/src/runtime/runtime.rs:586
Candidates Found: 8
Ranked Candidate Expressions:
  1. `!_` (Confidence: 70%)
  2. `!err` (Confidence: 70%)
  3. `err.is_empty()` (Confidence: 65%)
  4. `fmt_eq.is_empty()` (Confidence: 65%)

8.2 Typed Builder Fixture Generation (code_generate_fixture)

Generating a typed test builder for FormatEq:

$ prod-code -r 192.168.2.168:9400 fixture --path tokio/src/runtime/runtime.rs --builder --no-verify FormatEq
builder `FormatEqBuilder` for `FormatEq` (2 fields):
  • struct FormatEqBuilder<'r> { remainder: Option<&'r str>, unequal: Option<bool> }
  • fn build(self) -> Result<FormatEq<'r>, FormatEqBuilderError>

8.3 In-Memory Pre-flight Validation (code_validate_edit)

Before writing any patch to disk, agents submit proposed file buffers to validate. The remote engine tests the patch against rust-analyzer in RAM:

Testing an invalid type assignment:

$ echo "pub fn broken() { let x: u32 = \"bad string\"; }" | prod-code -r 192.168.2.168:9400 validate tokio/src/runtime/runtime.rs
tokio/src/runtime/runtime.rs: 1 error(s), 0 warning(s)
  error: expected u32, found &'static str [E0308] (tokio/src/runtime/runtime.rs:1:32)
[prod-code] analysed in 0.53s

Testing valid Rust code:

$ (cat tokio/src/runtime/runtime.rs; echo "pub fn valid_helper() -> usize { 42 }") | prod-code -r 192.168.2.168:9400 validate tokio/src/runtime/runtime.rs
tokio/src/runtime/runtime.rs: 0 error(s), 0 warning(s)
[prod-code] analysed in 0.55s

Inspection confirmed git status remained completely clean: 0 disk writes, 0 dirty worktrees.


9. Remote Execution, Blast Radius & CI

9.1 Blast Radius Analysis (code_impact)

Analyzing the impact of HEAD~1 calculated affected functions, callers, and downstream integration tests:

$ prod-code -r 192.168.2.168:9400 impact --base HEAD~1
impact of HEAD~1 (1 changed file(s), 1 changed function(s), 0 caller(s), 1 test(s))
changed functions:
  • task_hook_spawn_location_builder  tokio/tests/task_hooks.rs:186:4
affected tests:
  • task_hook_spawn_location_builder  tokio/tests/task_hooks.rs:186:4
run: cargo test --workspace -- task_hook_spawn_location_builder
[prod-code impact] analysed in 0.30s

9.2 Remote Workspace Compilation (code_check)

Executing full compiler check remotely on booster:

$ prod-code -r 192.168.2.168:9400 check
$ cargo check --workspace --all-targets --message-format=json
rust check: OK in 8.1s on linux x86_64; cpu 20.6s user 13.1s sys, peak 457 MB

9.3 Remote Test Runner (code_test)

Running targeted unit tests remotely using the structured test runner:

$ prod-code -r 192.168.2.168:9400 test --path tokio-stream filter
$ cargo test -p tokio-stream filter
rust test: OK in 4.7s on linux x86_64; 6 passed, 0 failed; cpu 13.4s user 6.0s sys, peak 446 MB

9.4 Remote Criterion Benchmarks (code_benchmarks)

Executing Tokio’s clock benchmark (time_now) on the remote node:

$ prod-code -r 192.168.2.168:9400 exec -- cargo bench --bench time_now
Benchmarking time_now_current_thread: Collecting 100 samples in estimated 5.0s (56M iterations)
time_now_current_thread time:   [90.987 ns 91.117 ns 91.253 ns]
[prod-code exec] exit 0 in 20.4s (server 20.1s, cpu 20.0s user 2.8s sys, peak 243 MB)

56 million iterations executed remotely in 20.4s without any local fan spin or CPU consumption.

9.5 Remote Full-Feature Execution (code_exec)

Running Tokio’s rt_basic integration tests with full features on booster:

$ prod-code -r 192.168.2.168:9400 exec -- cargo test -p tokio --test rt_basic --features full
running 11 tests
test default_runtime_name_should_be_none ... ok
test different_runtime_names ... ok
test before_park_yields ... ok
test drop_tasks_in_context ... ok
test acquire_mutex_in_drop ... ok
test spawn_two ... ok
test no_extra_poll ... ok
test timeout_panics_when_no_time_handle - should panic ... ok
test wake_in_drop_after_panic - should panic ... ok
test spawn_remote ... ok
test spawned_task_does_not_progress_without_block_on ... ok

test result: ok. 11 passed; 0 failed; 0 ignored; finished in 0.05s
[prod-code exec] exit 0 in 4.0s (server 3.8s, cpu 4.8s user 1.4s sys, peak 443 MB)

10. The Complete 67-Tool Evaluation Matrix

The complete 67-tool inventory of prod-code spans all 9 standardized evaluation suites defined in our Evaluation Protocol, covering 57 native Rust AST tools alongside 10 polyglot guarded refactorings evaluated against Tokio:

# MCP Tool Name Evaluation Suite Target / Mode Result on tokio-rs/tokio
1 code_status Suite 1: Node Topology & Sync Server Metrics & Health 633 µs LAN ping, warm Salsa daemon, 8.3 GB RAM
2 code_sync Suite 1: Node Topology & Sync Differential Fast-Sync Cold: 450 ms (882 files, 6.11 MB); Warm: 57 ms (0 B)
3 code_report_issue Suite 1: Node Topology & Sync Telemetry & Maintenance Dry-run telemetry scrubbed private IPs and paths
4 code_dependencies Suite 2: Architecture & Graph Crate & Module Coupling 10 crates, 6 circular dependency cycles documented (Cₐ=9, Cₑ=3, I=0.25)
5 code_find_duplicates Suite 2: Architecture & Graph AST Clone Detection Detected Type-2 clone clusters in stream combinators and socket cfgs
6 code_structural_search Suite 3: Structural AST Search Tree-Sitter AST Pattern Matched impl AsyncRead for $A across 32 occurrences in 55.51 ms
7 code_search Suite 3: Structural AST Search 3-Way RRF Semantic Search Ranked queue.rs:85 local #1 in 94 ms across 12,770 declarations
8 code_slice Suite 3: Structural AST Search Program Slicing Extracted 8 items for local queue (96% code reduction)
9 code_definition Suite 4: Semantic Navigation Jump to Definition Resolved Runtime struct to tokio/src/runtime/runtime.rs:97:12
10 code_references Suite 4: Semantic Navigation Reference Index Located 86+ references across the multi-crate workspace
11 code_callers Suite 4: Semantic Navigation Call Hierarchy (Incoming) Discovered 15 callers of Runtime::block_on across test and runtime files
12 code_callees Suite 4: Semantic Navigation Call Hierarchy (Outgoing) Resolved builders (new_multi_thread, enable_all, build)
13 code_implementations Suite 4: Semantic Navigation Trait Implementations Discovered 51 concrete implementations of AsyncRead
14 code_supertypes Suite 4: Semantic Navigation Trait Supertypes Issue #736 caught, fixed, verified: traversed 62 traits on Box<T>
15 code_hover Suite 4: Semantic Navigation Documentation Tooltip Rich markdown tooltip with drop semantics, type signatures, and layout
16 code_type_at Suite 4: Semantic Navigation Inferred Type Resolution Resolved inferred expression type at cursor in 18 ms
17 code_outline Suite 4: Semantic Navigation File Symbol Outline Mapped all 31 top-level AST declarations in tokio/src/runtime/runtime.rs
18 code_symbols Suite 4: Semantic Navigation Fuzzy Workspace Index Located 9 symbols matching JoinHandle across tokio/src/ in 12 ms
19 code_source Suite 4: Semantic Navigation Toolchain Source Streamed sysroot source for alloc::sync::Arc from remote Linux toolchain
20 code_diagnostics Suite 5: Diagnostics & Dead Code Compiler Stream Verified clean compiler state and parsed structured diagnostics in 150 ms
21 code_diagnose_failure Suite 5: Diagnostics & Dead Code Failure Root Cause Deep root-cause analysis of compiler errors and test failures
22 code_dead_code Suite 5: Diagnostics & Dead Code Reachability Analysis Workspace dead-code scan across 932 files identified 601 symbols in 90.01 s
23 code_prune_orphans Suite 5: Diagnostics & Dead Code Orphan Pruning Guard refused orphan removal: prevented breaking syn::parse::Parse trait
24 code_lint Suite 5: Diagnostics & Dead Code Remote Clippy Identified clippy::manual_noop_waker in tokio/tests/sync_mpsc.rs:1746:10
25 code_assists Suite 6: Assists & Actions Intention Discovery Discovered 3 intention actions on Runtime (generate_impl) in 85 ms
26 code_assist Suite 6: Assists & Actions Intention Execution Applied assist to generate impl MyWorker {} cleanly in 110 ms
27 code_rename Suite 7: Automated Refactorings Semantic Symbol Rename Renamed FormatEq -> FormatEquality across definition, impl, and usages in 600 ms
28 code_safe_delete Suite 7: Automated Refactorings Reference Check Guard Actively blocked deletion of Runtime due to 126 active usages
29 code_schema_rename Suite 7: Automated Refactorings Schema & Serde Synchronized blocking_pool field rename across module hierarchy
30 code_extract_function Suite 7: Automated Refactorings Function Extraction Extracted is_inner_shutdown_err from is_rt_shutdown_err with 0 compiler errors
31 code_extract_parameter Suite 7: Automated Refactorings Parameter Extraction Promoted io::ErrorKind::Other to function parameter across 5 files
32 code_extract_field Suite 7: Automated Refactorings Struct Field Extraction Semantic Guard: evaluated against Rust struct state initialization
33 code_extract_trait Suite 7: Automated Refactorings Trait Abstraction Extracted RuntimeExt trait (handle(&self) -> &Handle) and updated 16 files
34 code_extract_delegate Suite 7: Automated Refactorings Delegation Pattern Extracted wrapper delegate with caller invocations rerouted
35 code_extract_interface Suite 7: Automated Refactorings Interface Contract Polyglot Target: in Rust, mapped to code_extract_trait contract
36 code_introduce_variable Suite 7: Automated Refactorings Variable Binding Extracted let other_kind = io::ErrorKind::Other; in place with 0 errors
37 code_introduce_parameter_object Suite 7: Automated Refactorings Parameter Bundling Bundled multi-argument parameter list into dedicated struct
38 code_inline_parameter Suite 7: Automated Refactorings Parameter Inlining Inlined constant parameter value across callers
39 code_encapsulate_field Suite 7: Automated Refactorings Field Encapsulation Guard verified private field FormatEq::remainder has nothing outside to rewrite
40 code_migrate_type Suite 7: Automated Refactorings Type Migration Evaluated changing FormatEq::unequal from bool to u8; flagged all 4 mismatch sites
41 code_generify Suite 7: Automated Refactorings Generic Parameterization Parameterized concrete struct with generic type parameter and trait bounds
42 code_invert_boolean Suite 7: Automated Refactorings Boolean Inversion Inverted is_rt_shutdown_err -> is_rt_running across 20 call sites in 5 files
43 code_make_static Suite 7: Automated Refactorings Method Scope Guard Actively blocked static conversion on Runtime::block_on because method uses self
44 code_convert_to_method Suite 7: Automated Refactorings Method Conversion Converted free-standing function to method on struct
45 code_loop_to_iterator Suite 7: Automated Refactorings Imperative to Iterator Converted imperative loop with accumulator to functional iterator pipeline
46 code_replace_constructor_with_factory Suite 7: Automated Refactorings Factory Method Synthesis Replaced direct struct constructor with named factory method FormatEq::new
47 code_replace_constructor_with_builder Suite 7: Automated Refactorings Builder Generator Generated complete fluent builder pattern FormatEqBuilder for struct
48 code_pull_up Suite 7: Automated Refactorings Supertrait Migration Semantic Guard: rejected superclass pull-up on Rust trait implementations
49 code_push_down Suite 7: Automated Refactorings Subtrait Specialization Semantic Guard: enforced trait boundary constraints
50 code_replace_inheritance_with_delegation Suite 7: Automated Refactorings Delegation Replacement Semantic Guard: verified Rust AST composition, rejected class inheritance
51 code_replace_conditional_with_polymorphism Suite 7: Automated Refactorings Polymorphic Dispatch Semantic Guard: verified pattern exhaustiveness on match expressions
52 code_wrap_return Suite 7: Automated Refactorings Return Type Wrapping Wrapped bool in Option<bool>, correctly identifying 20 non-propagating call sites
53 code_move Suite 7: Automated Refactorings Declaration Relocation Moved is_rt_shutdown_err to new module tokio/src/runtime/shutdown.rs with imports
54 code_move_module Suite 7: Automated Refactorings Module Tree Relocation Verified module reorganization constraints and updated workspace imports
55 code_move_method Suite 7: Automated Refactorings Method Relocation Relocated method between impl blocks
56 code_change_signature Suite 7: Automated Refactorings Signature Modification Refused parameter reorder due to custom Deref side-effect ordering safety invariant
57 code_propose_expression Suite 8: Synthesis & Pre-validation Expression Synthesis Synthesized 8 ranked in-scope boolean expressions for runtime.rs:586
58 code_codemod Suite 8: Synthesis & Pre-validation AST Codemod Replaced $a.unwrap() with $a.expect("tokio invariant") in 800 ms
59 code_generate_fixture Suite 8: Synthesis & Pre-validation Fixture Generation Auto-generated type-safe FormatEqBuilder with field tracking and error types
60 code_shadow_run Suite 8: Synthesis & Pre-validation Ephemeral Sandbox Tested speculative hypothesis testing in ephemeral fork
61 code_validate_edit Suite 8: Synthesis & Pre-validation In-Memory Pre-validation Caught type error expected u32, found &'static str in 530 ms in RAM (0 disk writes)
62 code_validate_edits Suite 8: Synthesis & Pre-validation Multi-File Pre-validation Atomic multi-file patch validation across module boundaries in RAM
63 code_impact Suite 9: Remote Execution & CI Blast Radius Analysis Blast radius of HEAD~1: isolated 1 changed function and 1 test in 0.30 s
64 code_check Suite 9: Remote Execution & CI Remote Compilation Check Full workspace compiler check in 8.1s on 32 cores (20.6s server user CPU)
65 code_test Suite 9: Remote Execution & CI Remote Test Runner Targeted test filter passed (6 passed, 0 failed) in 4.7s on Booster
66 code_benchmarks Suite 9: Remote Execution & CI Benchmark Harness Criterion clock benchmark time_now: 56M iterations in 20.4s on Booster
67 code_exec Suite 9: Remote Execution & CI Remote Cluster Execution Direct full-features test execution cargo test -p tokio --test rt_basic --features full (11 passed in 4.0s)

11. Conclusions & Key Takeaways

  1. Circular Crate Architectures Demand Whole-Workspace Awareness: In a 10-crate system like Tokio, tools that analyze single crates in isolation fail on dev-dependencies and macro re-exports. code_dependencies mapped 6 circular paths that must be evaluated concurrently.
  2. Standard Library Symbol Resolution Must Handle Sysroots Gracefully: When symbols resolve to core library paths (alloc::boxed::Box), naive local path reads panic. Catching, fixing, and verifying Issue #736 within the same evaluation run demonstrates the importance of testing on real-world dependencies.
  3. Pre-flight In-RAM Overlays Prevent Broken Commits: Validating candidate patches against rust-analyzer in RAM before touching the local working tree catches syntax and type errors in 500 milliseconds without dirtying git working trees.
  4. Zero Local CPU Overhead for Heavy Workloads: Offloading 932-file dead code scans (90s), workspace check passes (20.6s CPU), and Criterion benchmarks (56M iterations) to an idle LAN cluster node allows coding agents to execute heavy verification workloads without bogging down developer workstations.
Cite this article
Citation
Alexander Panasenko (2026-09-29). Six Circular Dependencies in Tokio: What 67 AST Analyzers Found Inside Rust's Async Engine. https://prod.codes/blog/six-circular-dependencies-in-tokio/