① Pre-check counts FT employees correctly (off_map awareness)
② P3 removes dead FT branch (FT never has req_map entries)
③ 5b open-prep constraint includes FT employees with can_open
④ 5c cleanup constraint includes FT employees with can_cleanup
⑤ P2b late-night penalty skips FT (dinner is their default duty)
⑥ Best-effort solver gets P5 slot-split soft penalties (500k/300k)
⑦ P3b timeslot penalty removed (P5 hard constraints cover this)
⑧ SolverConfig: remove double_penalty_scale (P2 is now hard constraint)
Generate route and template updated accordingly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: P5 slot priority - remove slider, use high fixed penalties
Remove slot_pref_scale (UI slider not needed per user request).
P5 is a fixed baseline rule, not a UI setting.
Increase penalties to "soft-hard constraint" level:
BREAKFAST_FT_COST = 500,000 (was 30,000 → 10x P1)
DINNER_PT_COST = 300,000 (was 20,000 → 6x P1)
At these values:
- FT in breakfast costs 550,000 vs PT 50,000 (11x more expensive)
- PT in dinner costs 360,000 vs FT 60,000 (6x more expensive)
- Solver will virtually never assign FT to breakfast when PT can cover
- Hard staffing minimum still overrides when PT is genuinely insufficient
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SolverConfig.slot_pref_scale controls the strength of the breakfast/
dinner slot assignment priority (P5 penalty). P5 is always active
(hard-coded base values), and the UI slider multiplies the strength:
低 (0.1): 3,000 / 2,000 - allows more mixing
中 (1.0): 30,000 / 20,000 - baseline (current strong preference)
高 (10.0):300,000 /200,000 - very strict separation
Added "朝食/ディナー 分業強度" slider to generate/index.html with
popover explanation. Default is 中 (baseline behavior preserved).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: remove needs_regen from generate page checklist
The warning was unreliable due to bfcache, AJAX auth redirects, and
DB sync timing issues. The generate page is where users go TO regenerate,
so showing "please regenerate" there is redundant — they already know.
The warning remains on the schedule page and customers page where it is
actually useful: reminding the user after saving counts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: generate page stale needs_regen due to bfcache
Two-pronged fix:
1. Cache-Control: no-store on generate index response prevents the page
from being stored in bfcache at all.
2. updateChecklist() now fetches fresh data from /generate/checklist/<id>
on every call (AJAX), and on pageshow when e.persisted=true (bfcache
restore). Falls back to embedded data if fetch fails.
3. New /generate/checklist/<period_id> endpoint returns fresh DB data.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: resolve generation timeout on HuggingFace (2 vCPU environment)
Root causes:
1. num_search_workers=2 competed with 2 gunicorn workers for 2 vCPUs,
causing OR-Tools to run much slower than the 25s timeout allowed.
Changed to num_search_workers=1 (both phase 1 and phase 2).
2. Google Fonts stylesheet link was render-blocking, delaying the
waiting page JS startup and eating into the client-side timer.
Changed to rel="preload" onload pattern for non-blocking load.
3. TIMEOUT_SEC 90→150 to give more buffer for CPU-constrained envs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- DB: add needs_regen column to schedule_periods
- customers/save: set needs_regen=True when saving counts after generation,
flash warning to re-run generation
- generate/run (done): auto-clear needs_regen=0 on successful generation
- customers/index: show "シフト生成済み・再生成推奨" banner with direct link
- schedule/index: show "客数更新済み・再生成推奨" banner when needs_regen=True
- generate/index: show per-period checklist (shift filled count, counts status,
regen warning) that updates when period selector changes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add help popovers to priority settings + radio button UX
- ? badge next to each priority label opens a popover with explanation
- Popover triggered by tap/click (mobile-friendly), closes on outside tap
- Only one popover open at a time
- Radio button group (低/中/高) replaces select dropdown for easier one-tap selection
- Help text explains: cost, pt preference, double-shift penalty, balance, late night
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix infinite generation loop and improve progress visibility
- web_app.py: reset stuck 'generating' status on startup (survives hot-reload/crash)
- db/database.py: set SQLite timeout=30s and enable WAL mode to prevent write-lock failures
- optimizer/solver.py: fix _solve_best_effort ignoring always_available flags; add phase/score tracking to progress callback; notify phase-2 start when falling back to best-effort
- routes/generate.py: pass period_id to solve(); expose phase/obj fields in status endpoint
- waiting.html: rAF-driven smooth bar (moves from page load, not first callback); phase labels (step 1/2 vs 2/2); objective score display with delta; 90s client-side timeout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix generation stuck: direct DB conn in callback, longer timeouts
- update_period_gen_status: use Connection() directly (not get_connection)
so it's safe to call from C++ callback threads without Flask app_context
Cache invalidation is best-effort only
- Main solver: 10s→25s, best-effort: 10s→15s (local test showed 12.3s needed)
- SolveProgressCallback max_time updated to match
- waiting.html MAX_SEC updated to 25
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Progress bar driven by real solver data, not fake time animation
- Remove requestAnimationFrame time-fill; bar only moves on actual poll data
- elapsed comes from SolveProgressCallback.WallTime() stored in DB
- Before first callback: bar stays at 0% with 'exploring...' label
- After callback: bar = elapsed/10s * 100% (honest time budget display)
- solution count shown as secondary indicator
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add progress bar to shift generation waiting page
- Solver runs in background thread (non-blocking UI)
- Waiting page polls /generate/status every 2s, auto-redirects when done
- max_time_in_seconds: 30→10 (still finds good solutions in <5s typically)
- num_search_workers: 4→1 (avoids CPU oversubscription on 2vCPU free tier)
- gen_status/gen_message columns track job state in DB
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>