Commit Graph

2 Commits

Author SHA1 Message Date
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
c2bed46ee4 fix(agent): pass-2 Rust production cutover + comprehensive differential + CI gate
Production cutover (Thufir finding 1, Rust half):
- Add normalize_effort_for_databricks_v2() and anthropic_thinking_config_for_databricks_v2()
  as generated-backed production helpers for DatabricksV2 requests.
- llm.rs DatabricksV2 dispatch now routes through these helpers: OpenAiResponses and
  MlflowChatCompletions paths call normalize_effort_for_databricks_v2(); anthropic_body
  calls anthropic_thinking_config_for_databricks_v2(). The adopted F1 corrections
  (e.g. databricks-gpt-5-5: [low,medium,high]) are now enforced in real requests.
- Pure OpenAi/Databricks path retains normalize_effort_for_openai_route (unchanged).

Comprehensive Rust differential (Thufir finding 4):
- Replace the simple route-only differential test (20-vector literal list, no allowlist
  scoping) with a comprehensive multi-axis test covering all 3 input sets:
  effortTable.fixture.json (36), normative-corpus.json (45), catalog-sample-fixture.json (14).
- Axes: supported_efforts, default_effort, databricks_v2_wire_route, thinking_mode.
- Allowlist is axis-scoped; 7 entries, all doc-cited. Stale entries FAIL (mirrors JS
  harness semantics — no whole-record skip).
- Exposes strip_catalog_prefix as pub(crate); adds #[cfg(test)] pub(crate) helpers
  is_manual_budget_model_for_test, is_adaptive_thinking_model_for_test, and
  valid_effort_values_for_provider_model_for_test so llm.rs tests can call
  config.rs classifiers without duplicating them.
- Result: 95 input entries, 7/7 allowlist slots exercised, 0 unexpected divergences.

CI gate (Thufir finding 3):
- Extend model-capability-regen-diff workflow path filter to cover the differential
  harness, all three fixtures, and both old/new consumer files (buzzAgentConfig.ts,
  config.rs, llm.rs) so any change to either side triggers the gate.
- Add a final step: node --experimental-strip-types scripts/run-differential.mjs.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-07-31 13:51:34 -04:00
Will Pfleger
4d47f48143 feat(agent): Phase 1 — model-capability manifest, generator, and test oracle (#3821)
## What this does

Introduces the model-capability manifest infrastructure (Phase 1 of the
Model-Capability Manifest plan v4, Thufir-approved 9/9/9). No consumer
cutover — `config.rs`, `llm.rs`, `catalog.rs`, and `buzzAgentConfig.ts`
are unchanged. Phase 2 wires them.

**Single source of truth** replaces hand-mirrored metadata across four
files:

```
scripts/model-capabilities.json         → hand-curated manifest
scripts/generate-model-capabilities.mjs → emits Rust + TS artifacts
crates/buzz-agent/src/generated_model_capabilities.rs
desktop/src/features/agents/ui/modelCapabilities.ts
```

## Resolver contract (plan v4 §Resolver contract)

Total function `resolve(provider, raw_model_id) → CapabilityResult`.
Three ordered steps:

1. Provider-qualified raw exact lookup — key is `(provider,
raw_model_id)`, matched before any prefix stripping. A prefixed alias
never inherits an exact record.
2. Provider-scoped ordered family rules — on normalized
(prefix-stripped) alias, by `match_priority` desc.
3. Per-axis provider fallback — `blank` vs `concrete_unknown`, per
provider.

Result is complete — every axis populated, runtime consumers never
compose fields.

## Boundaries the manifest does NOT own

- Transport for pure OpenAI, legacy Databricks, OpenRouter:
`OpenAiApi`/`openai_request()` remain authoritative.
`databricks_v2_wire_route` is DBv2-only (all other providers emit
`not-applicable`).
- Final display labels: `resolveModelLabel()` three-tier precedence
unchanged. `registry_label` feeds only the static registry tier.
- `llm.rs` scope: only `databricks_v2_route_for_model` (Phase 2).

## Test oracle (three independent layers)

1. Generated full-table coverage —
`scripts/generated-model-capabilities-coverage.json`: every manifest
entry + provider fallbacks.
2. Hand-authored normative corpus — `scripts/normative-corpus.json` (44
vectors): Anthropic manual-budget/adaptive families, OpenAI gpt-5
adversarial boundary cases, DBv2 segment-routing collision tests, P2-A
resolver-contract vectors, P2-B blank/concrete-unknown per provider.
Runs against JS resolver (`run-corpus.mjs`) and mirrored in Rust
(`generated_model_capabilities_tests.rs`).
3. Schema-negative tests — `scripts/test-manifest-validator.mjs` (17
tests): every validator rule has a failing-input test.

## Reconciliation table

`scripts/MODELS_DEV_RECONCILIATION.md` — all models.dev divergences
dispositioned. `databricks-gpt-5-4-mini` and `databricks-gpt-5-4-nano`
adopt models.dev `[low,medium,high]` (family rule adds `none+xhigh` the
endpoint doesn't advertise).

## CI

`.github/workflows/model-capability-regen-diff.yml`: triggers on
manifest/generator/artifact changes; regenerates and fails if stale;
runs JS corpus + schema-negative tests.

## Acceptance criteria (plan v4 Phase 1)

- Byte-clean regen: `node scripts/generate-model-capabilities.mjs
--check` passes
- Rust compiles: `cargo check -p buzz-agent`
- TS typechecks: `pnpm tsc --noEmit --strict`
- 44/44 normative corpus vectors pass (JS interpreter)
- 41/41 Rust corpus tests pass
- 17/17 schema-negative tests pass (every validator rule)
- Reconciliation table complete with doc citations
- No consumer changes (config.rs, llm.rs, catalog.rs, buzzAgentConfig.ts
untouched)

---------

Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
2026-07-31 12:39:37 -04:00