Update dependency analysis artifacts

Generated comprehensive static dependency analysis for g3 workspace:

- graph.json: 108 nodes (9 crates, 99 files), 186 edges
- graph.summary.md: Overview with metrics, entrypoints, fan-in/fan-out rankings
- sccs.md: No cycles detected (DAG structure confirmed)
- layers.observed.md: 4-layer crate hierarchy identified
- hotspots.md: ui_writer.rs (15 fan-in), agent_mode.rs (13 fan-out) as key nodes
- limitations.md: Documents extraction methodology and caveats

Updated AGENTS.md with artifact documentation table.

Agent: euler
This commit is contained in:
Dhanji R. Prasanna
2026-01-29 11:46:39 +11:00
parent cba7d31996
commit 853237e62e
7 changed files with 2234 additions and 2146 deletions

View File

@@ -1,103 +1,67 @@
# Analysis Limitations
## Extraction Method
## What Was Observed
Dependencies extracted via:
1. Cargo.toml parsing for crate-level dependencies
2. Regex-based `use` and `mod` statement extraction from source files
| Category | Method | Coverage |
|----------|--------|----------|
| Crate dependencies | Cargo.toml parsing | Complete |
| Module structure | `mod` declarations in lib.rs/main.rs | Complete |
| File imports | `use g3_*` and `use crate::` patterns | Partial |
| Submodule structure | mod.rs file inspection | Complete |
## Known Limitations
## What Could Not Be Observed
### 1. Conditional Compilation Not Evaluated
### 1. Implicit Dependencies
```rust
#[cfg(target_os = "macos")]
use core_graphics::window::*;
```
- **Trait implementations**: A file implementing a trait from another module creates a dependency not captured by `use` statements
- **Type aliases**: Types re-exported through `pub use` chains
- **Derive macros**: Dependencies introduced by `#[derive(...)]`
Platform-specific imports in `g3-computer-control` are included unconditionally. The actual dependency graph varies by target platform.
### 2. Dynamic Patterns
**Affected files:**
- `crates/g3-computer-control/src/platform/macos.rs`
- `crates/g3-computer-control/src/platform/linux.rs`
- `crates/g3-computer-control/src/platform/windows.rs`
- **Trait objects**: `dyn Trait` usage creates runtime dependencies
- **Generic bounds**: `T: SomeTrait` constraints
- **Associated types**: Dependencies through associated type resolution
### 2. Macro-Generated Imports Not Detected
### 3. Conditional Compilation
Imports generated by procedural macros (e.g., `#[derive(...)]`, `#[async_trait]`) are not captured. These may introduce implicit dependencies.
- **Platform-specific code**: `#[cfg(target_os = "...")]` blocks not evaluated
- **Feature flags**: `#[cfg(feature = "...")]` dependencies not traced
- **Test-only code**: `#[cfg(test)]` modules excluded
**Common macros in codebase:**
- `serde::Serialize`, `serde::Deserialize`
- `async_trait::async_trait`
- `clap::Parser`
### 4. Build System
### 3. Re-Exports Not Fully Traced
- **build.rs**: Build script dependencies not analyzed
- **Procedural macros**: Macro crate dependencies not traced
- **Workspace-level features**: Feature unification effects not modeled
```rust
pub use some_module::SomeType;
```
### 5. Excluded Files
Re-exports create transitive dependencies that are not fully traced. A file importing `SomeType` from a re-exporting module has an indirect dependency on the original module.
| Category | Count | Reason |
|----------|-------|--------|
| Test files (`/tests/`) | ~40 | Out of scope |
| Example files (`/examples/`) | ~10 | Out of scope |
| Worktree copies | ~100 | Duplicates |
### 4. Glob Imports Partially Resolved
## What Was Inferred
```rust
use crate::types::*;
```
Glob imports are recorded but individual items are not enumerated. The actual coupling may be higher or lower than represented.
### 5. Test Code Excluded
Files matching these patterns are excluded:
- `*_test.rs`
- `tests/*.rs`
- `mod tests { ... }` blocks
Test dependencies are not represented in the graph.
### 6. Build Scripts Not Analyzed
`build.rs` files are not included. Build-time dependencies (e.g., code generation) are not captured.
**Affected:**
- `crates/g3-computer-control/build.rs`
### 7. External Crate Dependencies Not Graphed
Only workspace-internal dependencies are represented. External crates (tokio, serde, etc.) are not included in the graph.
### 8. Inline Module Definitions
```rust
mod foo {
// inline definition
}
```
Inline module definitions without corresponding files are detected but may not resolve to file edges.
### 9. Path Aliases Not Resolved
```rust
use crate::foo as bar;
```
Aliased imports are recorded with original path, but alias usage elsewhere is not correlated.
| Inference | Basis | Confidence |
|-----------|-------|------------|
| Layer assignment | Topological sort of crate deps | High |
| Fan-in/fan-out metrics | Edge counting | High |
| Module-to-file mapping | Naming convention (mod.rs, *.rs) | High |
| Entrypoints | lib.rs/main.rs presence | High |
## What May Invalidate Conclusions
1. **Feature flags**: Cargo features may enable/disable entire modules
2. **Workspace changes**: Adding/removing crates changes the graph structure
3. **Refactoring**: Moving code between modules changes edges without changing functionality
4. **Dynamic dispatch**: Trait objects create runtime dependencies not visible statically
1. **Hidden re-exports**: If `g3-core/lib.rs` re-exports types from submodules, actual coupling may be higher
2. **Macro-generated code**: Macros like `#[derive(Serialize)]` add implicit serde dependency
3. **Runtime plugin loading**: If any crate loads code dynamically, static analysis misses it
4. **Workspace member changes**: Adding/removing crates from workspace invalidates crate-level graph
## Confidence Assessment
## Recommendations for Improved Analysis
| Aspect | Confidence |
|--------|------------|
| Crate-level dependencies | High (from Cargo.toml) |
| Module tree structure | High (from mod declarations) |
| Cross-crate imports | Medium (regex-based) |
| Intra-module coupling | Low (not analyzed) |
| Runtime dependencies | Not captured |
1. Use `cargo metadata` for authoritative crate graph
2. Use `cargo tree` for transitive dependency analysis
3. Use `rust-analyzer` for semantic import resolution
4. Parse AST for type references beyond `use` statements