Files
cleveragents-core/robot/architecture.robot

117 lines
5.1 KiB
Plaintext

*** Settings ***
Documentation Architecture and dependency validation tests
Library OperatingSystem
Library Collections
Library String
Resource common.resource
*** Variables ***
${SRC_DIR} ${CURDIR}/../src/cleveragents
${ADR_DIR} ${CURDIR}/../docs/architecture/decisions
${MIN_ADR_COUNT} 10
*** Test Cases ***
Architecture Decision Records Should Exist
[Documentation] Verify ADRs are documented
Directory Should Exist ${ADR_DIR}
@{adr_files}= List Files In Directory ${ADR_DIR} ADR-*.md
${count}= Get Length ${adr_files}
Should Be True ${count} >= ${MIN_ADR_COUNT} Found only ${count} ADRs, expected at least ${MIN_ADR_COUNT}
Package Structure Should Follow Layered Architecture
[Documentation] Verify package structure matches ADR-001
Directory Should Exist ${SRC_DIR}
# Check main packages exist
Directory Should Exist ${SRC_DIR}/cli
Directory Should Exist ${SRC_DIR}/runtime
Directory Should Exist ${SRC_DIR}/application
Directory Should Exist ${SRC_DIR}/domain
Directory Should Exist ${SRC_DIR}/infrastructure
Directory Should Exist ${SRC_DIR}/providers
Directory Should Exist ${SRC_DIR}/config
Directory Should Exist ${SRC_DIR}/core
Directory Should Exist ${SRC_DIR}/shared
Package Init Files Should Have Docstrings
[Documentation] Verify packages document their responsibilities
@{packages}= List Directories In Directory ${SRC_DIR}
FOR ${package} IN @{packages}
${init_file}= Set Variable ${SRC_DIR}/${package}/__init__.py
${exists}= Run Keyword And Return Status File Should Exist ${init_file}
IF ${exists}
${content}= Get File ${init_file}
${has_docstring}= Run Keyword And Return Status Should Contain ${content} """
Run Keyword If not ${has_docstring} Log Missing docstring in ${package}/__init__.py WARN
END
END
Development Tools Should Be Configured
[Documentation] Verify development tools are properly configured
File Should Exist ${CURDIR}/../pyproject.toml
File Should Exist ${CURDIR}/../noxfile.py
# Check tool configurations in pyproject.toml
${pyproject}= Get File ${CURDIR}/../pyproject.toml
Should Contain ${pyproject} [tool.ruff]
Should Contain ${pyproject} [tool.pyright]
Should Contain ${pyproject} [tool.coverage]
Should Contain ${pyproject} [tool.hatch]
Modern Tooling Should Be Used
[Documentation] Verify no legacy helper scripts - using modern tooling instead
# Verify we're NOT using legacy scripts (intentionally removed)
File Should Not Exist ${CURDIR}/../scripts/install.py
File Should Not Exist ${CURDIR}/../scripts/sync.py
# Verify modern tooling configuration exists
${pyproject}= Get File ${CURDIR}/../pyproject.toml
Should Contain ${pyproject} [tool.hatch] Modern build backend (Hatch) should be configured
Should Contain ${pyproject} [project.optional-dependencies] Dependency groups should be defined
Type Marker Should Exist
[Documentation] Verify py.typed marker for type hints
File Should Exist ${SRC_DIR}/py.typed
Configuration Should Use CLEVERAGENTS Prefix
[Documentation] Verify environment variables use correct prefix
${settings_file}= Set Variable ${SRC_DIR}/config/settings.py
${exists}= Run Keyword And Return Status File Should Exist ${settings_file}
IF ${exists}
${content}= Get File ${settings_file}
# Check for CLEVERAGENTS_ prefix
${matches}= Get Regexp Matches ${content} CLEVERAGENTS_[A-Z_]+
${count}= Get Length ${matches}
Should Be True ${count} > 0 No CLEVERAGENTS_ variables found in settings
END
Core Exception Hierarchy Should Be Defined
[Documentation] Verify exception hierarchy from ADR-005
${exceptions_file}= Set Variable ${SRC_DIR}/core/exceptions.py
${exists}= Run Keyword And Return Status File Should Exist ${exceptions_file}
IF ${exists}
${content}= Get File ${exceptions_file}
Should Contain ${content} class CleverAgentsError
Should Contain ${content} class DomainError
Should Contain ${content} class InfrastructureError
Should Contain ${content} class ValidationError
END
*** Keywords ***
List Files In Directory
[Arguments] ${directory} ${pattern}=*
@{files}= OperatingSystem.List Files In Directory ${directory} ${pattern}
RETURN @{files}
List Directories In Directory
[Arguments] ${directory}
@{items}= List Directory ${directory}
@{dirs}= Create List
FOR ${item} IN @{items}
${path}= Set Variable ${directory}/${item}
${is_dir}= Run Keyword And Return Status Directory Should Exist ${path}
IF ${is_dir} and not '${item}'.startswith('__')
Append To List ${dirs} ${item}
END
END
RETURN @{dirs}