Ran behavision-setup in a fresh Linux container: Python 3.12, nothing else, the release contents mounted read-only the way Program Files or a shared drive would be. It failed, and then it failed differently, and both failures would have been the client's first experience. 1. `pip install <folder>` makes setuptools write behavision.egg-info INTO the folder. The folder is read-only wherever a release is sensibly unzipped, so: "could not create 'behavision.egg-info': Read-only file system". The release now ships a wheel - pure Python, buildable anywhere, nothing to build on the shop PC, and pip never touches the unzipped folder. Source stays as a fallback and is copied somewhere writable first. 2. The engine's paths.py knows two worlds - frozen (ProgramData) and a checkout (the repo root) - and a pip-installed engine is neither. It resolved its state root to site-packages: database there, camera list there, and its generated API credential in a folder the app never reads, while the app looked in ProgramData. Every call would be 401 on a stock install, with nothing in either log saying why. The same disease as the Mac checkout two days ago, now in production shape. engine.ChildEnv is the one place the engine's environment is built, used by the desktop app, the headless agent and the installer's own smoke test. It passes BEHAVISION_DATA_DIR = this process's state root, which paths.py honours ahead of every other rule, so the two halves agree by construction however the engine was installed. It also seeds config/default.yaml into the state root: a package in site-packages has no config beside it to seed from. Re-run on the same clean container: seven steps, all pass, models downloaded, engine started and answered, and its data/ landed beside agent.json - not in site-packages. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGcjxF1cNLcuwc3DAPcnfj
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package engine
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/loyaly/behavision-agent/pkg/paths"
|
|
)
|
|
|
|
// The engine must be told where THIS process keeps state, or a pip-installed
|
|
// engine decides on site-packages and the two halves never find each other.
|
|
func TestTheEngineIsToldWhereStateLives(t *testing.T) {
|
|
t.Setenv("BEHAVISION_DATA_DIR", t.TempDir())
|
|
|
|
env := ChildEnv("http://127.0.0.1:5555/events")
|
|
|
|
want := "BEHAVISION_DATA_DIR=" + paths.StateRoot()
|
|
if !contains(env, want) {
|
|
t.Fatalf("engine env lacks %q - a source-installed engine would put its "+
|
|
"database and credential somewhere this process never looks", want)
|
|
}
|
|
if !contains(env, "BEHAVISION_WEBHOOK_URL=http://127.0.0.1:5555/events") {
|
|
t.Fatal("webhook url not passed to the engine")
|
|
}
|
|
}
|
|
|
|
// Before the bridge has a port there is no webhook. An empty variable would be
|
|
// read by the engine as a webhook at "", which is not the same as none.
|
|
func TestNoWebhookMeansNoVariable(t *testing.T) {
|
|
for _, v := range ChildEnv("") {
|
|
if strings.HasPrefix(v, "BEHAVISION_WEBHOOK_URL=") {
|
|
t.Fatalf("empty hook still exported: %q", v)
|
|
}
|
|
}
|
|
}
|
|
|
|
func contains(env []string, want string) bool {
|
|
for _, v := range env {
|
|
if v == want {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|