Skip to content

feat: implement Ports & Adapters architecture and enhance macOS network device collection#20

Merged
kennethdsheridan merged 19 commits into
mainfrom
macos-compatibility
Jul 27, 2025
Merged

feat: implement Ports & Adapters architecture and enhance macOS network device collection#20
kennethdsheridan merged 19 commits into
mainfrom
macos-compatibility

Conversation

@kennethdsheridan
Copy link
Copy Markdown
Contributor

@kennethdsheridan kennethdsheridan commented Jul 26, 2025

Summary

  • Implemented complete Ports & Adapters architecture while maintaining backward compatibility
  • Enhanced macOS network device information collection with real system data
  • Fixed Apple Silicon hardware identification to use Apple Fabric instead of PCIe

Test plan

  • Run nix build to verify build succeeds
  • Run ./result/bin/hardware_report on macOS to verify enhanced network information
  • Verify backward compatibility with legacy ServerInfo API
  • Check that all tests pass in Nix sandbox environment
  • All CI checks passing (formatting, linting, clippy)

Commits

  1. 119e6c7 - implement Ports & Adapters architecture foundation
  2. da99610 - feat: generate both JSON and TOML output files
  3. ccfe905 - feat: enhance macOS network device information collection
  4. 1e60729 - feat: add macOS compatibility while maintaining Linux functionality
  5. 870b1f0 - fix: resolve macOS compatibility issues and improve hardware detection
  6. 1e02e9d - fix: resolve Nix build compatibility issues
  7. 07dfec5 - fix: resolve macOS CPU core parsing test failure
  8. 238baed - fix: make command executor tests compatible with Nix sandbox
  9. 3597860 - fix: correct doctest examples for create_service function
  10. 545d1da - fix: apply cargo fmt formatting corrections
  11. 05eae10 - fix: remove unused imports and variables
  12. cf40114 - fix: apply final cargo fmt corrections
  13. fe5a65e - fix: resolve all clippy warnings
  14. c32cf7a - fix: apply final cargo fmt adjustments
  15. 4f23c4b - fix: resolve all remaining clippy warnings (88 total)

Key Achievements

  • ✅ Implemented complete Ports & Adapters (Hexagonal) architecture
  • ✅ Enhanced network device information collection for macOS
  • ✅ Fixed all "Unknown" values in network interfaces
  • ✅ Properly represented Apple Silicon architecture with "Apple Fabric (Integrated)"
  • ✅ Maintained 100% backward compatibility with legacy API
  • ✅ All CI checks passing (formatting, linting, clippy, tests)
  • ✅ Zero compiler warnings with -D warnings flag
  • ✅ Clean, idiomatic Rust code following best practices

- Add platform-specific system information gathering using system_profiler, sysctl, and ioreg on macOS
- Implement conditional compilation with cfg!(target_os = "macos") for platform-specific code paths
- Add macOS-specific implementations for CPU, memory, storage, GPU, and system info collection
- Update Nix flake to handle platform-specific runtime dependencies (Linux tools vs macOS built-ins)
- Enhance storage size parsing to handle both Linux (123G) and macOS (123 GB) formats
- Disable Linux-specific features (NUMA topology, IPMI/BMC) on macOS
- Update documentation to reflect macOS compatibility and system requirements
- Maintain full backwards compatibility with existing Linux functionality
- Successfully tested on Apple Silicon (M3 Max) with 16 cores, 64GB RAM, and multiple storage devices
- Fix CPU model detection to recognize 'Chip:' field for Apple Silicon Macs
- Add platform-specific BIOS/firmware and chassis information gathering for macOS
- Update main binary to avoid calling dmidecode on macOS (prevents 'No such file or directory' error)
- Improve system info extraction to include chip information in product name
- Add proper macOS chassis type detection (Laptop, Desktop, All-in-One, Mini PC)
- Successfully tested on Apple M4 Max MacBook Pro with complete hardware detection
Always create both JSON and TOML hardware report files regardless of the --file-format flag and display information about both formats being available at the end of the report output.
- Add domain layer with entities, errors, services, and parsers
- Define primary ports (HardwareReportingService) for external consumption
- Define secondary ports (SystemInfoProvider, CommandExecutor, DataPublisher) for dependencies
- Extract pure parsing functions for CPU, memory, storage, network, and system info
- Create legacy compatibility layer with From traits for smooth migration
- Maintain backward compatibility - both binary and library still work
- Add comprehensive example showing both old and new APIs

Next: Implement concrete adapters for system interaction
- Fixed module re-exports to avoid conflicts with legacy types
- Added missing architecture files to git tracking
- Updated examples to use correct import paths
- Resolved ServiceContainer import issues in lib.rs
- Fixed parse_macos_cpu_info to correctly extract core count from 'Total Number of Cores: 10 (8 performance and 2 efficiency)' format
- Added proper whitespace splitting to handle Apple's detailed core descriptions
- All tests now pass successfully
- Modified test_command_availability_check to not require specific commands in PATH
- Updated test_get_command_path to handle missing commands gracefully
- Tests now verify functionality without asserting on command availability
- All tests pass in both normal and sandboxed environments
- Added missing Option<ReportConfig> parameter (None) to create_service() calls
- Fixed both library usage example and function documentation examples
- All doctests now compile and pass successfully
This commit significantly improves network device information on macOS
by integrating real-time data from ifconfig with system_profiler output
and properly implementing Apple Silicon architecture details.

Key improvements:
- Remove spurious "Network" section header interface
- Fix GPU and network interface PCI IDs to show "Apple Fabric (Integrated)"
- Extract real MAC addresses and IP addresses from ifconfig
- Properly classify interface types (AirPort, Ethernet, VPN)
- Add accurate speed estimates for different interface types
- Improve GPU memory descriptions with core counts

The network interfaces now show comprehensive, accurate information
instead of "Unknown" placeholders, providing better hardware visibility
for Apple Silicon systems.
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Jul 26, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/posting.rs  50% smaller
  src/bin/hardware_report.rs  45% smaller
  result  44% smaller
  src/lib.rs  3% smaller
  .direnv/bin/nix-direnv-reload Unsupported file format
  .direnv/flake-inputs/01x5k4nlxcpyd85nnr0b9gm89rm8ff4x-source  0% smaller
  .direnv/flake-inputs/0d3h8gi2q46fb4l563h6pginjw2a90r4-source  0% smaller
  .direnv/flake-inputs/66s1gxivwqgr1n5kzw260mvxxv14l3fj-source  0% smaller
  .direnv/flake-inputs/gim4sdpq0h6c8cnfnrmb8mi75fw73vdk-source  0% smaller
  .direnv/flake-inputs/nfqw3h3qc2mq37v6amw80b1rpi0g9x61-source  0% smaller
  .direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source  0% smaller
  .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa  0% smaller
  .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc Unsupported file format
  Cargo.lock Unsupported file format
  Cargo.toml Unsupported file format
  MYQQGPTJ6J_hardware_report.json  0% smaller
  MYQQGPTJ6J_hardware_report.toml Unsupported file format
  MYQQGPTJ6J_new_architecture_report.json  0% smaller
  MYQQGPTJ6J_new_architecture_report.toml Unsupported file format
  README.md Unsupported file format
  Unknown_S_N_hardware_report.toml Unsupported file format
  examples/library_usage.rs  0% smaller
  examples/new_architecture_demo.rs  0% smaller
  flake.nix Unsupported file format
  src/adapters/mod.rs  0% smaller
  src/adapters/primary/mod.rs  0% smaller
  src/adapters/secondary/command/mod.rs  0% smaller
  src/adapters/secondary/command/unix.rs  0% smaller
  src/adapters/secondary/mod.rs  0% smaller
  src/adapters/secondary/publisher/file.rs  0% smaller
  src/adapters/secondary/publisher/http.rs  0% smaller
  src/adapters/secondary/publisher/mod.rs  0% smaller
  src/adapters/secondary/system/linux.rs  0% smaller
  src/adapters/secondary/system/macos.rs  0% smaller
  src/adapters/secondary/system/mod.rs  0% smaller
  src/container.rs  0% smaller
  src/domain/entities.rs  0% smaller
  src/domain/errors.rs  0% smaller
  src/domain/legacy_compat.rs  0% smaller
  src/domain/mod.rs  0% smaller
  src/domain/parsers/common.rs  0% smaller
  src/domain/parsers/cpu.rs  0% smaller
  src/domain/parsers/memory.rs  0% smaller
  src/domain/parsers/mod.rs  0% smaller
  src/domain/parsers/network.rs  0% smaller
  src/domain/parsers/storage.rs  0% smaller
  src/domain/parsers/system.rs  0% smaller
  src/domain/services/hardware_collection.rs  0% smaller
  src/domain/services/mod.rs  0% smaller
  src/ports/mod.rs  0% smaller
  src/ports/primary/mod.rs  0% smaller
  src/ports/primary/reporting.rs  0% smaller
  src/ports/secondary/command.rs  0% smaller
  src/ports/secondary/config.rs  0% smaller
  src/ports/secondary/mod.rs  0% smaller
  src/ports/secondary/publisher.rs  0% smaller
  src/ports/secondary/system.rs  0% smaller

kennethdsheridan and others added 10 commits July 26, 2025 16:01
- Remove unnecessary mut keywords
- Mark unused fields with #[allow(dead_code)]
- Rename default() methods to with_defaults() to avoid trait confusion
- Use inline format strings instead of positional parameters
- Replace redundant closures with direct function references
- Fix all format string interpolations to use inline variables
- Fix collapsible if statement in macOS GPU detection
- Replace redundant closures with direct function references
- Rename default() methods to with_defaults() to avoid trait conflicts
- Fix trim before split_whitespace redundancy
- Reduce function argument count using parameter struct
- Add derivable Default implementation with #[derive(Default)]
- Update all format strings to use inline variable interpolation
- Fix unused variables in examples and binary
- Auto-fix various other clippy suggestions
- Fix multi-line expression formatting in linux.rs system adapter
- Apply consistent code formatting in hardware collection service
- Ensure formatting matches CI environment expectations
- All 88 clippy warnings remain resolved
- All tests continue to pass (33/33)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix 57 uninlined format args warnings across multiple files
- Update format strings to use inline variable interpolation
- Improve error message formatting in domain error types
- Optimize string formatting in parsers and system adapters
- All clippy warnings now resolved (0 total)
- All tests continue to pass (33/33)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix println\! format string warnings in hardware_report binary
- Update output filename generation to use inline variables
- Improve console output formatting consistency
- All clippy warnings now completely resolved
- All tests continue to pass (33/33)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix the last remaining println\! format string warning
- Update NUMA topology distance display to use inline variables
- Achieve complete clippy compliance with zero warnings
- All tests continue to pass (33/33)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kennethdsheridan kennethdsheridan merged commit 81b33ec into main Jul 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant