Skip to content

feat(platforms): implement Platform Registry as single source of truth#36

Merged
mischadiehm merged 5 commits intomainfrom
worktree-2025-12-26T05-53-48
Dec 26, 2025
Merged

feat(platforms): implement Platform Registry as single source of truth#36
mischadiehm merged 5 commits intomainfrom
worktree-2025-12-26T05-53-48

Conversation

@mischadiehm
Copy link
Copy Markdown
Contributor

@mischadiehm mischadiehm commented Dec 26, 2025

Overview

Implement a centralized Platform Registry that serves as the single source of truth for all platform metadata. Previously, platform information was scattered across 10+ files. Now adding a new platform requires updating only one file.

Core Implementation

  • registry.py: Pydantic models (PlatformStatus, PlatformCapabilities, PlatformInfo)
  • PLATFORM_REGISTRY: 10 platforms (3 implemented, 3 sequences_only, 4 planned)
  • Deleted 3 redundant constants.py files - registry is now the single source
  • Updated factory.py and operations classes to query registry
  • Updated config.py to use registry for device type validation

CLI Commands

nw platforms list                          # List all platforms
nw platforms list --status implemented     # Filter by status
nw platforms list --vendor cisco           # Filter by vendor
nw platforms list --capability config_backup  # Filter by capability
nw platforms info mikrotik_routeros        # Detailed platform info

Python API

from network_toolkit.api import list_platforms, get_platform_details, PlatformListOptions

# List all platforms
result = list_platforms()

# Filter by status
result = list_platforms(PlatformListOptions(status="implemented"))

# Get details for a specific platform
details = get_platform_details("mikrotik_routeros")

Auto-Generated Documentation

  • scripts/generate_platform_docs.py generates docs from registry
  • Generated files in docs/.generated/ are included via MkDocs snippets
  • Platform tables stay synchronized with code automatically

New Documentation

  • docs/adding-platforms.md: 800-line contributor guide with examples and checklists
  • Updated docs/multi-vendor-support.md with CLI examples
  • Updated docs/vendors/index.md with auto-generated vendor list

Testing

  • 49 registry tests (models, queries, validation, integrity)
  • 24 CLI tests (list filters, info, error handling)
  • 30 API tests (list_platforms, get_platform_details, filtering)
  • Total: 103 new platform-related tests, all passing

Squash commit message

feat(platforms): implement Platform Registry as single source of truth

Replace scattered platform metadata with centralized registry system.
Adding new platforms now requires updating only one file instead of 10+.

- Add registry.py with Pydantic models for platform metadata
- Add PLATFORM_REGISTRY with 10 platforms (MikroTik, Cisco, Arista, etc.)
- Add CLI commands: nw platforms list/info with filtering options
- Add Python API: list_platforms(), get_platform_details()
- Add auto-generation script for documentation from registry
- Add docs/adding-platforms.md contributor guide
- Add 103 tests for registry, CLI, and API
- Delete redundant constants.py files

Test plan

  • All 1087 tests pass
  • Pre-commit checks pass
  • MkDocs builds without warnings in strict mode
  • CLI commands work correctly with all filter options
  • Python API exports are accessible from network_toolkit.api

…endor

Replace legacy firmware calls with “nw firmware {upgrade,downgrade,bios}”
Remove deprecated “nw config-backup”; use “nw backup config” everywhere
Add vendor capability hints: “nw firmware vendors” and “nw backup vendors”
Update supported platforms list for IP targets (add cisco_ios, nokia_srlinux)
Add vendor page: index.md and nav entry; fix nav “Installation”
Correct outdated sequence example to “nw run …”
Refresh vendor guides (Cisco, MikroTik) and Vendors overview
Tweak Scrapli expansion plan wording to match firmware namespace
Fix mkdocs.yml indentation/labels; docs-only changes
Replace scattered platform metadata with centralized registry system.
Now adding platforms requires updating only one file instead of 10+.

Core Implementation:
- Created registry.py with Pydantic models (PlatformStatus, PlatformCapabilities, PlatformInfo)
- PLATFORM_REGISTRY: 10 platforms (3 implemented, 3 sequences_only, 4 planned)
- Deleted 3 constants.py files - registry is single source
- Updated factory.py and operations classes to query registry
- Updated config.py to use registry for device types

CLI Commands:
- nw platforms list (filter by status/vendor/capability)
- nw platforms info <platform>
- Rich tables with status indicators

Documentation:
- Auto-generation script (scripts/generate_platform_docs.py)
- docs/adding-platforms.md (767 line contributor guide)
- Updated multi-vendor-support.md and vendors/index.md with snippets

Testing:
- 49 registry tests (models, queries, validation, integrity)
- 24 CLI tests (list filters, info, error handling)
- All 73 platform tests passing

CI/CD:
- Added generate-docs task to Taskfile.yml
- Added doc generation to GitHub Actions workflow

Benefits: Single file updates, auto-generated docs, self-service CLI, type-safe validation
Integrate main branch changes with Platform Registry feature.

Resolved conflicts:
- .github/copilot-instructions.md: accepted main's phrasing
- .github/workflows/docs.yml: merged both, kept validation + added platform doc gen
- Taskfile.yml: merged task dependencies from both branches
- docs/backups.md: accepted main (removed deprecated --store-results)
- docs/multi-vendor-support.md: accepted main's CLI syntax
- src/network_toolkit/cli.py: kept both register_sync and register_platforms

Main branch additions merged:
- API layer (12 modules) for CLI/Library separation
- Inventory system (Nornir, SSH config sync)
- Multi-inventory support and session pooling
- LLM agent configurations
- Extensive test coverage

This branch additions preserved:
- Platform Registry as single source of truth
- nw platforms list/info CLI commands
- Auto-generated platform documentation
- Nokia SR Linux vendor page
- Add api/platforms.py with list_platforms() and get_platform_details()
- Refactor commands/platforms.py to use API layer (CLI/Library separation)
- Export platform API types from api/__init__.py
- Fix broken doc links in generate_platform_docs.py (remove ../ prefix)
- Add CLI docs generation step to docs.yml CI workflow
- Fix outdated test expecting Cisco to not support config_backup
- Add comprehensive unit tests for api/platforms.py (30 tests)
The vendor_list.md is included from docs/vendors/index.md via pymdownx.snippets.
Links to vendor docs like 'vendors/mikrotik/index.md' were becoming
'vendors/vendors/mikrotik/index.md' (doubled prefix) when included.

Strip the 'vendors/' prefix in generate_vendor_list() since the file is
included from within the vendors/ directory.
@mischadiehm mischadiehm changed the title feat(platforms): add API layer and fix post-merge issues feat(platforms): implement Platform Registry as single source of truth Dec 26, 2025
@mischadiehm mischadiehm merged commit 67495a8 into main Dec 26, 2025
13 checks passed
@mischadiehm mischadiehm deleted the worktree-2025-12-26T05-53-48 branch December 26, 2025 07:22
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