Coding and integration conventions for this repository.
- Handlers
- Keep router handlers minimal.
- Parse input, enforce access checks, call services, send response.
- Non-trivial behavior belongs in
services/or focused modules inother/.
- Services
- Services orchestrate business flow and adapters.
- Prefer explicit dependencies via
AppContext. - Keep method names behavior-oriented.
- Persistence
- DB reads/writes go through repositories in
db/repositories/. - Avoid ad-hoc SQL in routers.
- Parse, do not guess.
- Validate required fields for commands/events.
- For channel contracts (
#skynet ... command=...), reject invalid payloads with explicit error paths.
- Keep contracts explicit.
- If changing external/event behavior, update
docs/contracts(to be added in later iteration) and tests in the same change.
- Use
loguru.
- No
print()in runtime paths. - Log moderation actions and failures with stable fields (
action,chat_id,user_id,sourcewhere applicable).
- Prefer artifacts for moderation decisions.
- Ban/restrict/unban flows should leave observable artifacts (logs and/or SpamGroup messages).
- Add tests for behavior changes.
- Router-level behavior in
tests/routers/. - Repository/service logic in dedicated test modules.
- Keep tests deterministic.
- Use mocks/fakes for network and external APIs.
- Avoid hidden time/random coupling unless explicitly controlled.
Use Conventional Commits:
feat(scope): ...fix(scope): ...refactor(scope): ...docs(scope): ...chore(scope): ...