toga-ai 1.0.85 → 1.0.86

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.
@@ -44,12 +44,22 @@ relays the payload to the ClickUp API verbatim.
44
44
  `description => $body->description`, and custom fields for sales rep / presales email / presales
45
45
  user id / opportunity number / customer number.
46
46
 
47
- There are (at least) two NetSuite-side triggers feeding this one webhook:
48
- - **Real-time** UserEventScript on the Opportunity "Presales Lead" field
49
- (`custbody_ctc_solution_architect`, employee ref) fires on empty→set and posts a fully-populated
50
- payload. Produces correctly-named tasks. Verified 2026-06-15: touching one opp via REST PATCH
51
- (an `xedit`) produced the correct `60533 — 560 Endeavor Health — …` task.
52
- - **A scheduled/batch process** (runs ~:01 past the hour) source of the degenerate tasks below.
47
+ The single payload-builder is NetSuite **UserEvent script 2493 "Create Clickup Opportunity"**
48
+ (`customscript2493`, deployment `customdeploy1`), which fires `afterSubmit` when the Opportunity
49
+ "Presales Lead" field (`custbody_ctc_solution_architect`, employee ref) transitions **empty→set**.
50
+ Its output depends entirely on the trigger **context** (because it reads field values off
51
+ `context.newRecord`):
52
+ - **Full-record contexts** form save (`create`/`edit`), and REST/SOAP API edits (NetSuite context
53
+ `RWS`/`WS`, e.g. the `touch_opportunity_presales_lead.php` tool) — carry the whole record →
54
+ `tranid`/entity/title are present → **correct** name. Verified 2026-06-15: touching opp 5483750 via
55
+ REST produced `60533 — 560 Endeavor Health — Data Center Facility Consolidation Services`.
56
+ - **Partial-record `xedit`** — `submitFields()`, inline-grid edits, mass updates — put only the
57
+ changed field on `context.newRecord` → `tranid`/entity/title read empty → 2493 falls back to
58
+ `name = "OPP " + record.id` with empty descriptive/custom fields → the degenerate stub.
59
+
60
+ The degenerate trigger is **scheduled script 2412 "Update Opp Status / % to Close / Presales Lead"**
61
+ (deployment `customdeploy_update_opp_status_morning`, status SCHEDULED). It auto-assigns the Presales
62
+ Lead via `submitFields` (NetSuite context `SCH`, user `-System-`), which fires 2493 in `xedit` → stub.
53
63
 
54
64
  ## Data model
55
65
  - ClickUp Opportunities list `901111987449`; custom-item id `1009`.
@@ -62,18 +72,30 @@ There are (at least) two NetSuite-side triggers feeding this one webhook:
62
72
  None — single internal Agilant/True integration.
63
73
 
64
74
  ## Gotchas / known issues
65
- - **`OPP <internalId>` degenerate tasks (root cause).** Occasionally a task is named just
66
- `OPP 7147699` with no description/fields. The name is built entirely by NetSuite; TOGA relays it.
67
- The opportunities involved are **fully populated in NetSuite** (verified via SuiteQL `OPP 7147699`
68
- is internal id 7147699 = tranid 74197, "7904 Froedtert South", "Seal Shield Opportunity Assessment"),
69
- so this is **not** missing data and **not** a TOGA bug a NetSuite-side process sent a fallback
70
- payload (`name = "OPP " + record.id`, descriptive fields empty) without loading `tranid`/`entity`/
71
- `title`. The four observed (Jun 2026) all created at ~:01 past the hour by the dfranks token →
72
- a NetSuite **scheduled** script, distinct from the working real-time presales-lead trigger
73
- (~3% failure: 4 degenerate vs 122 correct from the same token). Fix is NetSuite-side
74
- (load the record / saved-search columns before building the name); the offending script lives in
75
- the NetSuite File Cabinet, not this repo. Optional TOGA backstop: in `createTask()`, if `name` is
76
- empty or matches `^OPP \d+$`, look the opp up by internal id and rebuild the name before POSTing.
75
+ - **`OPP <internalId>` degenerate tasks (root-caused & confirmed 2026-06-15).** A task named just
76
+ `OPP 7147699` with no description/fields. The name is built by NetSuite and relayed verbatim;
77
+ the opps are **fully populated** in NetSuite (so it's not missing data, not a TOGA bug). Cause:
78
+ scheduled script **2412** sets the Presales Lead via `submitFields` (empty→set) fires UserEvent
79
+ **2493** in `xedit` context 2493 reads `tranid`/entity/title off the partial `newRecord` (empty)
80
+ `name = "OPP " + id`. Confirmed via `systemnote`: each of the 4 stubs (Jun 12–13) was preceded
81
+ ~1–2s by a `context=SCH`, user `-System-`, `CUSTBODY_CTC_SOLUTION_ARCHITECT` set (to Cory Martin,
82
+ employee 38886). **Regression date:** script 2412's source file
83
+ (`Update_Opportunity_Status_Percent_to_Close.js`, file id 5182695) was last modified **2026-06-01**,
84
+ and **zero** stubs existed in the prior ~14 months (full ClickUp sweep, Apr 2025→Jun 12 2026) the
85
+ June 1 edit added the Presales-Lead auto-assignment. **Precise failure condition:** only the
86
+ *empty→set* transition fires it a scheduled set to an already-present lead is a no-op (confirmed
87
+ on opp 5483750, where a 07:02 `SCH` set produced no stub because the lead was already present).
88
+ - **Fix options (NetSuite-side, in script 2493):**
89
+ - *Preferred* — `record.load({type, id: context.newRecord.id})` (or `search.lookupFields` for
90
+ `tranid`/entity/title) before building `name`. Works for **every** trigger context; produces
91
+ correct names instead of stubs-or-nothing.
92
+ - *Alternative* — skip on `xedit` (`if (context.type === context.UserEventType.XEDIT) return;`).
93
+ Suppresses the stubs but **also drops** legitimate task creation from inline-grid edits, mass
94
+ updates, and any other `submitFields` automation. Does **not** affect full-form saves, creates,
95
+ or REST/SOAP edits (incl. the touch tool, which is `RWS`/full-edit). Trades a visible bug for a
96
+ silent one — only acceptable if presales leads are never set inline/in bulk.
97
+ - *TOGA backstop (optional)* — in `createTask()`, if `name` is empty or matches `^OPP \d+$`, look
98
+ the opp up by internal id and rebuild the name before POSTing.
77
99
  - **No inbound logging.** `Webhook_NetSuite::post()` has a `// Log payload to file` comment but does
78
100
  **nothing** — the raw NetSuite payload is persisted nowhere, which is why this was hard to trace.
79
101
  Adding real request logging here would make recurrences diagnosable immediately.
@@ -83,7 +105,26 @@ None — single internal Agilant/True integration.
83
105
  - Handler is triplicated; a fix must be applied to the live `webhook/` copy (and ideally the others
84
106
  to avoid drift).
85
107
 
108
+ ## Remediation (re-create a proper task for an existing stub)
109
+ Because the integration is create-only, an `OPP <id>` stub can't be "fixed" in place — you
110
+ re-fire 2493 from a full-record context, which creates a correctly-named task alongside the stub
111
+ (then delete the stub). Run the touch tool with the opp internal id(s):
112
+
113
+ ```
114
+ php test/@dave/touch_opportunity_presales_lead.php <id1>,<id2>,...
115
+ ```
116
+
117
+ It blanks then restores `custbody_ctc_solution_architect` via REST (`RWS`/full-edit), firing 2493
118
+ with the full record → proper `<tranid> — <custNum> <customer> — <title>` task ~1–2s later.
119
+ **Leaves the original stub** — delete the `OPP <id>` task in ClickUp afterward.
120
+ Done 2026-06-15 for opps 7147699/7147698/7147472/6382879 → 4 proper tasks created; the 4 stubs
121
+ (task ids `868k0tr41`, `868k0tr16`, `868k0rwtp`, `868k0h44m`) were left for deletion.
122
+
86
123
  ## Change history
124
+ - 2026-06-15 — Identified the exact NetSuite culprits (scheduled **2412** `submitFields`→`xedit`→
125
+ UserEvent **2493**), regression date (script 2412 modified 2026-06-01; no stubs before Jun 12),
126
+ and `systemnote`/`SCH` confirmation; added remediation-via-touch procedure and fix-option
127
+ trade-offs (`record.load` vs skip-`xedit`). (dfranks)
87
128
  - 2026-06-15 — Documented integration + root-caused `OPP <internalId>` degenerate tasks to a NetSuite
88
129
  scheduled (~:01 hourly) fallback payload; confirmed live receiver is `webhook/`, not api2/worker2;
89
130
  noted no-op inbound logging and the Opp#/Cust# swap. (dfranks)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
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",