Структурированная сводка для этой задачи не записана. Показан сохранённый результат без изменений.
Итог
You can now tick leads in /queue or /leads on a phone and send them in one step to the next AI research pass, the human review queue, or Reject. Each choice goes through a confirmation page first. All 21 focused tests pass with the acceptance command, and the full suite passes (286 tests, 6 skipped). Nothing runs research or contacts anyone.
How it works on screen
- Ticking leads shows a bottom bar with "N selected", an action picker (Research pass, Human review, Reject), Next and Clear.
- Next only opens a preview at
/batches/new and saves nothing. The preview lists each lead and what will happen to it. - To save, you enter your name and tick "I confirm" (Reject also needs a reason). The result page
/batches/{id} shows each lead's outcome and job state, and /batches lists past batches. - Leads with an open job show "Queued: research" or "Queued: human review" in the list and on the lead page.
- The phone nav still has 4 links, and the desktop table still has 7 columns.
What each action does
- Research pass: adds one queued job per lead for the AI executor. Rejected (INVALID) leads are skipped.
- The database stops any research job from moving past QUEUED (only cancelling is allowed) until a setting is turned on.
- That setting needs an owner acceptance reference, and no code turns it on. The scheduler is not touched.
- Human review: adds one queued job per lead. The lead's verdict does not change.
- Reject: sets the verdict to INVALID under your name, with the reason and the batch number in review history.
- Shortlisted leads and leads that are already INVALID are skipped, and evidence and the shortlist are left alone.
- No action can set a lead VALID, mark evidence VERIFIED, add a lead to the shortlist, or contact anyone. Tests check this against before/after copies of the database.
Storage and safety
- New tables:
lead_batches, lead_batch_items, lead_action_jobs, lead_action_job_events and lead_action_settings. - Batch records and job history can only be added to, never changed or deleted. Jobs can't be deleted.
- A lead can have at most one open job of each type.
- No duplicates: each confirmation page carries a one-time key. Submitting it twice returns the original batch ("Already recorded"). Reusing the key for a different request is refused.
- All or nothing: a bad lead id, more than 200 leads, a missing confirmation, name, reason or key, or any error mid-batch saves nothing and returns 400.
- Security checks (CSRF token, same origin) and sign-in reuse the existing middleware. Apache auth is unchanged.
Tests (tests/test_bulk_lead_actions.py)
- They cover security tokens, sign-in, idempotency, rollback, the research block, reject rules and the views.
- The HTTP tests need FastAPI, which the system
python3 doesn't have. Under python3 they are skipped and run again through the console venv, where they pass. - I updated one selection-bar assertion in
tests/test_compact_leads.py to match the new markup.
Mobile check
I ran the real app in headless Chrome at iPhone size (390×844): queue, tick 2 leads, choose Research pass, confirm, see the result, back to the queue.
- No page overflowed sideways (width stayed at 390).
- The bar showed "2 selected" at 48px tall.
- Batch #1 queued 2 jobs, and the queue then showed "Queued: research" on both leads.
- The database confirmed 2 QUEUED jobs and no verdict chang
[truncated]