← back to donghui-0126__amure-do

Function bodies 393 total

All specs Real LLM only Function bodies
new function · rust · L35-L45 (11 LOC)
crates/amure-db/src/edge.rs
    pub fn new(source: Uuid, target: Uuid, kind: EdgeKind) -> Self {
        Self {
            id: Uuid::new_v4(),
            source,
            target,
            kind,
            weight: 1.0,
            note: String::new(),
            created_at: Utc::now(),
        }
    }
with_weight function · rust · L46-L50 (5 LOC)
crates/amure-db/src/edge.rs
    pub fn with_weight(mut self, weight: f64) -> Self {
        self.weight = weight;
        self
    }
with_note function · rust · L51-L55 (5 LOC)
crates/amure-db/src/edge.rs
    pub fn with_note(mut self, note: String) -> Self {
        self.note = note;
        self
    }
test_edge_creation function · rust · L63-L71 (9 LOC)
crates/amure-db/src/edge.rs
    fn test_edge_creation() {
        let a = Uuid::new_v4();
        let b = Uuid::new_v4();
        let edge = Edge::new(a, b, EdgeKind::Support).with_weight(0.8).with_note("test".into());
        assert_eq!(edge.source, a);
        assert_eq!(edge.target, b);
        assert_eq!(edge.kind, EdgeKind::Support);
        assert_eq!(edge.weight, 0.8);
    }
new function · rust · L25-L32 (8 LOC)
crates/amure-db/src/graph.rs
    pub fn new() -> Self {
        Self {
            nodes: HashMap::new(),
            edges: HashMap::new(),
            adjacency: HashMap::new(),
            reverse_adj: HashMap::new(),
        }
    }
add_node function · rust · L35-L42 (8 LOC)
crates/amure-db/src/graph.rs
    pub fn add_node(&mut self, node: Node) -> Uuid {
        let id = node.id;
        self.nodes.insert(id, node);
        self.adjacency.entry(id).or_default();
        self.reverse_adj.entry(id).or_default();
        id
    }
get_node function · rust · L43-L46 (4 LOC)
crates/amure-db/src/graph.rs
    pub fn get_node(&self, id: &Uuid) -> Option<&Node> {
        self.nodes.get(id)
    }
Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
get_node_mut function · rust · L47-L50 (4 LOC)
crates/amure-db/src/graph.rs
    pub fn get_node_mut(&mut self, id: &Uuid) -> Option<&mut Node> {
        self.nodes.get_mut(id)
    }
remove_node function · rust · L51-L71 (21 LOC)
crates/amure-db/src/graph.rs
    pub fn remove_node(&mut self, id: &Uuid) -> Option<Node> {
        // Collect edge IDs to remove
        let mut edge_ids = Vec::new();
        if let Some(out_edges) = self.adjacency.get(id) {
            edge_ids.extend(out_edges.iter());
        }
        if let Some(in_edges) = self.reverse_adj.get(id) {
            edge_ids.extend(in_edges.iter());
        }
        let edge_ids: Vec<Uuid> = edge_ids.into_iter().copied().collect();

        // Remove edges
        for eid in edge_ids {
            self.remove_edge(&eid);
        }

        self.adjacency.remove(id);
        self.reverse_adj.remove(id);
        self.nodes.remove(id)
    }
nodes_by_kind function · rust · L72-L75 (4 LOC)
crates/amure-db/src/graph.rs
    pub fn nodes_by_kind(&self, kind: NodeKind) -> Vec<&Node> {
        self.nodes.values().filter(|n| n.kind == kind).collect()
    }
nodes_by_status function · rust · L76-L79 (4 LOC)
crates/amure-db/src/graph.rs
    pub fn nodes_by_status(&self, status: NodeStatus) -> Vec<&Node> {
        self.nodes.values().filter(|n| n.status == status).collect()
    }
node_count function · rust · L80-L83 (4 LOC)
crates/amure-db/src/graph.rs
    pub fn node_count(&self) -> usize {
        self.nodes.len()
    }
add_edge function · rust · L86-L93 (8 LOC)
crates/amure-db/src/graph.rs
    pub fn add_edge(&mut self, edge: Edge) -> Uuid {
        let id = edge.id;
        self.adjacency.entry(edge.source).or_default().push(id);
        self.reverse_adj.entry(edge.target).or_default().push(id);
        self.edges.insert(id, edge);
        id
    }
get_edge function · rust · L94-L97 (4 LOC)
crates/amure-db/src/graph.rs
    pub fn get_edge(&self, id: &Uuid) -> Option<&Edge> {
        self.edges.get(id)
    }
remove_edge function · rust · L98-L111 (14 LOC)
crates/amure-db/src/graph.rs
    pub fn remove_edge(&mut self, id: &Uuid) -> Option<Edge> {
        if let Some(edge) = self.edges.remove(id) {
            if let Some(adj) = self.adjacency.get_mut(&edge.source) {
                adj.retain(|eid| eid != id);
            }
            if let Some(radj) = self.reverse_adj.get_mut(&edge.target) {
                radj.retain(|eid| eid != id);
            }
            Some(edge)
        } else {
            None
        }
    }
Same scanner, your repo: https://repobility.com — Repobility
edge_count function · rust · L112-L115 (4 LOC)
crates/amure-db/src/graph.rs
    pub fn edge_count(&self) -> usize {
        self.edges.len()
    }
neighbors function · rust · L120-L159 (40 LOC)
crates/amure-db/src/graph.rs
    pub fn neighbors(
        &self,
        node_id: &Uuid,
        direction: Direction,
        edge_filter: Option<&[EdgeKind]>,
    ) -> Vec<(Uuid, &Edge)> {
        let mut result = Vec::new();

        let check_filter = |edge: &Edge| -> bool {
            edge_filter.map_or(true, |kinds| kinds.contains(&edge.kind))
        };

        // Outgoing
        if matches!(direction, Direction::Out | Direction::Both) {
            if let Some(edge_ids) = self.adjacency.get(node_id) {
                for eid in edge_ids {
                    if let Some(edge) = self.edges.get(eid) {
                        if check_filter(edge) {
                            result.push((edge.target, edge));
                        }
                    }
                }
            }
        }

        // Incoming
        if matches!(direction, Direction::In | Direction::Both) {
            if let Some(edge_ids) = self.reverse_adj.get(node_id) {
                for eid in edge_ids {
                 
walk function · rust · L162-L190 (29 LOC)
crates/amure-db/src/graph.rs
    pub fn walk(
        &self,
        start: &Uuid,
        max_hops: usize,
        edge_filter: Option<&[EdgeKind]>,
    ) -> Vec<(Uuid, usize)> {
        let mut visited = HashSet::new();
        let mut queue = VecDeque::new();
        let mut result = Vec::new();

        visited.insert(*start);
        queue.push_back((*start, 0usize));

        while let Some((node_id, depth)) = queue.pop_front() {
            result.push((node_id, depth));

            if depth >= max_hops {
                continue;
            }

            for (neighbor_id, _edge) in self.neighbors(&node_id, Direction::Both, edge_filter) {
                if visited.insert(neighbor_id) {
                    queue.push_back((neighbor_id, depth + 1));
                }
            }
        }

        result
    }
subgraph function · rust · L193-L200 (8 LOC)
crates/amure-db/src/graph.rs
    pub fn subgraph(&self, node_ids: &[Uuid]) -> (Vec<&Node>, Vec<&Edge>) {
        let id_set: HashSet<&Uuid> = node_ids.iter().collect();
        let nodes: Vec<&Node> = node_ids.iter().filter_map(|id| self.nodes.get(id)).collect();
        let edges: Vec<&Edge> = self.edges.values()
            .filter(|e| id_set.contains(&e.source) && id_set.contains(&e.target))
            .collect();
        (nodes, edges)
    }
summary function · rust · L203-L221 (19 LOC)
crates/amure-db/src/graph.rs
    pub fn summary(&self) -> GraphSummary {
        let mut kind_counts = HashMap::new();
        for node in self.nodes.values() {
            *kind_counts.entry(format!("{:?}", node.kind)).or_insert(0usize) += 1;
        }
        let mut edge_counts = HashMap::new();
        for edge in self.edges.values() {
            *edge_counts.entry(format!("{:?}", edge.kind)).or_insert(0usize) += 1;
        }
        let failed = self.nodes.values().filter(|n| n.is_failed()).count();

        GraphSummary {
            n_nodes: self.nodes.len(),
            n_edges: self.edges.len(),
            n_failed: failed,
            node_kinds: kind_counts,
            edge_kinds: edge_counts,
        }
    }
default function · rust · L225-L227 (3 LOC)
crates/amure-db/src/graph.rs
    fn default() -> Self {
        Self::new()
    }
make_claim function · rust · L242-L245 (4 LOC)
crates/amure-db/src/graph.rs
    fn make_claim(statement: &str, kw: &[&str]) -> Node {
        Node::new(NodeKind::Claim, statement.into(), kw.iter().map(|s| s.to_string()).collect())
    }
make_reason function · rust · L246-L249 (4 LOC)
crates/amure-db/src/graph.rs
    fn make_reason(statement: &str, kw: &[&str]) -> Node {
        Node::new(NodeKind::Reason, statement.into(), kw.iter().map(|s| s.to_string()).collect())
    }
Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
test_add_and_get function · rust · L252-L258 (7 LOC)
crates/amure-db/src/graph.rs
    fn test_add_and_get() {
        let mut g = AmureGraph::new();
        let node = make_claim("OI는 momentum 선행지표", &["OI", "momentum"]);
        let id = g.add_node(node);
        assert!(g.get_node(&id).is_some());
        assert_eq!(g.node_count(), 1);
    }
test_remove_node_cascades_edges function · rust · L261-L271 (11 LOC)
crates/amure-db/src/graph.rs
    fn test_remove_node_cascades_edges() {
        let mut g = AmureGraph::new();
        let c = g.add_node(make_claim("claim", &[]));
        let r = g.add_node(make_reason("reason", &[]));
        g.add_edge(Edge::new(r, c, EdgeKind::Support));
        assert_eq!(g.edge_count(), 1);

        g.remove_node(&c);
        assert_eq!(g.node_count(), 1);
        assert_eq!(g.edge_count(), 0);
    }
test_neighbors function · rust · L274-L289 (16 LOC)
crates/amure-db/src/graph.rs
    fn test_neighbors() {
        let mut g = AmureGraph::new();
        let c = g.add_node(make_claim("claim", &[]));
        let r1 = g.add_node(make_reason("support", &[]));
        let r2 = g.add_node(make_reason("rebut", &[]));
        g.add_edge(Edge::new(r1, c, EdgeKind::Support));
        g.add_edge(Edge::new(r2, c, EdgeKind::Rebut));

        // Incoming to claim
        let neighbors = g.neighbors(&c, Direction::In, None);
        assert_eq!(neighbors.len(), 2);

        // Filter support only
        let support_only = g.neighbors(&c, Direction::In, Some(&[EdgeKind::Support]));
        assert_eq!(support_only.len(), 1);
    }
test_walk_bfs function · rust · L292-L307 (16 LOC)
crates/amure-db/src/graph.rs
    fn test_walk_bfs() {
        let mut g = AmureGraph::new();
        let c = g.add_node(make_claim("claim", &[]));
        let r = g.add_node(make_reason("reason", &[]));
        let e = g.add_node(Node::new(NodeKind::Evidence, "evidence".into(), vec![]));
        g.add_edge(Edge::new(r, c, EdgeKind::Support));
        g.add_edge(Edge::new(e, r, EdgeKind::DerivedFrom));

        // Walk from claim, 2 hops
        let walked = g.walk(&c, 2, None);
        assert_eq!(walked.len(), 3); // claim(0), reason(1), evidence(2)

        // Walk from claim, 1 hop
        let walked_1 = g.walk(&c, 1, None);
        assert_eq!(walked_1.len(), 2); // claim(0), reason(1)
    }
test_subgraph function · rust · L310-L324 (15 LOC)
crates/amure-db/src/graph.rs
    fn test_subgraph() {
        let mut g = AmureGraph::new();
        let c = g.add_node(make_claim("claim", &[]));
        let r = g.add_node(make_reason("reason", &[]));
        let other = g.add_node(make_claim("other", &[]));
        g.add_edge(Edge::new(r, c, EdgeKind::Support));

        let (nodes, edges) = g.subgraph(&[c, r]);
        assert_eq!(nodes.len(), 2);
        assert_eq!(edges.len(), 1);

        // other is not in subgraph
        let (nodes2, _) = g.subgraph(&[c, other]);
        assert_eq!(nodes2.len(), 2);
    }
test_summary function · rust · L327-L334 (8 LOC)
crates/amure-db/src/graph.rs
    fn test_summary() {
        let mut g = AmureGraph::new();
        g.add_node(make_claim("c1", &[]));
        g.add_node(make_reason("r1", &[]).with_status(NodeStatus::Weakened));
        let s = g.summary();
        assert_eq!(s.n_nodes, 2);
        assert_eq!(s.n_failed, 1);
    }
new function · rust · L38-L50 (13 LOC)
crates/amure-db/src/node.rs
    pub fn new(kind: NodeKind, statement: String, keywords: Vec<String>) -> Self {
        let now = Utc::now();
        Self {
            id: Uuid::new_v4(),
            kind,
            statement,
            keywords,
            metadata: serde_json::Value::Null,
            status: NodeStatus::Draft,
            created_at: now,
            updated_at: now,
        }
    }
with_id function · rust · L51-L55 (5 LOC)
crates/amure-db/src/node.rs
    pub fn with_id(mut self, id: Uuid) -> Self {
        self.id = id;
        self
    }
Want this analysis on your repo? https://repobility.com/scan/
with_metadata function · rust · L56-L60 (5 LOC)
crates/amure-db/src/node.rs
    pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
        self.metadata = metadata;
        self
    }
with_status function · rust · L61-L65 (5 LOC)
crates/amure-db/src/node.rs
    pub fn with_status(mut self, status: NodeStatus) -> Self {
        self.status = status;
        self
    }
is_failed function · rust · L66-L69 (4 LOC)
crates/amure-db/src/node.rs
    pub fn is_failed(&self) -> bool {
        matches!(self.status, NodeStatus::Rejected | NodeStatus::Weakened)
    }
tokens function · rust · L72-L75 (4 LOC)
crates/amure-db/src/node.rs
    pub fn tokens(&self) -> Vec<String> {
        let text = format!("{} {}", self.statement, self.keywords.join(" "));
        tokenize(&text)
    }
tokenize function · rust · L79-L110 (32 LOC)
crates/amure-db/src/node.rs
pub fn tokenize(text: &str) -> Vec<String> {
    let lower = text.to_lowercase();
    let mut tokens = Vec::new();
    let mut current = String::new();

    let is_korean = |c: char| ('\u{AC00}'..='\u{D7A3}').contains(&c);
    let is_word = |c: char| c.is_ascii_alphanumeric() || c == '_' || c == '-';

    for ch in lower.chars() {
        if is_word(ch) || is_korean(ch) {
            if !current.is_empty() {
                let last = current.chars().last().unwrap();
                if (is_korean(last) && is_word(ch)) || (is_word(last) && is_korean(ch)) {
                    if current.len() >= 2 {
                        tokens.push(current.clone());
                    }
                    current.clear();
                }
            }
            current.push(ch);
        } else {
            if current.len() >= 2 {
                tokens.push(current.clone());
            }
            current.clear();
        }
    }
    if current.len() >= 2 {
        tokens.push(current);
   
test_node_creation function · rust · L117-L126 (10 LOC)
crates/amure-db/src/node.rs
    fn test_node_creation() {
        let node = Node::new(
            NodeKind::Claim,
            "OI는 momentum의 선행지표다".into(),
            vec!["OI".into(), "momentum".into()],
        );
        assert_eq!(node.kind, NodeKind::Claim);
        assert_eq!(node.status, NodeStatus::Draft);
        assert!(!node.is_failed());
    }
test_failed_status function · rust · L129-L133 (5 LOC)
crates/amure-db/src/node.rs
    fn test_failed_status() {
        let node = Node::new(NodeKind::Claim, "test".into(), vec![])
            .with_status(NodeStatus::Rejected);
        assert!(node.is_failed());
    }
test_tokenize function · rust · L136-L141 (6 LOC)
crates/amure-db/src/node.rs
    fn test_tokenize() {
        let tokens = tokenize("OI momentum은 크립토에서 continuation alpha가 있다");
        assert!(tokens.contains(&"momentum".to_string()));
        assert!(tokens.contains(&"continuation".to_string()));
        assert!(tokens.contains(&"alpha".to_string()));
    }
Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
test_tokenize_underscore function · rust · L144-L148 (5 LOC)
crates/amure-db/src/node.rs
    fn test_tokenize_underscore() {
        let tokens = tokenize("open_interest cross_sectional");
        assert!(tokens.contains(&"open_interest".to_string()));
        assert!(tokens.contains(&"cross_sectional".to_string()));
    }
save function · rust · L11-L30 (20 LOC)
crates/amure-db/src/persistence.rs
    pub fn save(&self, dir: &Path) -> Result<(), Box<dyn std::error::Error>> {
        std::fs::create_dir_all(dir)?;

        let nodes: Vec<&Node> = self.nodes.values().collect();
        let edges: Vec<&Edge> = self.edges.values().collect();

        // Write to tmp then rename (atomic)
        let nodes_tmp = dir.join("nodes.json.tmp");
        let edges_tmp = dir.join("edges.json.tmp");
        let nodes_path = dir.join("nodes.json");
        let edges_path = dir.join("edges.json");

        std::fs::write(&nodes_tmp, serde_json::to_string_pretty(&nodes)?)?;
        std::fs::write(&edges_tmp, serde_json::to_string_pretty(&edges)?)?;

        std::fs::rename(&nodes_tmp, &nodes_path)?;
        std::fs::rename(&edges_tmp, &edges_path)?;

        Ok(())
    }
load function · rust · L33-L56 (24 LOC)
crates/amure-db/src/persistence.rs
    pub fn load(dir: &Path) -> Result<Self, Box<dyn std::error::Error>> {
        let mut graph = Self::new();

        let nodes_path = dir.join("nodes.json");
        let edges_path = dir.join("edges.json");

        if nodes_path.exists() {
            let content = std::fs::read_to_string(&nodes_path)?;
            let nodes: Vec<Node> = serde_json::from_str(&content)?;
            for node in nodes {
                graph.add_node(node);
            }
        }

        if edges_path.exists() {
            let content = std::fs::read_to_string(&edges_path)?;
            let edges: Vec<Edge> = serde_json::from_str(&content)?;
            for edge in edges {
                graph.add_edge(edge);
            }
        }

        Ok(graph)
    }
test_save_load_roundtrip function · rust · L66-L90 (25 LOC)
crates/amure-db/src/persistence.rs
    fn test_save_load_roundtrip() {
        let dir = tempfile::tempdir().unwrap();
        let mut g = AmureGraph::new();

        let c = g.add_node(Node::new(
            NodeKind::Claim, "test claim".into(), vec!["test".into()],
        ));
        let r = g.add_node(
            Node::new(NodeKind::Reason, "test reason".into(), vec![])
                .with_status(NodeStatus::Weakened)
        );
        g.add_edge(Edge::new(r, c, EdgeKind::Support).with_note("test edge".into()));

        g.save(dir.path()).unwrap();

        let g2 = AmureGraph::load(dir.path()).unwrap();
        assert_eq!(g2.node_count(), 2);
        assert_eq!(g2.edge_count(), 1);
        assert!(g2.get_node(&c).is_some());
        assert_eq!(g2.get_node(&r).unwrap().status, NodeStatus::Weakened);

        // Adjacency works after load
        let neighbors = g2.neighbors(&c, crate::graph::Direction::In, None);
        assert_eq!(neighbors.len(), 1);
    }
test_load_empty_dir function · rust · L93-L97 (5 LOC)
crates/amure-db/src/persistence.rs
    fn test_load_empty_dir() {
        let dir = tempfile::tempdir().unwrap();
        let g = AmureGraph::load(dir.path()).unwrap();
        assert_eq!(g.node_count(), 0);
    }
default function · rust · L36-L43 (8 LOC)
crates/amure-db/src/search.rs
    fn default() -> Self {
        Self {
            top_k: 10,
            max_hops: 2,
            include_failed: true,
            mmr_lambda: 0.7,
        }
    }
search function · rust · L47-L88 (42 LOC)
crates/amure-db/src/search.rs
pub fn search(
    graph: &AmureGraph,
    query: &str,
    synonyms: &SynonymDict,
    opts: &SearchOptions,
) -> Vec<SearchResult> {
    let query_tokens = tokenize(query);
    if query_tokens.is_empty() {
        return Vec::new();
    }

    // Layer 1: Token match + synonym expansion
    let expanded = synonyms.expand_all(&query_tokens);
    let entry_points = token_match(graph, &expanded, opts.top_k * 3);

    // Layer 2: Graph walk from entry points
    let candidates = graph_walk(graph, &entry_points, opts.max_hops);

    // Layer 3: MMR reranking
    let mut results = mmr_rerank(graph, candidates, &expanded, opts);

    // Label failed paths
    for r in &mut results {
        if let Some(node) = graph.get_node(&r.node_id) {
            if node.is_failed() {
                r.failed_path = true;
                let reason = node.metadata.get("reject_reason")
                    .and_then(|v| v.as_str())
                    .unwrap_or("기각됨");
                r.path_label = Some
token_match function · rust · L91-L118 (28 LOC)
crates/amure-db/src/search.rs
fn token_match(
    graph: &AmureGraph,
    expanded_tokens: &[String],
    top_k: usize,
) -> Vec<(Uuid, f64)> {
    let token_set: HashSet<&str> = expanded_tokens.iter().map(|s| s.as_str()).collect();
    let n_query = expanded_tokens.len().max(1) as f64;

    let mut scored: Vec<(Uuid, f64)> = graph.nodes.iter().filter_map(|(id, node)| {
        // Keyword match (weight 0.6)
        let kw_matches = node.keywords.iter()
            .filter(|k| token_set.contains(k.to_lowercase().as_str()))
            .count();

        // Statement token match (weight 0.4)
        let node_tokens = node.tokens();
        let text_matches = node_tokens.iter()
            .filter(|t| token_set.contains(t.as_str()))
            .count();

        let score = (kw_matches as f64 * 0.6 + text_matches as f64 * 0.4) / n_query;
        if score > 0.0 { Some((*id, score)) } else { None }
    }).collect();

    scored.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
    scored.trunc
Same scanner, your repo: https://repobility.com — Repobility
jaccard function · rust · L220-L227 (8 LOC)
crates/amure-db/src/search.rs
fn jaccard(a: &HashSet<String>, b: &HashSet<String>) -> f64 {
    if a.is_empty() && b.is_empty() {
        return 0.0;
    }
    let intersection = a.intersection(b).count() as f64;
    let union = a.union(b).count() as f64;
    if union > 0.0 { intersection / union } else { 0.0 }
}
build_test_graph function · rust · L234-L268 (35 LOC)
crates/amure-db/src/search.rs
    fn build_test_graph() -> AmureGraph {
        let mut g = AmureGraph::new();

        let c1 = g.add_node(Node::new(
            NodeKind::Claim,
            "OI 변화량은 momentum의 선행지표다".into(),
            vec!["OI".into(), "momentum".into(), "open_interest".into()],
        ));

        let r1 = g.add_node(Node::new(
            NodeKind::Reason,
            "OI 증가는 conviction 유입을 의미한다".into(),
            vec!["OI".into(), "conviction".into()],
        ));

        let r2 = g.add_node(
            Node::new(
                NodeKind::Reason,
                "거래소별 OI 집계가 달라서 노이즈가 크다".into(),
                vec!["noise".into(), "exchange".into()],
            ).with_status(NodeStatus::Weakened)
        );

        let c2 = g.add_node(Node::new(
            NodeKind::Claim,
            "funding rate 극단값은 mean reversion 시그널이다".into(),
            vec!["funding".into(), "mean_reversion".into()],
        ));

        g.add_edge(Edge::new(r1, c1, EdgeKind::Support));
        g.add_edge(
test_search_basic function · rust · L271-L279 (9 LOC)
crates/amure-db/src/search.rs
    fn test_search_basic() {
        let g = build_test_graph();
        let syn = SynonymDict::new();
        let results = search(&g, "OI momentum", &syn, &SearchOptions::default());

        assert!(!results.is_empty());
        // First result should be the OI claim (direct keyword match)
        assert!(results[0].statement.contains("OI"));
    }
page 1 / 8next ›