Skip to content

test: make #57's trigger fire for the person who trips it - #159

Merged
yuanhao merged 1 commit into
mainfrom
test/57-provider-metadata-guard
Aug 23, 2026
Merged

test: make #57's trigger fire for the person who trips it#159
yuanhao merged 1 commit into
mainfrom
test/57-provider-metadata-guard

Conversation

@yuanhao

@yuanhao yuanhao commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Closes #57 by moving its conditional somewhere it will actually be noticed.

Why not just leave the issue open

#57 proposed replacing Content::ToolCall.provider_metadata's untyped Option<serde_json::Value> with a typed, namespaced enum. Its own "when to do this" was a conditional:

Trigger: the moment a second provider needs provider_metadata — do both items together before shipping that provider, since that is when the key-collision risk becomes real.

An open issue is a poor mechanism for a conditional. Whoever adds OpenAI reasoning IDs will not check the tracker first, so the reminder fires for nobody — which is what happened: open since 2026-07-05, doing nothing.

This test fires for exactly that person, at exactly that moment, in the diff that trips it:

A provider outside the Gemini family now writes `provider_metadata`:

  openai_responses.rs:210 — provider_metadata: Some(serde_json::json!({"reasoning_id": "r-1"})),

... Do #57 first, then add the field.

The issue's analysis is preserved in the test's module docs, including why now is the last cheap moment: after a second family ships, persisted Session JSONL carries the untyped shape and the migration inherits a serde back-compat burden it doesn't need.

What it actually checks

Deliberately not a grep for provider_metadata: Some. The Gemini production sites assign a variable (provider_metadata: metadata), and the Some literals in those files are test fixtures — so matching on Some would guard test code and miss the real writes. The invariant that holds today is the stronger one: every provider outside the Gemini family writes the literal None.

Two exclusions, both earned by the guard failing on them first rather than assumed up front:

  • A struct field declaration is not a write — mock.rs declares the field on its fixture type.
  • mock.rs echoes whatever MockToolCall was handed, so it forwards metadata rather than originating any. It cannot be the second family this watches for.

Verification

Real trigger simulated openai_responses.rs writing a reasoning_idfails, naming file, line and remedy
Guard reads nothing asserted against — a layout change that found <5 provider modules fails rather than passing green
Second Gemini key also a trigger, since that is where namespacing starts to matter

cargo test --all-features: 629 passed, 0 failed. Clippy clean under -Dwarnings.

Test-only — no library change.

🤖 Generated with Claude Code

#57 proposed a typed ProviderMetadata enum, with an explicit conditional:
do it "the moment a second provider needs provider_metadata". An open
issue is a poor mechanism for a conditional — whoever adds OpenAI
reasoning IDs will not read the tracker first, so the reminder fires for
nobody. It sat open since 2026-07-05 doing exactly that.

This fails in the diff that trips it, naming the file, the line, and what
to do instead.

Deliberately not a grep for `provider_metadata: Some`. The Gemini
production sites assign a variable, and the Some literals in those files
are test fixtures — matching on Some would guard test code and miss the
real writes. The invariant that holds today is the stronger one: every
provider outside the Gemini family writes the literal None.

Two exclusions, both earned by the guard failing on them first. A struct
field declaration is not a write (mock.rs declares the field on its
fixture type). And mock.rs echoes whatever MockToolCall was given, so it
forwards metadata rather than originating any — it cannot be the second
family this watches for.

Verified against the real trigger: adding
`provider_metadata: Some(json!({"reasoning_id": "r-1"}))` to
openai_responses.rs fails it with the file, the line and the remedy. The
source-reading itself is guarded too — a layout change that made this
read nothing fails rather than passing green.

629 passed, clippy clean under -Dwarnings.

Closes #57
@yuanhao
yuanhao merged commit c01f8d0 into main Aug 23, 2026
8 checks passed
@yuanhao
yuanhao deleted the test/57-provider-metadata-guard branch August 23, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typed ProviderMetadata enum + drop the google-fc- magic-string coupling

1 participant