# Memory

## User Profile
- [Ignacio's agent authority stance](user_ignacio_agent_authority.md) — all AI models are equal, only Ignacio has authority

## Feedback
- [Gateway restarts allowed](feedback_gateway_restarts.md) — don't treat as hard prohibition

## Supermarket Price System

### Data Sources
- **SEPA**: Daily government price data (all stores). DB: `~/.openclaw/workspace/data/sepa/db/sepa-prices.db`
  - Publishes daily at ~16:19 UTC. Timer fires at 16:30 UTC.
  - Stores: Coto(12), DIA(15), Carrefour(10), Cencosud(9), Changomas(11)
  - `id_producto` (col 3) = EAN. `productos_ean` (col 4) = boolean flag, NOT barcode
  - SEPA lista = base/shelf price, SEPA promo = discounted price (matches VTEX online)
  - Cencosud and Changomas report ZERO promos in SEPA
- **VTEX**: Direct API scraping for Jumbo, Disco, Carrefour, Changomas, DIA. Timer: 03:15 UTC
  - Script: `scripts/fetch_product_promos.js`. Output: `data/discounts/product-promos-latest.json`
- **Coto Constructor.io**: Product catalog + offers via `ac.cnstrc.com`
  - API key: `key_r6xzz4IAoTWcipni` (extracted from main.js)
  - Store 060 = Coto Digital (online), usually lower prices. Store 133 = mayorista. Store 710 = special channel (~13% products)
  - 18,389 offers fetched by browsing each sale_type separately (bypasses 10k CIO cap)
  - Script: `scripts/coto_fetch_products.js`. Timer: 03:15 UTC
- **Coto ATG API**: Bank/day promos. Endpoint: `/rest/model/atg/actors/cProfileActor/getPromociones?enviroment=ag`
  - Script: `scripts/coto_fetch_promos.js`. Timer: 03:15 UTC
- **Blue dollar**: Bluelytics API (`api.bluelytics.com.ar/v2/evolution.json`)

### Architecture
- Two-tier SEPA model: NEARBY (≤3km branches) + ONLINE (one representative per chain)
- Online tier fix applied: all stores get online tier even when all branches are nearby
- User location: Céspedes 2491, CABA. Coords: -34.5700, -58.4490
- **Unified API**: port 3005, route `/preview/products-api/` — search, product detail, virtual cart
  - Per-store latest date (handles stores with stale data gracefully)
  - Enriches SEPA data with Coto CIO (images, discounts) and VTEX (promo labels)
  - Systemd service: `product-search-server` (always-on, auto-restart)
  - sqlite3 at `/home/linuxbrew/.linuxbrew/bin/sqlite3` (needs PATH in systemd)
- **Carrito page**: `/usr/lib/node_modules/openclaw/dist/control-ui/carrito.html`
  - Product search + cross-store price comparison + virtual cart + cheapest calculation
  - Cart persisted in localStorage (`pipo-cart`)
- Descuentos page: same dir, `descuentos.html` (old VTEX-only format, needs update)
- **Handoff doc**: `~/.openclaw/workspace/HANDOFF-CODEX.md` — detailed instructions for Codex

### Stores (7 chains, online tier product counts as of Mar 8)
- Coto: 5,371 | DIA: 4,204 | Carrefour: 2,658 | Changomas: 28,841
- Disco: 6,464 | Jumbo: 4,752 | Vea: 5,811
- Cencosud (Jumbo/Disco/Vea) data lags — last in SEPA ZIPs: Mar 5

### Known Issues (as of Mar 8)
- VTEX fetch script broken (last 2 runs returned 0 items) — needs debugging
- Coto CIO products lack EAN — matched ~7.9K via price+fuzzy name, not yet integrated
- Carrefour/DIA/Cencosud missing some days in online tier (SEPA ZIP gaps)

### Timers Summary
| Timer | Time (UTC) | AR time | Purpose |
|-------|-----------|---------|---------|
| product-promos-fetch | 03:15 | 00:15 | VTEX store promos |
| coto-fetch-products | 03:15 | 00:15 | Coto offers (Constructor.io) |
| coto-fetch-promos | 03:15 | 00:15 | Coto bank/day promos (ATG) |
| sepa-ingest | 16:30 | 13:30 | SEPA daily prices |

### Key Constraints
- Coto WAF blocks web pages from VPS. Use ATG REST API or Constructor.io instead.
- OpenClaw gateway serves SPA for all paths. Static files go in `/usr/lib/node_modules/openclaw/dist/control-ui/`
- CSP blocks external scripts. Use inline CSS only.
- Precios Claros API is broken (DB overloaded). Not usable.
