Resolve¶
resolve
¶
Dependency graph resolution for KB symbol precedence.
Given a custom module and a list of symbol entries (each from a different upstream module), this module selects the most relevant entry — i.e. the one that is closest to the custom module in the dependency graph.
Algorithm¶
- Build the full transitive dependency list of the custom module by walking
the
dependsgraph from the KB (BFS, closest-first). - For each symbol entry, compute its position in that list (lower index = closer to the custom module = higher precedence).
- Return the entry with the lowest index (most specific).
- Tie-break with the static tier order: third-party > apik > enterprise > odoo.
- If the symbol is not found in the depends chain at all, fall back to tier order and emit a warning.
Functions:
| Name | Description |
|---|---|
build_depends_chain |
Return the ordered transitive dependency list of a module (BFS). |
format_source_line |
Format a Source: line for a docstring from a KB entry. |
resolve_symbol |
Select the most relevant KB entry for a symbol. |
build_depends_chain
¶
Return the ordered transitive dependency list of a module (BFS).
The result is ordered from most specific (direct depends of module)
to least specific (deep transitive dependencies). module itself is
NOT included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
the starting module name. |
required |
|
Dict[str, Dict[str, Any]]
|
{ name: {"origin": str, "depends": [str, ...]} } as returned by KBReader.get_modules(). |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
Ordered list of module names, closest first. |
List[str]
|
Modules absent from the index are silently skipped. |
Source code in src/oops/kb/resolve.py
format_source_line
¶
Format a Source: line for a docstring from a KB entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Dict[str, Any]
|
A KB symbol dict with |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted string like |
Source code in src/oops/kb/resolve.py
resolve_symbol
¶
resolve_symbol(entries: List[Dict[str, Any]], custom_module: str, modules_index: Dict[str, Dict[str, Any]]) -> Optional[Dict[str, Any]]
Select the most relevant KB entry for a symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
List[Dict[str, Any]]
|
list of dicts from KBReader.get_symbol(), each with at least 'module' and 'origin' keys. |
required |
|
str
|
name of the module being refactored. |
required |
|
Dict[str, Dict[str, Any]]
|
full modules dict from KBReader.get_modules(). |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
The selected entry dict, or None if entries is empty. |