Repository navigation
OpenTea DX-OS v1.7.0
Added
- Tea leaf disease model:
ai-models/tea_leaf_model.keras(MobileNetV2 transfer learning, 224×224, 8 classes listed inai-models/tea_class_names.txt, 9.2 MB) with Vietnamese labels intea_class_names_vi.json, each marked for officer review.ai-models/tea/holds the reproducible pipeline (train.py,datasets.jsonwith DOIs, download URLs and SHA-256, pinnedrequirements.txt) that runs inpython: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 inai-models/ATTRIBUTION.md; no image is committed.ai-models/tea/MODEL_CARD.mdreports 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 calledhealthyat 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=teaondisease-apiuses the tea leaf model next to the general one (still the default; any other model name answers 400). Responses gainmodelanduncertain; a tea result belowTEA_CONFIDENCE_THRESHOLD(default0.60, rejected at startup outside (0, 1]) has null names and keepstop3./healthaddsmodelswith each model's state - Tea disease flow in the web app: a parcel whose crop names
chè/teais diagnosed with the tea model, any other with the general one. An uncertain result is stored asKhông xác định, and every result still goes to the officers; the farmer screen saysĐã gửi cán bộ kỹ thuật xeminstead of presenting a final diagnosis. A 503 from the tea model is an outage (503AI_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]/reviewtakesconfirmed_diagnosis, required when approving, and stores it inconfirmed_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 aHARVESTEDparcel toTENDINGand opens the cycleLứ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 keypara/<htxCode>/Areas/Journal/<yyyy>/<uuid>-<safe name>, whichPOST /api/journalaccepts asphoto_minio_key. Onlyimage/jpeg,image/pngandimage/webpare 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 lyfor each parcel of the farmer's household whose latest safe harvest date (from journal entries not rejected) is still ahead;Nis whole days, rounded up - Tea demo data:
npm run seed(new script, runsprisma 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). ParcelTC-A3has, relative to the seed run, a fertiliser entry, a spraying entry still under its 7-day withdrawal, a harvested previous round whose lotTC-CHE-A3-001is already exported with a public trace page, and one pending tea disease report. Re-running it changes onlyTCandLBrows (plus the shared market, bulletin and partner rows); the history of the seeded parcels is rebuilt with fresh dates.platform/tests/seed-test.shchecks this on a throwaway database - Tea demo accounts in the realm:
manager_tc,officer_tc,farmer_tc,manager_lb,officer_lb,farmer_lb(passwordTest1234!; 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_syncalso fetches HS0902and stores it asTea;vietnam_market_syncadds a simulated dried tea bud price (Tea,VND/kg). Every price that workflow simulates is now written under the sourceMô 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 pricesgiá 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 ofapps/web/src/styles/globals.css, which now has a dark value for every colour token, applied underprefers-color-scheme: darkunless the viewer picked light, or underdata-theme="dark". A theme button (Sáng → Tối → Theo hệ thống, stored inlocalStoragekeyopentea-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'sdark: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 thatDESIGN.mdmatchesglobals.css. A colour guard fails on hard-coded colours in*.module.cssand*.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.tsruns "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 thedisease-apiaccess 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 ofTC-A2; the public pages/q/<code>of that lot and ofTC-CHE-A3-001show their withdrawal status.tests/e2e/visual/screens.spec.tssaves 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 undertest-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. Theplatform-smokeCI job now seeds the demo data, startsdisease-apiwithweb, runs both specs after the core tenant spec and uploads the screenshots as thepriority-screensartifact.make platform-smokealso createssmoke_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.txthas an exact version, andtensorflow-cpu(unpinned, no arm64 wheel) is replaced bytensorflow==2.21.0withkeras==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-OSeverywhere (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), fromapps/web/src/lib/brand.ts. The Keycloak theme directory and realm keep the nameagrimarket - 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-sansuses 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ùais nowLịch thu hái; a new zone's season defaults toLứa 1/<year>; the default commodity of the bulletin, market widget and market API isChè/Tea(the farmer bulletin page now looks it up by its English name, as the workflows store it, andGET /api/bulletinwithout?commodityreadsTeafor any tea crop of the HTX, such asChè 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
MD2rice 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,officer1andfarmer1are 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_userrefuses any other name, so tests never reset a demo user's password or TOTP. The A3 story and the screenshots also sign in asfarmer_tc, which has no TOTP step; a login does not change the account. Thetwo-htx.sqlfixture shares theTC/LBprofiles 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.cssand*.tsxunderapps/web/srctakes its colours fromglobals.css, so all screens follow the dark theme, and the colour guard's baseline is empty. Text on primary fills uses--color-primary-foregroundand on success or danger fills--color-ink-inverse; the always-dark surfaces (sidebar, bulletin header) use the sidebar tokens. The guard'sexceptionsname 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, whichleaflet.csskeeps white. The lot page's decorative QR preview follows the theme. About 80 variables thatglobals.cssnever 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;@themenames count as undeclared because Tailwind emits them only when a utility needs them. A test fails on anyvar(--…)thatglobals.cssdoes 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,TENDINGorHARVEST_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_tcandfarmer_lbneed. On an existing stack either (a) delete the realm (Realm settings > Action > Delete) and rundocker compose -f docker/docker-compose.yml restart keycloakso--import-realmimports it again, which also drops users created at runtime; or (b) deletemanager1,officer1andfarmer1, then Realm settings > Action > Partial import ofdocker/keycloak/realm-agrimarket.jsonwith only Users and Overwrite, which replaces themanager_tc,manager_lbandfarmer_tcthe 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 deletedocker_pgdata: the realm lives in itskeycloakdatabase next to all app data - Demo data: run
npm run seedonly on a demo database: it rebuilds the history of theTCandLBparcels 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-apicontainer (docker compose -f docker/docker-compose.yml up -d --build --wait web disease-api);make platform-updoes not start it - Never
down -von the main stack: earlier upgrade notes (1.3.0) suggested recreating the Postgres volume or runningdocker compose down -vonce for n8n. Both deletedocker_pgdata, which holds the Keycloak realm and all app data. UseREINDEX DATABASEfor the collation change and let n8n create its tables in then8nschema (README, "Nâng cấp môi trường dev cũ") - Storage: no change to
docker/.env.localis needed.MINIO_ENDPOINTmay beminioorminio:9000
Fixed
- web image on arm64:
npm installin the Dockerfile could leave out@next/swc-linux-*-muslwithout an error (npm skips an optional download that fails), and BuildKit then reused that broken layer, sonext buildfailed 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_ENDPOINTas a host name whiledocker/.env.local.examplesetsminio:9000, so every request ofwebthat touched storage failed withInvalid endPoint: journal photo upload, diagnosis, the farmer's diagnosis history, the officer's disease screens, documents and QR export. Both adapters now accepthostorhost:port. The browser's presignedPUTto 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/streamevent 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 rawQR_EXPORTED(orREADY) pill and now showsĐã xuất QR,Sẵn sàngorBản nháp; the officer disease queue and review showedPENDINGand now showChờ duyệt; the farmer's diagnosis history mapped a status the reports never take (RESOLVED) and showedCONFIRMED/REJECTEDraw, and now showsChờ duyệt,Đã xác nhậnorBị 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-001is gradedLoại 1instead ofGrade 1 - disease-api health check allows 60 seconds for both TensorFlow models to load before failed checks count, so
up --waitdoes 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/loginor the NO_HTX notice.playwright.config.tssets an e2e-onlyAUTH_SECRETfor the dev server and the specs, and one helper (tests/e2e/helpers/forged-session.ts, HTXTC) 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
--cardwith 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-inversetext - 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 storesQR_EXPORTEDand the generated QR image. Snapshots already stored withREADYare 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/journalaccepted anyphoto_minio_keyinsidepara/<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 fromGET /api/journal. It now accepts only a file key underpara/<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.988as1.0%), and the low-confidence warning always showed. They now show98.8%and warn only below 70%
Container images
ghcr.io/maiychrus25/opentea-dx-os-web:1.7.0ghcr.io/maiychrus25/opentea-dx-os-api:1.7.0ghcr.io/maiychrus25/opentea-dx-os-postgres:1.7.0ghcr.io/maiychrus25/opentea-dx-os-scanner:1.7.0ghcr.io/maiychrus25/opentea-dx-os-migrate:1.7.0ghcr.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.