toga-ai 1.0.407 → 1.0.408
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.
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: session
|
|
3
|
+
slug: true-79533-wholehome-per-address-guard
|
|
4
|
+
title: Rate Whole Home Warranty — one active warranty per validated address
|
|
5
|
+
author: mhammontree
|
|
6
|
+
repos: [_underscore, dbchanges2, test]
|
|
7
|
+
framework: "2.0"
|
|
8
|
+
client: rate
|
|
9
|
+
status: active
|
|
10
|
+
created: 2026-07-21
|
|
11
|
+
updated: 2026-07-21
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Session: true-79533-wholehome-per-address-guard
|
|
15
|
+
**Date:** 2026-07-21
|
|
16
|
+
**Project/Repo:** _underscore + dbchanges2 (2.0), client Rate
|
|
17
|
+
**Task:** TRUE-79533 — implement, verify, deploy-to-beta, and CodeRabbit-harden a backend guard so a Rate Whole Home Warranty (WH) can only be purchased for a carrier-validated address, with one active WH per distinct physical address, globally.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## What WORKED
|
|
22
|
+
- **prePost guard** in `_underscore/Model/Rate/Entitlement.php` — WH-only (title contains "warranty"); requires a service address; hard-blocks if carrier validation (`_Model_Client_Address::validateAddress`, USPS→FedEx→UPS) returns `success:false`; adopts the carrier-normalized address; then hard-blocks a 2nd active WH on the same address via `hasActiveWarrantyAtAddress()`. Committed on `TRUE-79533`.
|
|
23
|
+
- **postPost `persistWarrantyServiceAddress()`** — after save, sets `Addresses.isValidated=1` and `Entitlements.c_serviceAddressId`; wrapped so it never blocks the AIG-contract/email flow.
|
|
24
|
+
- **Migration** `dbchanges2/Client_Rate/2026-07-07a - WholeHomeWarrantyPerAddressGuard.sql` — adds `c_serviceAddressId` + index, guarded (`NOT EXISTS`) `CustomRecordFields`(191,NUMBER) + `ApiPayloadInterceptors`(191, PRE/POST), and an idempotent backfill of existing WH from the contact primary-address chain. Run against local + **beta** `Client_Rate`.
|
|
25
|
+
- **Verification** `test/@Mark/Rate/verify_wholehome_per_address_guard.php` — **18/18 pass** against the real migrated local `Client_Rate` (helpers + dedup matrix + prePost branches).
|
|
26
|
+
- **CodeRabbit fixes** (committed on `TRUE-79533`): (1) `c_serviceAddressId` declared as FK array form `[FIELD_FOREIGNKEY, FIELDOPT_FOREIGNKEY_MODEL => '\_Model_Client_Address']`; (2) `hasActiveWarrantyAtAddress()` now resolves the address via `COALESCE(c_serviceAddressId, contact primary address)` so an unpinned WH is still deduped. `php -l` clean.
|
|
27
|
+
- **Beta deploy + integration:** `_underscore` `TRUE-79533` pushed to beta, migration run on beta `Client_Rate`. Front-end dev (Tanner) pointed his local `toga2-view` at beta and confirmed the flow "looks good."
|
|
28
|
+
- **Knowledge captured/pushed:** rate `whole-home-warranty-purchase-guard` + `_underscore/address-validation` features, `aig-contract-creation` update, `2.0/standards/backend-testing.md` update (lazy-transaction commit-before-read), and `_underscore/workflows/running-a-2.0-app-locally.md`.
|
|
29
|
+
|
|
30
|
+
## What did NOT work — DO NOT RETRY THESE
|
|
31
|
+
- **Running the full app login locally** never fully succeeded — do not sink more time into it; beta is the test path. The cascade encountered:
|
|
32
|
+
- Stale local `Core_2` (missing `Core/2026-06-10 - TrackingNumberBridges.sql`) still had Records row 41 (`ItemFulfillmentPackages`, model `\_Model_Client_ItemFulfillmentPackage`); V2 loops every `Core.Records` model (`$model::TABLE`, V2.php:3445) and **fatals every request** on the deleted model file. That migration is NON-IDEMPOTENT (fixed ids 317-322 / RecordFields 2171-2200).
|
|
33
|
+
- After refreshing `Core_2`, login returned the silent `Route.php:525` "Failed to determine how to render view" — the API handler returned no response. **Ruled OUT:** production env (confirmed `ENVIRONMENT=dev-markhammontree-laptop` via `?__env=1` die in api2/index.php). **Confirmed CORRECT locally:** `Core_2.Domains` row `http://rate.togaview` (port-stripped, id 580, appId 36, clientId 39); `clientId 39` = local Rate; `dev`→`localhost` DatabaseHosts for client+log+archive; login user `sa-qa-aug21-a@yopmail.com` exists, isActive=1, hasPassword.
|
|
34
|
+
- `VAR=x php ...` (bash env prefix) in **PowerShell** silently no-ops → script falls back to defaults. Use `$env:VAR='x'; php ...`.
|
|
35
|
+
- `_Query` has **no bind/params API** — use `_Database::escape()` (int-cast for ids); do NOT copy the raw-interpolation style in `_Model_Aig_Entitlement`.
|
|
36
|
+
- Standalone `test/` scripts run with **autocommit OFF + a separate read connection** — a write is invisible to a later read until `_Database::transactionCommit(DB_CLIENT)`. Seed → commit → read → assert → commit cleanup.
|
|
37
|
+
|
|
38
|
+
## Not tried yet (candidates for next session)
|
|
39
|
+
- **Local full-app login (if ever needed):** the two remaining unverified gaps are the base **`Logs`** database (DB_LOGS → `Logs.Api`, table `Api` must exist — separate from `Logs_Rate`) and **`Core_2.Apis`** being seeded (secret-bearing, excluded from backups). Provision those before re-attempting.
|
|
40
|
+
- **Optional — api2 relationship expansion for `serviceAddress`:** set `CustomRecordFields.foreignRecordId` → Addresses record (id 13) via a NEW `dbchanges2` migration (the `2026-07-07a` file already ran on beta). Not currently needed; the FK model declaration alone was the CodeRabbit ask.
|
|
41
|
+
- **Optional — extend the verify script** with an unpinned-entitlement case (c_serviceAddressId NULL + a contact primary address at the test address → expect blocked) to behaviorally cover the new fallback.
|
|
42
|
+
|
|
43
|
+
## Current file state
|
|
44
|
+
| File | Status | Notes |
|
|
45
|
+
|------|--------|-------|
|
|
46
|
+
| `_underscore/Model/Rate/Entitlement.php` | Committed (TRUE-79533) | prePost/postPost guard + CodeRabbit fixes (FK decl, COALESCE dedup fallback). NOTE: working tree may show the pre-guard TRUE-79191 version — the guard lives on branch `TRUE-79533`. |
|
|
47
|
+
| `_underscore/Model/Client/Address.php` | Committed (TRUE-79533) | Dead commented `validateAddress` block removed. |
|
|
48
|
+
| `dbchanges2/Client_Rate/2026-07-07a - WholeHomeWarrantyPerAddressGuard.sql` | Committed; run on beta | column+index+guarded registrations+backfill. |
|
|
49
|
+
| `test/@Mark/Rate/verify_wholehome_per_address_guard.php` | Committed | 18/18; does not yet cover the unpinned fallback. |
|
|
50
|
+
| `C:\WWW\true79533.md` | Local working ref | Logic-flow walkthrough with Mermaid diagrams (overlaps the captured guard doc). |
|
|
51
|
+
|
|
52
|
+
## Decisions made
|
|
53
|
+
- **Uniqueness = global per distinct address** (not per-borrower). Rationale: AIG one-plan-per-property; `line2` distinguishes apartment units so a landlord's 2A/2B/2C = 3 allowed WHs. Rejected: per-borrower scoping.
|
|
54
|
+
- **Invalid address → hard-block** the purchase (no entitlement). Rejected: allow-with-flag.
|
|
55
|
+
- **Persist `c_serviceAddressId` on the entitlement** rather than derive from the contact's (mutable) primary address; backfill existing WH. Rationale: reliable dedup + enables per-plan address display.
|
|
56
|
+
- **CodeRabbit #2 → fallback join, NOT pin-throw.** Rationale: making the pin required would reintroduce the block-the-save risk we deliberately designed out; COALESCE fallback closes the blind spot without that risk.
|
|
57
|
+
- **Deploy to beta + FE points local→beta** instead of fully rebuilding the local backend stack. Rationale: local full-app run needs base Logs + Apis seeding; beta has a complete stack; ticket verified independently (18/18).
|
|
58
|
+
|
|
59
|
+
## Blockers
|
|
60
|
+
None for the ticket — code committed on `TRUE-79533`, deployed to beta, integration-confirmed by the FE dev, CodeRabbit review resolved. (Local full-app login remains unresolved but is NOT blocking; beta is the test path.)
|
|
61
|
+
|
|
62
|
+
## Exact next step
|
|
63
|
+
> QA of TRUE-79533 on beta/QA: exercise the multi-unit landlord case (same building, different `line2` → multiple WHs allowed), the duplicate block (2nd active WH on same address rejected), invalid-address hard-block → toaster, tech-support unaffected, and the backfill against pre-existing WH. If QA files anything, use `C:\WWW\true79533.md` + the captured `clients/rate/features/whole-home-warranty-purchase-guard.md` as the reference.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
_Saved by /session-save on 2026-07-21_
|
package/package.json
CHANGED