Files
Behavision/server/internal/api/main_test.go
Suriyakumarvijayanayagam dad04e8cda Behavision: face recognition for retail, edge to head office
Five components that ship as one product:

- behavision/  the recognition engine. RTSP ingest, YuNet detection, IoU
               tracking, ArcFace embeddings, a FAISS/SQLite gallery, and a
               FastAPI dashboard. Identity is decided once per TRACK from an
               average of at least three embeddings, never per frame.
- agent/       the Go edge agent: supervises the engine, holds a durable
               spool, and drains it to MQTT. Nothing is acked before the
               broker confirms.
- desktop/     the shop PC application (Wails + React + tray).
- server/      the cloud API, MQTT consumer, reports and assistant.
- web/         platform.loyaly.ai, the head-office app, embedded in the
               server binary.

The gallery stores 512-float embeddings and timestamps - no images unless
`app.store_faces` is switched on. Those embeddings are biometric personal
data under GDPR and India's DPDP: template inversion reconstructs a
recognisable face from an ArcFace vector, so data/behavision.db is treated
as a biometric database and DELETE /api/visitors/{id} is a real erasure.

CLAUDE.md carries the reasoning behind every non-obvious decision here,
including the ones that were measured and the ones that were wrong first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HViLj9gYNRtSr7YVZmW5sn
2026-09-04 11:14:18 +05:30

26 lines
774 B
Go

package api
import (
"os"
"testing"
"github.com/loyaly/behavision-server/internal/auth"
)
// The whole package runs at bcrypt's minimum cost.
//
// Almost every test here signs in, and at the production cost of 12 that is
// ~500 ms of hashing per test for a hash and a verify. Under the race detector
// that pushed this package past `go test`'s ten-minute default - a CI failure
// with no failing assertion in it, which is the worst kind to debug.
//
// What this does NOT weaken: the tests that care about hashing care about
// whether two paths take the SAME time as each other, not how long either
// takes. Lowering both sides equally leaves that intact.
func TestMain(m *testing.M) {
restore := auth.UseTestCost()
code := m.Run()
restore()
os.Exit(code)
}