K2Trace: Scaling Software Traceability with Structural Knowledge Mining

A Self-enhanced Automatic Traceability Link Recovery via Structure Knowledge Mining for Small-scale Labeled Data

2021-07-01
Lei Chen, Dandan Wang, Lin Shi, Qing Wang
Summary
Problem
Method
Results
Takeaways
Abstract

This paper introduces K2Trace, a self-enhanced supervised framework for automated Requirement-to-Code (R2C) traceability link recovery. It leverages structure knowledge mining and transitive relationship reasoning to achieve state-of-the-art performance, specifically targeting projects with small-scale labeled data.

Executive Summary

In the lifecycle of software evolution, maintaining the "thread" between high-level requirements and actual source code is notoriously difficult. K2Trace, a novel framework presented in this paper, addresses the "data scarcity" problem in supervised traceability recovery. By mining structure knowledge—the complex web of how code calls code and how requirements relate—the authors have built a system that outperforms state-of-the-art models like ALCATRAL, even when provided with 70% less training data.

Problem & Motivation: The "Labeling Debt"

Automated traceability recovery usually falls into two camps:

  1. Unsupervised IR: Simple, but fails at "term mismatch" (e.g., a requirement says "Security" while code says Authenticator).
  2. Supervised Learning: Effective, but "hungry" for labeled data. Most models require developers to manually verify thousands of links to train the AI.

The authors identify a critical oversight in previous works: they treat requirements and code as isolated bags of words, ignoring the contextual ecosystem. A requirement for "Login" doesn't just link to a LoginServlet; it is contextually tied to UserRole, DatabaseConnection, and SessionManager through structural dependencies.

Methodology: Fusing Semantics and Structure

K2Trace operates on a multi-step pipeline that transforms raw artifacts into a multidimensional feature space.

1. The Requirement-Code Knowledge Graph

The authors build a Knowledge Graph (KG) defining 14 types of relationships, including code-level (method calls, inheritance, field types) and requirement-level (includes, extends, implies).

2. Relation-Aware Representation (TransR + CNN)

Unlike traditional models that use simple word embeddings, K2Trace uses a Complex Relation-aware Knowledge Representation Learning model. It combines:

  • Textual Semantics: Extracted via a Convolutional Neural Network (CNN) from descriptions and comments.
  • Structural Context: Encoded using TransR, which projects entities (requirements/code) into a relation-specific space.

Physical Intuition: If a Role class and a Login requirement share a similar structural neighborhood (both interact with Permissions), their embeddings are pulled closer together even if their text doesn't match.

Overall Framework of K2Trace

3. Self-Enhancement via Transitive Reasoning

To solve the data scarcity problem, K2Trace uses Inference Rules. By calculating "Closeness" (based on shared data types and method call frequency), the system identifies transitive links.

  • Example: If Req A links to Class B, and Class B has a high closeness score with Class C, the system automatically infers a potential link between Req A and Class C, essentially labeling its own training data.

Experiments & Results: Doing More with Less

The authors tested K2Trace on three benchmarks: eAnci, eTour, and SMOS.

SOTA Comparison

The most striking result is the performance at low data volumes. With only 10% of data labeled, K2Trace achieved an F1-score average of 59.0%, whereas the baseline ALCATRAL trailed at 47.4%.

Ablation Study Highlights

  • The Power of Context: Using only context embeddings (structural info) outperformed using only text embeddings in some scenarios, proving structure is a high-signal feature.
  • Automatic Expansion: The inference rules boosted the F1-score by 10.2% on average for small training sets, effectively replacing human effort with quantitative reasoning.

Performance Comparison

Critical Analysis & Conclusion

Takeaways: This work shifts the focus from "bigger models" to "smarter features." By exploiting the Inherent Structure of software, K2Trace bridges the logical abstraction gap. It proves that the "logic" of a system is encoded in its structure as much as its documentation.

Limitations:

  1. Language Specificity: Currently optimized for Java. Translating this to loosely typed languages (Python) or different architectures (Microservices) might require rethinking the closeness metrics.
  2. Noise at Scale: Interestingly, the paper notes that when 90% of data is available, the inference rules can actually add noise, slightly decreasing performance. This suggests the rules are best used as a cold-start mechanism.

Future Outlook: In the age of Large Language Models (LLMs), K2Trace provides a grounded approach. Combining the structural reasoning of K2Trace with the generative power of LLMs could lead to "Zero-shot" traceability recovery with near-human accuracy.

Find Similar Papers

Try Our Examples

  • Search for recent papers that utilize Knowledge Graph Embeddings or Graph Neural Networks for software traceability link recovery beyond 2021.
  • How does the use of TransR in software engineering tasks compare to more recent rotation-based or hyperbolic graph embedding models like RotatE or MuRE?
  • Find research that applies the concept of "Transitive Traceability Links" to cross-project or multi-modal software maintenance tasks.
Contents
K2Trace: Scaling Software Traceability with Structural Knowledge Mining
1. Executive Summary
2. Problem & Motivation: The "Labeling Debt"
3. Methodology: Fusing Semantics and Structure
3.1. 1. The Requirement-Code Knowledge Graph
3.2. 2. Relation-Aware Representation (TransR + CNN)
3.3. 3. Self-Enhancement via Transitive Reasoning
4. Experiments & Results: Doing More with Less
4.1. SOTA Comparison
4.2. Ablation Study Highlights
5. Critical Analysis & Conclusion