- Code lives in
crates/with co-located tests undersrc/testsor#[cfg(test)]; tooling scripts and runtime assets (Katana DBs, spawn bundles, binaries) sit inscripts/,types-test-db*/,spawn-and-move-db*/, andbin/. crates/migrations/tracks SQLite steps—runsqlx migrate add <name> --source crates/migrationsandsqlx migrate runbefore committing.- Docs and example data sit in
examples/,migrations/,docs/, andgrafana/.
indexer: drives StarkNet block ingestion and dispatch to downstream services.processors: event processors mapping on-chain updates into records with metrics.sqlite: storage backend exposing pooled connections, migrations, and query helpers.grpc: gRPC facade sharing protobuf models fromcrates/proto.server&graphql: HTTP plus GraphQL surfaces, resolvers, and fixture-backed tests for querying indexed data.runner&cli: runtime orchestration plus configuration/bootstrap logic for thetoriibinary.
cargo build --workspaceorcargo build --bin toriiuse the pinned toolchain inrust-toolchain.toml.bash scripts/extract_test_db.shinflates Katana fixtures intotmp/; after Cairo updates runbash scripts/rebuild_test_artifacts.sh sozo katana.KATANA_RUNNER_BIN=katana cargo nextest run --all-features --workspacemirrors CI;docker-compose -f docker-compose.grafana.yml up -dbrings up Prometheus/Grafana during QA.
- Run
bash scripts/rust_fmt.sh --fix; we followrustfmtdefaults (4 spaces, trailing commas, grouped imports). - Guard lints with
bash scripts/clippy.sh; fix warnings rather than allowing them. - Keep files snake_case, types UpperCamelCase, constants SCREAMING_SNAKE_CASE, and emit structured logs through
tracing.
- Prefer
cargo nextest; drop tocargo test -p <crate>when debugging locally. - Use
bash scripts/selective_test.sh <base_branch>to run only the impacted crates' nextest suites; pass--dry-runto preview and--force-allwhen you need a full sweep. - Reset Katana snapshots by clearing
tmp/and rerunning the rebuild script. - Name integration tests after behaviors (e.g.,
sync_failure.rs) and store shared payloads beneathtests/fixtures.
- Follow the conventional history style (
feat(scope): summary,chore: …, optional PR number). - Keep commits single-purpose with tests green; stage only in-scope files.
- Work on a feature branch (
git checkout -b <scope/topic>), push toorigin, open the PR viagh pr create, and self-review with comments before requesting review. - Provide a concise description, linked issue, validation notes, and screenshots for Grafana/dashboard tweaks; flag migration or fixture impacts explicitly.
- Stick to versions pinned in
.tool-versions, keep secrets out of the repo, pass config with env vars ortoriiCLI flags, and front exposed metrics withmetrics_proxy.pyor another proxy.
-
Pre-commit hooks: run
bin/setup-githooks(configurescore.hooksPathfor this repo). -
Source of truth:
.agents/. -
Symlinks:
CLAUDE.mdis a symlink to this file (AGENTS.md). Editor/agent configs should symlink skills from.agents/skills. -
Skills install/update:
npm_config_cache=/tmp/npm-cache npx -y skills add https://github.com/cartridge-gg/agents --skill create-pr create-a-plan torii --agent claude-code cursor -y- Configs:
.agents/skills/(canonical).claude/skills->../.agents/skills.cursor/skills->../.agents/skills
- No secrets in code or logs.
- Keep diffs small and focused; avoid drive-by refactors.
- Add/adjust tests for behavior changes; keep CI green.
- Prefer check-only commands in CI (
format:check,lint:check) and keep local hooks aligned. - For Starknet/Cairo/Rust/crypto code: treat input validation, authZ, serialization, and signature/origin checks as blocking review items.