Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
~/.cache/acton
out
key: acton-${{ hashFiles('**/build.act.json') }}-${{ steps.setup-acton.outputs.version }}
- run: acton build --dev
- run: acton build
- run: acton test
- run: acton test perf
- uses: actions/upload-artifact@v4
Expand All @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
TESTENV: [quicklab-crpd, quicklab-xrd]
TESTENV: [quicklab-crpd, quicklab-xrd, quicklab-xe]
runs-on: ubuntu-24.04
env:
IMAGE_PATH: ${{ secrets.IMAGE_PATH || format('ghcr.io/{0}/', github.repository) }}
Expand Down
75 changes: 53 additions & 22 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Build Commands

- **Build project**: `acton build --dev`
- **Build project**: `acton build`
- **Run tests**: `acton test`

## Testing

### Running Tests
- **Run all tests**: `acton test`
- **Run all tests from a module**: `acton test --module <module_name>`
- Example: `acton test --module test_drivers`
- **Run specific test**: `acton test --name <test_name>` (use function name WITHOUT `_test_` prefix)
- Example: For function `_test_driver_state_transition_validation`, run: `acton test --name driver_state_transition_validation`
- **Update golden files**: `acton test --name <test_name> --golden-update`
- Updates expected output when test behavior changes intentionally
- Note: The test will show as "FAIL" once while updating the golden file - this is expected behavior
- **Golden files location**: `test/golden/<module_name>/<test_name>`

## Project Structure

This is the netcli package - a CLI client library system built on Acton with the following architecture:
Expand Down Expand Up @@ -34,34 +47,52 @@ The project provides CLI client libraries for network device management:

### Router Driver System (`src/drivers.act`)
- **Formal State Machine Architecture**: Implements a complete state machine for router device interactions
- **Multi-Platform Support**: Base driver with Juniper JUNOS and Cisco IOS XR implementations
- **Multi-Platform Support**: Base driver with Juniper JUNOS, Cisco IOS XR, and Cisco IOS XE implementations
- **State-Based Validation**: Prevents invalid operations and ensures proper command sequencing
- **Enhanced Error Handling**: Centralized error management with automatic cleanup and recovery

**Driver State Machine**:
```
INITIALIZING → READY → EXECUTING_COMMAND → READY
↓ ↓
ENTERING_CONFIG → CONFIG_MODE → APPLYING_CONFIG → TRANSACTION_ACTIVE
↓ ↓ ↓ ↓
ROLLING_BACK ABORTING_CONFIG COMMITTING ABORTING_CONFIG
↓ ↓ ↓ ↓
READY ←← READY ←← READY ←← READY
ERROR → READY/DISCONNECTED
State transitions:

INITIALIZING ──→ READY
├──→ EXECUTING_COMMAND ──→ READY
├──→ ENTERING_CONFIG ──→ CONFIG_MODE ──┬──→ APPLYING_CONFIG ──→ COMMITTING ──┬──→ READY
│ │ │
│ └──→ READY (exit) └──→ ABORTING_CONFIG ──→ READY
│ (on failure)
└──→ ROLLING_BACK ──→ READY

Special transitions (from any state):
- Any state ──→ ERROR ──→ READY (recovery)
- Any state ──→ DISCONNECTED ──→ INITIALIZING (reconnect)

Valid state transitions:
- INITIALIZING: → READY, ERROR, DISCONNECTED
- READY: → EXECUTING_COMMAND, ENTERING_CONFIG, ROLLING_BACK, ERROR, DISCONNECTED
- EXECUTING_COMMAND: → READY, ERROR, DISCONNECTED
- ENTERING_CONFIG: → CONFIG_MODE, ERROR, DISCONNECTED
- CONFIG_MODE: → APPLYING_CONFIG, ABORTING_CONFIG, READY, ERROR, DISCONNECTED
- APPLYING_CONFIG: → COMMITTING, ERROR, DISCONNECTED
- COMMITTING: → READY, ABORTING_CONFIG, ERROR, DISCONNECTED
- ABORTING_CONFIG: → READY, ERROR, DISCONNECTED
- ROLLING_BACK: → READY, ERROR, DISCONNECTED
- ERROR: → READY, DISCONNECTED
- DISCONNECTED: → INITIALIZING
```

**Driver States**:
- `INITIALIZING`: Driver startup and initialization
- `READY`: Ready for commands or configuration operations
- `EXECUTING_COMMAND`: Processing a single command
- `ENTERING_CONFIG`: Transitioning to configuration mode
- `CONFIG_MODE`: In device configuration mode
- `CONFIG_MODE`: In device configuration mode, ready to apply configuration
- `APPLYING_CONFIG`: Applying configuration commands sequentially
- `TRANSACTION_ACTIVE`: Configuration applied but not committed (can commit or abort)
- `COMMITTING`: Committing configuration changes
- `ABORTING_CONFIG`: Discarding current configuration changes
- `ROLLING_BACK`: Reverting to previous committed configuration
- `COMMITTING`: Committing/saving configuration changes (platform-specific)
- `ABORTING_CONFIG`: Rolling back after commit failure (automatic)
- `ROLLING_BACK`: Explicit rollback to previous configuration (user-requested)
- `ERROR`: Error state with automatic cleanup
- `DISCONNECTED`: SSH connection lost

Expand All @@ -74,15 +105,15 @@ INITIALIZING → READY → EXECUTING_COMMAND → READY
- **Rollback Operations**: Support for reverting to previous configurations
- **Platform Abstraction**: Device-specific prompt patterns and command syntax

**Transaction Management**:
- **configure()**: Enter config mode and apply changes → TRANSACTION_ACTIVE state
- **commit_transaction()**: Commit active transaction to device (internal driver method)
- **abort_configuration()**: Discard current uncommitted changes
- **rollback_configuration(commits_back)**: Revert to previous configuration state
**Key Operations**:
- **execute_command(command)**: Execute a single operational command
- **configure_and_commit(config_list)**: Apply configuration atomically with automatic rollback on failure
- **rollback_configuration(commits_back)**: Revert to a previous configuration state

**Platform-Specific Commands**:
- **Juniper JUNOS**: `rollback`, `rollback N`, `commit`, `exit`
- **Cisco IOS XR**: `abort`, `rollback configuration last N`, `commit`, `end`
- **Cisco IOS XE**: `archive config` (checkpoint), `configure replace` (rollback), `write memory` (save)

### Usage Examples
- `src/router_example.act`: Router client examples for both Juniper and Cisco platforms
Expand All @@ -102,4 +133,4 @@ INITIALIZING → READY → EXECUTING_COMMAND → READY
- Buffer class changes have highest impact but require careful testing
- All changes should maintain core functionality and test coverage
- Focus on simplicity and maintainability over preserving existing APIs
- Before writing code, prepare a detailed plan for changes
- Before writing code, prepare a detailed plan for changes
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

.PHONY: build
build:
acton build --dev $(DEP_OVERRIDES) $(TARGET)
acton build $(DEP_OVERRIDES) $(TARGET)

.PHONY: build-linux
build-linux:
Expand Down
Loading