read.markets/alembic/versions
Giorgio Gilestro 8946dee2e0 feedback: thumb up/down on logs + reviewer self-score 0-10
Two unrelated features bundled because they ship together and share
migration 0028.

Strategic-log feedback (thumb up/down):
- New strategic_log_feedback table with UNIQUE(log_id, user_id) so each
  user has one vote per log, flippable in place (up -> down -> clear).
  UI shows aggregate counts only.
- app/services/log_feedback.py: set_vote, get_counts, sign/verify
  feedback tokens (same itsdangerous pattern as auth.sign_pending,
  30-day TTL for email links).
- POST /api/log/{id}/feedback: web vote, auth required, returns counts
  + the requesting user's own vote.
- GET /feedback?token=...&vote=...: email-link target, no auth, signed
  token encodes (user, log, vote), renders feedback_thanks.html.
- partials/log.html: thumbs row below content, JS-driven swap via the
  POST endpoint. Dashboard latest-log card and /log page both render
  this partial via htmx, so the buttons appear in all three surfaces.
- digest emails: a "How was today's read?" row above the unsub footer,
  with signed-token URLs against the latest StrategicLog at send time.
  Plain-text fallback included.

Reviewer self-score (0-10):
- _SYSTEM_PROMPT asks for an integer score with anchors (10 exemplary,
  5 borderline, 0 unfit). Verdict gains score: int | None.
- Deterministic-layer hits get score=0 (hard rule, no nuance);
  error rows get None; LLM rows get the model's score clamped 0..10.
- ReviewerVerdict.score, StrategicLog.reviewer_score, and
  IndicatorSummary.reviewer_score all new SMALLINT NULL columns.
- ai_log_job + indicator_summary_job persist verdict.score onto their
  content rows when committing the row alongside content.

Tests:
- tests/test_strategic_log_feedback.py: vote, flip, clear, aggregate
  across users, invalid vote, token round-trip + tamper + garbage +
  'clear' not signable for email path.
- tests/test_output_review.py: score parsing, clamping (>10, <0),
  missing/non-numeric -> None, deterministic-layer score=0.

Full suite: 427 passed (was 412), 5 skipped, no regressions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 21:28:03 +02:00
..
0001_initial_schema.py initial commit — cassandra v0.1 2026-05-15 21:56:10 +01:00
0002_position_name.py initial commit — cassandra v0.1 2026-05-15 21:56:10 +01:00
0003_log_tone_analysis.py initial commit — cassandra v0.1 2026-05-15 21:56:10 +01:00
0004_indicator_summaries.py add Eurostat + UK ONS sources; valuation/bubble/economy/bonds groups; aggregate read; market-open header 2026-05-15 23:07:42 +01:00
0005_widen_quote_symbol.py alembic: make migration chain SQLite-compatible (fresh upgrade) 2026-05-28 00:16:09 +02:00
0006_instrument_map.py phase B (1/4): CSV parser + InstrumentMap (T212 shortcode → Yahoo ticker) 2026-05-16 10:53:08 +01:00
0007_users.py phase A: user accounts + session-cookie auth 2026-05-16 11:12:10 +01:00
0008_email_otps.py phase G: data minimisation + passwordless auth + DeepSeek-first LLM 2026-05-18 14:16:57 +01:00
0009_ticker_universe.py phase G: data minimisation + passwordless auth + DeepSeek-first LLM 2026-05-18 14:16:57 +01:00
0010_drop_password.py phase G: data minimisation + passwordless auth + DeepSeek-first LLM 2026-05-18 14:16:57 +01:00
0011_drop_portfolio_tables.py phase G: data minimisation + passwordless auth + DeepSeek-first LLM 2026-05-18 14:16:57 +01:00
0012_headlines_tags.py news: auto-tag headlines + market-aware cadence + filter UI 2026-05-21 23:25:03 +01:00
0013_referrals.py alembic: make migration chain SQLite-compatible (fresh upgrade) 2026-05-28 00:16:09 +02:00
0014_user_credit_until.py phase D milestones 1+2: referral system + paid-access gate 2026-05-21 23:25:35 +01:00
0015_portfolio_sync.py sync: encrypted cloud backup for portfolios + settings UX rework 2026-05-23 16:15:54 +02:00
0016_portfolio_sync_pepper_fp.py sync: detect orphaned blobs (pepper rotation) + fix AESGCM arg order 2026-05-25 12:49:11 +02:00
0017_email_digest.py db: drop redundant user_id index on email_sends 2026-05-25 22:55:33 +02:00
0018_polar_webhook.py alembic: make migration chain SQLite-compatible (fresh upgrade) 2026-05-28 00:16:09 +02:00
0019_stripe.py alembic: make migration chain SQLite-compatible (fresh upgrade) 2026-05-28 00:16:09 +02:00
0020_trial_end.py stripe: per-cadence cooling-off + manage-subscription button 2026-05-26 20:06:19 +02:00
0021_csv_format_template.py alembic: use sa.text() for integer server_defaults in 0021 2026-05-27 12:06:05 +02:00
0022_localization.py alembic: add 0022 localization (users.lang + strategic_log_translations) 2026-05-27 16:53:27 +02:00
0023_lang_index_and_qd_symbol_widen.py alembic: make migration chain SQLite-compatible (fresh upgrade) 2026-05-28 00:16:09 +02:00
0024_ind_summary_translations.py i18n: localize indicator summaries (per-group + aggregate read) 2026-05-27 20:19:47 +02:00
0025_align_translation_columns.py models: align translation column naming + add token counts 2026-05-27 21:18:29 +02:00
0026_compliance_purge_and_audit.py compliance: flag-gate AI portfolio + cloud sync + Stripe; de-risk prompts; harden reviewer 2026-05-29 19:57:12 +02:00
0027_user_acknowledgements.py auth: affirmative versioned sign-up acknowledgement (EN + IT) 2026-05-29 20:50:38 +02:00
0028_log_feedback_and_reviewer_score.py feedback: thumb up/down on logs + reviewer self-score 0-10 2026-05-29 21:28:03 +02:00