Tracker Deploy - AI Assistant Instructions
This is a deployment infrastructure proof-of-concept for the Torrust ecosystem. It uses OpenTofu (Terraform), Ansible, and Rust to provision and manage deployment environments with LXD VM instances.
- DDD Layers: The codebase follows Domain-Driven Design with
domain/(business logic),application/(use cases and commands), andinfrastructure/(external integrations) layers. - Three-Level Pattern: Commands orchestrate Steps, which execute remote Actions - providing clear separation of concerns across deployment operations (see
docs/codebase-architecture.md).
- Languages: Rust, Shell scripts, YAML, TOML
- Infrastructure: OpenTofu (Terraform), Ansible
- Virtualization Providers: LXD VM instances
- Tools: Docker, cloud-init, testcontainers
- Linting Tools: markdownlint, yamllint, shellcheck, clippy, rustfmt, taplo (TOML)
src/- Rust source code organized by DDD layers (domain/,application/,infrastructure/,shared/)src/bin/- Binary executables (linter, E2E tests)data/- Environment-specific data and source templatestemplates/- Generated template examples and test fixturesbuild/- Generated runtime configurations (git-ignored)docs/- Project documentationdocs/user-guide/- User-facing documentation (getting started, commands, configuration)docs/decisions/- Architectural Decision Records (ADRs)scripts/- Shell scripts for development tasksfixtures/- Test data and keys for developmentpackages/- Rust workspace packages (linting tools)
.markdownlint.json- Markdown linting rules.yamllint-ci.yml- YAML linting configuration.taplo.toml- TOML formatting and lintingcspell.json- Spell checking configurationproject-words.txt- Project-specific dictionary
The development of this application is guided by fundamental principles that ensure quality, maintainability, and user experience. For detailed information, see docs/development-principles.md.
Core Principles:
- Observability: If it happens, we can see it - even after it happens (includes deep traceability)
- Testability: Every component must be testable in isolation and as part of the whole
- User Friendliness: All errors must be clear, informative, and solution-oriented
- Actionability: The system must always tell users how to continue with detailed instructions
Code Quality Standards:
Both production and test code must be:
- Clean: Well-structured with clear naming and minimal complexity
- Maintainable: Easy to modify and extend without breaking existing functionality
- Sustainable: Long-term viability with proper documentation and patterns
- Readable: Clear intent that can be understood by other developers
- Testable: Designed to support comprehensive testing at all levels
These principles should guide all development decisions, code reviews, and feature implementations.
-
Before placing code in DDD layers: Read
docs/contributing/ddd-layer-placement.mdfor comprehensive guidance on which code belongs in which layer (Domain, Application, Infrastructure, Presentation). This guide includes rules, red flags, examples, and a decision flowchart to help you make the right architectural decisions. -
Before creating branches: Read
docs/contributing/branching.mdfor naming conventions ({issue-number}-{short-description}) -
Before committing: Read
docs/contributing/commit-process.mdfor conventional commits- With issue branch:
{type}: [#{issue}] {description}(when branch name starts with{issue-number}-) - Without issue branch:
{type}: {description}(when working on main or branch without issue number prefix)
- With issue branch:
-
Before committing: Always run the pre-commit verification script - all checks must pass before staging files or creating commits, regardless of the tool or method used:
./scripts/pre-commit.sh
This applies to any method of committing:
- Terminal:
git add,git commit,git commit -am,cd ../ && git add ...,git add . && git commit -m "..." - VS Code: Git panel, Source Control view, commit shortcuts
- IDEs: IntelliJ, CLion, RustRover git integration
- Git clients: GitHub Desktop, GitKraken, etc.
- CI/CD: Any automated commits or merges
- Terminal:
-
Before working with Tera templates: Read
docs/contributing/templates.mdfor correct variable syntax - use{{ variable }}not{ { variable } }. Tera template files have the.teraextension. -
When adding new Ansible playbooks: Read
docs/contributing/templates.mdfor the complete guide. CRITICAL: Static playbooks (without.teraextension) must be registered insrc/infrastructure/external_tools/ansible/template/renderer/mod.rsin thecopy_static_templatesmethod, otherwise they won't be copied to the build directory and Ansible will fail with "playbook not found" error. -
When handling errors in code: Read
docs/contributing/error-handling.mdfor error handling principles. Prefer explicit enum errors over anyhow for better pattern matching and user experience. Make errors clear, include sufficient context for traceability, and ensure they are actionable with specific fix instructions. -
Understanding expected errors: Read
docs/contributing/known-issues.mdfor known issues and expected behaviors. Some errors that appear red in E2E test output (like SSH host key warnings) are normal and expected - not actual failures. -
Before making engineering decisions: Document significant architectural or design decisions as Architectural Decision Records (ADRs) in
docs/decisions/. Readdocs/decisions/README.mdfor the ADR template and guidelines. This ensures decisions are properly documented with context, rationale, and consequences for future reference. -
When organizing code within modules: Follow the module organization conventions in
docs/contributing/module-organization.md. Use top-down organization with public items first, high-level abstractions before low-level details, and important responsibilities before secondary concerns like error types. Prefer imports over full namespace paths - always import types and use short names (e.g.,Arc<UserOutput>) unless disambiguating name conflicts. Never use long paths likestd::sync::Arc<crate::presentation::user_output::UserOutput>in regular code. -
When writing Markdown documentation: Be aware of GitHub Flavored Markdown's automatic linking behavior. Read
docs/contributing/github-markdown-pitfalls.mdfor critical patterns to avoid. NEVER use hash-number patterns for enumeration or step numbering - this creates unintended links to GitHub issues/PRs. Use ordered lists or alternative formats instead.
- Lint:
cargo run --bin linter all(comprehensive - tests stable & nightly toolchains)- Individual linters:
cargo run --bin linter {markdown|yaml|toml|cspell|clippy|rustfmt|shellcheck} - Alternative:
./scripts/lint.sh(wrapper that calls the Rust binary)
- Individual linters:
- Dependencies:
cargo machete(mandatory before commits - no unused dependencies) - Build:
cargo build - Test:
cargo test - Unit Tests: When writing unit tests, follow conventions described in
docs/contributing/testing/ - E2E Tests:
cargo run --bin e2e-tests-full(comprehensive - all tests) or individual tests:cargo run --bin e2e-provision-tests- Infrastructure provisioning testscargo run --bin e2e-config-tests- Configuration validation tests
Follow the project conventions and ensure all checks pass.