Repository navigation
Conversation
… inventory_sources Move the 32 source collection and command planning methods of InventoryService, the two source DTOs and the twelve module constants they read into app/services/inventory_sources.py, as InventorySourceCollectionMixin. InventoryService inherits the mixin, so the methods stay methods of the same instance and class: self and cls lookups stay late-bound and the collector state stays on the service. The moved lines are unchanged. app.services.inventory keeps every name it had: the constants and DTOs are re-exported as the same objects. The new module does not import the inventory module; the inventory module binds itself at the end of its import, and the three leaf helpers that stay there are looked up on it at each call. The moved code logs through the same logger object. One existing assertion is widened to accept the new file name in logged stack frames. The inventory.py size ceiling is lowered to 18250. No behaviour change. Refs #1328
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
What moved
The source collection and command planning block of
InventoryServicemoves fromapp/services/inventory.pyinto the new moduleapp/services/inventory_sources.py:_summarize_ssh_failuresto_collect_inventory_source_bundle(1,172 lines), intoInventorySourceCollectionMixin;SourcePublicationandInventorySourceBundle;SSH_FAILURE_CONTEXTS_BY_COMMAND,SSH_FAILURE_CONTEXTS_BY_PREFIX,MPRUTIL_UNIT_COMMAND_PATTERN,MPRUTIL_UNNUMBERED_READ_PATTERN,MPRUTIL_SUBCOMMAND_LABELS,DEFAULT_SSH_FAILURE_CONTEXT,SSH_COMMAND_FAILURE_REASON,SCALE_CONFIGURED_SG_SES_FAILURE_REGEX,SSH_LOGIN_FAILURE_REASONS,SSH_PARTIAL_INTERNAL_ERROR_STATUS,LINUX_NVME_LIST_SUBSYS_COMMAND,LINUX_ENCLOSURE_SYSFS_MAP_COMMAND.Every moved line is unchanged apart from leading whitespace. Source TTLs, cache admission, publication, locks and generations stay on
InventoryService.How the old names keep working
InventoryServiceinheritsInventorySourceCollectionMixin. The methods stay methods of the same instance and class, with the same kind (instance, class or static method) and signature.self.andcls.lookups stay late-bound, so a replacement on the instance or on the class still reaches moved code, and the collector state attributes stay on the service instance.app.services.inventoryre-exports every moved constant and DTO by name; they are the same objects.app.services.inventory. That module callsinventory_sources.bind_facade(...)at the end of its import._drain_inventory_worker,_certificate_verify_code_labeland_public_source_failure_messagestay ininventory.py; the moved code calls them through three one-line wrappers that look them up on the inventory module at each call, so a replacement there still takes effect. The literalInventoryService.reads in one moved static method read the class bound bybind_facade; nothing subclassesInventoryService.logging.getLogger("app.services.inventory").inventory.py, markednoqa: F401, so those names stay importable from it.Behaviour
Unchanged. The only visible difference is the file name inside logged stack frames of the internal-error log line, which now reads
inventory_sources.py:<line>for frames in moved code. Message text, category, level and logger name do not change. One existing assertion that pinnedinventory.pyin those frames is widened in one line to accept either file name; it still requires a frame (tests/test_inventory_status_error_text.py:673).Tests
New class
InventorySourceCollectionModuleTestsintests/test_inventory.py, 8 tests. All 8 fail on the base commit because the new module does not exist (1 failure, 7 errors). They check that the new module imports without the inventory module, that every moved method and name is reachable where it was, that replacements made on the instance, on the class and on the inventory module still reach moved code (each with a control case), that moved code logs through the inventory logger, and that the mixin docstring lists exactly what the mixin reads on its host.Local runs, all OK, 0 failed:
python -m unittest tests.test_inventory: 617 run.tests.test_account_bootstrap tests.test_background_refresh_busy_routes tests.test_background_refresh_deadlines tests.test_bounded_parser_work tests.test_combined_shelf_upgrade tests.test_core_counter_markers tests.test_core_fabric_legacy_controller tests.test_disk_retention_accounting tests.test_history_service tests.test_inventory_status_error_text tests.test_platform_parity_fixtures tests.test_route_contracts tests.test_sas_fabric tests.test_ssh_connection_keep tests.test_ssh_diagnostic_safety tests.test_ssh_failure_contexts tests.test_truenas_middleware_limits tests.test_ses_unknown_occupancy_consumers tests.test_public_doc_privacy tests.test_source_shape tests.test_unittest_shards tests.test_unittest_identities tests.test_dev_check tests.test_ci_contract tests.test_changelog_fragments): 1,403 run.ruff checkon the touched files andgit diff --check: clean.Size
app/services/inventory.pygoes from 19,284 to 17,929 lines; its ceiling intests/test_source_shape.pyis lowered from 19750 to 18250. The new module has 1,504 lines.Refs #1328