You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/.beans/vibed-fdph--escalating-dail...

30 lines
2.2 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
# vibed-fdph
title: Escalating daily pixel rewards (triangular per-day)
status: completed
type: feature
priority: normal
created_at: 2026-07-14T22:38:42Z
updated_at: 2026-07-14T22:46:49Z
---
Reward doing more habits in a single day: the Nth habit checked in a day reveals N units of pixels (1+2+3+... = triangular). Derive revealed pixels from the log per-day triangular sum instead of a flat checks counter; recalibrate pixelsPerCheck so a perfect month still finishes an image. Update DESIGN.md, README.md, ARCHITECTURE.md.
## Summary of Changes
Escalating daily reward implemented in `index.html`:
- Reveal is now **derived from the log** instead of a stored `checks` counter. New helpers `triangular(k)` and `revealedUnits(image)` sum `k·(k+1)/2` units per day (days ≥ startedAt). The Nth habit checked in a day is worth N units, so a 4-check day = 1+2+3+4 = 10 units.
- `getRevealInfo`: `revealedCount = min(opaque, floor(units · pixelsPerCheck))`.
- `pixelsPerCheckFor` recalibrated to `max(1, round(opaque / (triangular(habitCount) · 30)))` so a perfect month still fills the image (verified: ~30 days).
- `onHabitToggle`: snapshots `before` prior to mutating the log; uncheck path no longer touches a counter (past days can't un-reveal). Removed unused `computeFloor`.
- Dropped vestigial `checks` field from `normalizeImage`/`buildImageFromDef`; legacy saves load fine (field ignored, reveal recomputed).
- Upload day-estimate updated to use `triangular(habitCount)·ppc` per perfect day.
- Docs updated: DESIGN.md §3.2 + §9, data model, README.md, ARCHITECTURE.md.
Validation: no external refs (grep http/https/fetch clean), `node --check` passes, pure-function simulation confirms 3/6/9/12-px escalation and ~30-day perfect-month finish. Not opened in a live browser (none available in this environment).
## Browser Verification (headless Firefox 152)
Drove the real app's DOM in headless Firefox with a seeded 4-habit / 4x4-opaque state (pixelsPerCheck=1). Checking habits 14 revealed running totals 1, 3, 6, 10 (deltas +1, +2, +3, +4) — escalating exactly as specified, day total = 10. Unchecking the 4th dropped 10→6 (only today's contribution shrank). No console or window errors (`errors: []`).