Skip to content

TL-15: suggest-and-confirm rules and synthetic policy signals (C) - #31

Merged
SJAryan merged 5 commits into
mainfrom
c/tl-15-suggest-needs
Nov 8, 2026
Merged

SJAryan merged 5 commits into
mainfrom
c/tl-15-suggest-needs

Conversation

@KsAashrith87

@KsAashrith87 KsAashrith87 commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #28. Refs #27 (C's part). TL-03 (#20) has merged, so the diff now shows only the TL-15 files.

What: spacetimedb/src/domain/suggest.ts

  • suggestNeeds(signals) → suggested needs with id, resident-facing label, dispatchNeed (for equipment only), confidence and sources.
    • Signals are coded fields (oxygen_concentrator, ramp, hand_controls, …), not free text. Unknown codes are ignored.
    • Equipment listed on the life policy → battery backup. High confidence with a disability policy, medium without.
    • Home and/or car accessibility modifications → step-free access (medium if both, low if one). Not a dispatch need; a driver note.
    • A disability policy alone suggests nothing.
  • confirmedNeed(answer) → { id, dispatchNeed? }. Confirm keeps the suggestion's id (step-free access is kept with no dispatchNeed), correct returns the resident's need, skip returns nothing.

Synthetic signals in fixtures/policy-signals.ts (H17, H22, F03, F09).

Check: npx tsx --test fixtures/*.test.ts → 19 pass, 0 fail (8 for TL-15):

  • H17 → powered equipment, battery, high, sources = life policy note + disability policy
  • F03 → step-free access, medium, from home ramp + car hand controls
  • F09 (no signals) and H22 (disability policy only) → no suggestion
  • Free text and unknown codes never suggest anything (review repros: "Backyard trampoline installed", "Does not use home oxygen")
  • Suggestions contain no diagnosis
  • Confirming step-free access returns { id: 'step_free_access' }; skip returns nothing
  • A confirmed need gives the identical evaluateOptions result as a self-reported one
  • A skipped household gets identical assistance

For D: the confirm screen shows label and sources, with Confirm / Correct / Skip, and the "Prototype – synthetic policy data" label.
For A: store only the confirmedNeed(...) object (id, optional dispatchNeed) with the consent record. Pass dispatchNeed to dispatch and show step_free_access to the assigned driver as an access note. Do not store or expose sources to the coordinator or driver.

🤖 Generated with Claude Code

KsAashrith87 and others added 3 commits November 7, 2026 19:45
Reapplies 1643c69, which #18 merged and #19 reverted. Same four files,
unchanged. Refs #3.

Proof: npx tsx --test fixtures/*.test.ts -> 10 pass, 0 fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
evaluateOptions returned act_now before checking silence, so an overdue,
unanswered household lost its silent status when its margin fell under
+15 or no compatible resource existed. CaseResult now carries a separate
`silent` flag computed before any lane decision; lane order is unchanged.

Proof: npx tsx --test fixtures/*.test.ts -> 11 pass, 0 fail. The new
regression test and two silent assertions fail on 1d99a61.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #27. Pure rule suggestNeeds(signals) in spacetimedb/src/domain/suggest.ts
maps synthetic life policy notes, disability policy, home and car
modifications to suggested needs with confidence and source signals.
confirmedNeed() turns the resident's confirm/correct/skip into the need
that reaches dispatch. All data synthetic.

Proof: npx tsx --test fixtures/*.test.ts -> 17 pass, 0 fail (6 new).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eywords

confirmedNeed() returned undefined for step-free access, the same as Skip,
so the confirmed driver note was lost. It now returns { id, dispatchNeed? }.

Substring matching on free text produced false suggestions ("trampoline"
contains "ramp"; "Does not use home oxygen" matched oxygen). Policy signals
are now coded fields; unknown codes are ignored.

Proof: npx tsx --test fixtures/*.test.ts -> 19 pass, 0 fail. The review
repros and the step-free confirmation test fail on 5a6987c.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… need

The test compared H17 with itself, so it could not show that confirming
changed anything. It now starts from H17 with no recorded need (Act now,
nothing compatible) and checks that confirming the suggestion turns it
into Watch with R4 +17, identical to H17's TL-03 result.

Proof: npx tsx --test fixtures/*.test.ts -> 19 pass, 0 fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@SJAryan
SJAryan merged commit e065de8 into main Nov 8, 2026
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.

C

2 participants