---
id: define-edge-types-and-edgekind-enum
level: task
title: "Define Edge types and EdgeKind enum"
short_code: "PROJEC-T-0002"
created_at: 2026-01-08T03:02:50.067449+00:00
updated_at: 2026-01-08T13:36:45.340652+00:00
parent: PROJEC-I-0001
blocked_by: []
archived: true

tags:
  - "#task"
  - "#phase/completed"


exit_criteria_met: false
strategy_id: NULL
initiative_id: PROJEC-I-0001
---

# Define Edge types and EdgeKind enum

*This template includes sections for various types of tasks. Delete sections that don't apply to your specific use case.*

## Parent Initiative **[CONDITIONAL: Assigned Task]**

[[PROJEC-I-0001]]

## Objective

Define the edge types that represent relationships between symbols in the code graph. These edges capture structural relationships (contains, imports), call relationships (direct, FFI, dynamic), type relationships (inherits, implements), and special cases (macros, generated code).

## Acceptance Criteria

## Acceptance Criteria

## Acceptance Criteria

## Acceptance Criteria

- [ ] `EdgeKind` enum with all edge types from ADR-002
- [ ] `CallType` enum for distinguishing call variants (Direct, Method, Dynamic, FFI, API)
- [ ] `Edge` struct with source_id, target_id, kind, and metadata
- [ ] Derive Serialize/Deserialize for all types
- [ ] Unit tests for edge construction
- [ ] Documentation comments explaining each edge type's semantics

## Implementation Notes

### Location
`crates/muninn-graph/src/edges.rs`

### Types to Define

```rust
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum CallType {
    Direct,       // foo()
    Method,       // self.foo()
    StaticMethod, // Type::foo()
    Dynamic,      // vtable, trait object, reflection
    FFI,          // extern "C", PyO3, ctypes
    API,          // HTTP, gRPC external calls
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum EdgeKind {
    /// Parent contains child (File -> Function)
    Contains,
    
    /// Import/use relationship
    Imports { path: String, alias: Option<String> },
    
    /// Function/method call
    Calls { call_type: CallType, line: usize },
    
    /// Class inheritance
    Inherits,
    
    /// Interface/trait implementation
    Implements,
    
    /// Type reference in signature or body
    UsesType,
    
    /// Object/struct construction
    Instantiates,
    
    /// Variable/constant reference
    References,
    
    /// Macro expansion (macro -> expanded code)
    ExpandsTo,
    
    /// Generated code tracking
    GeneratedBy { generator: String },
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Edge {
    pub source_id: String,
    pub target_id: String,
    pub kind: EdgeKind,
}
```

### Edge Semantics

| Edge | Source | Target | Example |
|------|--------|--------|---------|
| Contains | File/Module | Function/Struct | `main.rs` contains `fn main()` |
| Imports | File | Module/Symbol | `use std::io::Read` |
| Calls | Function | Function | `parse()` calls `tokenize()` |
| Inherits | Class | Class | `Dog` inherits `Animal` |
| Implements | Struct | Trait | `Vec` implements `Iterator` |
| UsesType | Function | Type | `fn foo(x: MyStruct)` |
| ExpandsTo | Macro | Code | `vec![]` expands to allocation |
| GeneratedBy | File | Generator | `schema.rs` generated by `sqlx` |

### Dependencies
- Depends on: PROJEC-T-0001 (Symbol types for ID references)

## Status Updates

*To be added during implementation*