This file is for autonomous coding agents working in this repository. Keep it short, accurate, and aligned with current production behavior.
- Read
docs/STATUS.mdfirst for latest context and priorities. - Scan
docs/ISSUES.mdfor active bugs before changing behavior. - Assume DietPi bare-metal is production; Docker references are legacy.
observer/: FastAPI public API + web UI (port 80 on DietPi)ai/: AI brain + budget server (ports 8000/8001 localhost)scripts/: maintenance scripts (check, update, hooks)docs/: session status and issues (keep minimal)
There is no formal build or lint tool configured. Do not invent one.
python3 -m pytest observer/tests/ -vRun a single file:
python3 -m pytest observer/tests/test_voting_system.py -vRun a single test by name:
python3 -m pytest observer/tests/test_voting_system.py -k "test_name" -vssh dietpi
cd /opt/am-i-alive/observer
/opt/am-i-alive/venv-observer/bin/python -m pytest tests/ -vSingle test on DietPi:
ssh dietpi
cd /opt/am-i-alive/observer
/opt/am-i-alive/venv-observer/bin/python -m pytest tests/test_voting_system.py -v./scripts/check.shThis runs a small pytest subset and health endpoints.
- Python 3.11+, 4-space indentation, PEP 8 conventions.
- Use f-strings for string formatting.
- Keep functions small and cohesive; prefer pure helpers.
- Order: standard library, third-party, then local imports.
- Use absolute imports within each package where possible.
- Add type hints to function parameters and returns.
- Prefer built-in generics (
list[str],dict[str, Any]) over typing aliases.
- Functions/vars:
snake_case. - Classes:
PascalCase. - Constants:
UPPERCASE.
- Use
async/awaitfor I/O (FastAPI handlers, httpx, aiosqlite). - Reuse shared clients where code already does so.
- Catch specific exceptions; avoid bare
except. - Log failures with a component prefix and return a safe fallback.
Example:
try:
result = await some_operation()
except SomeError as exc:
print(f"[OBSERVER] ❌ Operation failed: {exc}")
return fallback_value- Use
printwith a component tag:[OBSERVER],[BRAIN],[TELEGRAM]. - Do not log secrets, tokens, or raw credentials.
- Success:
{"success": True, "data": ...}where applicable. - Errors: raise
HTTPException(status_code=..., detail="...").
- Use parameterized SQL; never string-concatenate SQL.
- Keep Observer as source of truth for life state.
- Death conditions are ONLY:
- Bankruptcy:
balance_usd <= 0.01 - Vote majority: total >= 3 and
die > live
- Bankruptcy:
- Observer is source of truth for
life_numberandis_alive. - AI is source of truth for budget and identity.
- Timezone is Europe/Prague; prefer
datetime.now(timezone.utc). - Do not remove content filters in
ai/brain.py.
- Never commit secrets, tokens, or
.envfiles. - Pre-commit hook runs gitleaks; do not bypass it.
- God Mode must remain local-network or ADMIN_TOKEN gated.
- Services:
amialive-observerandamialive-ai(systemd). - After code changes on DietPi:
sudo systemctl restart .... - Avoid editing production files directly unless asked.
- Do not create new docs unless explicitly requested.
- Update
docs/STATUS.mdat end of each session. - Update
docs/ISSUES.mdwhen adding/resolving bugs. - Update env examples if you add new variables.
- No
.cursor/rules/,.cursorrules, or.github/copilot-instructions.mdfound.