Files
f68eb9d905 fix(takes): kill propose_takes rescan loop, keep every claim, and route cycle/brainstorm models through config (#2804 #2805)
Takeover of #2804 and #2805 (stacked), rebased onto current master.

Rescan loop + dropped claims (#2804):
- Zero-claim scans now write a status='empty' sentinel row so the
  (source_id, page_slug, content_hash, prompt_version) cache hits on
  every subsequent cycle instead of re-spending the extractor LLM call
  on the same unchanged page forever.
- The idempotency index gains md5(claim_text): multi-claim pages keep
  every claim (the 4-column unique index silently dropped claims 2..N
  via ON CONFLICT DO NOTHING). proposals_inserted now counts rows that
  actually landed (RETURNING id), not insert attempts.
- Migration renumbered 123 -> 125 (master shipped v123
  configurable_fts_language and v124 after the PR was cut; the
  duplicate v123 would never have run under the version > current
  runner). Schema parity across schema.sql, pglite-schema.ts,
  schema-embedded.ts.

Model-tier honoring (#2805), reworked for current master:
- propose_takes, grade_takes, calibration_profile resolve their model
  through resolveModel(models.<phase> > models.default > env >
  getChatModel()) — per-phase config keys are now honored while the
  gateway chat model (already tier-resolved by
  reconfigureGatewayWithEngine) stays the default, preserving master's
  #2451 semantics (provider-prefixed stored ids, nested prefixes like
  openrouter:... intact) and the #2997 opts.model ?? getChatModel()
  idiom. The PR's original bare-tail-everywhere approach was dropped
  where it conflicted with #2451; grade_takes keeps the bare tail ONLY
  for its cache key / stored judge_model_id (continuity with historical
  rows), while the judge call itself gets the full resolved string —
  fixing the live label-vs-actual mismatch (call rode chat_model,
  telemetry recorded a hardcoded claude-sonnet-4-6).
- brainstorm resolves via models.brainstorm > tier chain (was
  hardcoded anthropic:claude-sonnet-4-6).
- gbrain models lists the four new per-task keys; output caps and
  context-window entries added for newer Claude models.

Tests: test/propose-takes-rescan.test.ts (new, hermetic PGLite);
config-key coverage in propose-takes/grade-takes tests; existing #2451
and gateway-chat-model tests pass unchanged.

Co-authored-by: p3ob7o <p3ob7o@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 14:33:19 -07:00
..