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:
15
AGENTS.md
15
AGENTS.md
@@ -67,3 +67,18 @@ These areas have subtle bugs if modified incorrectly:
|
|||||||
3. **"Tool results are always small"** - File reads can return megabytes
|
3. **"Tool results are always small"** - File reads can return megabytes
|
||||||
4. **"Sessions persist across runs"** - Sessions are ephemeral by default
|
4. **"Sessions persist across runs"** - Sessions are ephemeral by default
|
||||||
5. **"All platforms are equal"** - macOS has more features (Vision, Accessibility)
|
5. **"All platforms are equal"** - macOS has more features (Vision, Accessibility)
|
||||||
|
|
||||||
|
## Dependency Analysis Artifacts
|
||||||
|
|
||||||
|
The `analysis/deps/` directory contains static analysis artifacts generated by the euler agent:
|
||||||
|
|
||||||
|
| File | Purpose |
|
||||||
|
|------|--------|
|
||||||
|
| `graph.json` | Canonical dependency graph with nodes (crates, files) and edges (imports) |
|
||||||
|
| `graph.summary.md` | One-page overview with metrics, entrypoints, and top fan-in/fan-out nodes |
|
||||||
|
| `sccs.md` | Strongly connected components (dependency cycles) analysis |
|
||||||
|
| `layers.observed.md` | Observed layering structure derived from dependency direction |
|
||||||
|
| `hotspots.md` | Files with disproportionate coupling (high fan-in or fan-out) |
|
||||||
|
| `limitations.md` | What could not be observed and what may invalidate conclusions |
|
||||||
|
|
||||||
|
These artifacts are useful for understanding coupling, planning refactors, and identifying architectural boundaries.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -2,92 +2,85 @@
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
| Metric | Count |
|
| Metric | Value |
|
||||||
|--------|-------|
|
|--------|-------|
|
||||||
| Workspace crates | 10 |
|
| Total nodes | 108 |
|
||||||
| Crate-level edges | 17 |
|
| Total edges | 186 |
|
||||||
| Source files (non-test) | 95 |
|
| Crate nodes | 9 |
|
||||||
| File-level edges | 123 |
|
| File nodes | 99 |
|
||||||
| Cross-crate imports | 43 |
|
| Crate-level edges | 14 |
|
||||||
| Strongly connected components | 0 |
|
| File-level edges | 172 |
|
||||||
|
|
||||||
## Crate-Level Structure
|
## Crate Structure
|
||||||
|
|
||||||
### Crates by Type
|
| Crate | Path | Direct Dependencies |
|
||||||
|
|-------|------|---------------------|
|
||||||
| Crate | Type | Files |
|
| g3 | `.` | g3-cli, g3-providers |
|
||||||
|-------|------|-------|
|
| g3-cli | `crates/g3-cli` | g3-core, g3-config, g3-planner, g3-computer-control, g3-providers |
|
||||||
| g3 | bin (root) | 1 |
|
| g3-core | `crates/g3-core` | g3-providers, g3-config, g3-execution, g3-computer-control |
|
||||||
| g3-cli | lib | 16 |
|
| g3-providers | `crates/g3-providers` | (none) |
|
||||||
| g3-core | lib | 38 |
|
| g3-config | `crates/g3-config` | (none) |
|
||||||
| g3-providers | lib | 7 |
|
| g3-execution | `crates/g3-execution` | (none) |
|
||||||
| g3-config | lib | 2 |
|
| g3-planner | `crates/g3-planner` | g3-providers, g3-core, g3-config |
|
||||||
| g3-execution | lib | 1 |
|
| g3-computer-control | `crates/g3-computer-control` | (none) |
|
||||||
| g3-computer-control | lib | 16 |
|
| studio | `crates/studio` | (none) |
|
||||||
| g3-planner | lib | 8 |
|
|
||||||
| g3-ensembles | lib | 4 |
|
|
||||||
| studio | bin | 3 |
|
|
||||||
|
|
||||||
### Fan-In (Most Depended Upon)
|
|
||||||
|
|
||||||
| Crate | Dependents |
|
|
||||||
|-------|------------|
|
|
||||||
| g3-config | 4 |
|
|
||||||
| g3-providers | 4 |
|
|
||||||
| g3-core | 3 |
|
|
||||||
| g3-computer-control | 2 |
|
|
||||||
| g3-cli | 1 |
|
|
||||||
| g3-ensembles | 1 |
|
|
||||||
| g3-execution | 1 |
|
|
||||||
| g3-planner | 1 |
|
|
||||||
|
|
||||||
### Fan-Out (Most Dependencies)
|
|
||||||
|
|
||||||
| Crate | Dependencies |
|
|
||||||
|-------|-------------|
|
|
||||||
| g3-cli | 6 |
|
|
||||||
| g3-core | 4 |
|
|
||||||
| g3-planner | 3 |
|
|
||||||
| g3 | 2 |
|
|
||||||
| g3-ensembles | 2 |
|
|
||||||
|
|
||||||
## File-Level Structure
|
|
||||||
|
|
||||||
### Top Fan-Out Files (Most Outgoing Edges)
|
|
||||||
|
|
||||||
| File | Edges | Description |
|
|
||||||
|------|-------|-------------|
|
|
||||||
| crates/g3-core/src/lib.rs | 29 | Core library root |
|
|
||||||
| crates/g3-cli/src/lib.rs | 17 | CLI library root |
|
|
||||||
| crates/g3-core/src/tools/mod.rs | 9 | Tools module root |
|
|
||||||
| crates/g3-planner/src/lib.rs | 8 | Planner library root |
|
|
||||||
| crates/g3-providers/src/lib.rs | 6 | Providers library root |
|
|
||||||
| crates/g3-computer-control/src/lib.rs | 5 | Computer control root |
|
|
||||||
| crates/g3-planner/src/llm.rs | 5 | LLM integration |
|
|
||||||
|
|
||||||
### Top Fan-In (Most Imported)
|
|
||||||
|
|
||||||
| Target | Imports |
|
|
||||||
|--------|--------|
|
|
||||||
| g3-core (crate) | 21 |
|
|
||||||
| g3-providers (crate) | 11 |
|
|
||||||
| g3-config (crate) | 9 |
|
|
||||||
| g3-computer-control (crate) | 2 |
|
|
||||||
|
|
||||||
## Entrypoints
|
## Entrypoints
|
||||||
|
|
||||||
| File | Type |
|
| Type | Location | Evidence |
|
||||||
|------|------|
|
|------|----------|----------|
|
||||||
| src/main.rs | Binary entrypoint (g3) |
|
| Binary | `crates/g3-cli/src/lib.rs` | `run()` function, CLI dispatch |
|
||||||
| crates/studio/src/main.rs | Binary entrypoint (studio) |
|
| Binary | `crates/studio/src/main.rs` | `main()` function |
|
||||||
| crates/g3-cli/src/lib.rs | Library root |
|
| Library | `crates/g3-core/src/lib.rs` | `Agent` struct, core API |
|
||||||
| crates/g3-core/src/lib.rs | Library root |
|
|
||||||
|
## Top Fan-In Nodes (Most Depended Upon)
|
||||||
|
|
||||||
|
| Node | Fan-In | Type |
|
||||||
|
|------|--------|------|
|
||||||
|
| crate:g3-core | 35 | crate |
|
||||||
|
| crate:g3-providers | 19 | crate |
|
||||||
|
| file:crates/g3-core/src/ui_writer.rs | 15 | file |
|
||||||
|
| crate:g3-config | 13 | crate |
|
||||||
|
| file:crates/g3-cli/src/g3_status.rs | 10 | file |
|
||||||
|
| file:crates/g3-cli/src/simple_output.rs | 8 | file |
|
||||||
|
| file:crates/g3-core/src/context_window.rs | 6 | file |
|
||||||
|
| file:crates/g3-cli/src/template.rs | 6 | file |
|
||||||
|
| file:crates/g3-core/src/paths.rs | 5 | file |
|
||||||
|
| crate:g3-computer-control | 4 | crate |
|
||||||
|
|
||||||
|
## Top Fan-Out Nodes (Most Dependencies)
|
||||||
|
|
||||||
|
| Node | Fan-Out | Type |
|
||||||
|
|------|---------|------|
|
||||||
|
| file:crates/g3-cli/src/agent_mode.rs | 13 | file |
|
||||||
|
| file:crates/g3-core/src/lib.rs | 13 | file |
|
||||||
|
| file:crates/g3-cli/src/commands.rs | 12 | file |
|
||||||
|
| file:crates/g3-cli/src/interactive.rs | 12 | file |
|
||||||
|
| file:crates/g3-cli/src/accumulative.rs | 11 | file |
|
||||||
|
| file:crates/g3-planner/src/planner.rs | 8 | file |
|
||||||
|
| file:crates/g3-cli/src/autonomous.rs | 8 | file |
|
||||||
|
| file:crates/g3-core/src/tools/acd.rs | 7 | file |
|
||||||
|
| file:crates/g3-planner/src/llm.rs | 6 | file |
|
||||||
|
| file:crates/g3-cli/src/utils.rs | 5 | file |
|
||||||
|
|
||||||
|
## File Counts by Crate
|
||||||
|
|
||||||
|
| Crate | Source Files |
|
||||||
|
|-------|-------------|
|
||||||
|
| g3-cli | 23 |
|
||||||
|
| g3-core | 42 |
|
||||||
|
| g3-providers | 9 |
|
||||||
|
| g3-config | 2 |
|
||||||
|
| g3-execution | 1 |
|
||||||
|
| g3-planner | 8 |
|
||||||
|
| g3-computer-control | 11 |
|
||||||
|
| studio | 3 |
|
||||||
|
|
||||||
## Extraction Limitations
|
## Extraction Limitations
|
||||||
|
|
||||||
- Only `use` and `mod` statements at line start are parsed
|
1. **Static analysis only**: Dynamic dispatch and trait objects not traced
|
||||||
- Conditional compilation (`#[cfg(...)]`) not evaluated
|
2. **Use statement parsing**: Only `use g3_*` and `use crate::` patterns captured
|
||||||
- Macro-generated imports not detected
|
3. **Conditional compilation**: `#[cfg(...)]` blocks not evaluated
|
||||||
- Re-exports through `pub use` not fully traced
|
4. **Re-exports**: `pub use` chains not fully resolved
|
||||||
- Test modules (`mod tests`) excluded from graph
|
5. **Test files excluded**: Files in `/tests/` directories not included
|
||||||
- Test files (`*_test.rs`, `tests/`) excluded from graph
|
6. **Examples excluded**: Files in `/examples/` directories not included
|
||||||
|
|||||||
@@ -1,112 +1,69 @@
|
|||||||
# Coupling Hotspots
|
# Coupling Hotspots
|
||||||
|
|
||||||
## Method
|
## High Fan-In Files (Most Depended Upon)
|
||||||
|
|
||||||
Hotspots identified by:
|
Files with disproportionately high incoming dependencies.
|
||||||
1. Fan-in > 2× average (high incoming dependencies)
|
|
||||||
2. Fan-out > 2× average (high outgoing dependencies)
|
|
||||||
3. Cross-group edge concentration
|
|
||||||
|
|
||||||
## Metrics
|
| File | Fan-In | Crate | Role |
|
||||||
|
|------|--------|-------|------|
|
||||||
|
| ui_writer.rs | 15 | g3-core | UI abstraction trait |
|
||||||
|
| g3_status.rs | 10 | g3-cli | Status message formatting |
|
||||||
|
| simple_output.rs | 8 | g3-cli | Output helper |
|
||||||
|
| context_window.rs | 6 | g3-core | Token/context management |
|
||||||
|
| template.rs | 6 | g3-cli | Template processing |
|
||||||
|
| paths.rs | 5 | g3-core | Path utilities |
|
||||||
|
|
||||||
### Crate Level
|
### Evidence: ui_writer.rs (fan-in: 15)
|
||||||
|
|
||||||
| Metric | Value |
|
Depended on by:
|
||||||
|--------|-------|
|
- g3-cli: accumulative.rs, agent_mode.rs, autonomous.rs, commands.rs, interactive.rs, task_execution.rs, ui_writer_impl.rs, utils.rs
|
||||||
| Average fan-in | 2.0 |
|
- g3-core: compaction.rs, feedback_extraction.rs, lib.rs, retry.rs, tool_dispatch.rs, tools/*.rs
|
||||||
| Average fan-out | 1.7 |
|
|
||||||
| Threshold (2×) | 4.0 / 3.4 |
|
|
||||||
|
|
||||||
### File Level
|
### Evidence: g3_status.rs (fan-in: 10)
|
||||||
|
|
||||||
| Metric | Value |
|
Depended on by:
|
||||||
|--------|-------|
|
- commands.rs, interactive.rs, simple_output.rs, task_execution.rs, and others in g3-cli
|
||||||
| Total edges | 123 |
|
|
||||||
| Total files | 95 |
|
|
||||||
| Average fan-out | 1.3 |
|
|
||||||
| Threshold (2×) | 2.6 |
|
|
||||||
|
|
||||||
## Crate-Level Hotspots
|
## High Fan-Out Files (Most Dependencies)
|
||||||
|
|
||||||
### High Fan-In (Most Depended Upon)
|
Files with disproportionately high outgoing dependencies.
|
||||||
|
|
||||||
| Crate | Fan-In | Status |
|
| File | Fan-Out | Crate | Role |
|
||||||
|-------|--------|--------|
|
|------|---------|-------|------|
|
||||||
| g3-config | 4 | **HOTSPOT** (2× avg) |
|
| agent_mode.rs | 13 | g3-cli | Agent mode entry point |
|
||||||
| g3-providers | 4 | **HOTSPOT** (2× avg) |
|
| lib.rs | 13 | g3-core | Core library root |
|
||||||
| g3-core | 3 | Near threshold |
|
| commands.rs | 12 | g3-cli | Command handlers |
|
||||||
|
| interactive.rs | 12 | g3-cli | Interactive REPL |
|
||||||
|
| accumulative.rs | 11 | g3-cli | Accumulative mode |
|
||||||
|
| planner.rs | 8 | g3-planner | Planning orchestration |
|
||||||
|
|
||||||
**Evidence for g3-config:**
|
### Evidence: agent_mode.rs (fan-out: 13)
|
||||||
- Depended on by: g3-cli, g3-core, g3-planner, g3-ensembles
|
|
||||||
- Contains: Configuration types, loading logic
|
|
||||||
|
|
||||||
**Evidence for g3-providers:**
|
Depends on:
|
||||||
- Depended on by: g3, g3-cli, g3-core, g3-planner
|
- g3-core: Agent, ui_writer::UiWriter
|
||||||
- Contains: LLM provider trait, message types, streaming
|
- Internal: project_files, display, language_prompts, simple_output, embedded_agents, ui_writer_impl, interactive, template
|
||||||
|
|
||||||
### High Fan-Out (Most Dependencies)
|
### Evidence: g3-core/lib.rs (fan-out: 13)
|
||||||
|
|
||||||
| Crate | Fan-Out | Status |
|
Depends on:
|
||||||
|-------|---------|--------|
|
- External crates: g3-config, g3-providers
|
||||||
| g3-cli | 6 | **HOTSPOT** (3.5× avg) |
|
- Internal modules: ui_writer, context_window, paths, compaction, streaming, tools, etc.
|
||||||
| g3-core | 4 | **HOTSPOT** (2.4× avg) |
|
|
||||||
| g3-planner | 3 | Near threshold |
|
|
||||||
|
|
||||||
**Evidence for g3-cli:**
|
## Cross-Crate Coupling
|
||||||
- Depends on: g3-core, g3-config, g3-planner, g3-computer-control, g3-providers, g3-ensembles
|
|
||||||
- Role: Top-level integration point
|
|
||||||
|
|
||||||
**Evidence for g3-core:**
|
| Source Crate | Target Crate | Edge Count |
|
||||||
- Depends on: g3-providers, g3-config, g3-execution, g3-computer-control
|
|--------------|--------------|------------|
|
||||||
- Role: Central engine with multiple infrastructure dependencies
|
| g3-cli | g3-core | 35 |
|
||||||
|
| g3-core | g3-providers | 10 |
|
||||||
## File-Level Hotspots
|
| g3-core | g3-config | 5 |
|
||||||
|
| g3-planner | g3-core | 4 |
|
||||||
### High Fan-Out Files
|
| g3-planner | g3-providers | 3 |
|
||||||
|
| g3-core | g3-computer-control | 2 |
|
||||||
| File | Fan-Out | Threshold | Status |
|
|
||||||
|------|---------|-----------|--------|
|
|
||||||
| crates/g3-core/src/lib.rs | 29 | 2.6 | **HOTSPOT** (22× avg) |
|
|
||||||
| crates/g3-cli/src/lib.rs | 17 | 2.6 | **HOTSPOT** (13× avg) |
|
|
||||||
| crates/g3-core/src/tools/mod.rs | 9 | 2.6 | **HOTSPOT** (7× avg) |
|
|
||||||
| crates/g3-planner/src/lib.rs | 8 | 2.6 | **HOTSPOT** (6× avg) |
|
|
||||||
| crates/g3-providers/src/lib.rs | 6 | 2.6 | **HOTSPOT** (4.6× avg) |
|
|
||||||
| crates/g3-computer-control/src/lib.rs | 5 | 2.6 | **HOTSPOT** (3.8× avg) |
|
|
||||||
| crates/g3-planner/src/llm.rs | 5 | 2.6 | **HOTSPOT** (3.8× avg) |
|
|
||||||
|
|
||||||
**Note:** High fan-out in `lib.rs` files is expected (module re-exports). The `tools/mod.rs` and `llm.rs` hotspots are more significant as they represent actual coupling.
|
|
||||||
|
|
||||||
### Cross-Crate Import Concentration
|
|
||||||
|
|
||||||
| Source File | Cross-Crate Imports |
|
|
||||||
|-------------|--------------------|
|
|
||||||
| crates/g3-cli/src/lib.rs | 5 (g3-core, g3-config, g3-providers, g3-planner, g3-ensembles) |
|
|
||||||
| crates/g3-planner/src/llm.rs | 4 (g3-config, g3-core, g3-providers) |
|
|
||||||
| crates/g3-cli/src/autonomous.rs | 2 (g3-core) |
|
|
||||||
| crates/g3-cli/src/task_execution.rs | 2 (g3-core) |
|
|
||||||
|
|
||||||
## Observations
|
## Observations
|
||||||
|
|
||||||
1. **g3-core/src/lib.rs** has extreme fan-out (29 edges) due to declaring 22+ modules
|
1. **ui_writer.rs** is a central abstraction point; changes here affect 15+ files
|
||||||
2. **g3-config** and **g3-providers** are foundational crates with high fan-in
|
2. **g3-cli** files have high fan-out due to orchestration responsibilities
|
||||||
3. **g3-cli** is the integration hub, pulling together all subsystems
|
3. **g3-core/lib.rs** is the primary API surface with expected high coupling
|
||||||
4. **tools/mod.rs** aggregates 9 tool modules - natural aggregation point
|
4. **g3_status.rs** and **simple_output.rs** form a UI utility cluster in g3-cli
|
||||||
5. **g3-planner/src/llm.rs** has notable cross-crate coupling (imports from 3 other crates)
|
5. **tools/*.rs** files consistently depend on ui_writer and ToolCall types
|
||||||
|
|
||||||
## Cross-Group Edges
|
|
||||||
|
|
||||||
Total cross-crate imports: 43
|
|
||||||
|
|
||||||
| From Crate | To Crate | Count |
|
|
||||||
|------------|----------|-------|
|
|
||||||
| g3-cli | g3-core | 21 |
|
|
||||||
| g3-cli | g3-config | 4 |
|
|
||||||
| g3-cli | g3-providers | 2 |
|
|
||||||
| g3-planner | g3-core | 5 |
|
|
||||||
| g3-planner | g3-providers | 4 |
|
|
||||||
| g3-planner | g3-config | 2 |
|
|
||||||
| g3-core | g3-providers | 8 |
|
|
||||||
| g3-core | g3-config | 3 |
|
|
||||||
| g3-core | g3-computer-control | 2 |
|
|
||||||
| g3-ensembles | g3-core | 1 |
|
|
||||||
| g3-ensembles | g3-config | 1 |
|
|
||||||
|
|||||||
@@ -1,172 +1,80 @@
|
|||||||
# Observed Layering
|
# Observed Layering
|
||||||
|
|
||||||
## Derivation Method
|
## Crate-Level Layers
|
||||||
|
|
||||||
Layers derived mechanically from:
|
Based on dependency direction, the following layers are observed:
|
||||||
1. Crate dependency direction in Cargo.toml
|
|
||||||
2. Path-based module grouping
|
|
||||||
3. Import directionality analysis
|
|
||||||
|
|
||||||
## Crate Hierarchy
|
|
||||||
|
|
||||||
```
|
```
|
||||||
┌─────────────────────────────────────────────────────────────┐
|
Layer 0 (Leaf crates - no internal dependencies):
|
||||||
│ Layer 0: Binaries │
|
├── g3-config
|
||||||
│ g3 (main entry) │
|
├── g3-execution
|
||||||
│ studio (standalone tool) │
|
├── g3-providers
|
||||||
└─────────────────────────────────────────────────────────────┘
|
├── g3-computer-control
|
||||||
│
|
└── studio
|
||||||
▼
|
|
||||||
┌─────────────────────────────────────────────────────────────┐
|
Layer 1 (Depends on Layer 0):
|
||||||
│ Layer 1: Application │
|
└── g3-core
|
||||||
│ g3-cli (CLI interface, 16 files) │
|
└── depends on: g3-providers, g3-config, g3-execution, g3-computer-control
|
||||||
└─────────────────────────────────────────────────────────────┘
|
|
||||||
│
|
Layer 2 (Depends on Layer 0 and 1):
|
||||||
▼
|
├── g3-cli
|
||||||
┌─────────────────────────────────────────────────────────────┐
|
│ └── depends on: g3-core, g3-config, g3-planner, g3-computer-control, g3-providers
|
||||||
│ Layer 2: Orchestration │
|
└── g3-planner
|
||||||
│ g3-planner (planning logic, 8 files) │
|
└── depends on: g3-providers, g3-core, g3-config
|
||||||
│ g3-ensembles (multi-agent, 4 files) │
|
|
||||||
└─────────────────────────────────────────────────────────────┘
|
Layer 3 (Application root):
|
||||||
│
|
└── g3
|
||||||
▼
|
└── depends on: g3-cli, g3-providers
|
||||||
┌─────────────────────────────────────────────────────────────┐
|
|
||||||
│ Layer 3: Core Engine │
|
|
||||||
│ g3-core (agent engine, 38 files) │
|
|
||||||
└─────────────────────────────────────────────────────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────────────────────────────────────────────┐
|
|
||||||
│ Layer 4: Infrastructure │
|
|
||||||
│ g3-providers (LLM providers, 7 files) │
|
|
||||||
│ g3-config (configuration, 2 files) │
|
|
||||||
│ g3-execution (code execution, 1 file) │
|
|
||||||
│ g3-computer-control (desktop automation, 16 files) │
|
|
||||||
└─────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Intra-Crate Module Structure
|
## Layer Metrics
|
||||||
|
|
||||||
### g3-core (38 files)
|
| Layer | Crates | Description |
|
||||||
|
|-------|--------|-------------|
|
||||||
|
| 0 | 5 | Foundation crates with no internal deps |
|
||||||
|
| 1 | 1 | Core engine |
|
||||||
|
| 2 | 2 | High-level orchestration |
|
||||||
|
| 3 | 1 | Application entry point |
|
||||||
|
|
||||||
```
|
## Observed Groupings by Path
|
||||||
lib.rs
|
|
||||||
├── acd.rs # Aggressive Context Dehydration
|
|
||||||
├── background_process.rs # Background process management
|
|
||||||
├── code_search/ # Tree-sitter code search
|
|
||||||
│ ├── mod.rs
|
|
||||||
│ └── searcher.rs
|
|
||||||
├── compaction.rs # Context compaction
|
|
||||||
├── context_window.rs # Context window management
|
|
||||||
├── error_handling.rs # Error classification
|
|
||||||
├── feedback_extraction.rs # Coach feedback extraction
|
|
||||||
├── paths.rs # Path utilities
|
|
||||||
├── project.rs # Project abstraction
|
|
||||||
├── prompts.rs # System prompts
|
|
||||||
├── provider_config.rs # Provider configuration
|
|
||||||
├── provider_registration.rs # Provider registration
|
|
||||||
├── retry.rs # Retry logic
|
|
||||||
├── session.rs # Session management
|
|
||||||
├── session_continuation.rs # Session continuation
|
|
||||||
├── streaming.rs # Streaming utilities
|
|
||||||
├── streaming_parser.rs # Tool call parser
|
|
||||||
├── task_result.rs # Task result types
|
|
||||||
├── tool_definitions.rs # Tool definitions
|
|
||||||
├── tool_dispatch.rs # Tool routing
|
|
||||||
├── tools/ # Tool implementations
|
|
||||||
│ ├── mod.rs
|
|
||||||
│ ├── acd.rs
|
|
||||||
│ ├── executor.rs
|
|
||||||
│ ├── file_ops.rs
|
|
||||||
│ ├── memory.rs
|
|
||||||
│ ├── misc.rs
|
|
||||||
│ ├── research.rs
|
|
||||||
│ ├── shell.rs
|
|
||||||
│ ├── todo.rs
|
|
||||||
│ └── webdriver.rs
|
|
||||||
├── ui_writer.rs # UI abstraction
|
|
||||||
├── utils.rs # General utilities
|
|
||||||
└── webdriver_session.rs # WebDriver session
|
|
||||||
```
|
|
||||||
|
|
||||||
### g3-cli (16 files)
|
### g3-core/src/tools/
|
||||||
|
Tool implementations grouped under `tools/` submodule:
|
||||||
|
- executor.rs (tool context and execution)
|
||||||
|
- acd.rs, file_ops.rs, memory.rs, misc.rs, research.rs, shell.rs, todo.rs, webdriver.rs
|
||||||
|
|
||||||
```
|
### g3-core/src/code_search/
|
||||||
lib.rs
|
Code search functionality:
|
||||||
├── accumulative.rs # Accumulative mode
|
- mod.rs (API types)
|
||||||
├── agent_mode.rs # Agent mode
|
- searcher.rs (tree-sitter implementation)
|
||||||
├── autonomous.rs # Autonomous mode
|
|
||||||
├── cli_args.rs # CLI argument parsing
|
|
||||||
├── coach_feedback.rs # Coach feedback
|
|
||||||
├── filter_json.rs # JSON filtering
|
|
||||||
├── interactive.rs # Interactive mode
|
|
||||||
├── metrics.rs # Metrics/timing
|
|
||||||
├── project_files.rs # Project file loading
|
|
||||||
├── simple_output.rs # Simple output helper
|
|
||||||
├── streaming_markdown.rs # Markdown formatting
|
|
||||||
├── task_execution.rs # Task execution
|
|
||||||
├── theme.rs # UI theming
|
|
||||||
├── ui_writer_impl.rs # UiWriter implementation
|
|
||||||
└── utils.rs # CLI utilities
|
|
||||||
```
|
|
||||||
|
|
||||||
### g3-computer-control (16 files)
|
### g3-computer-control/src/platform/
|
||||||
|
Platform-specific implementations:
|
||||||
|
- macos.rs, linux.rs, windows.rs (conditional compilation)
|
||||||
|
|
||||||
```
|
### g3-computer-control/src/webdriver/
|
||||||
lib.rs
|
Browser automation:
|
||||||
├── macax/ # macOS Accessibility
|
- safari.rs, chrome.rs, diagnostics.rs
|
||||||
│ ├── mod.rs
|
|
||||||
│ └── controller.rs
|
|
||||||
├── ocr/ # OCR engines
|
|
||||||
│ ├── mod.rs
|
|
||||||
│ ├── tesseract.rs
|
|
||||||
│ └── vision.rs
|
|
||||||
├── platform/ # Platform implementations
|
|
||||||
│ ├── mod.rs
|
|
||||||
│ ├── linux.rs
|
|
||||||
│ ├── macos.rs
|
|
||||||
│ └── windows.rs
|
|
||||||
├── types.rs # Shared types
|
|
||||||
└── webdriver/ # WebDriver implementations
|
|
||||||
├── mod.rs
|
|
||||||
├── chrome.rs
|
|
||||||
├── diagnostics.rs
|
|
||||||
└── safari.rs
|
|
||||||
```
|
|
||||||
|
|
||||||
### g3-providers (7 files)
|
### g3-providers/src/
|
||||||
|
LLM provider implementations:
|
||||||
|
- anthropic.rs, openai.rs, gemini.rs, databricks.rs, embedded.rs
|
||||||
|
- oauth.rs (authentication)
|
||||||
|
- mock.rs (testing)
|
||||||
|
|
||||||
```
|
## Directionality
|
||||||
lib.rs
|
|
||||||
├── anthropic.rs # Anthropic Claude
|
|
||||||
├── databricks.rs # Databricks
|
|
||||||
├── embedded.rs # Local llama.cpp
|
|
||||||
├── oauth.rs # OAuth flow
|
|
||||||
├── openai.rs # OpenAI-compatible
|
|
||||||
└── streaming.rs # Streaming utilities
|
|
||||||
```
|
|
||||||
|
|
||||||
### g3-planner (8 files)
|
| From | To | Direction | Violations |
|
||||||
|
|------|----|-----------|------------|
|
||||||
```
|
| g3 | g3-cli | down | none |
|
||||||
lib.rs
|
| g3-cli | g3-core | down | none |
|
||||||
├── code_explore.rs # Code exploration
|
| g3-cli | g3-planner | lateral | none |
|
||||||
├── git.rs # Git operations
|
| g3-core | g3-providers | down | none |
|
||||||
├── history.rs # History management
|
| g3-core | g3-config | down | none |
|
||||||
├── llm.rs # LLM integration
|
| g3-planner | g3-core | lateral | none |
|
||||||
├── planner.rs # Planning logic
|
|
||||||
├── prompts.rs # Planner prompts
|
|
||||||
└── state.rs # State management
|
|
||||||
```
|
|
||||||
|
|
||||||
## Layer Violations
|
|
||||||
|
|
||||||
**None detected.**
|
|
||||||
|
|
||||||
All dependencies flow downward through the layer hierarchy. No upward dependencies exist.
|
|
||||||
|
|
||||||
## Uncertainty
|
## Uncertainty
|
||||||
|
|
||||||
- Layer assignment is based on dependency direction, not semantic intent
|
- **studio**: Isolated crate with no detected internal dependencies; may have runtime integration not captured
|
||||||
- `studio` is isolated (no internal crate dependencies) - layer assignment is nominal
|
- **g3-execution**: Minimal crate (1 file); purpose unclear from static analysis alone
|
||||||
- Some crates at Layer 4 could arguably be split further (e.g., `g3-computer-control` is large)
|
- **Lateral dependencies**: g3-cli ↔ g3-planner relationship suggests potential for extraction or consolidation
|
||||||
|
|||||||
@@ -1,103 +1,67 @@
|
|||||||
# Analysis Limitations
|
# Analysis Limitations
|
||||||
|
|
||||||
## Extraction Method
|
## What Was Observed
|
||||||
|
|
||||||
Dependencies extracted via:
|
| Category | Method | Coverage |
|
||||||
1. Cargo.toml parsing for crate-level dependencies
|
|----------|--------|----------|
|
||||||
2. Regex-based `use` and `mod` statement extraction from source files
|
| 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
|
- **Trait implementations**: A file implementing a trait from another module creates a dependency not captured by `use` statements
|
||||||
#[cfg(target_os = "macos")]
|
- **Type aliases**: Types re-exported through `pub use` chains
|
||||||
use core_graphics::window::*;
|
- **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:**
|
- **Trait objects**: `dyn Trait` usage creates runtime dependencies
|
||||||
- `crates/g3-computer-control/src/platform/macos.rs`
|
- **Generic bounds**: `T: SomeTrait` constraints
|
||||||
- `crates/g3-computer-control/src/platform/linux.rs`
|
- **Associated types**: Dependencies through associated type resolution
|
||||||
- `crates/g3-computer-control/src/platform/windows.rs`
|
|
||||||
|
|
||||||
### 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:**
|
### 4. Build System
|
||||||
- `serde::Serialize`, `serde::Deserialize`
|
|
||||||
- `async_trait::async_trait`
|
|
||||||
- `clap::Parser`
|
|
||||||
|
|
||||||
### 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
|
### 5. Excluded Files
|
||||||
pub use some_module::SomeType;
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
| Inference | Basis | Confidence |
|
||||||
use crate::types::*;
|
|-----------|-------|------------|
|
||||||
```
|
| Layer assignment | Topological sort of crate deps | High |
|
||||||
|
| Fan-in/fan-out metrics | Edge counting | High |
|
||||||
Glob imports are recorded but individual items are not enumerated. The actual coupling may be higher or lower than represented.
|
| Module-to-file mapping | Naming convention (mod.rs, *.rs) | High |
|
||||||
|
| Entrypoints | lib.rs/main.rs presence | High |
|
||||||
### 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.
|
|
||||||
|
|
||||||
## What May Invalidate Conclusions
|
## What May Invalidate Conclusions
|
||||||
|
|
||||||
1. **Feature flags**: Cargo features may enable/disable entire modules
|
1. **Hidden re-exports**: If `g3-core/lib.rs` re-exports types from submodules, actual coupling may be higher
|
||||||
2. **Workspace changes**: Adding/removing crates changes the graph structure
|
2. **Macro-generated code**: Macros like `#[derive(Serialize)]` add implicit serde dependency
|
||||||
3. **Refactoring**: Moving code between modules changes edges without changing functionality
|
3. **Runtime plugin loading**: If any crate loads code dynamically, static analysis misses it
|
||||||
4. **Dynamic dispatch**: Trait objects create runtime dependencies not visible statically
|
4. **Workspace member changes**: Adding/removing crates from workspace invalidates crate-level graph
|
||||||
|
|
||||||
## Confidence Assessment
|
## Recommendations for Improved Analysis
|
||||||
|
|
||||||
| Aspect | Confidence |
|
1. Use `cargo metadata` for authoritative crate graph
|
||||||
|--------|------------|
|
2. Use `cargo tree` for transitive dependency analysis
|
||||||
| Crate-level dependencies | High (from Cargo.toml) |
|
3. Use `rust-analyzer` for semantic import resolution
|
||||||
| Module tree structure | High (from mod declarations) |
|
4. Parse AST for type references beyond `use` statements
|
||||||
| Cross-crate imports | Medium (regex-based) |
|
|
||||||
| Intra-module coupling | Low (not analyzed) |
|
|
||||||
| Runtime dependencies | Not captured |
|
|
||||||
|
|||||||
@@ -1,44 +1,27 @@
|
|||||||
# Strongly Connected Components Analysis
|
# Strongly Connected Components (Cycles)
|
||||||
|
|
||||||
## Method
|
## Summary
|
||||||
|
|
||||||
Tarjan's algorithm applied to file-level dependency graph.
|
| Metric | Value |
|
||||||
|
|--------|-------|
|
||||||
|
| Non-trivial SCCs | 0 |
|
||||||
|
| Total nodes in cycles | 0 |
|
||||||
|
|
||||||
Edge types considered:
|
## Analysis
|
||||||
- `mod_declaration`: Parent module declares child module
|
|
||||||
- `cross_crate_import`: File imports from another crate
|
|
||||||
|
|
||||||
## Results
|
No strongly connected components with more than one node were detected in the dependency graph.
|
||||||
|
|
||||||
**No non-trivial SCCs detected.**
|
This indicates the codebase has a **directed acyclic graph (DAG)** structure at both the crate and file level for the dependencies that were extracted.
|
||||||
|
|
||||||
The file-level dependency graph is acyclic. All `mod` declarations form a strict tree structure within each crate, and cross-crate imports follow the crate dependency DAG.
|
## Methodology
|
||||||
|
|
||||||
## Crate-Level Cycle Analysis
|
- Tarjan's algorithm applied to all 108 nodes and 186 edges
|
||||||
|
- Only SCCs with 2+ nodes reported (trivial single-node SCCs excluded)
|
||||||
|
- Analysis covers `use` statement imports only
|
||||||
|
|
||||||
The crate dependency graph was also analyzed:
|
## Caveats
|
||||||
|
|
||||||
```
|
1. **Trait implementations**: Mutual trait dependencies not captured by `use` statements
|
||||||
g3 → g3-cli → g3-core → g3-providers
|
2. **Type references**: Types referenced without explicit `use` not detected
|
||||||
→ g3-config
|
3. **Macro expansions**: Dependencies introduced by macros not traced
|
||||||
→ g3-execution
|
4. **Build-time dependencies**: `build.rs` dependencies not included
|
||||||
→ g3-computer-control
|
|
||||||
→ g3-planner → g3-core
|
|
||||||
→ g3-providers
|
|
||||||
→ g3-config
|
|
||||||
→ g3-ensembles → g3-core
|
|
||||||
→ g3-config
|
|
||||||
```
|
|
||||||
|
|
||||||
**No cycles detected at crate level.**
|
|
||||||
|
|
||||||
The workspace forms a directed acyclic graph (DAG) with:
|
|
||||||
- Leaf crates: `g3-providers`, `g3-config`, `g3-execution`, `g3-computer-control`, `studio`
|
|
||||||
- Mid-tier crates: `g3-core`, `g3-planner`, `g3-ensembles`
|
|
||||||
- Top-tier crates: `g3-cli`, `g3`
|
|
||||||
|
|
||||||
## Implications
|
|
||||||
|
|
||||||
- No circular dependencies exist
|
|
||||||
- Build order is deterministic
|
|
||||||
- Crates can be compiled in parallel respecting the DAG
|
|
||||||
|
|||||||
Reference in New Issue
Block a user