This file contains crucial context for AI agents working in this repository.
- Testing: Run
cargo nextest run --locked --all-features(CI specifically usesnextest; prefer this over standardcargo test). - Linting: Run
cargo clippy --locked --all-targets --all-features -- -D warnings. - Formatting: Run
cargo fmt --all -- --check. - SQLx Offline Mode: This project uses
sqlxwith offline query checking (evidenced by the.sqlx/dir). Whenever you modify a database query, you must runcargo sqlx prepare -- --all-targetsto update the cache. - Migration Creation: Always use
cargo sqlx migrate add <name>to generate new migrations. Manual creation of migration files is strictly prohibited to ensure proper tracking and naming conventions. - Destructive Schema Changes: Dropping/renaming columns requires synchronization with
sqlxcache.- Remove code references (mark fields
#[allow(dead_code)]if needed). - Run
cargo sqlx prepare. - Apply
ALTER TABLE ... DROP COLUMNmigration. - Cleanup removed fields/references.
- Run
cargo sqlx prepareagain.
- Remove code references (mark fields
-
Nix First: The project uses Nix flakes (
flake.nix) anddirenv, and the Rust toolchain is only available inside the dev shell. In interactive shells, direnv loads it automatically; in non-interactive/automated shells the direnv hook does not run, so load the environment explicitly before anycargoinvocation:- Run
direnv allowonce if the.envrcis blocked. - Run
eval "$(direnv export bash 2>/dev/null)", then verify withcommand -v cargo(should print a/nix/store/...path). - If direnv is unavailable or cannot evaluate the envrc (e.g. restricted home access), fall back to
nix develop -c <command>.
- Run
-
Runtime Variables: To run the server locally, you must ensure
CBRIDGE__AUTH__CLIENT_IDandCBRIDGE__AUTH__PEM_PATHare set (pointing to a valid GitHub App private key). -
External Dependencies: Remote git operations are performed in-process via the
gixcrate; the application no longer shells out togit ls-remote, so an externalgitbinary is not required at runtime.
- Frameworks:
axumfor HTTP,sqlx(SQLite) for state,tokiofor async execution. - Execution Flow:
src/main.rsinitializes anaxumrouter and spawns two decoupled backgroundtokiotasks:polling/: Periodically checks remote git repositories for updates.trigger/: Receives update events from the polling engine viampscchannels and triggers GitHub Action workflows on target repositories.
- Error Handling: Use domain-specific error enums (
HandlerError,FatalError) defined insrc/error.rsusing thethiserrorcrate. EnsureIntoResponseis implemented for any errors that bubble up to Axum handlers.
When reviewing the correctness of code, always make sure that a potential issue can actually arise in the context of the affected piece of code.