Update AGENTS.md

- Refresh repo guidelines
This commit is contained in:
andrew committed 2026-12-01 11:14:11 +07:00
1 parent ea1f376e1f
commit 17e2244129
1 file changed
+13 -6
+13 -6
View File
@@ -2,7 +2,7 @@
## Project Overview
Feedmill is a production edge counter for feed sacks and boxes. A Rockchip RK3588 NPU runs YOLO (RKNN) over an RTSP camera stream; ByteTrack tracks objects; a line-crossing rule increments counts. Counts persist to SQLite + JSON state; a Flask dashboard on port 7000 exposes batch control and reporting. Truck detections are used only to define the horizontal counting zone, not counted.
Feedmill is a production edge counter for feed sacks and boxes. A Rockchip RK3588 NPU runs YOLO (RKNN) over an RTSP camera stream; ByteTrack tracks objects; a line-crossing rule increments counts. Counts persist to SQLite + JSON state; a Flask dashboard exposes batch control/reporting on the configured port (default 7000 via `.env`). Truck detections define the horizontal counting zone only and are not counted. Batches are unified: one batch tracks combined `count` plus separate `sack_count`/`box_count`.
## Architecture & Data Flow
@@ -13,9 +13,9 @@ Feedmill is a production edge counter for feed sacks and boxes. A Rockchip RK358
5. Tracking: `ByteTracker.update` associates detections across frames.
6. Crossing: `crossed_line(prev_pos, pos, line_pos)` plus `is_duplicate_cross` dedup; on crossing, `BatchStore.record_counted_object_crossing(tid, object_label=...)`.
7. Persistence: `batch_store.py` writes `batches`/`daily_summaries` and `current_batch.json`.
8. Dashboard (`counter_dashboard.py`) reads DB/state and proxies start/stop to the counter control server (`counter_control.py`, 127.0.0.1:5000).
8. Dashboard (`counter_dashboard.py`) reads DB/state and proxies start/stop to the counter control server (`counter_control.py`, `127.0.0.1:5001`).
Batches: manual mode (operator start/stop; passing objects ignored while stopped) or auto mode (first crossing opens; idle timeout closes). Each batch tracks combined `count` plus separate `sack_count`/`box_count`.
Batches: manual mode (operator start/stop; passing objects ignored while stopped) or auto mode (first crossing opens; idle timeout closes; timeout held while truck in zone). Peer-sync requests are ignored in auto mode.
## Key Directories
@@ -47,6 +47,9 @@ sudo systemctl status feedmill-counter feedmill-dashboard
sudo journalctl -u feedmill-counter -f
sudo ./install-services.sh
sudo ./uninstall-services.sh
# optional model conversion (needs rknn, torch, onnx, ultralytics)
/opt/feedmill/venv/bin/python convert_pt_to_rknn.py model.pt -o /opt/models/model.rknn --imgsz 480 --target rk3588
```
No build step, lint config, or package manifest beyond `requirements.txt`.
@@ -61,6 +64,7 @@ No build step, lint config, or package manifest beyond `requirements.txt`.
- Atomic live-frame writes via temp file + `os.replace`.
- Dedup keys: `{label}:{track_id}` in `counted_event_ids`.
- Tests mock `rknnlite` import when unavailable; use temp SQLite/state files.
- Peer API validation: `X-API-Key` checked only when header present; wrong/missing expected token returns 401.
## Important Files
@@ -72,19 +76,22 @@ No build step, lint config, or package manifest beyond `requirements.txt`.
- `requirements.txt` — Python dependencies.
- `feedmill-counter.service`, `feedmill-dashboard.service` — systemd units.
- `API.md`, `DEPLOY.md`, `README.md` — API, deployment, overview docs.
- `docs/peer_sync_handoff.md` — FCP peer-sync contract.
## Runtime/Tooling Preferences
- Python 3.12.3 in `/opt/feedmill/venv` (system-site-packages false).
- Dependencies: `numpy<2`, `rknn-toolkit-lite2`, `opencv-python`, `flask`, `python-dotenv`, `openpyxl`.
- RKNN runtime 2.3.2 targeting RKNPU v2 (RK3588). Models live in `/opt/models/*.rknn`.
- RKNN runtime targeting RKNPU v2 (RK3588); models live in `/opt/models/*.rknn`.
- Install scripts require root; services run as root with `PYTHONNOUSERSITE=1`.
- Dashboard port comes from `.env` (`DASHBOARD_PORT`, typically 7000); code default is 5000.
- Internal control port defaults to 5001.
- No Node/Bun tooling; frontend is server-rendered Jinja + Chart.js.
## Testing & QA
- Framework: stdlib `unittest`; no pytest/conftest/CI config.
- Suites: `tests/test_batch_store.py` (8), `tests/test_crossing_guards.py` (5), `tests/test_dashboard.py` (13).
- Suites: `tests/test_batch_store.py` (12), `tests/test_crossing_guards.py` (5), `tests/test_dashboard.py` (15).
- Run from `/opt/feedmill` so top-level imports resolve.
- Coverage gaps: inference loop/RKNN loading, camera capture, control-server error paths, peer forwarding, frontend JS, concurrency/migration against production DB, service scripts.
- Dashboard tests mutate module globals (`DB_PATH`, `CURRENT_BATCH_PATH`) and create a persistent temp root at import.
- Dashboard tests mutate module globals (`DB_PATH`, `CURRENT_BATCH_PATH`) and create a persistent temp root at import.