# Session notes (personal, git-excluded)

Updated 2026-11-06, before sweeping Claude Code sessions. **Read this first, then `.claude/plans/here-s-what-i-ve-decided-typed-lovelace.md`** (the "SESSION HANDOFF" section at the top has the environment and rules) **and the Sprint 4 plan in `.claude/plans/ysp-sprint4-failure-controls.md`** (moved out of that file on 2026-11-11; it also records that Step 2 is in progress).

## Where things are
- Branch `task/ysp-card-failure-controls` (Sprint 4), created from `task/create-db-logs` (Sprint 3). Pushed up to `d4e0302` (Steps 1-7 done). Working tree: only the 3 deliberately deleted `priv/repo/migrations/20250707_*` files (never commit them).
- Sprints (errors-branch numbering, now in `CLAUDE.md`): 1 slice (done, PR #30 waiting on review), 2 support-friendly errors (done, branch `task/ysp-card-support-errors`, no PR), 3 DB call log (done, branch `task/create-db-logs`, no PR), 4 simulator failure controls and critical-path safety (planned, not started). All branches are pushed.
- PR #30 (Sprint 1) is based on `task/add_ysp-simulator` (PR #29, no reviewer assigned). The user is waiting on their manager and knows; do not nag.

## Sprint 4 steps (details in `.claude/plans/ysp-sprint4-failure-controls.md`; the user says "Do Step N")
1. [DONE 2026-11-11] Baseline: simulator 367 tests, middle layer (YSP + activity) 84 tests, 0 failures in both, base `30ad7f9`.
2. [DONE 2026-11-11] Simulator `fail_next` queue + route accept card endpoints with a `mode`.
3. [DONE 2026-11-11] Simulator modes `error_code`, `latency_ms`, `timeout`, `drop_response_after_apply` in `card_api.ex`.
4. [DONE 2026-11-11, `63ef65b` pushed] Simulator docs (`simulator-routes.md`, `docs/behaviour/`), commit.
5. [DONE 2026-11-11, `e5117d3` pushed] Unique index on `(endpoint, txn_ref_no)` (new migration), `Endpoints.reuses_ref?/1` (statusrequest, otpvalidation exempt), drop script updated.
6. [DONE 2026-11-11] `CallLog.start/2` returns `:ok | :replay | :error`, reuses the row and bumps `attempt`.
7. [DONE 2026-11-11] `YspCard.Reconcile` (Status Request 4.20). 104 tests.
8. Replay rules in `YspCard.call/2`: a settled critical replay returns the stored answer and sends nothing; unknown rows are reconciled first; `TIDEXT` from YSP triggers reconcile.
9. Bounded retry for standard calls only (fresh `txnRefNo` per retry, caller-supplied ref = no retry).
10. Live integration tests against the simulator: load twice, block twice, response dropped, timeout.
11. End-to-end run, docs (`docs/ysp-card-call-log.md`, `CLAUDE.md`), commit by explicit path; the user pushes.
User decisions: replay is stopped in the middle layer; reconcile automatic on `TIDEXT` plus a function by hand (no route, no job); core now, polish (recent-calls list, `demo.sh`, manager summary) later.

## Commands (run from the repo root on the server)
- Tests: `MQTT_CLIENT_ID=rohan_calllog MIX_TEST_PARTITION=_calllog mix test test/da_product_app/ysp_card test/da_product_app/activity` (private DB `da_product_app_test_calllog`; set-up SQL in `docs/ysp-card-call-log.md`). Simulator tests: `cd ysp-simulator && mix test`.
- Run: `cd ysp-simulator && mix run --no-halt` (4180), then `YSP_CARD_BASE_URL=http://localhost:4180 MQTT_CLIENT_ID=rohan_calllog mix phx.server` (4006).

## Things to remember
- The user wants to do checkouts and pushes themselves; commit only when told, stage by explicit path, never `git add -A`.
- Open items: no auth on `/api/card/*`; PINs/CVV/OTP/card numbers stored in plain text in the call log (fix before real YSP); the old migrations can't build a fresh DB (duplicate `20250707`, signed vs unsigned foreign key in `20250606000001`); five checkouts share one MQTT client id, so always set an own `MQTT_CLIENT_ID`.
- `UNDERSTANDING_YSP.md` (git-excluded personal guide) has clickable links with line anchors that drift as code changes; offer the walkthrough or a quiz when the user wants to learn it.
- More reminders are in the auto-memory folder: `/home/rohan/.claude/projects/-var-www-internaltesting-rohan-prverification-QRMiddleLayer/memory/`. Do not delete that folder.
- Boss-requested task (2026-11-12): deactivate 27 of 40 simulator endpoints via an active-list gate. Branch `task/deactivate-ysp-endpoints`, cut from `task/ysp-card-postman-flow` (PR base = postman-flow). Plan: `DEACTIVATE_YSP_PLAN.md` at repo root (git-excluded copy; original in `.claude/plans/i-ve-been-given-an-encapsulated-pancake.md`). Not started yet, no code changes made.
- Reminder (2026-11-12): Step 2 of the deactivate plan is done (2.1-2.4 committed). Offer to break step 4 (middle-layer mirror) into atomic commits before starting it, as was done for step 2. The user is editing ysp-simulator/README.md (splitting the endpoint table into active/inactive); do not touch it. The shared simulator on 4180 must not be reset or restarted: test with YSP_SIM_PORT=4181 for both `mix run --no-halt` and `bash demo.sh`.
- Parked (2026-11-12): store request/response logs (big boss asked). Separate branch from task/ysp-card-failure-controls, which already has the ysp_api_calls call log (unmerged). First ask what is being asked for. Details in DEACTIVATE_YSP_PLAN.md under "Parked". Step 4 of the deactivate plan is now split into 4.0-4.6 (4.0 = get a green middle-layer test baseline first).
- 4.0 done (2026-11-12): middle-layer YSP tests baseline = 231 pass with integration, 128 by default. See DEACTIVATE_YSP_PLAN.md 4.0 for the commands. NEVER run --include integration without YSP_CARD_BASE_URL=http://localhost:4181 (they reset the simulator; default is the shared 4180).
