AUTOMATED CONTEXT EXTRACTION FROM SOURCE CODE FOR LANGUAGE MODELS
A method implements automated context extraction from source code for language models. The method involves extracting source context data from a source codebase by processing the source codebase. The method further involves extracting external context data from an external codebase by processing the external codebase referenced by the source codebase. The method further involves generating a knowledge graph by processing the source context data and the external context data. The method further involves processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph.
Latest Oracle Patents:
An issue in software development is the extraction of relevant context for applications that utilize language models (e.g., large language models (LLMs)). However, language models may have a limited context length for relevant information to be included. The inclusion of irrelevant context in the input to a model may lead to low-quality outputs from language models, as including irrelevant context feeds the language models with noise.
Relevant contextual information may be extracted but may fail to address the complexity of real-world development scenarios. For example, generating functions with contextual dependencies, such as calls to user-defined functions and project-defined data protocols, remains a challenge. Hallucinations from language models in code generated by the language models arise due to factual knowledge conflicts and project context conflicts. The conflicts may stem from the generated code not complying with background knowledge or from incorrectly used project contexts.
The relevant context for a software engineering task may be spread through a source codebase (e.g., application source code) and external codebases (e.g., third-party dependencies in the application source code). Additionally, changes to the source codebase and the external codebases may further change what is relevant for a given task. For instance, adding a to an external codebase may alter the usage of the application programming interface and change the relevant context for tasks using the application programming interface. A challenge is to automatically extract relevant context into knowledge graphs and interactively display suggestions and improvements for downstream tasks performed by language models.
SUMMARYIn general, in one or more aspects, the disclosure relates to a method for automated context extraction from source code for language models. The method involves extracting source context data from a source codebase by processing the source codebase. The method further involves extracting external context data from an external codebase by processing the external codebase referenced by the source codebase. The method further involves generating a knowledge graph by processing the source context data and the external context data. The method further involves processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph.
In general, in one or more aspects, the disclosure relates to a system that includes at least one processor and an application that executes on the at least one processor. Executing the application performs extracting source context data from a source codebase by processing the source codebase. Executing the application further performs extracting external context data from an external codebase by processing the external codebase referenced by the source codebase. Executing the application further performs generating a knowledge graph by processing the source context data and the external context data. Executing the application further performs processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph.
In general, in one or more aspects, the disclosure relates to a non-transitory computer readable medium including instructions executable by at least one processor. Executing the instructions performs extracting source context data from a source codebase by processing the source codebase. Executing the instructions further performs extracting external context data from an external codebase by processing the external codebase referenced by the source codebase. Executing the instructions further performs generating a knowledge graph by processing the source context data and the external context data. Executing the instructions further performs processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph.
Other aspects of one or more embodiments may be apparent from the following description and the appended claims.
Similar elements in the various figures may be denoted by similar names and reference numerals. The details of the features and elements described in one figure may extend to similarly named features and elements in different figures.
DETAILED DESCRIPTIONSystems and methods implementing the present disclosure process source codebases and external codebases to automatically extract relevant context into knowledge graphs and interactively display suggestions and improvements for downstream tasks. Context data is extracted from a source codebase and from external codebases referenced by the source codebase. The context data is processed to generate a knowledge graph, which is further augmented with edge data derived from static analysis output. The augmented knowledge graph is a representation of the source codebase and the dependencies of the source codebase to external codebases.
The augmented knowledge graph may be used by context extraction agents to generate downstream task prompts. The downstream task prompts may instruct language models to execute software engineering tasks, such as code repair, bug detection, test generation, etc. The codebases may be monitored to identify changes. The codebases may be processed to update the augmented knowledge graph responsive to the changes to keep the context information current.
Systems and methods implementing the present disclosure may integrate with integrated development environments (IDEs) to interactively display issues in source files from the codebases using the augmented knowledge graph in a graphical user interface, enabling features, such as real-time bug highlighting, code suggestion pop-ups, and interactive issue resolution directly within the development environment. Integration improves the integrated development environments to display immediate feedback and insights, enhancing the productivity and the quality of the suggestions and updates generated within the integrated development environments.
Systems and methods implementing the present disclosure improve knowledge graphs, language models, agents, integrated development environments, graphical user interfaces, etc. Knowledge graphs are improved to include relationships between constructs within the software of codebases to provide context for downstream tasks. Language models are improved to include contextual information extracted from knowledge graphs to produce enhanced responses. Agents are improved to extract context of codebases from knowledge graphs to include in prompts to language models. Integrated development environments are improved to incorporate agents to display responses from language models based on context extracted from knowledge graphs. Graphical user interfaces are improved to dynamically display suggestions and fixes to code from codebases.
Turning to
The context extraction application (102) is a component of a computing system. The context extraction application (102) may include a collection of data and programs to extract context from the source codebase (112) and the external codebase (130) to generate the augmented knowledge graph (158). The data and programs utilized by the context extraction application (102) include the source codebase (112), the source context extractor (115), the source context data (118), the static analysis tool (120), the static analysis output (122), the external codebase (130), the external context extractor (132), the external context data (135), the knowledge graph generator (150), the knowledge graph (152), the augmentation engine (155), and the augmented knowledge graph (158).
The source codebase (112) is a collection of data for a software engineering project. The source codebase (112) includes a human-readable collection of source code files that form a specific software project, application, or system. The source codebase (112) may include code authored by developers that may be written in one or more programming languages. The source codebase (112) may also include configuration files, build scripts, non-executable resources, etc., that may be used for compilation and execution.
The components of the source codebase (112) include source code files, which are text files containing instructions written in a programming language, such as Python, Java, C++, or JavaScript. The source codebase (112) may be organized into a hierarchical directory structure, with files logically grouped by functionality or module. The organizational structure manages the complexity of larger software projects. The source codebase (112) may include each of the source files used to generate an executable version of the software, such as the main application logic, incorporated libraries, custom-developed components, etc.
The source codebase (112) includes files in a human-readable format, designed for comprehension and modification by programmers. The source codebase (112) may also include files that are compiled or in machine code, to be executed by a computing system. A version control system may be used to manage the source codebase. Version control systems may track changes over time, facilitate collaborative development, and maintain a history of the software engineering project.
The source code files within the source codebase (112) may include references to other software engineering projects that are not contained within the source codebase (112). For example, one of the source code files may include a reference to the software engineering project represented by the external codebase (130).
In addition to source code files, the source codebase (112) may include related files used during the software development lifecycle. For example, build scripts may be present, which automate the processes of compiling and linking the source code into a runnable application. Configuration files may also be included, which specify the settings and parameters that may control the behavior of the programs generated from the source codebase (112). Documentation may also be included, embedded within the source code itself (e.g., docstrings) or as files in structured text formats (e.g., Markdown) within the source codebase (112). Test files, containing the source code for unit tests, integration tests, and other forms of testing, may also be included within the source codebase (112) that are used to measure the quality and reliability of the programs generated from the source codebase (112).
The source context extractor (115) is an application utilized by the context extraction application (102). Inputs to the source context extractor (115) include the source codebase (112) and the static analysis output (122). Output from the source context extractor (115) includes the source context data (118). The source context extractor (115) processes the source codebase (112) and the static analysis output (122) to generate the source context data (118). For example, the source context extractor (115) may process an abstract syntax tree in the static analysis output (122) to identify programming constructs within the source codebase (112), which are stored in the source context data (118).
The source context data (118) is contextual information extracted from the source codebase (112). The source context data (118) may be stored as structured text (e.g., JavaScript object notation (JSON)) and include information about programming constructs, such as class definitions, methods, fields, variables, imports, etc. The information about the programming constructs may include names and locations of the programming constructs within the source files of the source codebase (112) stored as key-value pairs.
The static analysis tool (120) is an application utilized by the context extraction application (102) to analyze the source code of the source codebase (112). The static analysis tool (120) may perform an analysis on the source code without execution. The static analysis tool (120) may generate several data structures to record the analysis. The data structures generated by the static analysis tool (120) may include an abstract syntax tree, a points-to graph (also referred to as an alias graph), a call graph, a data flow graph, a control flow graph, etc., which form the static analysis output (122).
The static analysis output (122) is the output from the static analysis tool (120). The static analysis output (122) may include multiple data structures, such as an abstract syntax tree, a points-to graph (also referred to as an alias graph), a call graph, a data flow graph, a control flow graph, etc.
The external codebase (130) is a collection of data for a software engineering project that is used by the software engineering project of the source codebase (112). The external codebase (130) may include multiple files written in multiple languages, which may execute to perform functions that are different from the functions performed by the software engineering project of the source codebase (112).
The external context extractor (132) is an application utilized by the context extraction application (102). Inputs to the external context extractor (132) include the external codebase (130) and may also include the static analysis output (122). Output from the external context extractor (132) includes the external context data (135). The external context extractor (132) processes the external codebase (130) and may also process the static analysis output (122) to generate the external context data (135). For example, the external context extractor (132) may process an abstract syntax tree in the static analysis output (122) to identify the application programming interface (API) that is exposed by applications defined by the external codebase (130).
The external context data (135) is contextual information extracted from the external codebase (130). The external context data (135) may be stored as structured text (e.g., JavaScript object notation (JSON)) and include information about the application programming interface exposed by the programs defined by the external codebase (130). The information about the application programming interface may include names of classes and methods defined in the external codebase (130) stored as key-value pairs.
The knowledge graph generator (150) is an application utilized by the context extraction application (102). Inputs to the knowledge graph generator (150) include the source context data (118) and the external context data (135). Output from the knowledge graph generator (150) includes the knowledge graph (152). The knowledge graph generator (150) processes the source context data (118) and the external context data (135) to generate the knowledge graph (152).
The knowledge graph (152) is a data structure representing knowledge organized as a graph. The knowledge graph (152) is composed of nodes, which represent entities that may include programming constructs from the source codebase (112) and the external codebase (130). Connecting the nodes are edges, which delineate the relationships between the entities. Nodes and edges may include properties, which are attributes or characteristics that define additional context and detail.
The knowledge graph (152) may be semantic such that the underlying meaning of the data may be encoded within the structure of the knowledge graph (152). The knowledge graph (152) may be inherently connected, as entities are linked through defined relationships, to form a network of interconnected information. The interconnectedness may be used to explore indirect relationships and discover associations. The knowledge graph (152) may be extensible for the addition of new data and relationships without alterations to the existing structure. The information within the knowledge graph (152) is queryable such that specific data and complex relationships may be retrieved and explored, which may be performed with graph-based query languages. The knowledge graph (152) may be implemented as a programming object that is instantiated on a computing system and is accessible through an application programming interface.
The augmentation engine (155) is an application utilized by the context extraction application (102). Inputs to the augmentation engine (155) include the knowledge graph (152) and the static analysis output (122). Output from the augmentation engine (155) includes the augmented knowledge graph (158). The augmentation engine (155) processes the knowledge graph (152) with the static analysis output (122) to generate the augmented knowledge graph (158). For example, the augmentation engine (155) may process a points-to graph, a call graph, a data flow graph, a control flow graph, etc., from the static analysis output (122) to identify relationships between the programming constructs from the source codebase (112) and the external codebase (130) that are identified in the knowledge graph (152).
The augmented knowledge graph (158) is an enhanced version of the knowledge graph (152). The augmented knowledge graph (158) includes additional edges that define relationships between the nodes of the knowledge graph (152), such as points-to relationships where a pointer variable references a specific object.
The analysis application (162) is a component of a computing system. The analysis application (162) includes a collection of data and programs to perform a downstream task using context about the source codebase (112) accessed through the augmented knowledge graph (158). The downstream task may be a software engineering task, such as code repair, bug detection, test generation, etc., for the source codebase (112). The data and programs utilized by the analysis application (162) include the context extraction prompt (165), the context extraction agent (168), the downstream task prompt (170), the downstream task agent (172), the downstream task response (175), and the language model (180).
The context extraction prompt (165) is a prompt for a language model to extract context from the augmented knowledge graph (158) for a downstream task. A prompt is textual input or instruction that is input to a language model (e.g., a large language model) to generate a specific output referred to as a response. The prompt is an input that directs the language model to generate subsequent text, which may take the form of an answer to a query, the completion of a thought, the execution of a designated task, etc. A prompt is a string of text that may include questions, statements, commands, keywords, examples, etc., with implicit or explicit instructions and contextual information to instruct the language model to produce a response. The context extraction prompt (165) may be specific to a particular downstream task, and other context extraction prompts may be used for different tasks.
The context extraction agent (168) is a component of the analysis application (162). The context extraction agent (168) may include programs that process and execute the context extraction prompt (165) to generate the downstream task prompt (170) using the language model (180). Responsive to instructions in the context extraction prompt (165), the context extraction agent (168) may utilize application programming interface calls to the programming object that instantiates the augmented knowledge graph (158) to extract the context relevant to the downstream task from the augmented knowledge graph (158) for the downstream task prompt (170).
The downstream task prompt (170) is a prompt for the downstream task agent (172) to perform a downstream task. The downstream task prompt (170) may include text with data, instructions, examples, etc., that direct the downstream task agent (172) to generate the downstream task response (175) with context extracted from the augmented knowledge graph (158) and included in the downstream task prompt (170). The downstream task prompt (170) may be dynamically generated in response to a specific downstream task and as a response to the context extraction prompt (165). For example, for bug repair, the downstream task prompt (170) may be generated in response to processing the context extraction prompt (165) and may include data that was extracted from the augmented knowledge graph (158).
The downstream task agent (172) is a component of the analysis application (162). The downstream task agent (172) may include programs that process and execute the downstream task prompt (170) to generate the downstream task response (175) using the language model (180). Responsive to instructions in the downstream task prompt (170), the downstream task agent (172) may perform a downstream task using the language model (180).
The downstream task response (175) is the output from the language model (180) in response to the downstream task prompt (170). The downstream task response (175) may include text generated by the language model (180) that performs a downstream task. For example, with bug repair, the downstream task response (175) may include snippets of code that may be incorporated into the source codebase (112) to remove a bug from the source codebase (112).
The language model (180) is a component utilized by the analysis application (162) to process prompts and generate responses. The language model (180) processes the downstream task prompt, which includes context extracted from the augmented knowledge graph, to generate a response tailored to the specific software engineering task. The language model (180) may be the same language model used within the context extraction agent (168) to process the context extraction prompt (165).
Turning to
Block 202 involves extracting source context data from the source codebase by processing a source codebase. Processing the source codebase may involve identifying source files within the source codebase and processing the source files to identify programming constructs and relations between the programming constructs. The process may involve the acquisition and storage of the source codebase, where the system retrieves the source files from a location, which could be a local directory, a version control repository, a remote server, etc., and storing the source files in memory. The system may perform lexical analysis where the raw stream of characters that constitutes the source code is broken down into a sequence of programming language tokens that identify keywords, identifiers, operators, literals, etc.
The programming language tokenization differs from natural language tokenization for language models in that the tokens for a programming language represent discrete programming constructs, whereas the tokens for natural language represent sequences of characters used in natural language. The distinction in tokenization provides for identifying programming constructs to extract meaningful context from the source code. The programming language tokenization process may be carried out by a lexer that identifies and categorizes elements, such as keywords, identifiers, operators, and literals, forming the basic vocabulary. Syntactic analysis, or parsing, is performed where the stream of tokens is examined for adherence to the grammatical rules of the programming language. After syntactic analysis, contextual information extraction may be performed. Contextual information extraction is where specific details about the source code are identified and retrieved, such as function signatures detailing names and parameters, class structures outlining attributes and methods, variable declarations specifying names and types, and information regarding control flow and data flow within the program.
Processing the source codebase may involve processing the source codebase to generate and store an abstract syntax tree that represents a program from the source codebase. Generation of the abstract syntax tree may be by a parser as part of syntactic analysis after lexical analysis. The parser takes a sequential stream of programming language tokens representing the source code and analyzes the tokens according to the grammatical rules defined by the programming language. The parser determines if the sequence of tokens forms a valid program construct according to the syntax of the language. As the parser analyzes the token stream and verifies the syntax, the parser may simultaneously construct the abstract syntax tree (AST). Constructing the abstract syntax tree involves creating a hierarchical, tree-like data structure that embodies the syntactic structure of the program. Unlike a concrete syntax tree, the abstract syntax tree may remove some of the surface-level syntactic details, such as specific delimiters or grouping symbols, to focus on representing the underlying semantic relationships between the different elements of the code, with each node in the tree corresponding to a specific construct like an expression, a statement, a declaration, etc. The computing system may store the abstract syntax tree.
Processing the source codebase may involve processing the abstract syntax tree to extract the source context data. Once the abstract syntax tree (AST) is generated, the computing system begins traversing the tree to extract the source context data. The traversal may be performed using various methods, such as depth-first search (DFS) or breadth-first search (BFS). During the traversal, each node in the tree is visited.
As the system traverses the nodes of the abstract syntax tree, each node may be analyzed individually. Nodes in the abstract syntax tree represent different programming constructs in the source code, such as variables, functions, loops, and expressions. The system examines the type and attributes of each node to understand the role within the source code.
For each node encountered during traversal, relevant context data may be extracted. The extraction involves identifying variable declarations, function definitions, control structures, and expressions. Information about where variables are declared is gathered, including the scope and usage of the variables. Details about functions may also be extracted, including the names, parameters, return types, bodies, etc., from the functions. Control structures like loops and conditionals may be analyzed to document the flow of execution.
Block 205 involves extracting external context data from the external codebase by processing an external codebase referenced by the source codebase. References to the external codebases are identified within the source codebase. The references may include import statements, library dependencies, application programming interface calls, module inclusions, etc. Once the external references are identified, the external codebase is fetched. The retrieval may involve downloading the code from repositories, accessing remote servers, or retrieving files from specified locations.
Processing the external codebase may involve processing the source codebase to identify one or more references to the external codebase. To identify references to an external codebase within a source codebase, references are extracted by identifying import statements and external application programming interface calls. The extraction involves scanning the source code for explicit references to external modules or packages and recognizing function calls, class instantiations, or other application programming interface usages that belong to the external codebase. Once the references are extracted, cross-references are generated by matching identifiers in the source code with those in the external codebase to find potential references. A dependency analysis may be performed to determine if certain modules or packages from the external codebase are being used.
Processing the external codebase may involve cloning the external codebase by downloading a copy from a remote repository to generate a local external codebase copy for analysis. Cloning involves creating a local copy to enable analysis without modifying the original codebase, ensuring that the context extraction process does not interfere with the live code. The cloning process includes transferring source code files, configuration files, documentation, and any other relevant assets while preserving the directory structure and file hierarchy in the cloned copy. Following the data transfer, integrity checks may be performed to confirm that the files have been copied, which may involve comparing file sizes, checksums, or other metadata. Additionally, consistency checks may be conducted to verify that the cloned codebase is complete and free from corruption, ensuring the local external codebase copy matches the original external codebase.
Processing the external codebase may involve processing the local external codebase copy to extract the external context data related to an application programming interface for the external codebase used by a program of the source codebase. To process the local external codebase copy and extract the external context data related to an application programming interface (API) used by a program of the source codebase, the application programming interface elements within the external codebase copy are identified, which may include functions, classes, methods, and endpoints. Metadata related to the application programming interface elements, including the signatures, documentation, and dependencies, is extracted. After extraction, the application programming interface usage in the source codebase is matched with the identified application programming interface elements in the external codebase copy, extracting context data related to the matched application programming interface elements, such as usage examples, parameter descriptions, and return values. The extracted application programming interface context data is checked for accuracy and relevance to the source codebase to verify that relevant context data for the application programming interface has been extracted.
Block 208 involves generating a knowledge graph by processing the source context data and the external context data. To process the source context data and the external context data to generate a knowledge graph, relationships such as function calls, class inheritance, and data dependencies are identified between the entities within the source context data and the external context data. Identifying relationships includes analyzing dependencies, interactions, and hierarchies to create a structure that represents the interactions between the entities. The knowledge graph is constructed by creating nodes for each entity with edges to represent the relationships between the nodes, defining the type and nature of each relationship.
Processing the source context data and the external context data to generate the knowledge graph may involve processing the source context data to generate a set of nodes representing a set of data structures within a program defined in the source codebase. The data structures within the source code are identified, which may include classes, structs, arrays, lists, etc. Metadata related to the identified data structures is extracted, including the definitions, member variables, methods, relationships, etc., for the data structures within the source code. Nodes are created for each data structure to generate the knowledge graph. Attributes for each node are defined, such as the name, type, members, etc., of a data structure.
Processing the source context data and the external context data to generate the knowledge graph may involve processing the source context data to generate a set of edges representing relationships between the set of data structures, such as function calls or class inheritance. Relationships are identified between the data structures within the source context data. Relationship identification involves analyzing dependencies, interactions, and hierarchies to create a structure that represents the interactions and relations between the data structures. Edges are created to represent the relationships between the identified data structures. Attributes for each edge are defined, such as the type and nature of the relationship, including inheritance, composition, and association.
Block 210 involves processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph. The existing knowledge graph is loaded into memory and prepared for processing. The static analysis output is also loaded, which contains additional edge data. Edge data is identified and extracted from the static analysis output, and may include relationships, dependencies, and interactions, such as points-to relationships where a pointer variable references a specific object. The extracted edge data is mapped to the existing nodes in the knowledge graph. The system creates new edges in the knowledge graph based on the static analysis output, defining attributes for each edge, such as the type and nature of the relationship.
Processing the knowledge graph with the static analysis output may involve processing the source codebase to identify one or more points-to relationships, which indicate where a pointer variable references a specific object or memory location. The pointer variables and references within the source code are identified by the computing system. The points-to sets for each pointer are determined, which represent the possible values or memory locations that the pointer may reference. Points-to relationships are extracted by analyzing the interactions between pointers and target variables or memory locations. The relationships are mapped to create a structure that represents how pointers interact with other elements in the code.
Processing the knowledge graph with the static analysis output may involve processing the knowledge graph to update a set of edges of the knowledge graph to include the one or more points-to relationships and form the augmented knowledge graph. Edge data is extracted from the points-to relationships, which includes source and target nodes. The extracted points-to relationships are mapped to the existing nodes in the knowledge graph to identify the points-to relationships between the programming constructs represented by the nodes. Edges in the knowledge graph are created based on the points-to relationships, defining attributes for each edge, such as the type and nature of the relationship.
The method (200) may involve processing the augmented knowledge graph and a context extraction agent to generate a downstream task prompt. The context extraction agent identifies and extracts relevant context data from the augmented knowledge graph, focusing on entities, relationships, and metadata that relate to the downstream task. The system analyzes the extracted context data to identify the relationships and dependencies between entities. A downstream task prompt is created using the analysis of the extracted context data that reflects the relationships and dependencies identified in the augmented knowledge graph. Relevant context is incorporated into the prompt to include details and instructions for the downstream task.
The method (200) may involve processing the downstream task prompt with a language model to execute the downstream task. The downstream task prompt is loaded that contains the instructions and context to execute the downstream task. The language model generates a response (referred to as a downstream task response) that addresses the instructions and context provided in the downstream task prompt. The downstream task response may include text, code, and other outputs used to execute the downstream task. If the downstream task involves specific actions, such as generating code, querying a database, or performing calculations, the actions may be executed based on the downstream task response generated by the language model.
The method (200) may involve processing a context extraction agent to access an application programming interface for the knowledge graph to extract context data from the knowledge graph and convert the context data into text for a downstream task prompt by extracting specific attributes and formatting them into a natural language description, wherein the context data comprises one or more of the source context data and the external context data. The context extraction agent that is responsible for interfacing with the knowledge graph application programming interface and extracting relevant context data is initialized. A connection to the knowledge graph application programming interface is established. The context extraction agent generates one or more queries to the knowledge graph application programming interface to retrieve context data, designed to extract specific entities, relationships, and metadata from the knowledge graph for the downstream task. Based on the queries, the context data is retrieved, which includes one or more of the source context data and the external context data. The context data is converted into text format by extracting specific attributes and formatting them into a natural language description. The system then formulates a downstream task prompt based on the converted text, incorporating relevant context and providing details and instructions for the downstream task.
The method (200) may involve executing a downstream task from a downstream task prompt generated with the augmented knowledge graph to repair an issue in the source codebase. The downstream task prompt that contains the instructions and context for repairing the issue in the source codebase is loaded by a downstream task agent. A downstream task response generated from the downstream task prompt may include instructions and commands to analyze sections of the source codebase to diagnose the issue, using techniques such as static analysis, dynamic analysis, code inspection methods, etc., to determine the cause of the issue. Based on the output of the analysis, the downstream task agent may execute another prompt to generate a solution to repair the issue, which may involve generating revised code, modifying existing code, applying patches, etc. The solution is integrated into the source codebase, e.g., by the downstream task agent issuing a pull request to incorporate the revised code into the source codebase.
The method (200) may involve processing the source codebase and the external codebase periodically to identify a set of changes to one or more of the source codebase and the external codebase. A baseline snapshot of both the source codebase and the external codebase may be created to capture a current state to be used for comparison. Periodic monitoring may be scheduled at specified intervals to check for changes in the codebases. At each interval, changes may be detected by comparing the current state of the codebases to the baseline snapshot. Files that have been added, modified, or deleted may be identified in both the source codebase and the external codebase, and detailed information about the changes may be extracted, including the specific lines of code that have been altered.
The method (200) may involve processing the source codebase and the external codebase to generate updates to the augmented knowledge graph responsive to the set of changes. Changes are identified through comparing the current state of the codebases to the previous state or baseline snapshot. Context data related to the identified changes are extracted, focusing on entities, relationships, and metadata that are relevant to the augmented knowledge graph. The system creates new nodes and edges or updates existing ones in the knowledge graph based on the identified changes, defining attributes for each node and edge, such as the type and nature of the relationship.
The method (200) may involve displaying an issue, such as a syntax error or a bug, in a source file from the source codebase using the augmented knowledge graph and an interactive graphical user interface, where the interface highlights the issue and provides context-aware suggestions. An identifier or description of the issue to be displayed is received by the computing system. The augmented knowledge graph is queried to retrieve relevant information about the issue, including relationships, dependencies, and metadata. One or more source files in the source codebase are identified that are related to the issue based on the knowledge graph data. The relevant portions of the source code from the identified source files are retrieved. A visual representation of the issue within the context of the source code is generated, which may include highlighting the affected lines, adding annotations, and displaying related metadata. Interactive elements for the graphical user interface, such as tooltips, clickable links, and expandable sections, may be generated and presented to provide additional information and facilitate user interaction. The visual representation of the issue is displayed within the interactive graphical user interface, allowing a user to view and interact with the information, and enables user interactions, such as navigating to related code sections, viewing detailed information, and making annotations or comments.
Turning to
Turning to
The values in the key-value pairs of the source context template (400) may be updated to include information from the source codebase. For example, line 13 may be updated to identify the name of the method from the source code (300) as “parse_date” (from line 1 of the source code (300)).
Turning to
Turning to
The classes (602) are definitions of objects and corresponding behaviors within a program, serving as blueprints for creating instances. The super classes (605) are parent classes from which other classes inherit properties and methods, establishing a hierarchy and promoting code reuse. The packages (608) are collections of related classes and interfaces grouped together, facilitating organization and modularity. The interfaces (610) are abstract types that specify methods a class implements for consistent behavior across different classes. The global variables (612) are variables accessible from any part of the program, providing a means to store and retrieve data universally. The comments (615) are annotations in code that explain or clarify the functionality, aiding in readability
And Maintenance.The types (618) define data structures and corresponding properties, specifying the kind of data that may be stored and manipulated. The methods (650) are functions defined within a class to perform specific actions, encapsulating behavior and promoting object-oriented principles. The tokens (652) are the elements of a programming language, such as keywords and operators, which are used to construct the syntax of the code. The source imports (655) involve the inclusion of code from other files within the same project, enabling code reuse and modularity. The external imports (658) refer to the inclusion of code from external libraries or frameworks, expanding functionality and leveraging existing solutions. The exceptions (660) are events that disrupt normal program flow, which may be due to errors, and provide mechanisms for error handling. The annotations (662) are metadata added to code elements to provide additional information, which may be used for configuration or documentation purposes. The invocations (665) are calls to methods or functions to execute corresponding code, triggering the defined behavior. The arguments and parameters (668) are values passed to methods or functions and the variables that receive them, facilitating data exchange and manipulation within the program. The local variables (670) are variables defined within a method or function, accessible within the scope of the method or function, promoting encapsulation and preventing unintended interactions.
The knowledge graph (600) may be generated from an abstract syntax tree that is generated from the source codebase. The knowledge graph (600) may be augmented to include additional edges that identify the relationships between the nodes within the knowledge graph (600).
Turning to
The commented code (700) may be displayed in an interactive graphical user interface of an integrated development environment (IDE). For example, the source code (300) of
Turning to
The revised code (750) may be displayed in an interactive graphical user interface of an integrated development environment (IDE). For example, the source code (300) of
The revised code (750) may be displayed in an interactive graphical user interface of an integrated development environment (IDE). For example, the source code (300) of
One or more embodiments may be implemented on a computing system specifically designed to achieve an improved technological result. When implemented in a computing system, the features and elements of the disclosure provide a significant technological advancement over computing systems that do not implement the features and elements of the disclosure. Any combination of mobile, desktop, server, router, switch, embedded device, or other types of hardware may be improved by including the features and elements described in the disclosure.
For example, as shown in
The input device(s) (810) may include a touchscreen, keyboard, mouse, microphone, touchpad, electronic pen, or any other type of input device. The input device(s) (810) may receive inputs from a user that are responsive to data and messages presented by the output device(s) (812). The inputs may include text input, audio input, video input, etc., which may be processed and transmitted by the computing system (800) in accordance with one or more embodiments. The communication interface (808) may include an integrated circuit for connecting the computing system (800) to a network (not shown) (e.g., a local area network (LAN), a wide area network (WAN), such as the Internet, mobile network, or any other type of network) or to another device, such as another computing device, and combinations thereof.
Further, the output device(s) (812) may include a display device, a printer, external storage, or any other output device. One or more of the output device(s) (812) may be the same or different from the input device(s) (810). The input device(s) (810) and output device(s) (812) may be locally or remotely connected to the computer processor(s) (802). Many different types of computing systems exist, and the aforementioned input device(s) (810) and output device(s) (812) may take other forms. The output device(s) (812) may display data and messages that are transmitted and received by the computing system (800). The data and messages may include text, audio, video, etc., and include the data and messages described above in the other figures of the disclosure.
Software instructions in the form of computer readable program code to perform embodiments may be stored, in whole or in part, temporarily or permanently, on a non-transitory computer readable medium, such as a solid state drive (SSD), compact disk (CD), digital video disk (DVD), storage device, a diskette, a tape, flash memory, physical memory, or any other computer readable storage medium. Specifically, the software instructions may correspond to computer readable program code that, when executed by the computer processor(s) (802), is configured to perform one or more embodiments, which may include transmitting, receiving, presenting, and displaying data and messages described in the other figures of the disclosure.
The computing system (800) in
The nodes (e.g., node X (822) and node Y (824)) in the network (820) may be configured to provide services for a client device (826). The services may include receiving requests and transmitting responses to the client device (826). For example, the nodes may be part of a cloud computing system. The client device (826) may be a computing system, such as the computing system shown in
The computing system of
As used herein, the term “connected to” contemplates multiple meanings. A connection may be direct or indirect (e.g., through another component or network). A connection may be wired or wireless. A connection may be a temporary, permanent, or a semi-permanent communication channel between two entities.
The various descriptions of the figures may be combined and may include, or be included within, the features described in the other figures of the application. The various elements, systems, components, and steps shown in the figures may be omitted, repeated, combined, or altered as shown in the figures. Accordingly, the scope of the present disclosure should not be considered limited to the specific arrangements shown in the figures.
In the application, ordinal numbers (e.g., first, second, third, etc.) may be used as an adjective for an element (i.e., any noun in the application). The use of ordinal numbers is not to imply or create any particular ordering of the elements, nor to limit any element to being only a single element unless expressly disclosed, such as by the use of the terms “before,” “after,” “single,” and other such terminology. Rather, ordinal numbers distinguish between the elements. By way of an example, a first element is distinct from a second element, and the first element may encompass more than one element and succeed (or precede) the second element in an ordering of elements.
Further, unless expressly stated otherwise, the conjunction “or” is an inclusive “or” and, as such, automatically includes the conjunction “and,” unless expressly stated otherwise. Further, items joined by the conjunction “or” may include any combination of the items with any number of each item, unless expressly stated otherwise.
In the above description, numerous specific details are set forth in order to provide a more thorough understanding of the disclosure. However, it will be apparent to one of ordinary skill in the art that the technology may be practiced without these specific details. In other instances, well-known features have not been described in detail to avoid unnecessarily complicating the description. Further, other embodiments not explicitly described above can be devised which do not depart from the scope of the claims as disclosed herein. Accordingly, the scope should be limited only by the attached claims.
Claims
1. A method comprising:
- extracting source context data from a source codebase by processing the source codebase;
- extracting external context data from an external codebase by processing the external codebase referenced by the source codebase;
- generating a knowledge graph by processing the source context data and the external context data; and
- processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph.
2. The method of claim 1, further comprising:
- generating a downstream task prompt by processing the augmented knowledge graph and a context extraction agent; and
- executing the downstream task by processing the downstream task prompt with a language model.
3. The method of claim 1, further comprising:
- processing a context extraction agent to access an application programming interface for the knowledge graph to extract context data from the knowledge graph and convert the context data into text for a downstream task prompt by extracting specific attributes and formatting the specific attributes into a natural language description, wherein the context data comprises one or more of the source context data and the external context data.
4. The method of claim 1, further comprising:
- executing a downstream task from a downstream task prompt generated with the augmented knowledge graph to repair an issue in the source codebase.
5. The method of claim 1, wherein processing the source codebase comprises:
- generating and storing, by processing the source codebase, an abstract syntax tree that represents a program from the source codebase; and
- extracting the source context data by processing the abstract syntax tree.
6. The method of claim 1, further comprising:
- processing the source codebase to identify one or more references to the external codebase;
- cloning the external codebase by downloading a copy from a remote repository to generate a local external codebase copy for analysis; and
- processing the local external codebase copy to extract the external context data related to an application programming interface for the external codebase used by a program of the source codebase.
7. The method of claim 1, further comprising:
- processing the source context data to generate a set of nodes representing a set of data structures within a program defined in the source codebase; and
- processing the source context data to generate a set of edges representing relationships between the set of data structures, such as function calls or class inheritance.
8. The method of claim 1, further comprising:
- processing the source codebase to identify one or more points-to relationships, which indicate where a pointer variable references a specific object or memory location; and
- processing the knowledge graph to update a set of edges of the knowledge graph to include the one or more points-to relationships and form the augmented knowledge graph.
9. The method of claim 1, further comprising:
- processing the source codebase and the external codebase periodically to identify a set of changes to one or more of the source codebase and the external codebase; and
- processing the source codebase and the external codebase to generate updates to the augmented knowledge graph responsive to the set of changes.
10. The method of claim 1, further comprising:
- displaying an issue, such as a syntax error or a bug, in a source file from the source
- codebase using the augmented knowledge graph and an interactive graphical user interface, wherein the interactive graphical user interface highlights the issue and provides context-aware suggestions.
11. A system comprising:
- at least one computer processor; and
- an application that, when executing on the at least one computer processor, performs operations comprising:
- extracting source context data from a source codebase by processing the source codebase, extracting external context data from an external codebase by processing the external codebase referenced by the source codebase, generating a knowledge graph by processing the source context data and the external context data, and processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph.
12. The system of claim 11, wherein the application performs operations further comprising:
- generating a downstream task prompt by processing the augmented knowledge graph and a context extraction agent; and
- executing the downstream task by processing the downstream task prompt with a language model.
13. The system of claim 11, wherein the application performs operations further comprising:
- processing a context extraction agent to access an application programming interface for the knowledge graph to extract context data from the knowledge graph and convert the context data into text for a downstream task prompt by extracting specific attributes and formatting the specific attributes into a natural language description, wherein the context data comprises one or more of the source context data and the external context data.
14. The system of claim 11, wherein the application performs operations further comprising:
- executing a downstream task from a downstream task prompt generated with the augmented knowledge graph to repair an issue in the source codebase.
15. The system of claim 11, wherein processing the source codebase comprises:
- generating and storing, by processing the source codebase, an abstract syntax tree that represents a program from the source codebase; and
- extracting the source context data by processing the abstract syntax tree.
16. The system of claim 11, wherein the application performs operations further comprising:
- processing the source codebase to identify one or more references to the external codebase;
- cloning the external codebase by downloading a copy from a remote repository to generate a local external codebase copy for analysis; and
- processing the local external codebase copy to extract the external context data related to an application programming interface for the external codebase used by a program of the source codebase.
17. The system of claim 11, wherein the application performs operations further comprising:
- processing the source context data to generate a set of nodes representing a set of data structures within a program defined in the source codebase; and
- processing the source context data to generate a set of edges representing relationships between the set of data structures, such as function calls or class inheritance.
18. The system of claim 11, wherein the application performs operations further comprising:
- processing the source codebase to identify one or more points-to relationships, which indicate where a pointer variable references a specific object or memory location; and
- processing the knowledge graph to update a set of edges of the knowledge graph to include the one or more points-to relationships and form the augmented knowledge graph.
19. The system of claim 11, wherein the application performs operations further comprising:
- processing the source codebase and the external codebase periodically to identify a set of changes to one or more of the source codebase and the external codebase; and
- processing the source codebase and the external codebase to generate updates to the augmented knowledge graph responsive to the set of changes.
20. A non-transitory computer readable medium comprising instructions executable by at least one computer processor to perform:
- extracting source context data from a source codebase by processing the source codebase;
- extracting external context data from an external codebase by processing the external codebase referenced by the source codebase;
- generating a knowledge graph by processing the source context data and the external context data; and
- processing the knowledge graph with static analysis output to update the knowledge graph with edge data from the static analysis output and form an augmented knowledge graph.
Type: Application
Filed: May 20, 2025
Publication Date: Nov 26, 2026
Applicant: Oracle International Corporation (Redwood Shores, CA)
Inventors: Jovan JANCIC (Wien), Mahinthan CHANDRAMOHAN (Brisbane), Padmanabhan KRISHNAN (Brisbane)
Application Number: 19/213,986