Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ae974a5
#137: Gemini grading provider (plan)
wjduenow May 28, 2026
b28c0b5
#137: extend plan after comparison with #136 OpenAI plan
wjduenow May 28, 2026
dbfff41
#137: apply 3 plan refinements from #136 cross-review
wjduenow May 28, 2026
50167a2
#137: devolve plan to beads (phase=devolved)
wjduenow May 28, 2026
b459360
#137: adjust plan now that #136 is being implemented first
wjduenow May 28, 2026
660d74b
bd_1-scaffolding-txe.6: #137 US-006 — add Gemini pricing SKUs (gemini…
wjduenow May 28, 2026
dc5e010
Merge bead bd_1-scaffolding-txe.6: #137 US-006 Gemini pricing SKUs
wjduenow May 28, 2026
8ed9aed
bd_1-scaffolding-txe.1: #137 US-001 — _gemini_client.py shim + new AS…
wjduenow May 28, 2026
40db0aa
Merge bead bd_1-scaffolding-txe.1: #137 US-001 _gemini_client.py shim…
wjduenow May 28, 2026
43c70d1
bd_1-scaffolding-txe.3: #137 US-003 — pyproject.toml [gemini] extra +…
wjduenow May 28, 2026
6634bde
Merge bead bd_1-scaffolding-txe.3: #137 US-003 pyproject [gemini] ext…
wjduenow May 28, 2026
b6bb73d
bd_1-scaffolding-txe.2: #137 US-002 — GeminiProvider(LLMProvider) + r…
wjduenow May 28, 2026
f40e110
Merge bead bd_1-scaffolding-txe.2: #137 US-002 GeminiProvider + regis…
wjduenow May 28, 2026
1f731d3
bd_1-scaffolding-txe.9: #137 US-009 — operator-facing docs + CHANGELO…
wjduenow May 28, 2026
2ce09b6
Merge bead bd_1-scaffolding-txe.9: #137 US-009 docs + CHANGELOG
wjduenow May 28, 2026
9367194
bd_1-scaffolding-txe.4: #137 US-004 — FakeGeminiClient + offline prov…
wjduenow May 28, 2026
0e25898
Merge bead bd_1-scaffolding-txe.4: #137 US-004 FakeGeminiClient + int…
wjduenow May 28, 2026
a3e4b16
bd_1-scaffolding-txe.5: #137 US-005 — provider-neutrality e2e tests (…
wjduenow May 28, 2026
abde849
Merge bead bd_1-scaffolding-txe.5: #137 US-005 provider-neutrality e2…
wjduenow May 28, 2026
f45d166
bd_1-scaffolding-txe.8: #137 US-008 — gemini marker + live tests (raw…
wjduenow May 28, 2026
3ec024f
Merge bead bd_1-scaffolding-txe.8: #137 US-008 live tests + marker + …
wjduenow May 28, 2026
6dd86d1
#137: harden DEC-019 cross-epic gate via bd sentinel bead
wjduenow May 28, 2026
a1c8c0f
Merge dev (#153 README refresh) into feature/137-gemini-grading
wjduenow May 28, 2026
b5a226f
Merge dev (#136 OpenAI grading) into feature/137-gemini-grading
wjduenow May 28, 2026
098c1f6
bd_1-scaffolding-txe.7: #137 US-007 — GeminiProvider.estimate_input_t…
wjduenow May 28, 2026
ac2f4c3
Merge bead bd_1-scaffolding-txe.7: #137 US-007 GeminiProvider.estimat…
wjduenow May 28, 2026
f15a469
bd_1-scaffolding-txe.10: #137 Quality Gate — fix bugs from 4-reviewer…
wjduenow May 28, 2026
430566c
bd_1-scaffolding-txe.11: #137 Patterns & Memory — durable rules for G…
wjduenow May 28, 2026
00dc673
#137: Address PR review feedback (Copilot + CodeRabbit)
wjduenow May 28, 2026
cbcfe4b
#137: Address second-round PR review (Copilot, 4 new comments)
wjduenow May 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ All notable changes to SignalForge are documented here. The format is loosely ba

## [Unreleased]

_Nothing yet — entries land here on `dev` and get promoted to a dated section at release time._
### Added

- **Google Gemini as a grading + drafting provider (#137).** Set `grade.provider: gemini` or `llm.provider: gemini` in `signalforge.yml`; requires the `[gemini]` install extra (`pip install signalforge-dbt[gemini]`) and `GOOGLE_API_KEY`. Recommended SKU for both drafter and judge is `gemini-2.5-flash` (also registered: `gemini-2.5-pro`, `gemini-2.0-flash`). Ships **without prompt caching** in v0.3 — the `LLMProvider` strategy reports `supports_prompt_caching=False` / `supports_token_count=False`, so `call_llm` skips the `cache_control` marker, the `extended-cache-ttl` beta header, and the pre-send `count_tokens` gate; budget per-call cost accordingly under `provider: gemini` (especially for the grader's 4-criterion × ~12-artifact fan-out). Explicit Gemini context caching is tracked as a follow-up.

## [0.3.0] — 2026-05-27

Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,25 @@ SF_RUN_BQ)`.
The tests query `bigquery-public-data.samples.shakespeare` (164K rows,
free under the 1 TB/month BigQuery tier). They are maintainer-only for
v0.1; no CI job runs them.

## Gemini live smoke

Three tests under `tests/llm/test_gemini_live.py`,
`tests/draft/test_gemini_draft_live.py`, and
`tests/grade/test_gemini_grade_live.py` exercise the Gemini provider
end-to-end against the real Google Gen AI API (raw `call_llm`,
`draft_schema`, and `grade_artifacts`). They are skipped by default —
via `@pytest.mark.gemini` (filtered out by `addopts = -m 'not gemini'`,
per DEC-012 of #137) and via a runtime env-var check on
`SF_RUN_GEMINI=1` + `GOOGLE_API_KEY`.

Maintainers should run them before declaring a `gemini`-touching PR
ready (mirrors the `snowflake` / `anthropic` / `bigquery` precedents):

```bash
SF_RUN_GEMINI=1 GOOGLE_API_KEY=... uv run pytest -m gemini --no-cov
```

The tests use `gemini-2.5-flash` (cheapest SKU in the pricing table)
with minimal token budgets — total cost per full run is well under a
US cent. They are maintainer-only for v0.3; no CI job runs them.
Comment thread
wjduenow marked this conversation as resolved.
Resolved
26 changes: 21 additions & 5 deletions docs/draft-ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ beta header, and the pre-send `count_tokens` gate only when the
selected `LLMProvider` reports `supports_prompt_caching` /
`supports_token_count`. A provider that supports neither simply reports
0 cache tokens and skips the marker. The default `anthropic` provider
supports both, so the behaviour below is unchanged.
supports both, so the behaviour below is unchanged. The `gemini`
provider (v0.3) supports neither yet, so every draft call transmits
the full prompt — see the `provider` field under [Configuration](#configuration)
for the budgeting note; explicit Gemini context caching is a follow-up.

Default `cache_ttl="5m"`; opt in to `"1h"` via `DraftConfig.cache_ttl`
(DEC-005, DEC-009). The `extended-cache-ttl-2025-04-11` beta header
Expand Down Expand Up @@ -520,11 +523,13 @@ other stages and silently ignored by the draft loader.
```yaml
# signalforge.yml
llm:
provider: anthropic # registry-validated; only "anthropic" registered today
provider: anthropic # registry-validated; "anthropic" and "gemini" registered today
# provider: gemini # alt: requires `pip install signalforge-dbt[gemini]` + GOOGLE_API_KEY
model: claude-sonnet-4-6
# model: gemini-2.5-flash # alt: recommended drafter SKU under provider: gemini
cheap_model: claude-haiku-4-5-20251001
max_output_tokens: 4096
cache_ttl: 5m # one of "5m" | "1h"
cache_ttl: 5m # one of "5m" | "1h" (inert under provider: gemini in v0.3)
max_retries_429: 3
max_retries_5xx: 1
max_retries_conn: 1
Expand All @@ -539,8 +544,19 @@ Field-by-field:
value fails loud at config-load, listing the registered provider
names. Deliberately a registry-validated `str`, not a `Literal` — the
provider registry is a forward-looking plugin point (#136 OpenAI /
#137 Gemini register more providers); today only `anthropic` is
registered.
#137 Gemini register more providers); today `anthropic` and `gemini`
are registered. Selecting `gemini` requires installing the optional
extra (`pip install signalforge-dbt[gemini]`) and setting
`GOOGLE_API_KEY`; recommended Gemini drafter SKU is
`gemini-2.5-flash`. **Gemini (v0.3) ships without prompt caching** —
every draft call transmits the full system + cached_block +
dynamic_block (the `LLMProvider` strategy reports
`supports_prompt_caching=False`, so `call_llm` skips the
`cache_control` marker, the `extended-cache-ttl` beta header, and the
pre-send `count_tokens` gate). Explicit Gemini context caching is
tracked as a follow-up; the drafter's per-model call volume is one
per `generate` invocation, so the budgeting impact is lighter than
the grader's per-criterion fan-out.
- **`model`** — the model id used by every `call_llm` invocation.
Default `claude-sonnet-4-6`. Any string the SDK accepts is allowed.
- **`cheap_model`** — informational; not selected automatically.
Expand Down
25 changes: 22 additions & 3 deletions docs/grade-ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ loader cannot drift):
```yaml
# signalforge.yml — grade stage configuration (v0.1)
grade:
provider: anthropic # registry-validated; only "anthropic" registered today
provider: anthropic # registry-validated; "anthropic" and "gemini" registered today
# provider: gemini # alt: requires `pip install signalforge-dbt[gemini]` + GOOGLE_API_KEY
model: claude-sonnet-4-6 # model id (default)
# model: gemini-2.5-flash # alt: recommended Gemini judge SKU under provider: gemini
cache_ttl: 1h # Prompt-cache TTL ('5m' or '1h')
max_output_tokens: 256 # Per-criterion JSON response cap
max_retries_429: 3 # Rate-limit retry budget
Expand Down Expand Up @@ -157,7 +159,7 @@ grade:

Field-by-field:

- **`provider`** — The LLM provider strategy name (issue #135 DEC-007), resolved against the `signalforge.llm.providers` registry and threaded into `call_llm` from the per-criterion judge call, independently of the drafter's `DraftConfig.provider`. Default `"anthropic"`. An unknown value fails loud at config-load, listing the registered provider names. Deliberately a registry-validated `str`, not a `Literal` — the provider registry is a forward-looking plugin point (#136 OpenAI / #137 Gemini register more providers); today only `anthropic` is registered.
- **`provider`** — The LLM provider strategy name (issue #135 DEC-007), resolved against the `signalforge.llm.providers` registry and threaded into `call_llm` from the per-criterion judge call, independently of the drafter's `DraftConfig.provider`. Default `"anthropic"`. An unknown value fails loud at config-load, listing the registered provider names. Deliberately a registry-validated `str`, not a `Literal` — the provider registry is a forward-looking plugin point (#136 OpenAI / #137 Gemini register more providers); today `anthropic` and `gemini` are registered. Selecting `gemini` requires installing the optional extra (`pip install signalforge-dbt[gemini]`) and setting `GOOGLE_API_KEY`; recommended Gemini judge SKU is `gemini-2.5-flash` (see [Cost guidance](#cost-guidance-dec-014) for the v0.3 no-caching note).
- **`model`** — The model id used by every per-pair judge call. Default `claude-sonnet-4-6`. Mirrors `DraftConfig.model` default. Haiku 4.5 is documented as a v0.2 cost-conscious option but not exposed in v0.1.
- **`cache_ttl`** — `Literal["5m", "1h"]`. Default `"1h"` (vs. the drafter's `"5m"`) because 60 sequential per-criterion calls under retry backoff can stretch beyond a 5-minute window; `"1h"` gives margin at no extra cost (cache writes are one-shot regardless of TTL).
- **`max_output_tokens`** — Per-criterion judge response cap. Default `256`. The expected JSON response is ~150 tokens; 256 gives 2× safety. Independent of `DraftConfig.max_output_tokens`.
Expand Down Expand Up @@ -482,7 +484,9 @@ default fan-out is too expensive for their use case:
reports `supports_prompt_caching` / `supports_token_count`. A provider
that supports neither reports 0 cache tokens and skips the marker; the
default `anthropic` provider supports both, so the economics below are
unchanged. The cached block (system prompt + rubric block) is constant
unchanged. The `gemini` provider (v0.3) supports neither yet — see the
"Gemini cost note (v0.3)" paragraph below for the budgeting impact.
The cached block (system prompt + rubric block) is constant
across every call in one `grade_artifacts` invocation; a 60-call run
reads the cache ~59 times after one write. Cache reads are 0.1× input pricing vs.
1.25× for writes; the break-even is ~2 reads per write. Switching
Expand All @@ -492,6 +496,21 @@ default fan-out is too expensive for their use case:
which the dual-zero cache-anomaly WARNING (DEC-014 of #5) surfaces
loudly. Leave at `"1h"` unless you have a specific reason.

**Gemini cost note (v0.3).** **Gemini (v0.3) ships without prompt
caching.** Every grade call transmits the full system + rubric prompt;
there is no Anthropic-style discount on the cached prefix. For a
default 4-criterion rubric over a 12-column model (~48 sequential
calls), budget the per-call cost accordingly — the `cache_ttl` knob
is inert under `provider: gemini` (the `LLMProvider` strategy reports
`supports_prompt_caching=False`, so `call_llm` skips the
`cache_control` marker, the `extended-cache-ttl` beta header, and the
pre-send `count_tokens` gate). Explicit Gemini context caching is
tracked as a follow-up. Selecting `provider: gemini` requires
`pip install signalforge-dbt[gemini]` and the `GOOGLE_API_KEY` env
var; `gemini-2.5-flash` is the recommended middle-of-the-road judge
SKU (the other registered SKUs are `gemini-2.5-pro` and
`gemini-2.0-flash`).

**v0.2 will offer batched-criteria as opt-in** for cost-conscious
operators (DEC-014). The current architecture preserves the option:
each criterion has its own prompt seam already, so a `cost_mode:
Expand Down
Loading
Loading