refactor: extract addon source scanner - #51
Conversation
|
@barry166 heads-up: today main took #48 (new |
The source scanner has an independent AST/XML boundary and should remain usable without coupling its implementation to the broader agent helper module. Compatibility re-exports preserve existing callers while the new module boundary is covered directly. Constraint: Preserve both addon-scanner and field-ranking compatibility re-exports after rebasing. Confidence: high Scope-risk: narrow Directive: Keep addon scanner helpers isolated from MCP surface modules and retain agent_tools compatibility imports. Tested: 910 pytest tests; Ruff; mypy; Black; import-linter; git diff checks. Not-tested: Live Odoo addon directory smoke test.
da1b566 to
9ab75d7
Compare
|
Rebased onto Local verification: 910 tests, Ruff, mypy, Black, and both import-linter contracts. The branch is mergeable and CI is green. |
tuanle96
left a comment
There was a problem hiding this comment.
Thanks for rebasing and preserving both re-export blocks. The branch is clean and the broad gates are healthy: 910 tests pass in an isolated HOME/XDG environment, Ruff and mypy pass, both import-linter contracts are kept, and the direct structural/architecture checks pass.
One compatibility blocker remains from the previous review: the legacy agent_tools monkeypatch surface still does not work end-to-end.
The new test only proves import identity:
assert getattr(agent_tools, name) is getattr(addon_scanner, name)That does not preserve late-bound helper lookup. scan_addons_source_report.__globals__ now belongs to odoo_mcp.addon_scanner, so a test or downstream consumer that patches agent_tools._normalize_scan_paths no longer affects the re-exported function. Reproduction on current head 9ab75d7:
from odoo_mcp import agent_tools
sentinel = "/tmp/legacy-agent-tools-monkeypatch-sentinel"
agent_tools._normalize_scan_paths = lambda _: [sentinel]
result = agent_tools.scan_addons_source_report(addons_paths=None, max_files=1)
assert result["paths"] == [sentinel]Current result:
expected: ['/tmp/legacy-agent-tools-monkeypatch-sentinel']
actual: []
function globals: odoo_mcp.addon_scanner
Please add an end-to-end regression that patches the legacy agent_tools namespace and proves the patched helper is actually used, then implement a compatibility shim (or explicitly revise the issue's compatibility contract if preserving monkeypatch behavior is no longer intended). Import identity alone is not sufficient.
The review driver also printed a structural PASS while saying the Python structural entry point was skipped; I did not use that as proof. The direct repository runner was executed separately and passed.
The extracted scanner now exposes a private path-resolved core so the agent_tools compatibility wrapper can continue resolving patched helpers in its original namespace without moving scanner logic back across the module boundary. Constraint: Keep addon scanning implemented outside agent_tools while retaining downstream monkeypatch behavior. Rejected: Synchronize module globals during each scan | thread-unsafe and obscures ownership. Confidence: high Scope-risk: narrow Directive: Keep path normalization late-bound in each public module wrapper. Tested: 911 pytest tests; Ruff; mypy; Black; import-linter; git diff check.
|
Fixed the remaining compatibility blocker in
|
tuanle96
left a comment
There was a problem hiding this comment.
Re-reviewed current head 6e05cfdfd967d927b06f28fa3c5591fb5f042ebc against the current MCP 2026-07-28 / SDK v2 main.
The previous compatibility blocker is addressed by the end-to-end legacy agent_tools._normalize_scan_paths monkeypatch regression. I also tested a temporary merge with current origin/main:
- 917 tests passed
- Ruff passed
- mypy passed across 35 source files
- both import-linter contracts were kept
Approved. Issue #31 can close when this PR merges.
Summary
addon_scannermoduleagent_toolsagent_toolshelper monkeypatches effective through a path-resolving compatibility wrapperCloses #31
Coverage
Verification
uv run python -m pytest -q uv run python -m ruff check . uv run python -m mypy src uv run python -m black --check src/odoo_mcp/addon_scanner.py src/odoo_mcp/agent_tools.py tests/test_addon_scanner_module.py PYTHONPATH=src uvx --from import-linter lint-imports git diff --checkResult: 911 tests passed; both import-linter contracts were kept.
Checklist
Notes for reviewers
The compatibility coverage now verifies both direct helper re-exports and the end-to-end late-bound lookup used when downstream code patches
agent_tools._normalize_scan_paths.