toga-ai 1.0.439 → 1.0.440

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.
@@ -14,60 +14,60 @@ updated: 2026-07-27
14
14
  # Session: true-79533-pin-depth
15
15
  **Date:** 2026-07-27
16
16
  **Project/Repo:** _underscore / dbchanges2 / toga2-view (2.0, client Rate)
17
- **Task:** Get the validated Whole Home Warranty service address to pin (`Entitlements.serviceAddressId`) and render on beta. Backend is done and correct; the live blocker is that the beta purchase POST sends `depth=-1`, which starves the `postPost` interceptor of the just-created address id.
17
+ **Task:** Get the validated Whole Home Warranty service address to pin (`Entitlements.serviceAddressId`) and render on beta. Backend is done and correct; the blocker was the beta purchase POST sending `depth=-1`, which starved the `postPost` interceptor of the just-created address id. **FIX CHOSEN: front-end drops `depth`; deploying to beta now — awaiting verification.**
18
18
 
19
19
  ---
20
20
 
21
21
  ## What WORKED
22
22
  <!-- Include specific file paths and evidence -->
23
- - **Backend pin implemented** in `_underscore/Model/Rate/Entitlement.php` `postPost` → `persistWarrantyServiceAddress`: reads the created address id from the in-memory hydrated payload (`$payload->contact->primaryContactAddress->address->id`), then `UPDATE Addresses SET isValidated=1` + `UPDATE Entitlements SET serviceAddressId=… WHERE uuid=…`. Committed `dff1fb5e`. **Proven working**: a no-`depth` (deep-payload) purchase — ET100057, made from the local FE against the beta backend — pinned `serviceAddressId=56` with `Addresses.id 56` (STE 400) `isValidated=1`.
24
- - **`serviceAddressId` is a STANDARD field** on base `_underscore/Model/Client/Entitlement.php:20` (`FIELD_FOREIGNKEY` → `_Model_Client_Address`), inherited by the Rate model. Verified in the model file. So V2 persists/reads it; the postPost UPDATE and the FE read both rely on this.
25
- - **Display EZ-2 fixed**: `dbchanges2/Client_Rate/2026-07-24a - AddressIdFieldPermission.sql` grants READ on `Addresses.id` for roles 1/2/3 (isWritable 0). Committed `ea1e0fb`. Applied on beta manually and verified (`AclFieldPermissions` field 41 → roles 1,2,3). This fixes the FE `GET /v2/addresses?fields=id,…` 403.
26
- - **Hard-blocks now return HTTP 400** via `_Exception_Validation` (the 3 prePost throws: missing address, unverifiable address, duplicate WH). Committed `41a5dc1a`. Verified against `api2/Controller/Index.php:204-222` — it catches `_Exception_Validation` → `DEFINED_MESSAGE_ERROR_BAD_REQUEST` (400 + clean message); all other exceptions → 500 + stack trace. This is what makes the FE blocked-purchase toaster work.
27
- - **Dedup** `hasActiveWarrantyAtAddress` forces the WRITE host + disables the query cache for a fresh read (committed). `COALESCE(serviceAddressId, ContactAddresses.addressId)` fallback so unpinned WHs are still deduped.
28
- - **Root cause proven via `Logs_Rate.Api`** (beta, MCP env `dev-sandbox`): the local-FE and beta-FE purchases hit the SAME beta backend instance (`i-0ce5624547cfecc93`, `api.beta.togahub.com`). The ONLY difference is the request query string — local: `transactionId=…` (no depth) → 64,650-byte deep response → **pinned**; beta: `depth=-1&transactionId=…` → 644-byte shallow response → **starved** (no address node in the payload postPost receives).
29
- - **`-1` source confirmed = front-end**: `toga2-view/src/pages/CheckOut/api/checkoutApi.ts:21` (`createService` passes `{ 'depth': -1 }`), serialized to `?depth=-1`. Confirmed in the logged query string.
30
- - **Beta interceptor config read** (`ApiPayloadInterceptors` join `Core.Records`): entitlements `postPost` = id **2**, active, **minDepth 5**; entitlements `prePost` = id 4, active, minDepth **null → default 3**; sales-orders `postPost` = id 3, null→3.
23
+ - **Backend pin implemented** in `_underscore/Model/Rate/Entitlement.php` `postPost` → `persistWarrantyServiceAddress`: reads the created address id from the in-memory hydrated payload (`$payload->contact->primaryContactAddress->address->id`), then `UPDATE Addresses SET isValidated=1` + `UPDATE Entitlements SET serviceAddressId=… WHERE uuid=…`. Committed `dff1fb5e`. **Proven working AND already on the beta backend**: ET100057 — a purchase whose request had **no `depth` param** (query string `transactionId=…`, 64,650-byte deep response) — pinned `serviceAddressId=56`, address 56 (STE 400) `isValidated=1`, on the same beta instance that fails for `depth=-1` calls. This is the exact config the FE fix reproduces.
24
+ - **`serviceAddressId` is a STANDARD field** on base `_underscore/Model/Client/Entitlement.php:20` (`FIELD_FOREIGNKEY` → `_Model_Client_Address`), inherited by the Rate model.
25
+ - **Display EZ-2 fixed**: `dbchanges2/Client_Rate/2026-07-24a - AddressIdFieldPermission.sql` grants READ on `Addresses.id` for roles 1/2/3. Committed `ea1e0fb`. Applied on beta manually and verified.
26
+ - **Hard-blocks return HTTP 400** via `_Exception_Validation` (committed `41a5dc1a`) — mapped by `api2/Controller/Index.php:204-222`. (NOT yet on beta — see blockers.)
27
+ - **Dedup** `hasActiveWarrantyAtAddress` forces WRITE host + disables query cache; `COALESCE(serviceAddressId, ContactAddresses.addressId)` fallback.
28
+ - **Root cause proven via `Logs_Rate.Api`** (MCP env `dev-sandbox`): local-FE and beta-FE purchases hit the SAME beta instance (`i-0ce5624547cfecc93`). Only difference = request query string depth: no-depth → 64 KB deep → **pins**; `depth=-1` → 644 B shallow (`meta.calcDepth: 1`, no `address` node) → **starved**.
29
+ - **`-1` source = front-end**: `toga2-view/src/pages/CheckOut/api/checkoutApi.ts:21` (`createService` passed `{ 'depth': -1 }`). Confirmed in the logged query string.
30
+ - **Interceptor config (Rohan-confirmed):** `ApiPayloadInterceptors` `minDepth` defaults to **3** when null; entitlements `postPost` (id 2) is explicitly **5**; `prePost` (id 4) & sales-orders (id 3) are null→3. Omitting the request `depth` yields a full/deep build that clears the 5 floor and includes the `address` node.
31
31
 
32
32
  ## What did NOT work — DO NOT RETRY THESE
33
33
  <!-- Exact failure reasons — do not vague-ify -->
34
- - **Forcing the write host inside `persistWarrantyServiceAddress`** (commit `7b63955d`, later removed in `dff1fb5e`): NO EFFECT. V2 already globally disables the read host for the entire create block (`api2/.../V2.php:5024`), so the lookup was ALREADY on the write connection — forcing it again was a no-op. Confirmed by a genuinely post-deploy purchase (ET100051/52/53) still returning null.
35
- - **The original 3-table JOIN lookup** in postPost (`Entitlement → Contacts.primaryContactAddressId → ContactAddresses → addressId`): returned 0 rows *in-request* on beta even on the write connection. The identical query resolves correctly *post-commit*. Superseded by the payload approach.
36
- - **The payload-based pin (`$address->id`) still returned null on beta** — NOT because the code is wrong, but because with `depth=-1` the payload built for `postPost` is shallow (`meta.calcDepth: 1`) and does **not contain the `contact.primaryContactAddress.address` node at all**, so `$address->id` (and the `uuid` fallback) find nothing. Root cause is the depth, not the pin code.
37
- - **Merging `_underscore` to `_beta` did NOT deploy to beta.** The beta EB env **API-Sandbox-Dev** pulls `_underscore` from branch **`_sandbox-dev`** via `api2/.platform/hooks/prebuild/git.sh` + `api2/.ebextensions/git.sandbox-dev.json` (the prebuild hook `rm -Rf`s and re-clones that branch, overwriting the pipeline copy). Deploying anything not on `_sandbox-dev` runs old code.
38
- - **"Removing `depth=-1` from the beta curl" (Fri/earlier)**: the edited curl STILL had `depth=-1` in the query string (it wasn't actually removed) — confirmed via the logged `queryString`. So that test never proved anything.
39
- - **The single-host-vs-multi-host connection theory** (an earlier hypothesis): DISPROVEN. Both local-FE and beta-FE requests run on the SAME beta backend instance. The difference is purely the request's `depth` param, not connection topology.
34
+ - **Forcing the write host inside `persistWarrantyServiceAddress`** (commit `7b63955d`, removed in `dff1fb5e`): NO EFFECT. V2 already disables the read host for the whole create block (`V2.php:5024`) — the lookup was already on the writer.
35
+ - **The 3-table JOIN lookup** (`Entitlement → Contacts.primaryContactAddressId → ContactAddresses → addressId`) in postPost: returns 0 rows *in-request* even on the writer; resolves only *post-commit*. Superseded by the payload approach.
36
+ - **Payload-based `$address->id` on beta with `depth=-1`**: null — the shallow payload (`calcDepth 1`) has NO `contact.primaryContactAddress.address` node at all, so there's nothing to read. Code is correct; depth is the cause.
37
+ - **Merging `_underscore` to `_beta` did NOT deploy to beta.** API-Sandbox-Dev EB pulls `_underscore` from **`_sandbox-dev`** via `api2/.platform/hooks/prebuild/git.sh` + `.ebextensions/git.sandbox-dev.json`.
38
+ - **"Removed depth" curl test (earlier)**: the edited curl STILL had `depth=-1` (per logged `queryString`) — proved nothing.
39
+ - **Single-host vs multi-host connection theory**: DISPROVEN — same beta instance both ways; the variable is the request `depth`, not topology.
40
40
 
41
41
  ## Not tried yet (candidates for next session)
42
- - **THE decisive test (do this first):** on beta `Client_Rate`, `UPDATE ApiPayloadInterceptors SET minDepth = 10 WHERE id = 2;` then fire one fresh WH purchase (FE still sends `depth=-1`) and check `meta.calcDepth` + whether the new entitlement pins (`serviceAddressId` set, its address `isValidated=1`). Open question for Rohan: does the `minDepth` clamp engage for the `-1` sentinel at all? It's already 5 yet the build came through at `calcDepth 1` — so either it needs > 5 or `-1` bypasses the clamp.
43
- - **FE fix (alternative/parallel):** drop `{ 'depth': -1 }` at `toga2-view/src/pages/CheckOut/api/checkoutApi.ts:21` (or set ≥ minDepth), deploy `toga2-view`. This is the FE-side lever; it's owned by Tanner/Alex and the repo is currently on `_beta`.
44
- - Merge `_underscore` `TRUE-79533` → `_sandbox-dev` + deploy (ships the pin + 400 fix; backend is NOT yet on beta).
45
- - Merge `dbchanges2` `TRUE-79533` to its deploy branch for prod parity (beta already has the migrations, applied manually).
42
+ - **PRIMARY (in flight):** Tanner removed `depth` from `checkoutApi.ts:21` on the front-end; the `toga2-view` change is **deploying to beta now**. Verify a fresh beta purchase pins (see Exact next step). This reproduces the proven-good ET100057 config.
43
+ - **FALLBACK if the FE fix somehow doesn't take:** on beta `Client_Rate`, `UPDATE ApiPayloadInterceptors SET minDepth = 10 WHERE id = 2;`, fire a purchase, check whether `calcDepth` rises and it pins. (Open Q: does the `minDepth` clamp engage for the `-1` sentinel? It's 5 yet built at `calcDepth 1`.)
44
+ - Merge `_underscore` `TRUE-79533` → `_sandbox-dev` + deploy (ships the `_Exception_Validation` 400 fix + full backend; pin itself is already on beta).
45
+ - Merge `dbchanges2` `TRUE-79533` for prod parity (beta already has the migrations).
46
46
  - Run `/capture`.
47
- - File side tickets: (1) framework `minDepth`-clamp appears to be a no-op for `depth=-1` (starves ALL payload interceptors); (2) AIG contract block (`postPost`) has the SAME `depth` starvation — silently skipped for beta-FE purchases; (3) SECURITY: plaintext GitHub PAT committed in `api2/.ebextensions/git.*.json` — rotate + move to env config.
47
+ - File side tickets: (1) framework `minDepth`-clamp no-op for low/`-1` depth (starves ALL payload interceptors); (2) AIG contract block has the SAME `depth` starvation — silently skipped for beta-FE purchases; (3) SECURITY: plaintext GitHub PAT committed in `api2/.ebextensions/git.*.json` — rotate + move to env config.
48
48
 
49
49
  ## Current file state
50
50
  | File | Status | Notes |
51
51
  |------|--------|-------|
52
- | `_underscore/Model/Rate/Entitlement.php` | Committed on `TRUE-79533` (HEAD `41a5dc1a`) | payload-based pin (`dff1fb5e`), dedup write-host, `_Exception_Validation` hard-blocks (`41a5dc1a`). NOT merged to `_sandbox-dev`. |
53
- | `_underscore/Model/Client/Entitlement.php` | Committed | `serviceAddressId` standard FK field (line 20). |
54
- | `dbchanges2/Client_Rate/2026-07-24a - AddressIdFieldPermission.sql` | Committed (`ea1e0fb`) | `Addresses.id` read ACL. Applied on beta manually. |
52
+ | `_underscore/Model/Rate/Entitlement.php` | Committed on `TRUE-79533` (HEAD `41a5dc1a`) | payload pin (`dff1fb5e`) + dedup write-host + `_Exception_Validation` (`41a5dc1a`). Pin already on beta; the 400-fix is NOT (needs `_sandbox-dev` merge). |
53
+ | `_underscore/Model/Client/Entitlement.php` | Committed | `serviceAddressId` standard FK (line 20). |
54
+ | `dbchanges2/Client_Rate/2026-07-24a - AddressIdFieldPermission.sql` | Committed (`ea1e0fb`) | `Addresses.id` read ACL. Applied on beta. |
55
55
  | `dbchanges2` serviceAddressId col + `Core` field + ACL migrations | Committed on `TRUE-79533` | Applied on beta manually; branch needs merge for prod. |
56
- | `toga2-view/src/pages/CheckOut/api/checkoutApi.ts` | UNCHANGED (on `_beta`) | Line 21 still `'depth': -1` — the FE fix is pending. |
57
- | `test/@Mark/Rate/verify_wholehome_per_address_guard.php` | Updated (personal, not in a repo) | `c_serviceAddressId` → `serviceAddressId`; documents the multi-host/depth caveat. |
56
+ | `toga2-view/src/pages/CheckOut/api/checkoutApi.ts` | **Tanner removed `depth` — DEPLOYING to beta now** | Line 21 `{ 'depth': -1 }` dropped so `postPost` gets a deep payload. THE unblocker. |
57
+ | `test/@Mark/Rate/verify_wholehome_per_address_guard.php` | Updated (personal, not in a repo) | `c_serviceAddressId` → `serviceAddressId`; documents the depth caveat. |
58
58
 
59
59
  ## Decisions made
60
- - **Pin from the in-memory hydrated payload, not a DB read-back.** Rationale: in-request DB SELECTs can't reliably see the transaction's own uncommitted nested writes; V2's `getFullModelData` hydrates the payload before `postPost`. Rejected: the JOIN lookup (0 rows in-request) and an async post-commit worker (more surface; unnecessary once depth is fixed).
61
- - **`serviceAddressId` = STANDARD field** (per Jeff), not the old Rate-custom `c_serviceAddressId`.
62
- - **Hard-blocks throw `_Exception_Validation`** so they map to HTTP 400 with the message surfaced (the FE checkout expects 400). Rejected: plain `_Exception` → 500 + stack trace.
63
- - **Preferred depth fix = raise the `postPost` interceptor `minDepth`** (Rohan's lever) over the FE change: config-only, FE-independent, and also un-breaks the AIG block. Pending the beta test to confirm the clamp actually deepens the build for a `depth=-1` request.
60
+ - **Fix depth on the FRONT-END (drop the `depth` param)** rather than bumping the interceptor `minDepth`. Rationale: it reproduces the already-proven ET100057 (no-depth) config that pinned on beta, needs no DB config change, and un-starves the AIG block for free. The `minDepth` bump remains the fallback / the proper systemic guardrail. (Rohan confirmed minDepth 3-default / 5 on postPost.)
61
+ - **Pin from the in-memory hydrated payload, not a DB read-back** (in-request reads can't see uncommitted nested writes; `getFullModelData` hydrates the payload before `postPost`).
62
+ - **`serviceAddressId` = STANDARD field** (per Jeff), not `c_serviceAddressId`.
63
+ - **Hard-blocks throw `_Exception_Validation`** → HTTP 400 + surfaced message (FE checkout expects 400).
64
64
 
65
65
  ## Blockers
66
- - Pin cannot fire on beta until the `depth` collision is resolved: FE sends `depth=-1`, and the `postPost` interceptor `minDepth 5` floor is NOT producing a deep-enough payload (`calcDepth 1`). Open question to Rohan: does the `minDepth` clamp engage for `depth=-1`, and what target value? Needs the beta `UPDATE` test to settle.
67
- - Backend (`TRUE-79533`) is not yet on beta — it lives on `TRUE-79533`, but beta deploys `_underscore` from `_sandbox-dev`.
66
+ - **Verification pending** — the front-end `depth` removal is mid-deploy to beta; can't confirm the pin until it lands and a fresh purchase is made.
67
+ - The `_Exception_Validation` 400-fix (`41a5dc1a`) and the rest of `TRUE-79533` are on `TRUE-79533` but NOT yet on beta (beta deploys `_underscore` from `_sandbox-dev`). Does NOT block the pin test (the pin code is already on beta), but needs merging for the 400/toaster behavior + prod.
68
68
 
69
69
  ## Exact next step
70
- > On beta (`dev-sandbox`, `Client_Rate`) run `UPDATE ApiPayloadInterceptors SET minDepth = 10 WHERE id = 2;`, then make one fresh WH purchase (FE unchanged, still sends `depth=-1`) and check the create response `meta.calcDepth` plus the new entitlement's `serviceAddressId` and its `Addresses.isValidated`. If it pins → the clamp works and 5 was too low; dial in the minimal value and ship it as a `dbchanges2 Client_Rate` migration (no FE change). If still null / `calcDepth` stays 1 → the clamp doesn't engage for `-1`; fix the FE (`checkoutApi.ts:21` drop `depth:-1`) instead. Confirm the intended target value with Rohan first.
70
+ > As soon as Tanner's `toga2-view` deploy lands, make ONE fresh WH purchase on beta and verify in the DB (MCP `dev-sandbox`, `Client_Rate`): the newest WH entitlement has `serviceAddressId` populated AND its `Addresses.isValidated = 1`, with NO manual backfill. Also confirm the create response no longer shows the `WO-1` depth warning (and `meta.calcDepth` is higher), and that AIG outbound calls resume in `Logs_Rate.Api`. If it pins → success; then merge `_underscore TRUE-79533` → `_sandbox-dev` (for the 400 fix), merge `dbchanges2`, and run `/capture`. If it still returns null → apply the FALLBACK (`UPDATE ApiPayloadInterceptors SET minDepth=10 WHERE id=2` on beta) and re-test.
71
71
 
72
72
  ---
73
73
  _Saved by /session-save on 2026-07-27_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.439",
3
+ "version": "1.0.440",
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",