fix(v1.1): item 5 — section counter keys off in-section events (2/2 -> 3/2 bug)

A card is decided only when a swipe event carries THIS section's id;
the lifetime swipes.action a second look wears into its section no longer
paints it as pre-decided. progress/undecided, report counts (latest
in-section event per listing) and maybe_exhaust all use the new
section_decided_ids() set; read path only, no writes. Every section_state
item carries decided_this_section; the FE counts server truth unless a
local intent is in flight, and sectDecided is clamped to sectTotal
everywhere (commit + paintSect) so the pill can never read past N/N.

Semantics note: completing a section now means striking EVERY item in it
(returns re-struck on their second look) — the exhaust selfcheck was
updated to strike all items, matching the deck's real flow. Undo-on-a-
return residual (event stays after the DELETE) is the accepted Q5 clamp-
only behavior, covered by a dedicated selfcheck case.
This commit is contained in:
Torres
2026-11-13 13:38:18 -04:00
parent ac613e680a
commit 98d345ceee
4 changed files with 141 additions and 10 deletions

View File

@@ -451,11 +451,18 @@ def create_app(db_path, img_dir, state_dir=None):
sec = conn.execute('SELECT * FROM sections WHERE id=?',
(sec['id'],)).fetchone()
mode = get_pref(conn, 'forge_mode', 'ondemand')
decided_ids = secmod.section_decided_ids(conn, sec)
items = [p3_payload(conn, engine, r, slot=r['slot'],
include_breakdown=True)
for r in data['items']]
for p in items:
# item 5: decided IN this section (real verdict), not the joined
# lifetime swipes decision — present on EVERY item so the FE's
# local-intent branch can't misfire
p['decided_this_section'] = p['id'] in decided_ids
data['items'] = items
data['mode'] = mode
data['recipe'] = (json.loads(sec['recipe']) if sec['recipe'] else {})
data['prefs'] = {'rubric_debug': get_pref(conn, 'rubric_debug', 'off')}
data['can_forge'] = (mode != 'strict'
or secmod.fresh_profile_exists(conn, sec))