Skip to content

TL-09: preparedness profile and voluntary agent contact (fixture) - #24

Merged
AnkithaThomas merged 3 commits into
mainfrom
TL-09-consent
Nov 8, 2026
Merged

AnkithaThomas merged 3 commits into
mainfrom
TL-09-consent

Conversation

@SJAryan

@SJAryan SJAryan commented Nov 8, 2026

Copy link
Copy Markdown
Owner

TL-09: preparedness profile and voluntary State Farm agent contact (fixture mode)

Adds the preparedness framing to registration and an optional, consented "ask a State Farm agent about coverage" request that appears only after the resident confirms delivery. It uses the TL-04 fixture store. The live reducer and private consent table come from A.

What a judge sees

  1. Registration site: the preparedness profile is free and needs no customer relationship. A short list shows what joining gives you: an iMessage check-in then a call, help in order of who runs out first, and the driver's name, arrival time and chat. The confirmation reads "Your preparedness profile is ready".
  2. Resident phone, after "I received the battery": "Battery received. You're all set." and then an optional offer, stating that help today did not depend on it.
    • "Ask an agent" stays disabled until the consent box ("I agree that a State Farm agent may contact me at (555) 010-0117 about coverage") is ticked.
    • Opting in shows a demo receipt, "Request saved, L-1", labeled: no one will actually call, and this is not a quote or a policy.
    • Skip saves nothing.
  3. Board: "200 registered for preparedness" and "N asked for agent contact after help". Opt-ins are counted separately from registrations.
  4. H17 drawer: an "Agent contact" row (Requested L-1 / Skipped / Offered) and a consent event in the timeline. The rail gains a seventh step, "Agent contact, optional".

Contract

requestAgentContact(consentId) returns committed, duplicate or conflict, as in the shared contract:

  • committed: the first request after the household's job is received, which saves one lead;
  • duplicate: the same consentId retried, with nothing new saved;
  • conflict: a different consentId once a lead exists, or any request before delivery.

Still fixture: A's reducer and private consent table aren't built yet (docs/setup.md). TL-07 swaps the store call for the reducer.

Acceptance check (run in the browser)

Check Result
Opt in, then retry with the same consent duplicate, one lead (L-1)
A second request with a different consent conflict, still one lead
Skip no lead, opt-in count 0
Request before delivery conflict: "offered only after help is delivered"
Help unaffected the offer renders only after receipt, so dispatch can't depend on it

The "both residents get identical assistance" check is shown with one interactive household: run it once opting in, Reset demo, and run it again choosing Skip. Dispatch and delivery are identical in both runs.

How to check

npm ci && npm run dev
Register, then Start outage, reply "30 to 60" on the resident phone, and Reserve on the board. On the driver phone tap Start route and I have arrived, then tap I received the battery on the resident phone. Expected: the agent offer appears. Tick consent and choose Ask an agent: expected receipt L-1, and the board count is 1. Reset, repeat, and choose Skip: nothing saved, count 0.

Notes

  • The second commit untracks the bundled design skills and the old frontend/ prototype that slipped into the first commit. The net diff is 8 files under src/. Please use Squash and merge so those files stay out of main's history.
  • No backend, dependency or shared-contract changes.
  • No real sales outreach, quotes or implied coverage. Synthetic resident only.

@SJAryan

SJAryan commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Fixed the P2 race in b09e11a:

  • Removed the 400 ms timer. requestAgentContact is called synchronously, so no callback can outlive the screen, and there's no saving window where the checkbox can change.
  • Store guard: requestAgentContact returns a conflict once the resident has skipped ("The resident skipped. Nothing was saved."), so a late request can never override Skip. Skip after an opt-in is still a no-op.

Checked in the browser: Ask, navigate away and back gives L-1 with no Skip button left. Skip, then a request, gives a conflict and opt-ins stay 0. Opt-in, then a retry, gives a duplicate. npm run build passes.

@AnkithaThomas
AnkithaThomas merged commit 5573705 into main Nov 8, 2026
gholapksh pushed a commit that referenced this pull request Nov 8, 2026
Part of #9 (A side; D's screens are PR #24). Adds two private tables:
`profile` (one free preparedness profile per household: medical need,
backup device, address, preferred contact) and `agent_contact` (at most
one consented lead per household).

- `enrollPreparedness(enrollmentId, medicalNeed, backupDevice, address,
  preferredContact)`: resident session only; a retry is a no-op; a second
  profile for the household is a conflict.
- `requestAgentContact(consentId)`: resident session only; offered only
  after that household has a delivered job; a retried consentId is a no-op;
  a second consentId is a conflict. Skip is client-side and creates nothing.
- Views: `my_profile`, `my_agent_request` (resident receipt),
  `coordinator_profiles`, and `coordinator_registry_stats` with
  registrations and agent opt-ins counted separately. Coordinators never
  see the leads. Dispatch never reads profiles or leads.

Proof: `npm ci && npm --prefix spacetimedb ci && spacetime start`, then
`npm run stdb:reset:local && npm run check:tl09`; expect
`PASS: TL-09 enrollment and agent contact`. TL-01, TL-05 and TL-06 still
pass.

Status: live locally; Maincloud needs a republish (new tables). Enrollment
requires the household's resident invite; no public signup.

Next: D replaces the fixture `requestAgentContact` and registration in
PR #24 with these reducers and views.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants