Story
As an operator,
I want a rover that would move off the plateau to stay in place,
so that it never leaves the grid and the mission always completes normally.
Architecture Reference: 05-building-blocks.md — MoveForward command; 01-introduction.md — FR-6; 10-quality-requirements.md — QS-3, QS-4; 02-constraints.md — DC-5
Backend Sub-Story
Story ID: NAV-BE-002.1
As a developer I want MoveForward to silently ignore out-of-bounds moves so that boundary violations never raise exceptions or abort the mission.
Architecture Reference: 05-building-blocks.md — MoveForward; 08-cross-cutting-concepts.md — safe-stop contract; 11-risks-and-technical-debts.md — R-1
Scenarios:
SCENARIO 1: Boundary check is embedded in MoveForward
Scenario ID: NAV-BE-002.1-S1
GIVEN
WHEN
THEN
The safe-stop behaviour is already encoded in MoveForward.__call__ (NAV-STORY-001). This story adds explicit tests to verify all four boundary edges and the multi-command continuation behaviour.
No new production code is required — this story is fully covered by tests.
Unit tests — tests/domain/test_boundary.py
import pytest
from mars_rover.domain.commands import MoveForward, TurnRight
from mars_rover.domain.heading import Heading
from mars_rover.domain.plateau import Plateau
from mars_rover.domain.rover import Rover
@pytest.fixture
def plateau():
return Plateau(5, 5)
def test_safe_stop_south_boundary(plateau):
rover = Rover(0, 0, Heading.S)
MoveForward(plateau)(rover)
assert rover.x == 0 and rover.y == 0
def test_safe_stop_north_boundary(plateau):
rover = Rover(5, 5, Heading.N)
MoveForward(plateau)(rover)
assert rover.x == 5 and rover.y == 5
def test_safe_stop_west_boundary(plateau):
rover = Rover(0, 0, Heading.W)
MoveForward(plateau)(rover)
assert rover.x == 0 and rover.y == 0
def test_safe_stop_east_boundary(plateau):
rover = Rover(5, 0, Heading.E)
MoveForward(plateau)(rover)
assert rover.x == 5 and rover.y == 0
def test_safe_stop_does_not_raise(plateau):
rover = Rover(0, 0, Heading.S)
try:
MoveForward(plateau)(rover)
except Exception as exc:
pytest.fail(f"MoveForward raised unexpectedly: {exc}")
def test_safe_stop_allows_subsequent_commands(plateau):
rover = Rover(0, 0, Heading.S)
move = MoveForward(plateau)
move(rover) # safe-stop: stays at (0, 0, S)
TurnRight()(rover) # now facing W
TurnRight()(rover) # now facing N
move(rover) # valid move: goes to (0, 1, N)
assert rover.x == 0 and rover.y == 1 and rover.heading == Heading.N
def test_safe_stop_multiple_blocked_moves(plateau):
rover = Rover(3, 5, Heading.N)
move = MoveForward(plateau)
for _ in range(3):
move(rover)
assert rover.x == 3 and rover.y == 5
Frontend Sub-Story
Story ID: NAV-FE-002.1
As an operator I want to receive the rover’s last safe position when a boundary is hit so that I always get a valid result with no special error handling needed.
Architecture Reference: 03-context.md — System → Operator interface
Scenarios:
SCENARIO 1: Boundary safe-stop produces normal output
Scenario ID: NAV-FE-002.1-S1
GIVEN
WHEN
THEN
Infrastructure Sub-Story
Story ID: NAV-INFRA-002.1
As a developer I want boundary safe-stop functionality to be containerized and testable so that boundary checking works consistently across environments.
Architecture Reference: 07-deployment.md — deployment topology; 11-risks-and-technical-debts.md — R-1; 02-constraints.md — DC-5
SCENARIO 2: Container handles multiple boundary violations gracefully
Scenario ID: NAV-INFRA-002.1-S2
GIVEN
WHEN
THEN
Each boundary violation is logged separately to stderr
All safe-stops are handled without stopping execution
Final positions reflect only valid moves
Container completes successfully with exit code 0
SCENARIO 3: Dockerfile builds with boundary checking dependencies
Scenario ID: NAV-INFRA-002.1-S3
GIVEN
WHEN
THEN
The build includes boundary checking code and dependencies
Plateau boundary validation is available in the container
The container can perform safe-stop operations correctly
Build completes without errors
SCENARIO 4: Test suite validates boundary checking inside container
Scenario ID: NAV-INFRA-002.1-S4
GIVEN
WHEN
THEN
All 7 boundary tests run inside the container
Tests validate safe-stop behavior for various boundary conditions
pytest discovers and executes all boundary-related tests
Container exits with code 0 on test success