Skip to content

feat(demo): serve Demo Insight in production for the demo organization only (M4-S2) - #17

Merged
athikarn5678 merged 5 commits into
mainfrom
feat/M4-S2-demo-insight-prod
Nov 18, 2026
Merged

athikarn5678 merged 5 commits into
mainfrom
feat/M4-S2-demo-insight-prod

Conversation

@athikarn5678

Copy link
Copy Markdown
Owner

What

Planner decision (2026-11-17): ADR-048 + Demo Insight in the production runtime for the demo organization only.

  • docs/decisions/0048-...md (accepted, owner decision 2026-11-17): amends ADR-042 for (a) the Learner Lab seed guard (verifyLearnerLabSeedTarget, STOCKWISE_DEMO_SEED_TARGET=learner-lab-ops, empty-or-demo-only DB, stockwise_demo schema pre-created by roles.sql) and (b) Demo Insight in production.
  • demo-insight.ts: the dev/test-only gate is replaced by: in production the reader serves only when the configured STOCKWISE_DEMO_INSIGHT_ORGANIZATION_ID equals the deterministic demo org (DEMO_INSIGHT_PRODUCTION_ORGANIZATION_ID). Unset = off everywhere. Label ข้อมูลตัวอย่าง, no provider call, ordinary authorization first.
  • environment.ts: removed the "disabled in production" validation (UUID format still validated); test updated.
  • Tests (demo-insight-production.integration.test.ts): on for the allowlisted org in production (th/en labels, 0 provider calls); off when unset; off for another org (variable names another org, or request targets another org); env accepts/omits the variable.

Deterministic demo organization UUID (for Worker C)

ce295c46-a4a1-5930-ba4f-75739461072d (demoId("organization","UAT Demo Siam Mart"); equals the organization created by demo:seed:90d). Set STOCKWISE_DEMO_INSIGHT_ORGANIZATION_ID to it in the API task. No infra/ file is touched here.

Caveats (infra follow-ups, not in this PR)

  1. The reader reads stockwise_demo.seed_runs; stockwise_app currently has no access to that schema (roles.sql grants it nothing). Without e.g. GRANT USAGE ON SCHEMA stockwise_demo + SELECT on seed_runs (default privileges for the migrator), production Demo Insight returns 404. Worker C owns roles.sql.
  2. The reader requires COMPLETE provenance with an unchanged business fingerprint, so any live write to the demo organization (a POS sale, including PromptPay) makes it 404 (ADR-042 behaviour retained).

Verification

pnpm verify: 201 test files passed, 1 skipped; 2274 tests passed, 2 skipped.

…n only (M4-S2)

ADR-048 records the Learner Lab seed guard and the production Demo Insight allowlist. The reader now runs in the production runtime only when the configured organization id is the deterministic demo organization; unset means off everywhere.
@athikarn5678
athikarn5678 merged commit f41ef16 into main Nov 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant