This commit is contained in:
2026-09-23 17:26:13 +05:30
parent 8e1549764b
commit 697b77f8c1
54 changed files with 5750 additions and 69 deletions

23
main.go
View File

@@ -57,6 +57,24 @@ func main() {
log.Fatal("POS schema migration failed:", err)
}
// What Nearle Buddy did, and on whose behalf. Its own table: these rows are
// written on a different schedule from anything else and are the only record
// of an assistant acting for a merchant.
//
// Logged and carried on rather than fatal, unlike the migrations around it,
// and the difference is deliberate. Those create tables the product cannot
// trade without — a POS order has nowhere to land if its table is missing.
// This one serves an assistant that may not even be switched on, and taking
// the whole backend down over it would stop every shop taking orders to
// protect a log.
//
// The degradation is already built: `DBAudit` writes to the log as well as
// the table, and reports each failed insert as AUDIT ROW LOST. So a missing
// table costs the queryable trail and nothing else, loudly.
if err := db.DB.AutoMigrate(&models.AssistantAudit{}); err != nil {
log.Printf("assistant: audit table unavailable, the trail is log-only: %v", err)
}
// Shift windows for till staff. Additive — `app_users.shiftid` already
// existed and pointed at the rider table, so an account with no shift is
// simply unassigned rather than broken.
@@ -376,7 +394,10 @@ func main() {
log.Printf("assistant: %s, balanced tier is %s", cfg.Assistant.Provider, cfg.Assistant.ModelFor(utils.TierBalanced))
}
f := facade.NewFacade(db.DB, db.CatalogueDB, embedder, chat)
// ASSISTANT_AGENTS_DIR replaces the compiled-in agent definitions wholesale.
// Empty uses the embedded ones, so a deployment cannot be broken by a missing
// directory.
f := facade.NewFacade(db.DB, db.CatalogueDB, embedder, chat, os.Getenv("ASSISTANT_AGENTS_DIR"))
routes.RegisterRoutes(app, f)