Skip to content

OpenTea DX-OS v1.7.0

Choose a tag to compare

@github-actions github-actions released this 10 Nov 20:53
· 1074 commits to main since this release

Added

  • Tea leaf disease model: ai-models/tea_leaf_model.keras (MobileNetV2 transfer learning, 224×224, 8 classes listed in ai-models/tea_class_names.txt, 9.2 MB) with Vietnamese labels in tea_class_names_vi.json, each marked for officer review. ai-models/tea/ holds the reproducible pipeline (train.py, datasets.json with DOIs, download URLs and SHA-256, pinned requirements.txt) that runs in python:3.12.15-slim-bookworm. It is trained on three CC BY 4.0 Mendeley datasets (Kimutai and Förster, Kenya; Islam, Bangladesh; Billah et al., Bangladesh), credited in ai-models/ATTRIBUTION.md; no image is committed. ai-models/tea/MODEL_CARD.md reports the measured numbers: test accuracy 0.8683 on 1,025 images and confidence threshold 0.60, but only 0.12 to 0.35 when one source is held out, and a random-noise image is called healthy at 0.988. Accuracy on Thái Nguyên photos is not measured; every result goes to an officer
  • Tea disease model served: POST /predict?model=tea on disease-api uses the tea leaf model next to the general one (still the default; any other model name answers 400). Responses gain model and uncertain; a tea result below TEA_CONFIDENCE_THRESHOLD (default 0.60, rejected at startup outside (0, 1]) has null names and keeps top3. /health adds models with each model's state
  • Tea disease flow in the web app: a parcel whose crop names chè/tea is diagnosed with the tea model, any other with the general one. An uncertain result is stored as Không xác định, and every result still goes to the officers; the farmer screen says Đã gửi cán bộ kỹ thuật xem instead of presenting a final diagnosis. A 503 from the tea model is an outage (503 AI_UNAVAILABLE), never a fallback to the general model
  • Officer's confirmed diagnosis: the review form has a Tên bệnh đã xác nhận field, pre-filled with the AI name (empty when uncertain). PUT /api/officer/diseases/[id]/review takes confirmed_diagnosis, required when approving, and stores it in confirmed_diagnosis; the farmer history, officer lists, soil-health screen, notification and archived report show it over the AI name
  • Tea harvest rounds: POST /api/parcels/[id]/start-round (officer only, TenantGuard.parcel) moves a HARVESTED parcel to TENDING and opens the cycle Lứa <n>/<year>, numbered within the year in Vietnam time. The status check and the new cycle are one transaction, so a second start, or a start on any other status, is refused with 422 and creates nothing. The officer's household screen has a Bắt đầu lứa mới button on harvested parcels
  • Journal photo upload: POST /api/journal/upload (farmer and officer) returns a presigned upload URL valid for 900 seconds and the key para/<htxCode>/Areas/Journal/<yyyy>/<uuid>-<safe name>, which POST /api/journal accepts as photo_minio_key. Only image/jpeg, image/png and image/webp are accepted; the name is reduced to its last segment without Vietnamese marks or unsafe characters, capped at 100 characters. The farmer journal form's photo upload called this route before it existed; the A3 browser story uploads a photo through it to storage and opens it again
  • Withdrawal on the farmer dashboard: Thửa <mã> còn <N> ngày cách ly for each parcel of the farmer's household whose latest safe harvest date (from journal entries not rejected) is still ahead; N is whole days, rounded up
  • Tea demo data: npm run seed (new script, runs prisma db seed) creates the Tân Cương (TC) and La Bằng (LB) cooperatives with made-up households and tea parcels (Trung du, LDP1, Kim Tuyên). Parcel TC-A3 has, relative to the seed run, a fertiliser entry, a spraying entry still under its 7-day withdrawal, a harvested previous round whose lot TC-CHE-A3-001 is already exported with a public trace page, and one pending tea disease report. Re-running it changes only TC and LB rows (plus the shared market, bulletin and partner rows); the history of the seeded parcels is rebuilt with fresh dates. platform/tests/seed-test.sh checks this on a throwaway database
  • Tea demo accounts in the realm: manager_tc, officer_tc, farmer_tc, manager_lb, officer_lb, farmer_lb (password Test1234!; managers and officers must set up TOTP). The farmers have fixed ids, which the seed uses to link them to their household
  • Tea market data: comtrade_export_sync also fetches HS 0902 and stores it as Tea; vietnam_market_sync adds a simulated dried tea bud price (Tea, VND/kg). Every price that workflow simulates is now written under the source Mô phỏng (Toàn quốc) instead of naming a ministry or market portal, and the dashboard price list, the market widget and the chatbot's market context label such prices giá mô phỏng; the chatbot and the bulletin prompt must say so too, and the chatbot's context no longer calls its market data "thực tế". The market widget names no source when it has no data. Prices already stored under the old source names are not relabelled
  • Design system and dark mode: DESIGN.md (google-labs-code/design.md format) documents the tokens of apps/web/src/styles/globals.css, which now has a dark value for every colour token, applied under prefers-color-scheme: dark unless the viewer picked light, or under data-theme="dark". A theme button (Sáng → Tối → Theo hệ thống, stored in localStorage key opentea-theme) sits in the top bar and on the home and login pages; an inline script sets the stored theme before first paint and does nothing if storage is blocked. Tailwind's dark: variant follows the same choice, and semantic tokens (bg-danger-subtle, text-ink-secondary, ...) are available as Tailwind colours. Tests check that every light token has a dark value, that text/background pairs reach WCAG AA 4.5:1 in both themes, and that DESIGN.md matches globals.css. A colour guard fails on hard-coded colours in *.module.css and *.tsx; its baseline of files still to convert (74 when it was added) was emptied by the move to tokens below
  • A3 story and priority screens in the browser: tests/e2e/story/tea-a3.spec.ts runs "Một ngày của lô chè A3" on the seeded stack with real Keycloak logins: the farmer sees A3's withdrawal and adds a journal entry with a photo uploaded to storage; a tea photo diagnosis goes through the gateway to the tea model (checked in the disease-api access log) and into the officer queue, where the officer confirms it with a name the farmer then sees; harvest approval and a lot of A3 are refused during the withdrawal; the officer creates and exports a lot of TC-A2; the public pages /q/<code> of that lot and of TC-CHE-A3-001 show their withdrawal status. tests/e2e/visual/screens.spec.ts saves the priority screens of spec §6.4 (9 pages: the disease review is both the queue and the review form) at 1280×800 and 390×844 in light and dark (36 screenshots under test-results/screens/) and fails on page-level horizontal overflow, on overlapping visible text, and on a theme button missing from or crowded in the phone top bar. The platform-smoke CI job now seeds the demo data, starts disease-api with web, runs both specs after the core tenant spec and uploads the screenshots as the priority-screens artifact. make platform-smoke also creates smoke_officer_tc, because the demo officers must set up TOTP first
  • Home page: / is now public for signed-out visitors, with a short introduction, a sign-in button and a lot code field that opens the public trace page /q/<code> (signed-in users are still sent to their dashboard). The PWA icons are real 192 and 512 px tea-leaf icons and are served without a session

Changed

  • disease-api dependencies pinned: every package in apps/disease-api/requirements.txt has an exact version, and tensorflow-cpu (unpinned, no arm64 wheel) is replaced by tensorflow==2.21.0 with keras==3.15.1, so the image also builds on arm64; it is larger than before. The 46-class general model gives the same prediction as with the previously resolved versions. A pytest suite (requirements-dev.txt: pytest, httpx2) covers model selection, the threshold and the general model, and the CI job "Lint FastAPI" now runs it with -W error
  • Brand: the product is named OpenTea DX-OS everywhere (page titles via one title template, sidebar, top bar, login, register and PIN pages, trace pages, PWA manifest and the Keycloak login theme's title), from apps/web/src/lib/brand.ts. The Keycloak theme directory and realm keep the name agrimarket
  • Colours: the accent is now amber (#b45309, was orange #EA580C); the status, feedback and tertiary text colours are darkened where white or coloured text missed 4.5:1; --font-family-sans uses Be Vietnam Pro instead of an Inter font that was never loaded. The login page uses tokens only
  • Tea vocabulary: the app no longer speaks of rice. Placeholders, chat suggestions, mock bulletins, the soil-health warning and the seeded market, bulletin and partner rows use tea; the seed no longer attributes made-up figures to real bodies (its FAOSTAT rows and the bulletin's WTO and Sở NN&PTNT sources are gone, and its one demo price is simulated); the menu item Lịch vụ mùa is now Lịch thu hái; a new zone's season defaults to Lứa 1/<year>; the default commodity of the bulletin, market widget and market API is Chè/Tea (the farmer bulletin page now looks it up by its English name, as the workflows store it, and GET /api/bulletin without ?commodity reads Tea for any tea crop of the HTX, such as Chè Trung du). The manager dashboard's price list shows the 3 newest tea prices, topped up with the newest other commodities only when fewer than 3 exist. A test fails when a rice word is back in the web source or the seed; its only exceptions are the commodity name maps for Comtrade rice and wheat rows
  • Demo data and accounts: the MD2 rice cooperative is no longer seeded, the old seed's backfill of households without an HTX is gone, and weather rows are seeded only for the seeded parcels. manager1, officer1 and farmer1 are removed from the realm
  • Smoke and browser tests use their own smoke_ accounts (smoke_manager_tc, smoke_manager_lb, smoke_manager_none, smoke_farmer_tc, smoke_officer_tc); ensure_user refuses any other name, so tests never reset a demo user's password or TOTP. The A3 story and the screenshots also sign in as farmer_tc, which has no TOTP step; a login does not change the account. The two-htx.sql fixture shares the TC/LB profiles with the seed instead of deleting them, and the household checks are scoped to the fixture rows plus an every-row HTX check
  • Colour tokens everywhere: every *.module.css and *.tsx under apps/web/src takes its colours from globals.css, so all screens follow the dark theme, and the colour guard's baseline is empty. Text on primary fills uses --color-primary-foreground and on success or danger fills --color-ink-inverse; the always-dark surfaces (sidebar, bulletin header) use the sidebar tokens. The guard's exceptions name the exact fixed colours a file may keep, each with a reason and the number of times it may occur: parcel colours drawn on map tiles, and text in Leaflet popups and controls, which leaflet.css keeps white. The lot page's decorative QR preview follows the theme. About 80 variables that globals.css never declared (--color-surface-border, --text-secondary, --radius-lg, ...) now point at real tokens, so borders, muted text and rounded corners that had fallen back to nothing render as designed; @theme names count as undeclared because Tailwind emits them only when a utility needs them. A test fails on any var(--…) that globals.css does not declare, apart from four variables set at runtime
  • QR export rule: every parcel of the lot needs a crop cycle harvested on or before the lot's harvest date (same day counts, in Vietnam time) instead of being in HARVESTED, TENDING or HARVEST_APPROVED. A lot of the previous round can be exported while the next round runs, and a parcel harvested only after the lot date is refused. The withdrawal block is unchanged

Upgrade

  • Realm: Keycloak imports the realm only when it is missing, and the Admin Console cannot set a user id, which farmer_tc and farmer_lb need. On an existing stack either (a) delete the realm (Realm settings > Action > Delete) and run docker compose -f docker/docker-compose.yml restart keycloak so --import-realm imports it again, which also drops users created at runtime; or (b) delete manager1, officer1 and farmer1, then Realm settings > Action > Partial import of docker/keycloak/realm-agrimarket.json with only Users and Overwrite, which replaces the manager_tc, manager_lb and farmer_tc the old smoke created and keeps the fixed ids. Overwrite also resets the six demo users' passwords and TOTP, so do it before setting up TOTP for a demo. Never delete docker_pgdata: the realm lives in its keycloak database next to all app data
  • Demo data: run npm run seed only on a demo database: it rebuilds the history of the TC and LB parcels with fresh dates. Re-run it before each demo so A3's withdrawal is active again
  • TOTP: managers and officers set up TOTP at their first login; set it up on the demo phone before the demo (README, "Cài TOTP trước buổi demo")
  • Disease diagnosis needs the disease-api container (docker compose -f docker/docker-compose.yml up -d --build --wait web disease-api); make platform-up does not start it
  • Never down -v on the main stack: earlier upgrade notes (1.3.0) suggested recreating the Postgres volume or running docker compose down -v once for n8n. Both delete docker_pgdata, which holds the Keycloak realm and all app data. Use REINDEX DATABASE for the collation change and let n8n create its tables in the n8n schema (README, "Nâng cấp môi trường dev cũ")
  • Storage: no change to docker/.env.local is needed. MINIO_ENDPOINT may be minio or minio:9000

Fixed

  • web image on arm64: npm install in the Dockerfile could leave out @next/swc-linux-*-musl without an error (npm skips an optional download that fails), and BuildKit then reused that broken layer, so next build failed on arm64 with "Failed to load SWC binary". The install step now fails when the musl SWC binary is missing
  • Photo uploads from the web app: the storage adapters used MINIO_ENDPOINT as a host name while docker/.env.local.example sets minio:9000, so every request of web that touched storage failed with Invalid endPoint: journal photo upload, diagnosis, the farmer's diagnosis history, the officer's disease screens, documents and QR export. Both adapters now accept host or host:port. The browser's presigned PUT to SeaweedFS needed no CORS change
  • Pages hanging after a few clicks in the installed app: the PWA service worker cached every same-origin /api/ GET with NetworkFirst, including the /api/notifications/stream event stream, which never ends. Each page left an open connection behind, and after a few pages the browser's 6 connections per host were taken: requests hung, then came from the cache after 10 seconds, and form posts never went out. The stream now bypasses the cache (NetworkOnly). Found by the A3 browser story, which failed about one run in six before
  • Vietnamese status labels on the demo screens: the trace page that the printed QR opens (/lot/<code>) showed the raw QR_EXPORTED (or READY) pill and now shows Đã xuất QR, Sẵn sàng or Bản nháp; the officer disease queue and review showed PENDING and now show Chờ duyệt; the farmer's diagnosis history mapped a status the reports never take (RESOLVED) and showed CONFIRMED/REJECTED raw, and now shows Chờ duyệt, Đã xác nhận or Bị từ chối. The lot form and the QR export show a refusal without its machine code (WITHDRAWAL_NOT_PASSED: ), which the API still returns
  • Market sources on the manager dashboard: the source box counted price rows instead of sources, called a simulated price "nguồn đã kiểm chứng", and with no data named USDA, WTO and Sở NN&PTNT. It now counts distinct real sources only, names simulated sources on their own line ("Nguồn mô phỏng: …"), and names none when there is no data
  • Farmer dashboard weather showed the stored WMO code (for example 3) and now shows its Vietnamese name (U ám)
  • Phone top bar: the product name broke after the hyphen ("OpenTea DX-" / "OS"); it now stays on one line, slightly smaller at 400 px and below
  • Demo lot grade: the seeded lot TC-CHE-A3-001 is graded Loại 1 instead of Grade 1
  • disease-api health check allows 60 seconds for both TensorFlow models to load before failed checks count, so up --wait does not give up on a cold machine
  • Missing report photos: a disease report whose photo is not in storage (the seeded A3 report, or one quarantined by the scanner) now shows "Không tải được ảnh" in the officer queue, the officer review and the farmer's history instead of a broken image
  • e2e session harness: the specs that forge an Auth.js cookie signed it with a fallback secret the Playwright dev server never had, and without htxCode, so 20 of them landed on /login or the NO_HTX notice. playwright.config.ts sets an e2e-only AUTH_SECRET for the dev server and the specs, and one helper (tests/e2e/helpers/forged-session.ts, HTX TC) replaces the 12 copies
  • Chatbot market context: its header said the data covered 48 hours while the query reads 30 days; it now says 30 days
  • Sidebar profile menu: it sat on --card with white text, so in light mode its links were white on white. It now uses the overlay surface and ink tokens
  • Journal reject button: the officer's "Từ chối nhật ký" button set its fill from an undefined variable, so it was transparent and its white text was invisible on the white dialog. It is now a danger fill with --color-ink-inverse text
  • Exported lot status on the public trace page: the snapshot stored at QR export was read before the export, so it kept status: 'READY' and the lot's earlier QR image (normally none); the public page then showed a READY pill and no "locked" banner for every lot exported in the app. The snapshot now stores QR_EXPORTED and the generated QR image. Snapshots already stored with READY are not rewritten, so lots exported before this fix still show READY on their public page (an exported lot cannot be exported again)
  • Journal photo keys: POST /api/journal accepted any photo_minio_key inside para/<htxCode>/, so a farmer could attach any document of their HTX, a manager-only one for example, and receive a signed download URL for it from GET /api/journal. It now accepts only a file key under para/<htxCode>/Areas/Journal/ (400 otherwise), and the journal list signs only such keys; a row stored with another key comes back without a photo. No legitimate photo is lost: the upload route did not exist before this release
  • Farmer diagnosis confidence: the result and history showed the 0–1 confidence as a percentage without scaling (0.988 as 1.0%), and the low-confidence warning always showed. They now show 98.8% and warn only below 70%

Container images

  • ghcr.io/maiychrus25/opentea-dx-os-web:1.7.0
  • ghcr.io/maiychrus25/opentea-dx-os-api:1.7.0
  • ghcr.io/maiychrus25/opentea-dx-os-postgres:1.7.0
  • ghcr.io/maiychrus25/opentea-dx-os-scanner:1.7.0
  • ghcr.io/maiychrus25/opentea-dx-os-migrate:1.7.0
  • ghcr.io/maiychrus25/opentea-dx-os-dataops:1.7.0

Deploy

Download opentea-dx-os-1.7.0.tar.gz, verify it with SHA256SUMS, then follow the
release deployment guide (6-step order: postgres, platform-init, migrate, platform-init again, rest, then --profile tools run --rm ollama-init to pull the pinned LLM model).
Set DXOS_MQTT_DEVICES and DXOS_MQTT_INGEST_PASSWORD in docker/.env.local first: the broker refuses to start while any MQTT password begins with change_me.
Also set MINIO_ACCESS_KEY, MINIO_SECRET_KEY (SeaweedFS refuses placeholders), KEYCLOAK_ADMIN and KEYCLOAK_ADMIN_PASSWORD, and run every command as docker compose --env-file docker/.env.local -f docker/docker-compose.yml -f docker/docker-compose.release.yml ..., otherwise Compose ignores those values.