Update dependency analysis artifacts
Refreshed static dependency analysis for the G3 codebase: - graph.json: 143 nodes (9 crates, 134 files), 189 edges - No cycles detected (DAG structure confirmed) - Top fan-in: g3-core (43), g3-providers (27), g3-config (16) - Top fan-out: g3-core/src/lib.rs (27), g3-cli/src/lib.rs (12) - 4-layer architecture: Foundation → Core → Services → Application Extraction method: Cargo.toml parsing + regex-based import analysis Limitations documented: internal crate imports, re-exports, conditional compilation Agent: euler
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,27 +2,47 @@
|
||||
|
||||
## Overview
|
||||
|
||||
| Metric | Value |
|
||||
| Metric | Count |
|
||||
|--------|-------|
|
||||
| Total Crates | 10 |
|
||||
| Total Source Files | 139 |
|
||||
| Crate-Level Dependency Edges | 16 |
|
||||
| File-Level Dependency Edges | 72 |
|
||||
| Total nodes | 143 |
|
||||
| Crate nodes | 9 |
|
||||
| File nodes | 134 |
|
||||
| Total edges | 189 |
|
||||
|
||||
## Crate Inventory
|
||||
## Node Distribution
|
||||
|
||||
| Crate | Type | File Count | Path |
|
||||
|-------|------|------------|------|
|
||||
| g3 | binary | 2 | . |
|
||||
| g3-cli | library | 11 | crates/g3-cli |
|
||||
| g3-core | library | 55 | crates/g3-core |
|
||||
| g3-config | library | 3 | crates/g3-config |
|
||||
| g3-providers | library | 9 | crates/g3-providers |
|
||||
| g3-planner | library | 12 | crates/g3-planner |
|
||||
| g3-execution | library | 2 | crates/g3-execution |
|
||||
| g3-computer-control | library | 28 | crates/g3-computer-control |
|
||||
| g3-console | binary+library | 18 | crates/g3-console |
|
||||
| g3-ensembles | library | 5 | crates/g3-ensembles |
|
||||
### Files by Crate
|
||||
|
||||
| Crate | File Count |
|
||||
|-------|------------|
|
||||
| g3-core | 60 |
|
||||
| g3-computer-control | 29 |
|
||||
| g3-cli | 12 |
|
||||
| g3-planner | 12 |
|
||||
| g3-providers | 10 |
|
||||
| g3-ensembles | 5 |
|
||||
| g3 (root) | 2 |
|
||||
| g3-config | 2 |
|
||||
| g3-execution | 2 |
|
||||
|
||||
### Files by Type
|
||||
|
||||
| Type | Count |
|
||||
|------|-------|
|
||||
| module | 72 |
|
||||
| test | 37 |
|
||||
| example | 15 |
|
||||
| lib | 8 |
|
||||
| build | 1 |
|
||||
| main | 1 |
|
||||
|
||||
## Edge Distribution
|
||||
|
||||
| Edge Type | Count | Description |
|
||||
|-----------|-------|-------------|
|
||||
| file_to_crate | 101 | File imports from external crate |
|
||||
| mod_declaration | 71 | Module declaration within crate |
|
||||
| crate_dependency | 17 | Cargo.toml dependency |
|
||||
|
||||
## Crate Dependency Structure
|
||||
|
||||
@@ -39,6 +59,7 @@ g3 (root binary)
|
||||
│ │ ├── g3-providers
|
||||
│ │ ├── g3-core
|
||||
│ │ └── g3-config
|
||||
│ ├── g3-computer-control
|
||||
│ ├── g3-providers
|
||||
│ └── g3-ensembles
|
||||
│ ├── g3-core
|
||||
@@ -46,69 +67,49 @@ g3 (root binary)
|
||||
└── g3-providers
|
||||
```
|
||||
|
||||
## Fan-In Analysis (Crates Depended Upon)
|
||||
## Top Fan-In Nodes (Most Depended Upon)
|
||||
|
||||
| Crate | Fan-In | Dependents |
|
||||
|-------|--------|------------|
|
||||
| g3-config | 5 | g3-cli, g3-core, g3-planner, g3-ensembles |
|
||||
| g3-providers | 4 | g3, g3-cli, g3-core, g3-planner |
|
||||
| g3-core | 3 | g3-cli, g3-planner, g3-ensembles |
|
||||
| g3-cli | 1 | g3 |
|
||||
| g3-planner | 1 | g3-cli |
|
||||
| g3-ensembles | 1 | g3-cli |
|
||||
| g3-execution | 1 | g3-core |
|
||||
| g3-computer-control | 1 | g3-core |
|
||||
| g3-console | 0 | (standalone) |
|
||||
| g3 | 0 | (root) |
|
||||
| Node | Fan-In |
|
||||
|------|--------|
|
||||
| g3-core | 43 |
|
||||
| g3-providers | 27 |
|
||||
| g3-config | 16 |
|
||||
| g3-computer-control | 12 |
|
||||
| g3-planner | 10 |
|
||||
| g3-cli | 5 |
|
||||
| g3-ensembles | 3 |
|
||||
| g3-execution | 2 |
|
||||
|
||||
## Fan-Out Analysis (Crates Depending On Others)
|
||||
## Top Fan-Out Nodes (Most Dependencies)
|
||||
|
||||
| Crate | Fan-Out | Dependencies |
|
||||
|-------|---------|-------------|
|
||||
| g3-cli | 5 | g3-core, g3-config, g3-planner, g3-providers, g3-ensembles |
|
||||
| g3-core | 4 | g3-providers, g3-config, g3-execution, g3-computer-control |
|
||||
| g3-planner | 3 | g3-providers, g3-core, g3-config |
|
||||
| g3-ensembles | 2 | g3-core, g3-config |
|
||||
| g3 | 2 | g3-cli, g3-providers |
|
||||
| g3-config | 0 | (leaf) |
|
||||
| g3-providers | 0 | (leaf) |
|
||||
| g3-execution | 0 | (leaf) |
|
||||
| g3-computer-control | 0 | (leaf) |
|
||||
| g3-console | 0 | (standalone) |
|
||||
| Node | Fan-Out |
|
||||
|------|--------|
|
||||
| ./crates/g3-core/src/lib.rs | 27 |
|
||||
| ./crates/g3-cli/src/lib.rs | 12 |
|
||||
| ./crates/g3-core/src/tools/mod.rs | 8 |
|
||||
| ./crates/g3-planner/src/lib.rs | 8 |
|
||||
| ./crates/g3-providers/src/lib.rs | 6 |
|
||||
| g3-cli | 6 |
|
||||
| ./crates/g3-computer-control/src/lib.rs | 5 |
|
||||
| ./crates/g3-planner/src/llm.rs | 5 |
|
||||
|
||||
## Entrypoints
|
||||
|
||||
| Binary | Entry File |
|
||||
|--------|------------|
|
||||
| g3 | src/main.rs |
|
||||
| g3-console | crates/g3-console/src/main.rs |
|
||||
| File | Type | Description |
|
||||
|------|------|-------------|
|
||||
| ./src/main.rs | main | Root binary entrypoint |
|
||||
| ./crates/g3-cli/src/lib.rs | lib | CLI library root |
|
||||
| ./crates/g3-core/src/lib.rs | lib | Core engine library root |
|
||||
| ./crates/g3-providers/src/lib.rs | lib | LLM providers library root |
|
||||
| ./crates/g3-config/src/lib.rs | lib | Configuration library root |
|
||||
| ./crates/g3-execution/src/lib.rs | lib | Execution library root |
|
||||
| ./crates/g3-computer-control/src/lib.rs | lib | Computer control library root |
|
||||
| ./crates/g3-ensembles/src/lib.rs | lib | Ensembles library root |
|
||||
| ./crates/g3-planner/src/lib.rs | lib | Planner library root |
|
||||
|
||||
## High Fan-In Files (Within Crates)
|
||||
## Extraction Method
|
||||
|
||||
| File | Fan-In | Role |
|
||||
|------|--------|------|
|
||||
| g3-core/src/ui_writer.rs | 10 | UI abstraction trait |
|
||||
| g3-core/src/lib.rs | 8 | Core agent types (Agent, ToolCall, etc.) |
|
||||
| g3-providers/src/lib.rs | 7 | Provider types (Message, MessageRole, etc.) |
|
||||
| g3-config/src/lib.rs | 5 | Configuration (Config) |
|
||||
| g3-core/src/utils.rs | 2 | Utility functions |
|
||||
| g3-core/src/paths.rs | 2 | Path utilities |
|
||||
| g3-core/src/webdriver_session.rs | 2 | WebDriver session management |
|
||||
| g3-computer-control/src/types.rs | 5 | Type definitions |
|
||||
| g3-console/src/models/mod.rs | 5 | Data models |
|
||||
|
||||
## Leaf Crates (No Internal Dependencies)
|
||||
|
||||
- g3-config
|
||||
- g3-providers
|
||||
- g3-execution
|
||||
- g3-computer-control
|
||||
- g3-console
|
||||
|
||||
## Extraction Limitations
|
||||
|
||||
1. **Dynamic imports**: Conditional compilation (`#[cfg(...)]`) may hide platform-specific dependencies
|
||||
2. **Macro-generated imports**: Imports generated by macros are not captured
|
||||
3. **Re-exports**: Transitive re-exports through `pub use` are not fully traced
|
||||
4. **Test dependencies**: Test-only dependencies (dev-dependencies) are included but not distinguished in file-level analysis
|
||||
5. **Build scripts**: build.rs dependencies are not analyzed for import relationships
|
||||
- Crate dependencies: Parsed from `Cargo.toml` files
|
||||
- File-to-crate edges: Extracted from `use g3_*::` statements
|
||||
- Module declarations: Extracted from `mod` and `pub mod` statements
|
||||
- File classification: Based on path patterns and filename conventions
|
||||
|
||||
@@ -1,95 +1,101 @@
|
||||
# Dependency Hotspots
|
||||
# Coupling Hotspots
|
||||
|
||||
## Definition
|
||||
## Identification Method
|
||||
|
||||
Hotspots are code artifacts with disproportionate coupling, measured by:
|
||||
- **Fan-in**: Number of files/crates that depend on this artifact
|
||||
- **Fan-out**: Number of files/crates this artifact depends on
|
||||
- **Cross-group edges**: Dependencies that cross module/crate boundaries
|
||||
Hotspots identified by:
|
||||
1. Fan-in: Number of incoming edges (dependents)
|
||||
2. Fan-out: Number of outgoing edges (dependencies)
|
||||
3. Cross-crate edges: Files with imports from multiple external crates
|
||||
|
||||
## Crate-Level Hotspots
|
||||
|
||||
### High Fan-In Crates
|
||||
### By Fan-In (Most Depended Upon)
|
||||
|
||||
| Crate | Fan-In | Evidence |
|
||||
|-------|--------|----------|
|
||||
| g3-config | 5 | Depended on by: g3-cli, g3-core, g3-planner, g3-ensembles, (tests) |
|
||||
| g3-providers | 4 | Depended on by: g3, g3-cli, g3-core, g3-planner |
|
||||
| g3-core | 3 | Depended on by: g3-cli, g3-planner, g3-ensembles |
|
||||
| Crate | Fan-In | Dependents |
|
||||
|-------|--------|------------|
|
||||
| g3-core | 43 | g3-cli, g3-ensembles, g3-planner + 40 file imports |
|
||||
| g3-providers | 27 | g3-core, g3-planner + 25 file imports |
|
||||
| g3-config | 16 | g3-cli, g3-core, g3-ensembles, g3-planner + 12 file imports |
|
||||
| g3-computer-control | 12 | g3-cli, g3-core + 10 file imports |
|
||||
|
||||
### High Fan-Out Crates
|
||||
### By Fan-Out (Most Dependencies)
|
||||
|
||||
| Crate | Fan-Out | Evidence |
|
||||
|-------|---------|----------|
|
||||
| g3-cli | 5 | Depends on: g3-core, g3-config, g3-planner, g3-providers, g3-ensembles |
|
||||
| g3-core | 4 | Depends on: g3-providers, g3-config, g3-execution, g3-computer-control |
|
||||
| g3-planner | 3 | Depends on: g3-providers, g3-core, g3-config |
|
||||
| Crate | Fan-Out | Dependencies |
|
||||
|-------|---------|-------------|
|
||||
| g3-cli | 6 | g3-core, g3-config, g3-planner, g3-computer-control, g3-providers, g3-ensembles |
|
||||
| g3-core | 4 | g3-providers, g3-config, g3-execution, g3-computer-control |
|
||||
| g3-planner | 3 | g3-providers, g3-core, g3-config |
|
||||
| g3-ensembles | 2 | g3-core, g3-config |
|
||||
|
||||
## File-Level Hotspots
|
||||
|
||||
### High Fan-In Files
|
||||
### By Fan-Out (Files with Most Dependencies)
|
||||
|
||||
| File | Fan-In | Importing Files |
|
||||
|------|--------|----------------|
|
||||
| `g3-core/src/ui_writer.rs` | 10 | lib.rs, tool_dispatch.rs, retry.rs, feedback_extraction.rs, tools/file_ops.rs, tools/shell.rs, tools/misc.rs, tools/todo.rs, tools/webdriver.rs, tools/executor.rs |
|
||||
| `g3-core/src/lib.rs` | 8 | streaming_parser.rs, feedback_extraction.rs, retry.rs, task_result_comprehensive_tests.rs, (external: g3-cli, g3-planner, g3-ensembles) |
|
||||
| `g3-providers/src/lib.rs` | 7 | anthropic.rs, databricks.rs, openai.rs, embedded.rs, (external: g3-core, g3-planner, examples) |
|
||||
| `g3-config/src/lib.rs` | 5 | (external: g3-core, g3-cli, g3-planner, g3-ensembles, tools/executor.rs) |
|
||||
| `g3-computer-control/src/types.rs` | 5 | platform/macos.rs, platform/linux.rs, platform/windows.rs, ocr/mod.rs, ocr/vision.rs, ocr/tesseract.rs |
|
||||
| `g3-console/src/models/mod.rs` | 5 | api/instances.rs, api/control.rs, logs.rs, process/controller.rs, process/detector.rs |
|
||||
|
||||
### High Fan-Out Files
|
||||
|
||||
| File | Fan-Out | Dependencies |
|
||||
| File | Fan-Out | Description |
|
||||
|------|---------|-------------|
|
||||
| `g3-core/src/tools/executor.rs` | 5 | background_process.rs, paths.rs, ui_writer.rs, webdriver_session.rs, g3-config |
|
||||
| `g3-core/src/tool_dispatch.rs` | 4 | tools/executor.rs, tools/mod.rs, ui_writer.rs, ToolCall |
|
||||
| `g3-core/src/retry.rs` | 4 | error_handling.rs, ui_writer.rs, lib.rs (Agent, TaskResult) |
|
||||
| `g3-planner/src/llm.rs` | 5 | g3-config, g3-core/project, g3-core/Agent, g3-core/error_handling, g3-providers, prompts.rs |
|
||||
| `g3-console/src/api/instances.rs` | 3 | logs.rs, models, process/detector.rs |
|
||||
| ./crates/g3-core/src/lib.rs | 27 | Core library root - declares 22 modules + 5 external imports |
|
||||
| ./crates/g3-cli/src/lib.rs | 12 | CLI library root - 5 modules + 7 external imports |
|
||||
| ./crates/g3-core/src/tools/mod.rs | 8 | Tools module - declares 8 submodules |
|
||||
| ./crates/g3-planner/src/lib.rs | 8 | Planner library root - 7 modules + 1 external import |
|
||||
| ./crates/g3-providers/src/lib.rs | 6 | Providers library root - 5 modules + 1 internal |
|
||||
| ./crates/g3-computer-control/src/lib.rs | 5 | Computer control root - 5 modules |
|
||||
| ./crates/g3-planner/src/llm.rs | 5 | LLM integration - 5 external imports |
|
||||
|
||||
## Cross-Boundary Dependencies
|
||||
### Files with Cross-Crate Imports
|
||||
|
||||
### External Crate Imports (Cross-Crate)
|
||||
| File | External Crates Imported |
|
||||
|------|-------------------------|
|
||||
| ./crates/g3-cli/src/lib.rs | g3-config, g3-core |
|
||||
| ./crates/g3-core/src/lib.rs | g3-config, g3-providers |
|
||||
| ./crates/g3-core/src/context_window.rs | g3-providers |
|
||||
| ./crates/g3-core/src/streaming.rs | g3-providers |
|
||||
| ./crates/g3-core/src/tool_definitions.rs | g3-providers |
|
||||
| ./crates/g3-core/src/tools/executor.rs | g3-config |
|
||||
| ./crates/g3-core/src/tools/research.rs | g3-config |
|
||||
| ./crates/g3-core/src/tools/webdriver.rs | g3-computer-control |
|
||||
| ./crates/g3-core/src/webdriver_session.rs | g3-computer-control |
|
||||
| ./crates/g3-planner/src/llm.rs | g3-config, g3-core, g3-providers |
|
||||
| ./crates/g3-planner/src/lib.rs | g3-providers |
|
||||
| ./crates/g3-ensembles/src/flock.rs | g3-config |
|
||||
|
||||
| From Crate | To Crate | Import Count | Key Types |
|
||||
|------------|----------|--------------|----------|
|
||||
| g3-core | g3-providers | 5 | Message, MessageRole, Usage, CacheControl, Tool, CompletionRequest, ProviderRegistry |
|
||||
| g3-core | g3-config | 3 | Config |
|
||||
| g3-core | g3-computer-control | 2 | WebDriverController, ChromeDriver, SafariDriver, WebElement |
|
||||
| g3-cli | g3-core | 3 | Agent, UiWriter, DiscoveryOptions, Project, error_handling |
|
||||
| g3-planner | g3-core | 3 | Agent, Project, error_handling |
|
||||
| g3-planner | g3-providers | 2 | Message, MessageRole, LLMProvider, CompletionRequest |
|
||||
| g3-ensembles | g3-core | 1 | (via g3-config) |
|
||||
## High-Coupling Observations
|
||||
|
||||
## Coupling Metrics Summary
|
||||
### g3-core/src/lib.rs
|
||||
|
||||
| Metric | Value | Threshold | Status |
|
||||
|--------|-------|-----------|--------|
|
||||
| Max crate fan-in | 5 (g3-config) | - | Expected for config |
|
||||
| Max crate fan-out | 5 (g3-cli) | - | Expected for CLI |
|
||||
| Max file fan-in | 10 (ui_writer.rs) | - | Trait abstraction |
|
||||
| Max file fan-out | 5 (executor.rs, llm.rs) | - | Orchestration files |
|
||||
| Cross-crate edges | 16 | - | Moderate |
|
||||
- Fan-out: 27 (highest in codebase)
|
||||
- Declares 22 public modules
|
||||
- Imports from: g3-config, g3-providers
|
||||
- Central hub for all core functionality
|
||||
|
||||
## Observations
|
||||
### g3-providers
|
||||
|
||||
1. **ui_writer.rs** has highest file-level fan-in (10 dependents)
|
||||
- This is a trait definition, high fan-in is expected
|
||||
- Implements dependency inversion pattern
|
||||
- Fan-in: 27 (second highest)
|
||||
- Imported by 25 files across 3 crates
|
||||
- Provides: Message, MessageRole, CompletionRequest, LLMProvider, etc.
|
||||
- Core abstraction layer for LLM communication
|
||||
|
||||
2. **g3-config** has highest crate-level fan-in (5 dependents)
|
||||
- Configuration is appropriately centralized
|
||||
- No code duplication observed
|
||||
### g3-config
|
||||
|
||||
3. **g3-cli** has highest crate-level fan-out (5 dependencies)
|
||||
- Expected for application entry point
|
||||
- Orchestrates all major subsystems
|
||||
- Fan-in: 16
|
||||
- Imported by 12 files across 4 crates
|
||||
- Provides: Config struct
|
||||
- Shared configuration across all layers
|
||||
|
||||
4. **tools/executor.rs** has high fan-out within g3-core
|
||||
- Central tool execution context
|
||||
- Coordinates background processes, paths, webdriver, config
|
||||
## Representative Evidence
|
||||
|
||||
5. **g3-console** is isolated
|
||||
- No dependencies on other workspace crates
|
||||
- Standalone monitoring application
|
||||
### g3-core imports from g3-providers (18 edges)
|
||||
|
||||
```
|
||||
./crates/g3-core/src/lib.rs: use g3_providers::{CacheControl, CompletionRequest, Message, MessageRole, ProviderRegistry};
|
||||
./crates/g3-core/src/context_window.rs: use g3_providers::{Message, MessageRole, Usage};
|
||||
./crates/g3-core/src/streaming.rs: use g3_providers::{CompletionRequest, MessageRole};
|
||||
./crates/g3-core/src/tool_definitions.rs: use g3_providers::Tool;
|
||||
```
|
||||
|
||||
### g3-planner imports from g3-core (5 edges)
|
||||
|
||||
```
|
||||
./crates/g3-planner/src/llm.rs: use g3_core::project::Project;
|
||||
./crates/g3-planner/src/llm.rs: use g3_core::Agent;
|
||||
./crates/g3-planner/src/llm.rs: use g3_core::error_handling::{classify_error, ErrorType};
|
||||
```
|
||||
|
||||
@@ -1,127 +1,106 @@
|
||||
# Observed Layering
|
||||
|
||||
## Layer Structure
|
||||
## Derivation Method
|
||||
|
||||
Based on crate dependencies and file imports, the following layers are observed:
|
||||
Layers derived mechanically from:
|
||||
1. Crate dependency direction in Cargo.toml
|
||||
2. Path-based grouping within crates
|
||||
3. Import directionality between files
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ LAYER 5: Binaries │
|
||||
│ │
|
||||
│ g3 (src/main.rs) g3-console (src/main.rs) │
|
||||
│ │ │ │
|
||||
└─────────┼───────────────────────────┼───────────────────────┘
|
||||
│ │
|
||||
▼ ▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ LAYER 4: Application │
|
||||
│ │
|
||||
│ g3-cli g3-console (lib) │
|
||||
│ ├── Interactive CLI ├── Web API │
|
||||
│ ├── TUI rendering ├── Process management │
|
||||
│ └── Session management └── Log parsing │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ LAYER 3: Orchestration │
|
||||
│ │
|
||||
│ g3-planner g3-ensembles │
|
||||
│ ├── Planning workflow ├── Flock mode │
|
||||
│ ├── Git integration └── Multi-agent status │
|
||||
│ └── LLM coordination │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ LAYER 2: Core │
|
||||
│ │
|
||||
│ g3-core │
|
||||
│ ├── Agent engine (lib.rs) │
|
||||
│ ├── Context window management │
|
||||
│ ├── Tool dispatch & execution │
|
||||
│ ├── Streaming parser │
|
||||
│ ├── Error handling & retry │
|
||||
│ └── Code search (tree-sitter) │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ LAYER 1: Foundation │
|
||||
│ │
|
||||
│ g3-providers g3-config g3-execution │
|
||||
│ ├── Anthropic ├── TOML └── Coverage tools │
|
||||
│ ├── Databricks │ parsing │
|
||||
│ ├── OpenAI └── Settings g3-computer-control │
|
||||
│ ├── Embedded ├── Platform (macOS/ │
|
||||
│ └── OAuth │ Linux/Windows) │
|
||||
│ ├── OCR │
|
||||
│ ├── WebDriver │
|
||||
│ └── MacAX │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
## Crate Layers
|
||||
|
||||
## Layer Dependency Rules
|
||||
### Layer 0: Foundation (No internal dependencies)
|
||||
|
||||
| From Layer | May Depend On |
|
||||
|------------|---------------|
|
||||
| 5 (Binaries) | 4, 1 |
|
||||
| 4 (Application) | 3, 2, 1 |
|
||||
| 3 (Orchestration) | 2, 1 |
|
||||
| 2 (Core) | 1 |
|
||||
| 1 (Foundation) | (none - leaf) |
|
||||
| Crate | Purpose (from Cargo.toml description) |
|
||||
|-------|---------------------------------------|
|
||||
| g3-config | Configuration management |
|
||||
| g3-execution | Code execution engine |
|
||||
| g3-providers | LLM provider abstractions |
|
||||
| g3-computer-control | Computer control (no description) |
|
||||
|
||||
## Observed Violations
|
||||
### Layer 1: Core Services
|
||||
|
||||
| Crate | Dependencies |
|
||||
|-------|-------------|
|
||||
| g3-core | g3-providers, g3-config, g3-execution, g3-computer-control |
|
||||
|
||||
### Layer 2: Higher-Level Services
|
||||
|
||||
| Crate | Dependencies |
|
||||
|-------|-------------|
|
||||
| g3-ensembles | g3-core, g3-config |
|
||||
| g3-planner | g3-providers, g3-core, g3-config |
|
||||
|
||||
### Layer 3: Application
|
||||
|
||||
| Crate | Dependencies |
|
||||
|-------|-------------|
|
||||
| g3-cli | g3-core, g3-config, g3-planner, g3-computer-control, g3-providers, g3-ensembles |
|
||||
| g3 (root) | g3-cli, g3-providers |
|
||||
|
||||
## Module Groupings Within Crates
|
||||
|
||||
### g3-core (60 files)
|
||||
|
||||
| Group | Files | Purpose |
|
||||
|-------|-------|--------|
|
||||
| tools/ | 9 | Tool implementations (file_ops, shell, webdriver, etc.) |
|
||||
| code_search/ | 2 | Tree-sitter based code search |
|
||||
| root modules | 22 | Core functionality (agent, context, streaming, etc.) |
|
||||
| tests/ | 27 | Integration and unit tests |
|
||||
|
||||
### g3-computer-control (29 files)
|
||||
|
||||
| Group | Files | Purpose |
|
||||
|-------|-------|--------|
|
||||
| platform/ | 5 | OS-specific implementations (macos, linux, windows) |
|
||||
| webdriver/ | 4 | Browser automation (safari, chrome) |
|
||||
| ocr/ | 3 | Text recognition (tesseract, vision) |
|
||||
| macax/ | 3 | macOS accessibility |
|
||||
| examples/ | 12 | Usage examples |
|
||||
|
||||
### g3-providers (10 files)
|
||||
|
||||
| Group | Files | Purpose |
|
||||
|-------|-------|--------|
|
||||
| providers | 5 | LLM implementations (anthropic, databricks, openai, embedded) |
|
||||
| support | 3 | OAuth, streaming utilities |
|
||||
| tests/ | 3 | Provider tests |
|
||||
|
||||
### g3-planner (12 files)
|
||||
|
||||
| Group | Files | Purpose |
|
||||
|-------|-------|--------|
|
||||
| core | 7 | Planner logic (planner, state, llm, git, history) |
|
||||
| tests/ | 4 | Planner tests |
|
||||
|
||||
## Observed Directionality
|
||||
|
||||
### Cross-Crate Import Patterns
|
||||
|
||||
| From Crate | To Crate | Edge Count |
|
||||
|------------|----------|------------|
|
||||
| g3-cli | g3-core | 5 |
|
||||
| g3-cli | g3-config | 2 |
|
||||
| g3-cli | g3-computer-control | 1 |
|
||||
| g3-core | g3-providers | 18 |
|
||||
| g3-core | g3-config | 6 |
|
||||
| g3-core | g3-computer-control | 2 |
|
||||
| g3-planner | g3-providers | 3 |
|
||||
| g3-planner | g3-core | 5 |
|
||||
| g3-planner | g3-config | 1 |
|
||||
| g3-ensembles | g3-core | 1 |
|
||||
| g3-ensembles | g3-config | 1 |
|
||||
|
||||
### Layer Violations
|
||||
|
||||
**None detected.**
|
||||
|
||||
All observed dependencies follow the layering rules:
|
||||
- Higher layers depend only on lower layers
|
||||
- No skip-level violations that bypass intermediate layers inappropriately
|
||||
- No upward dependencies
|
||||
All observed imports follow the declared crate dependency direction.
|
||||
No file imports from a crate that is not declared as a dependency.
|
||||
|
||||
## Cross-Cutting Concerns
|
||||
## Uncertainty
|
||||
|
||||
### g3-config
|
||||
Used by: g3-cli, g3-core, g3-planner, g3-ensembles
|
||||
- Provides `Config` struct across all layers
|
||||
- Appropriate as foundation-level shared configuration
|
||||
|
||||
### g3-providers
|
||||
Used by: g3, g3-cli, g3-core, g3-planner
|
||||
- Provides `Message`, `MessageRole`, `LLMProvider` types
|
||||
- Core abstraction for LLM communication
|
||||
- Appropriate as foundation-level abstraction
|
||||
|
||||
### UiWriter trait (g3-core/src/ui_writer.rs)
|
||||
Used by: 10 files within g3-core, implemented by g3-cli
|
||||
- Abstraction for output rendering
|
||||
- Defined in core, implemented in application layer
|
||||
- Follows dependency inversion principle
|
||||
|
||||
## Module Groupings by Path Convention
|
||||
|
||||
| Path Pattern | Purpose | Crates |
|
||||
|--------------|---------|--------|
|
||||
| `src/tools/*` | Tool implementations | g3-core |
|
||||
| `src/api/*` | HTTP API handlers | g3-console |
|
||||
| `src/models/*` | Data structures | g3-console |
|
||||
| `src/process/*` | Process management | g3-console |
|
||||
| `src/platform/*` | OS-specific code | g3-computer-control |
|
||||
| `src/ocr/*` | OCR implementations | g3-computer-control |
|
||||
| `src/webdriver/*` | Browser automation | g3-computer-control |
|
||||
| `src/macax/*` | macOS accessibility | g3-computer-control |
|
||||
| `src/code_search/*` | Tree-sitter search | g3-core |
|
||||
|
||||
## Confidence Assessment
|
||||
|
||||
| Aspect | Confidence | Notes |
|
||||
|--------|------------|-------|
|
||||
| Crate-level layering | High | Derived from Cargo.toml |
|
||||
| File-level layering | Medium | Based on import analysis |
|
||||
| Violation detection | Medium | May miss dynamic/conditional deps |
|
||||
| Module groupings | High | Based on path conventions |
|
||||
- Internal `use crate::` imports not fully resolved to specific files
|
||||
- Some module relationships inferred from `mod` declarations only
|
||||
- Test files may have additional dev-dependencies not tracked
|
||||
|
||||
@@ -1,121 +1,103 @@
|
||||
# Analysis Limitations
|
||||
|
||||
## Extraction Method
|
||||
## What Was Observed
|
||||
|
||||
This analysis used static parsing of:
|
||||
1. `Cargo.toml` files for crate-level dependencies
|
||||
2. `use` statements in `.rs` files for file-level imports
|
||||
3. `mod` declarations for module structure
|
||||
| Source | Method | Confidence |
|
||||
|--------|--------|------------|
|
||||
| Crate dependencies | Parsed from Cargo.toml `[dependencies]` sections | High |
|
||||
| External crate imports | Regex match on `use g3_*::` statements | High |
|
||||
| Module declarations | Regex match on `mod` and `pub mod` statements | High |
|
||||
| File classification | Path pattern matching (tests/, examples/, lib.rs, etc.) | High |
|
||||
|
||||
## What Could Not Be Observed
|
||||
## What Was Not Observed
|
||||
|
||||
### 1. Conditional Compilation
|
||||
### 1. Internal Module Imports
|
||||
|
||||
Dependencies gated by `#[cfg(...)]` attributes may be:
|
||||
- Platform-specific (e.g., `#[cfg(target_os = "macos")]`)
|
||||
- Feature-gated (e.g., `#[cfg(feature = "..." )]`)
|
||||
- Test-only (e.g., `#[cfg(test)]`)
|
||||
`use crate::` statements were detected but not resolved to specific target files.
|
||||
|
||||
**Impact**: Some edges may only exist on specific platforms or with specific features enabled.
|
||||
**Impact**: File-to-file edges within a crate are incomplete. Only `mod` declaration edges are captured.
|
||||
|
||||
**Affected crates**:
|
||||
- `g3-computer-control`: Has platform-specific modules (macos.rs, linux.rs, windows.rs)
|
||||
- `g3-providers`: May have feature-gated provider implementations
|
||||
**Example not captured**:
|
||||
```rust
|
||||
// In ./crates/g3-core/src/streaming.rs
|
||||
use crate::context_window::ContextWindow; // Edge to context_window.rs not in graph
|
||||
```
|
||||
|
||||
### 2. Macro-Generated Code
|
||||
### 2. Re-exports
|
||||
|
||||
Imports generated by procedural macros are not captured:
|
||||
- `#[derive(...)]` macros
|
||||
- `async_trait` macro expansions
|
||||
- Custom derive macros
|
||||
`pub use` statements that re-export items from submodules are not tracked as separate edges.
|
||||
|
||||
**Impact**: Some implicit dependencies on trait implementations may be missed.
|
||||
**Impact**: Transitive dependencies through re-exports are not visible.
|
||||
|
||||
### 3. Re-exports
|
||||
**Example**:
|
||||
```rust
|
||||
// In ./crates/g3-core/src/lib.rs
|
||||
pub use context_window::{ContextWindow, ThinScope}; // Re-export not tracked
|
||||
```
|
||||
|
||||
Transitive re-exports via `pub use` are partially traced:
|
||||
- Direct re-exports in `lib.rs` are captured
|
||||
- Nested re-exports may not be fully resolved
|
||||
### 3. Conditional Compilation
|
||||
|
||||
**Example**: `g3-providers/src/lib.rs` likely re-exports types from submodules.
|
||||
`#[cfg(...)]` attributes on imports are not parsed. All imports are treated as unconditional.
|
||||
|
||||
### 4. Dynamic Dispatch
|
||||
**Impact**: Platform-specific dependencies (e.g., macOS-only code in g3-computer-control) appear as universal.
|
||||
|
||||
Trait object usage (`dyn Trait`) creates runtime dependencies not visible in imports:
|
||||
- `Box<dyn LLMProvider>`
|
||||
- `Arc<dyn UiWriter>`
|
||||
### 4. Macro-Generated Imports
|
||||
|
||||
**Impact**: Actual runtime coupling may be higher than static analysis shows.
|
||||
Imports generated by macros (e.g., `derive` macros, `include!`) are not detected.
|
||||
|
||||
### 5. Build Script Dependencies
|
||||
**Impact**: Some edges may be missing if macros generate `use` statements.
|
||||
|
||||
`build.rs` files were identified but not analyzed for:
|
||||
- Generated code dependencies
|
||||
- Native library linkage
|
||||
- Environment-based configuration
|
||||
### 5. Dev-Dependencies
|
||||
|
||||
**Affected**: `g3-computer-control/build.rs`
|
||||
Only `[dependencies]` sections were parsed. `[dev-dependencies]` were not included in crate-level edges.
|
||||
|
||||
### 6. External Crate Dependencies
|
||||
**Impact**: Test-only dependencies (e.g., `tempfile`, `serial_test`) are not in the graph.
|
||||
|
||||
Only workspace-internal dependencies were analyzed. External crates from crates.io are listed in Cargo.toml but not traced at file level:
|
||||
- `tokio`, `reqwest`, `serde`, etc.
|
||||
- `tree-sitter-*` language grammars
|
||||
- Platform-specific crates (`core-graphics`, `x11`, `windows`)
|
||||
### 6. Build Dependencies
|
||||
|
||||
### 7. Test File Dependencies
|
||||
`[build-dependencies]` were not parsed.
|
||||
|
||||
Test files in `tests/` directories were included but:
|
||||
- May have different dependency patterns than production code
|
||||
- Use `dev-dependencies` not distinguished from regular dependencies
|
||||
- Integration tests may have broader access than unit tests
|
||||
**Impact**: Build script dependencies are not represented.
|
||||
|
||||
### 8. Example File Dependencies
|
||||
### 7. Feature-Gated Dependencies
|
||||
|
||||
Files in `examples/` directories:
|
||||
- Included in file counts
|
||||
- May demonstrate usage patterns not representative of core dependencies
|
||||
- Often have simplified or demonstration-only imports
|
||||
Cargo features that enable optional dependencies are not tracked.
|
||||
|
||||
**Impact**: Optional dependencies appear the same as required ones.
|
||||
|
||||
### 8. Workspace Dependencies
|
||||
|
||||
`[workspace.dependencies]` are resolved but the inheritance relationship is not tracked.
|
||||
|
||||
**Impact**: Cannot distinguish workspace-inherited vs crate-specific dependency versions.
|
||||
|
||||
## What Was Inferred
|
||||
|
||||
### 1. Module-to-File Mapping
|
||||
| Inference | Basis | Confidence |
|
||||
|-----------|-------|------------|
|
||||
| File type classification | Filename and path patterns | Medium-High |
|
||||
| Module file resolution | Rust module naming conventions (mod.rs, name.rs) | High |
|
||||
| Crate membership | File path prefix matching | High |
|
||||
|
||||
`mod foo;` declarations were mapped to `foo.rs` or `foo/mod.rs` by convention.
|
||||
## Potential Invalidation Conditions
|
||||
|
||||
**Confidence**: High (Rust standard convention)
|
||||
1. **Non-standard module structure**: If any crate uses `#[path = "..."]` attributes to override module paths, those edges will be incorrect.
|
||||
|
||||
### 2. Crate Root Identification
|
||||
2. **Generated code**: If any `.rs` files are generated at build time (not checked into git), they are not included.
|
||||
|
||||
`lib.rs` was assumed to be the crate root for libraries.
|
||||
`main.rs` was assumed to be the binary entry point.
|
||||
3. **Symlinks**: Symbolic links in the source tree are not followed or detected.
|
||||
|
||||
**Confidence**: High (Cargo convention)
|
||||
4. **External workspace members**: Only crates in `./crates/` and root `./src/` were analyzed. External workspace members would be missed.
|
||||
|
||||
### 3. Import Target Resolution
|
||||
## Verification Commands
|
||||
|
||||
`use crate::foo::Bar` was resolved to the file containing module `foo`.
|
||||
To verify crate-level dependencies match Cargo's resolution:
|
||||
```bash
|
||||
cargo tree --prefix none --no-dedupe | grep '^g3-'
|
||||
```
|
||||
|
||||
**Confidence**: Medium (may miss re-exports)
|
||||
|
||||
### 4. Cross-Crate Import Resolution
|
||||
|
||||
`use g3_core::Agent` was mapped to `g3-core/src/lib.rs`.
|
||||
|
||||
**Confidence**: Medium (actual definition may be in submodule)
|
||||
|
||||
## What May Invalidate Conclusions
|
||||
|
||||
1. **Significant refactoring** since analysis date
|
||||
2. **Feature flags** enabling/disabling major functionality
|
||||
3. **Platform-specific builds** with different dependency graphs
|
||||
4. **Workspace configuration changes** in Cargo.toml
|
||||
5. **New crates added** to workspace
|
||||
|
||||
## Recommendations for Improved Analysis
|
||||
|
||||
1. Use `cargo metadata` for authoritative crate dependency graph
|
||||
2. Use `cargo tree` for transitive dependency analysis
|
||||
3. Use `rust-analyzer` for precise import resolution
|
||||
4. Run analysis on each target platform separately
|
||||
5. Analyze with all feature combinations
|
||||
To find imports not captured by this analysis:
|
||||
```bash
|
||||
rg 'use crate::' --type rust | wc -l # Internal imports (not fully resolved)
|
||||
rg 'pub use' --type rust | wc -l # Re-exports (not tracked)
|
||||
```
|
||||
|
||||
@@ -1,169 +1,40 @@
|
||||
# Strongly Connected Components Analysis
|
||||
|
||||
## Crate-Level SCCs
|
||||
|
||||
**Result: No cycles detected**
|
||||
|
||||
All 10 crates form a directed acyclic graph (DAG). Each crate is its own trivial SCC of size 1.
|
||||
|
||||
### Topological Order (Bottom to Top)
|
||||
|
||||
1. **Leaf crates** (no internal dependencies):
|
||||
- g3-config
|
||||
- g3-providers
|
||||
- g3-execution
|
||||
- g3-computer-control
|
||||
|
||||
2. **Mid-level crates**:
|
||||
- g3-core (depends on: g3-providers, g3-config, g3-execution, g3-computer-control)
|
||||
- g3-console (standalone, no workspace dependencies)
|
||||
|
||||
3. **Higher-level crates**:
|
||||
- g3-planner (depends on: g3-providers, g3-core, g3-config)
|
||||
- g3-ensembles (depends on: g3-core, g3-config)
|
||||
|
||||
4. **Application layer**:
|
||||
- g3-cli (depends on: g3-core, g3-config, g3-planner, g3-providers, g3-ensembles)
|
||||
|
||||
5. **Root binary**:
|
||||
- g3 (depends on: g3-cli, g3-providers)
|
||||
|
||||
## File-Level SCCs Within Crates
|
||||
|
||||
### g3-core
|
||||
|
||||
No non-trivial SCCs detected. Internal module dependencies are acyclic:
|
||||
|
||||
```
|
||||
lib.rs
|
||||
├── ui_writer.rs
|
||||
├── context_window.rs
|
||||
│ └── paths.rs
|
||||
├── streaming_parser.rs
|
||||
├── tool_dispatch.rs
|
||||
│ └── tools/mod.rs
|
||||
│ ├── executor.rs
|
||||
│ │ ├── background_process.rs
|
||||
│ │ ├── paths.rs
|
||||
│ │ └── webdriver_session.rs
|
||||
│ ├── file_ops.rs → utils.rs, ui_writer.rs
|
||||
│ ├── shell.rs → utils.rs, ui_writer.rs
|
||||
│ ├── misc.rs → ui_writer.rs
|
||||
│ ├── todo.rs → ui_writer.rs
|
||||
│ └── webdriver.rs → webdriver_session.rs, ui_writer.rs
|
||||
├── error_handling.rs
|
||||
├── retry.rs → error_handling.rs, ui_writer.rs
|
||||
├── feedback_extraction.rs → ui_writer.rs
|
||||
├── task_result.rs → context_window.rs
|
||||
└── provider_config.rs
|
||||
```
|
||||
|
||||
### g3-providers
|
||||
|
||||
No non-trivial SCCs. Provider implementations depend on lib.rs types:
|
||||
|
||||
```
|
||||
lib.rs (types: Message, MessageRole, LLMProvider, etc.)
|
||||
├── anthropic.rs
|
||||
├── databricks.rs
|
||||
├── openai.rs
|
||||
├── embedded.rs
|
||||
└── oauth.rs
|
||||
```
|
||||
|
||||
### g3-planner
|
||||
|
||||
No non-trivial SCCs:
|
||||
|
||||
```
|
||||
lib.rs
|
||||
├── planner.rs
|
||||
│ ├── git.rs
|
||||
│ ├── history.rs
|
||||
│ ├── llm.rs → prompts.rs
|
||||
│ └── state.rs
|
||||
├── code_explore.rs
|
||||
└── prompts.rs
|
||||
```
|
||||
|
||||
### g3-computer-control
|
||||
|
||||
No non-trivial SCCs:
|
||||
|
||||
```
|
||||
lib.rs
|
||||
├── types.rs
|
||||
├── platform/mod.rs
|
||||
│ ├── macos.rs → ocr/mod.rs, types.rs
|
||||
│ ├── linux.rs → types.rs
|
||||
│ └── windows.rs → types.rs
|
||||
├── ocr/mod.rs → types.rs
|
||||
│ ├── vision.rs → types.rs
|
||||
│ └── tesseract.rs → types.rs
|
||||
├── webdriver/mod.rs
|
||||
│ ├── safari.rs
|
||||
│ └── chrome.rs
|
||||
└── macax/mod.rs
|
||||
└── controller.rs
|
||||
```
|
||||
|
||||
### g3-console
|
||||
|
||||
No non-trivial SCCs:
|
||||
|
||||
```
|
||||
lib.rs
|
||||
├── models/mod.rs
|
||||
│ ├── instance.rs
|
||||
│ └── message.rs
|
||||
├── api/mod.rs
|
||||
│ ├── instances.rs → logs.rs, models, process/detector.rs
|
||||
│ ├── control.rs → models, process/controller.rs
|
||||
│ ├── logs.rs → logs.rs, process/detector.rs
|
||||
│ └── state.rs → launch.rs
|
||||
├── process/mod.rs
|
||||
│ ├── controller.rs → models
|
||||
│ └── detector.rs → models
|
||||
├── logs.rs → models
|
||||
└── launch.rs
|
||||
```
|
||||
|
||||
### g3-ensembles
|
||||
|
||||
No non-trivial SCCs:
|
||||
|
||||
```
|
||||
lib.rs
|
||||
├── flock.rs → status.rs
|
||||
└── status.rs
|
||||
```
|
||||
|
||||
### g3-cli
|
||||
|
||||
No non-trivial SCCs:
|
||||
|
||||
```
|
||||
lib.rs
|
||||
├── filter_json.rs
|
||||
├── ui_writer_impl.rs → filter_json.rs
|
||||
├── machine_ui_writer.rs
|
||||
├── retro_tui.rs → theme.rs
|
||||
├── theme.rs
|
||||
├── tui.rs
|
||||
└── simple_output.rs
|
||||
```
|
||||
# Strongly Connected Components (Cycles)
|
||||
|
||||
## Summary
|
||||
|
||||
| Scope | Non-Trivial SCCs | Largest SCC Size |
|
||||
|-------|------------------|------------------|
|
||||
| Crate-level | 0 | 1 (all trivial) |
|
||||
| File-level (g3-core) | 0 | 1 |
|
||||
| File-level (g3-providers) | 0 | 1 |
|
||||
| File-level (g3-planner) | 0 | 1 |
|
||||
| File-level (g3-computer-control) | 0 | 1 |
|
||||
| File-level (g3-console) | 0 | 1 |
|
||||
| File-level (g3-ensembles) | 0 | 1 |
|
||||
| File-level (g3-cli) | 0 | 1 |
|
||||
**No non-trivial strongly connected components detected.**
|
||||
|
||||
The codebase exhibits clean layered architecture with no circular dependencies.
|
||||
The dependency graph is acyclic at both the crate level and the file level.
|
||||
|
||||
## Analysis Details
|
||||
|
||||
- Algorithm: Tarjan's SCC algorithm
|
||||
- Scope: All 143 nodes (9 crates + 134 files)
|
||||
- Result: 0 cycles with size > 1
|
||||
|
||||
## Crate-Level Verification
|
||||
|
||||
The crate dependency graph forms a directed acyclic graph (DAG):
|
||||
|
||||
```
|
||||
Leaf crates (no dependencies on other g3-* crates):
|
||||
- g3-providers
|
||||
- g3-config
|
||||
- g3-execution
|
||||
- g3-computer-control
|
||||
|
||||
Intermediate crates:
|
||||
- g3-core → depends on: g3-providers, g3-config, g3-execution, g3-computer-control
|
||||
- g3-ensembles → depends on: g3-core, g3-config
|
||||
- g3-planner → depends on: g3-providers, g3-core, g3-config
|
||||
|
||||
Top-level crates:
|
||||
- g3-cli → depends on: g3-core, g3-config, g3-planner, g3-computer-control, g3-providers, g3-ensembles
|
||||
- g3 (root) → depends on: g3-cli, g3-providers
|
||||
```
|
||||
|
||||
## Implications
|
||||
|
||||
- No circular dependencies exist between crates
|
||||
- Build order is deterministic
|
||||
- Crates can be compiled in topological order
|
||||
|
||||
Reference in New Issue
Block a user