toga-ai 1.0.716 → 1.0.717

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.
@@ -6,7 +6,7 @@ project: Worker
6
6
  client: shared
7
7
  type: feature
8
8
  status: active
9
- updated: 2026-08-28
9
+ updated: 2026-08-31
10
10
  owners: ["jcardinal", "mhammontree", "bala"]
11
11
  files:
12
12
  - worker2/Worker/Monitor/Compass.php
@@ -65,9 +65,24 @@ Each measures one Compass/Office Depot integration metric and pushes a decided a
65
65
  - **OfficeDepotEdiImportQueue** (S3) — counts files >10 min old in
66
66
  `s3://agilant-as2/OfficeDepot/`, excluding `OUTBOX/`, `SENT/` and directory placeholders.
67
67
  - **CompassSalesOrderTransmission** (DB) — approved SOs (both approval stages) with
68
- `c_dtTransmittedToCompass` NULL (not yet transmitted to MITS).
68
+ `c_dtTransmittedToCompass` NULL (not yet transmitted to MITS). Alarms on **either**
69
+ `pendingCount > 10` **OR** `oldestPendingAgeMinutes > 180` (3h), so a single order stuck too
70
+ long pages even under the count threshold — this catches the 1.0 cron's
71
+ [poison-order starvation](../../../clients/compass-usa/features/mits-sales-order-transmission-alerting.md).
72
+ **Age is measured from the FINAL (stage-2) approval decision** (`ApprovalDecisions` stage 2
73
+ `dtDecision` where `isApproved = 1` — not stage 1, not order date; that is the "eligible to
74
+ transmit" clock). The query **excludes canceled orders** (`salesOrderStageId IS NULL OR
75
+ <> 8`), mirroring the transmit cron's WHERE, so an order canceled after approval (e.g.
76
+ SA136567, now stage 8) neither counts nor false-alarms forever — this also fixed a
77
+ pre-existing count mismatch vs. the cron. Config: `$ALARM_AGE_MINUTES = 180`; body echoes
78
+ `oldestPendingAgeMinutes` + `alarmAgeMinutesThreshold`.
69
79
  - **CompassIncomingPurchaseOrders** (DB) — `SA%` SOs transmitted to MITS >4h ago (on/after
70
- the 2026-04-30 cutoff) with no PO returned.
80
+ the 2026-04-30 cutoff) with no PO returned. (This supersedes the 1.0
81
+ `App_SystemMonitor_Compass` "orders returned from MITS" sub-check, which is a **latent
82
+ no-op**: it selects `so`/`number`/etc but then reads `$row['pendingCount']`, a column the
83
+ query never returns, so `$pendingCount` is always null and that sub-check silently always
84
+ reports OK. Verified 2026-08-31 in `library/app/systemmonitor/compass.php` ~lines 111-140,
85
+ TRUE-78712.)
71
86
  - **CompassPurchaseOrderTransmissionsToVendors** (DB) — unsubmitted POs for monitored
72
87
  vendors (Office Depot, Strategic Systems, Compass, Presidio) due today or earlier.
73
88
  - **EmailedAsnImport** (mailbox) — counts inbox messages in the emailed-ASN mailbox via
@@ -415,6 +430,18 @@ check for another client.
415
430
  monitors must pass the region (see [Cloud S3 helpers](../../_underscore/features/cloud-s3-helpers.md)).
416
431
 
417
432
  ## Change history
433
+ - 2026-08-31 — Added **age-based detection** to `CompassSalesOrderTransmission()`: it now alarms
434
+ on `pendingCount > 10` **OR** `oldestPendingAgeMinutes > 180` (new `$ALARM_AGE_MINUTES = 180`),
435
+ so one order stuck too long pages even under the count threshold — catching the 1.0 transmit
436
+ cron's poison-order starvation. Age is measured from the **stage-2** (final) approval decision,
437
+ not stage 1 or order date. The query now also **excludes canceled orders** (`salesOrderStageId
438
+ IS NULL OR <> 8`), mirroring the transmit cron's WHERE, fixing a pre-existing count mismatch and
439
+ a canceled order (SA136567) false-alarming forever. New body fields `oldestPendingAgeMinutes` +
440
+ `alarmAgeMinutesThreshold`; no OneUptime criteria change needed — the age alarm rides the
441
+ existing `"alarm":"HIGH"` token ("dumb reporter, smart monitor"). Also recorded that the 1.0
442
+ `App_SystemMonitor_Compass` "orders returned from MITS" sub-check is a **latent no-op** (reads
443
+ `$row['pendingCount']`, a column its query never selects — always reports OK; TRUE-78712),
444
+ superseded by `CompassIncomingPurchaseOrders`. worker2-only, php -l passes, not deployed. (jcardinal)
418
445
  - 2026-08-28 — Made `EmailedAsnImport()` resilient to a transient IMAP TLS handshake timeout
419
446
  that was flipping the monitor Offline and paging even though it self-recovered next run:
420
447
  wrapped token+connect+count in an **in-run retry loop** (`MAX_CONNECT_ATTEMPTS = 3`,
@@ -6,7 +6,7 @@ client: compass-usa
6
6
  type: client-feature
7
7
  status: active
8
8
  updated: 2026-08-31
9
- owners: ["dfranks", "bala"]
9
+ owners: ["dfranks", "bala", "jcardinal"]
10
10
  files:
11
11
  - worker/crons/toga2/compass/workflow/1_transmit_compass_sales_orders_to_mits.php
12
12
  - worker/crons/toga2/compasscanada/workflow/1_transmit_compassCanada_sales_orders_to_mits.php
@@ -100,6 +100,44 @@ Configuration is **never retroactive**: `shouldNotify()` fires on the first occu
100
100
  escalation, or when the backed-off reminder interval elapses, and returns false for a window with
101
101
  zero events. The first email lands on the **next live rejection**, not on existing history.
102
102
 
103
+ ## Why the backlog happens — poison-order starvation (root cause)
104
+
105
+ The alert almost never fires on **volume**. It fires because one bad order **aborts the whole
106
+ run** and every un-processed order behind it starves. Diagnosed 2026-08-31 against a live
107
+ backlog (0 new, several >24h, one ~20 days old).
108
+
109
+ - The cron loops approved-but-untransmitted orders and `throw`s on any MITS rejection
110
+ (`App_Exception_Business` on a non-200, plain `Exception` on "No Items Found"). A throw
111
+ **ends the entire run**, so every order not yet reached that run stays untransmitted.
112
+ - The driver query uses **`ORDER BY RAND()`**, so *which* orders get processed before the bad
113
+ one is random each run. A stuck "poison" order therefore blocks a **different** set of good
114
+ orders every run — good orders can wait days behind one bad one.
115
+ - Throughput ceiling: the cron sleeps **30s per order** (86400s time limit), scheduled every
116
+ 3 min but overlap-guarded, so it is effectively one long-running instance — ~110 orders/hr.
117
+
118
+ **Two rejection signatures seen in prod** (Logs.Issue id 24, issueKey
119
+ `COMPASS_SALES_ORDER_MITS_TRANSMIT_REJECTED`, ~2329 occurrences since 2026-08-03):
120
+
121
+ 1. **HTTP 400 `The AssetType field is required`** — a line item's catalog Item has
122
+ `assetTypeId = NULL`, so the payload `assetType` is null and MITS rejects the **whole
123
+ order**. This was the active blocker (e.g. item `4U555A-S`; ~10 distinct NULL-assetType
124
+ items blocked 9 of 11 pending orders).
125
+ 2. **HTTP 403 `SalesOrder:Exists`** — MITS already created the order on a prior attempt, but
126
+ our side never recorded `c_dtTransmittedToCompass`, so the cron **retries it forever**.
127
+
128
+ **Fix the data:** assign the correct `assetTypeId` to the affected `Client_Compass.Items`
129
+ (business owns the mapping), and check whether the NetSuite item sync owns `assetType` — if it
130
+ does, it will revert the fix unless the source is corrected too.
131
+
132
+ **Recommended code hardening (NOT yet implemented):** wrap each order's transmit in
133
+ `try/catch` so one MITS rejection raises the business issue but **continues to the next
134
+ order** instead of aborting the batch. This removes the starvation entirely.
135
+
136
+ The worker2 OneUptime monitor now catches this starvation directly: `CompassSalesOrderTransmission`
137
+ alarms on `pendingCount > 10` **OR** `oldestAgeMinutes > 180`, so a single order stuck too long
138
+ pages even when the count is under threshold. See
139
+ [OneUptime push-metric monitors for 2.0 workers](../../../2.0/apps/worker2/features/oneuptime-worker2-monitoring.md).
140
+
103
141
  ## Gotchas / known issues
104
142
 
105
143
  - **Canada is the pre-2026-08-03 design, and it still carries the two problems that migration
@@ -131,6 +169,14 @@ zero events. The first email lands on the **next live rejection**, not on existi
131
169
  when this issue next fires. Watch that run rather than assuming it works.
132
170
 
133
171
  ## Change history
172
+ - 2026-08-31 — Diagnosed the recurring backlog's **root cause**: not volume but **poison-order
173
+ starvation**. One MITS rejection `throw`s and aborts the whole run, and because the driver
174
+ query uses `ORDER BY RAND()`, a stuck order blocks a random set of good orders every run.
175
+ Recorded the two live rejection signatures (`assetTypeId = NULL` → HTTP 400 "The AssetType
176
+ field is required"; already-created order → HTTP 403 "SalesOrder:Exists" retried forever),
177
+ the data fix (assign `assetTypeId`; check NetSuite item sync ownership), and the recommended
178
+ per-order `try/catch` hardening (not yet implemented). Cross-linked the new worker2 age-based
179
+ monitor. (jcardinal)
134
180
  - 2026-08-31 — Added `vburks@togatech.com` alongside `devteam@togatech.com` on **every** in-cron
135
181
  `App_Email_Agilant` alert in both MITS transmit crons (USA has one, Canada has three), so the
136
182
  business stakeholder is alerted on transmission failures. Broadened this doc to cover **both**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.716",
3
+ "version": "1.0.717",
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",