toga-ai 1.0.124 → 1.0.125

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,4 +4,4 @@
4
4
  |-----|---------|-------|
5
5
  | [TOGa Supply (toga2-supply) Architecture](architecture.md) | `toga2-supply` is the **React + Vite frontend** for TOGa Supply — warehouse fulfillment tooling (shipment selection, fulfill & ship against carrier APIs, NetSui | toga2-supply/src/api/toga.ts, toga2-supply/src/pages/ShipmentItems/view/ShipmentItemsPage.tsx, toga2-supply/src/pages/EditShipment/view/EditShipmentPage.tsx, toga2-supply/src/pages/EditShipment/api/UpdateShipmentApi.ts, toga2-supply/src/pages/Shipments/view/components/ShipmentsCardTableForm/ShipmentsCardTableForm.tsx |
6
6
  | [Fulfill & Ship](features/fulfill-and-ship.md) | Fulfill & Ship lets a warehouse user select sales-order line items, enter serials, pick a carrier/method, and in one action: create the Item Fulfillment records | toga2-supply/src/pages/ShipmentItems/view/ShipmentItemsPage.tsx, toga2-supply/src/pages/EditShipment/view/EditShipmentPage.tsx, toga2-supply/src/pages/EditShipment/view/components/forms/EditShipmentForm.tsx, toga2-supply/src/pages/EditShipment/api/UpdateShipmentApi.ts, toga2-supply/src/pages/Shipments/view/components/ShipmentsCardTableForm/ShipmentsCardTableForm.tsx, toga2-supply/src/pages/Shipments/api/ShipmentsApi.ts, _underscore/Model/Client/ItemFulfillment.php, _underscore/Trait/Netsuite/ItemFulfillment.php, _underscore/Component/Library/Carriers/Ups/Ups.php |
7
- | [AWS Amplify Build & Deploy (non-prod environments)](workflows/amplify-build-and-deploy.md) | How `toga2-supply` (React + Vite) builds and deploys to **AWS Amplify** for non-prod environments (Stage, QC Security, QC Performance, …). | toga2-supply/amplify.yml, toga2-supply/.github/workflows/sync-stage-environments.yml, toga2-supply/.env.qc-security |
7
+ | [AWS Amplify Build & Deploy (non-prod environments)](workflows/amplify-build-and-deploy.md) | How `toga2-supply` (React + Vite) builds and deploys on **AWS Amplify**. | toga2-supply/amplify.yml, toga2-supply/.github/workflows/sync-stage-environments.yml, toga2-supply/.env.qc-security |
@@ -6,7 +6,7 @@ project: TOGa Supply
6
6
  client: shared
7
7
  type: workflow
8
8
  status: active
9
- updated: 2026-06-17
9
+ updated: 2026-06-18
10
10
  owners: ["jcardinal"]
11
11
  files:
12
12
  - toga2-supply/amplify.yml
@@ -18,87 +18,90 @@ related:
18
18
 
19
19
  ## Summary
20
20
 
21
- How `toga2-supply` (React + Vite) builds and deploys to **AWS Amplify** for non-prod
22
- environments (Stage, QC Security, QC Performance, …). The **alpha/beta/gamma/production**
23
- environments historically deploy via **GitHub Actions** (`.github/workflows/*.yml`) into the
24
- `agilantsolutions/toga2-supply-build` repo — Amplify is the path used for the newer non-prod
25
- environments. The first Amplify build failed with a JavaScript heap OOM; this doc records the
26
- fix and the chosen **branch-per-environment** deployment model.
27
-
28
- ## Deployment model — branch per environment, mirrored from `_stage`
29
-
30
- The unit of an environment in Amplify is a **branch** (idiomatic Amplify: branch = environment).
31
- A single branch cannot fan out to multiple environments, and a branch can only be connected once
32
- per Amplify app. So:
33
-
34
- - **`_stage` is the integration branch** — where work lands and is reviewed. It is **not deployed
35
- directly**.
36
- - Each environment is its **own deployment branch** that mirrors `_stage` exactly:
37
- `stage`, `qc-security`, `qc-performance`, …
38
- - **Branch name == Vite mode == `.env.<branch>` filename.** `amplify.yml` builds with
39
- `--mode "$AWS_BRANCH"` (Amplify injects `$AWS_BRANCH`), so branch `qc-security` builds
40
- `--mode qc-security` and loads `.env.qc-security`. No per-branch env var needed.
41
- - A GitHub Action (`sync-stage-environments.yml`) **fast-forwards every environment branch to
42
- `_stage` on each push**, triggering each branch's Amplify build with its own mode.
21
+ How `toga2-supply` (React + Vite) builds and deploys on **AWS Amplify**. Each Amplify
22
+ **branch is one environment** (`_production`, `_beta`, `_gamma`, `_stage`, `_qc-security`,
23
+ `_qc-performance`, …). The first Amplify build failed with a JavaScript heap OOM, and a later
24
+ attempt **broke production** by silently pointing it at beta — this doc records both the heap
25
+ fix and the branch→mode mapping that prevents the mis-pointing.
26
+
27
+ ## Deployment model — one branch per environment
28
+
29
+ - Branch names are **underscore-prefixed** (`_production`, `_qc-security`); the Vite **mode**
30
+ and `.env` file are the **same name WITHOUT the underscore** (`production`, `qc-security`).
31
+ - The repo-root **`amplify.yml` drives the build for every branch** (it overrides the Amplify
32
+ console build spec for the whole app — including `_production`). It:
33
+ - Sets `NODE_OPTIONS=--max-old-space-size=8192` (the OOM fix; matches production), runs
34
+ `npm ci --legacy-peer-deps`, caches `.npm`.
35
+ - Derives the mode by **stripping the leading underscore** from `$AWS_BRANCH`
36
+ (`MODE="${AWS_BRANCH#_}"`), then runs `npx tsc && npx vite build --mode "$MODE"`.
37
+ - **Fails the build loudly** (`exit 1`) if `.env.$MODE` does not exist — see the gotcha below.
38
+ - `_stage` is **both** the Stage environment (builds `--mode stage`) **and** the integration
39
+ source for the QC environments. The `sync-stage-environments.yml` GitHub Action fans `_stage`
40
+ out to `_qc-security` and `_qc-performance` on every push (fast-forward `--force-with-lease`),
41
+ triggering each QC branch's own Amplify build.
43
42
 
44
43
  ```
45
- _stage (integration, not deployed)
46
- │ push → sync-stage-environments.yml fast-forwards ↓
47
- ├──▶ stage ──▶ Amplify ──▶ build --mode stage
48
- ├──▶ qc-security ──▶ Amplify ──▶ build --mode qc-security
49
- └──▶ qc-performance ──▶ Amplify ──▶ build --mode qc-performance
44
+ _production ──▶ Amplify ──▶ build --mode production (.env.production)
45
+ _beta ──▶ Amplify ──▶ build --mode beta
46
+ _gamma ──▶ Amplify ──▶ build --mode gamma
47
+ _stage ──▶ Amplify ──▶ build --mode stage
48
+ │ push → sync-stage-environments.yml fast-forwards ↓
49
+ ├──▶ _qc-security ──▶ Amplify ──▶ build --mode qc-security
50
+ └──▶ _qc-performance ──▶ Amplify ──▶ build --mode qc-performance
50
51
  ```
51
52
 
52
53
  ## Steps
53
54
 
54
- 1. **`amplify.yml` (repo root) drives the build.** When present it **overrides the Amplify
55
- console build settings entirely** — you cannot split "memory in the file, build command in the
56
- console." It sets `NODE_OPTIONS=--max-old-space-size=4096` (the OOM fix) and runs
57
- `npx tsc && npx vite build --mode "$AWS_BRANCH"`, publishing `dist/`.
58
- 2. **In the Amplify app, connect one branch per environment** (`stage`, `qc-security`,
59
- `qc-performance`, …). Each branch is its own environment with its own hosting domain.
60
- 3. **Each environment needs a committed `.env.<branch>` file** (Vite loads `.env.<mode>`).
61
- e.g. `.env.qc-security` provides `VITE_API`.
62
- 4. **Add the branch to the sync matrix.** Edit `sync-stage-environments.yml` → `matrix.branch`.
63
- 5. Push to `_stage`; the Action mirrors the env branches; Amplify rebuilds each.
55
+ 1. **Connect one Amplify branch per environment** (underscore-prefixed). Within a single
56
+ Amplify app a branch connects only once — you cannot point multiple environments at the same
57
+ branch connection, which is why each environment is its own branch.
58
+ 2. **Commit a matching `.env.<mode>` file** (no underscore): `.env.production`, `.env.beta`,
59
+ `.env.gamma`, `.env.alpha`, `.env.stage`, `.env.qc-security`. A new environment needs its
60
+ file before it can deploy (otherwise the build fails loudly by design).
61
+ 3. **For a fanned-out QC environment, add its underscore branch to the sync matrix** in
62
+ `sync-stage-environments.yml`.
63
+ 4. Push; Amplify builds each branch with its own mode. **Roll out `amplify.yml` changes on a
64
+ non-prod branch first** (it overrides production's build spec too).
64
65
 
65
66
  ## Systems involved
66
67
 
67
- - AWS Amplify (build + hosting) — one branch per environment, branch name selects the mode.
68
- - GitHub Actions — `sync-stage-environments.yml` mirrors `_stage` → env branches on push.
69
- - Vite 4 build (`vite build --mode <branch>`), TypeScript `tsc` precompile.
70
- - Sentry source-map upload via `@sentry/vite-plugin` (source maps are **on** —
71
- `build.sourcemap: true` in `vite.config.ts`).
68
+ - AWS Amplify (build + hosting) — one branch per environment; branch name (minus `_`) selects
69
+ the Vite mode and `.env` file.
70
+ - GitHub Actions — `sync-stage-environments.yml` mirrors `_stage` → `_qc-security`,
71
+ `_qc-performance`. (Separately, `alpha/beta/gamma/production.yml` are the older GitHub-Actions
72
+ build path into `agilantsolutions/toga2-supply-build`.)
73
+ - Vite 4 (`vite build --mode <mode>`), TypeScript `tsc` precompile. Source maps are **on**
74
+ (`build.sourcemap: true` in `vite.config.ts`).
72
75
 
73
76
  ## Edge cases & escalation
74
77
 
75
- - **OOM root cause:** Amplify gives Node the default ~2 GB old-space heap. This app
76
- (1793 modules + source maps on) exceeds it during Rollup's `rendering chunks` phase →
77
- `FATAL ERROR: Ineffective mark-compacts near heap limit`. Fix = raise `NODE_OPTIONS`.
78
- - **Heap vs. instance RAM:** `--max-old-space-size=4096` only helps if the build container
79
- has ≥4 GB. Amplify **Standard** compute is 4 GB (tight with source maps on). If it OOMs
80
- again, switch to the **Large build instance** (Amplify → App settings → Build settings)
81
- and raise to `6144`/`7168`. Setting the heap above physical RAM makes it worse, not better.
82
- - **"Can't pick `_stage` again" in the UI:** within one Amplify app a branch connects only once.
83
- This is why environments are separate *branches*, not multiple connections to `_stage`. (An
84
- alternative — multiple Amplify *apps* all pointed at `_stage` — works but is a non-idiomatic
85
- workaround: N apps to manage, no single dashboard. Branch-per-env is preferred.)
86
- - **Env branches are disposable deployment pointers — never commit to them directly.** The sync
87
- Action force-updates them (`--force-with-lease`) to match `_stage`; any direct commit is lost.
88
- - **Branch name must match the mode/`.env` filename.** `--mode qc-security` loads
89
- `.env.qc-security` exactly — a mismatch (e.g. a stray `.env.qc-security.beta`) is silently
90
- ignored: the build succeeds but ships with no `VITE_API`.
78
+ - **Silent wrong-endpoint trap (caused a production outage):** When Vite is given a `--mode`
79
+ with no matching `.env.<mode>`, it **silently falls back to the base `.env`** (which points at
80
+ beta) instead of erroring. An `amplify.yml` that built `--mode "$AWS_BRANCH"` therefore ran
81
+ `--mode _production` (no `.env._production`) and shipped beta endpoints to production. **Fix:**
82
+ strip the underscore to get the real mode, AND guard with `[ -f ".env.$MODE" ] || exit 1` so a
83
+ missing env file fails the build instead of mis-pointing.
84
+ - **`amplify.yml` overrides production.** A repo-root `amplify.yml` replaces the console build
85
+ spec for **all** branches including `_production`. Validate any change on a non-prod branch
86
+ before it can reach production.
87
+ - **OOM root cause:** Amplify gives Node the default ~2 GB old-space heap; this app
88
+ (1793 modules + source maps) exceeds it during Rollup's `rendering chunks` phase →
89
+ `FATAL ERROR: Ineffective mark-compacts near heap limit`. Fix = raise `NODE_OPTIONS`
90
+ (`8192` in production). Raising it only helps if the build instance has that much RAM; if it
91
+ still OOMs, use the **Large build instance**.
92
+ - **Env branches are disposable deployment pointers** — the sync Action force-updates
93
+ `_qc-security`/`_qc-performance` to match `_stage`. Never commit to them directly.
91
94
  - **Secret hygiene:** `.env.<mode>` files have historically carried a live `SENTRY_AUTH_TOKEN`.
92
95
  Prefer rotating it and moving it to an Amplify env var rather than committing it.
93
96
 
94
97
  ## Change history
95
98
 
96
- - 2026-06-17 — Switched to branch-per-environment: `amplify.yml` now builds `--mode "$AWS_BRANCH"`
97
- and added `sync-stage-environments.yml` to mirror `_stage` → env branches. (Superseded the
98
- earlier `VITE_BUILD_MODE` per-branch-env-var idea — unworkable because multiple environments
99
- must deploy from the single `_stage` branch.) (jcardinal)
100
- - 2026-06-17 — Created on first Amplify setup of a new QC environment: added root `amplify.yml`
101
- with raised Node heap (OOM fix); renamed `.env.qc-security.beta` → `.env.qc-security`. (jcardinal)
99
+ - 2026-06-18 — Fixed production-breaking deploy: `amplify.yml` now strips the leading `_` from
100
+ `$AWS_BRANCH` to get the Vite mode and **fails loudly** if `.env.$MODE` is missing (was
101
+ silently falling back to beta); heap set to 8192; sync workflow targets underscore-prefixed
102
+ `_qc-security`/`_qc-performance`. (jcardinal)
103
+ - 2026-06-17 — Initial Amplify setup for a new QC environment: added root `amplify.yml` with
104
+ raised Node heap (OOM fix); renamed `.env.qc-security.beta` → `.env.qc-security`. (jcardinal)
102
105
 
103
106
  ## Related docs
104
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.124",
3
+ "version": "1.0.125",
4
4
  "description": "TOGA Technology Team Claude Knowledge System — shared AI coding harness with skills, knowledge base CLI, and project installer for Claude Code.",
5
5
  "keywords": [
6
6
  "claude",