summaryrefslogtreecommitdiffhomepage
path: root/.rules/plan/16-20-retarget-misc-specs.md
blob: 6f5a6317abe3d99909ae17952b7f7f8584808943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Phase 16 — Retarget miscellaneous specs

**Estimated time:** ~20 minutes
**Touches:**
`spec/dispatch/adapter/minimax/model_catalog_spec.rb`,
`spec/dispatch/adapter/minimax/pricing_table_spec.rb`,
`spec/dispatch/adapter/minimax/errors_spec.rb`,
`spec/dispatch/adapter/minimax/strict_fallback_spec.rb`,
`spec/dispatch/adapter/minimax/http_client_spec.rb`,
`spec/dispatch/adapter/minimax/rate_limiter_spec.rb`,
`spec/dispatch/adapter/minimax_spec.rb` (the main top-level spec).

## Goal

Update the remaining smaller specs so the suite passes end to end. Most
of these are mechanical: rename Claude → MiniMax, update model ids,
fixture-derived assertions, and remove references to deleted code.

## Pre-reading

Read each file briefly before editing. They are smaller than the chat
specs from phase 15 — most are 50–200 lines.

## Per-file changes

### model_catalog_spec.rb

- Replace every Claude model id with a MiniMax id (`MiniMax-M2.7`,
  etc.).
- Update `supports_vision` assertions: now `false` for all MiniMax
  models (phase 07).
- Update `max_context_tokens` assertions: now `204_800` for all 7
  models.
- Update pricing assertions: every `*_per_mtok` field is `0.0`.
- Drop the `"(unrated) #{display_name}"` example (phase 07 dropped
  that branch).
- Add a test that `build("MiniMax-M2.7")` returns the right
  `ModelInfo` shape.
- Add a test that `build_from_api({"id"=>"MiniMax-M2","display_name"=>"M2"})`
  uses the display_name as `name`.

### pricing_table_spec.rb

- Replace Anthropic model ids with MiniMax ids.
- Assert `lookup("MiniMax-M2.7")` returns a `ModelPricing` with all
  four `*_per_mtok` fields equal to `0.0`.
- Assert `context_window("MiniMax-M2.7") == 204_800`.
- Assert `max_output_tokens("MiniMax-M2.7") == 16_384`.
- Assert `known_ids` is an array of exactly the 7 MiniMax model ids.
- DELETE any example that asserted real Anthropic price values.

### errors_spec.rb

- Rename `Dispatch::Adapter::ClaudeErrors` references to
  `Dispatch::Adapter::MiniMaxErrors`.
- Update `PROVIDER` assertion to `"MiniMax"`.
- Add a test for the new `parse_message` fallback to top-level
  `"message"` key (phase 11).
- Keep the existing tests for status-code → exception mapping (401/403
  → AuthenticationError, 429 → RateLimitError, 529 → OverloadedError,
  400/422 → RequestError, 5xx → ServerError, other → Error).
- The `OverloadedError < RateLimitError` test stays.

### strict_fallback_spec.rb

- Rename `ClaudeErrors` to `MiniMaxErrors` if referenced.
- Update model ids.
- Add new examples covering the broadened regex patterns from phase
  10:
  - `"compiled grammar too large"` → matches.
  - `"schema too complex"` → matches.
  - `"grammar exceeds maximum size"` → matches.
  - `"tool_schema too large"` → matches.
  - `"missing required field: messages"` → does NOT match.
  - Status 429 with grammar message → does NOT match (status guard).
  - Non-`RequestError` exception → does NOT match.

### http_client_spec.rb

- Rename `ClaudeErrors` to `MiniMaxErrors` if referenced.
- Replace `https://api.anthropic.com` URLs with
  `https://api.minimax.io/anthropic`.
- Drop `claude_code_only` parameter usage if any remains (it should
  not — phase 04 removed it).
- Update `Authorization` header expectations to `Bearer <key>`.
- Drop OAuth-token-refresh-related examples (deleted in phase 02; if
  any survived, delete them now).

### rate_limiter_spec.rb

- This spec exercises the `RateLimiter` class from
  `dispatch-adapter-interface`. It probably does NOT have many
  Claude/MiniMax-specific assertions. Check:
  - The state file path (was `~/.config/dispatch/claude_rate_limit`,
    now `~/.config/dispatch/minimax_rate_limit` per phase 02 step 4).
  - Update path expectations accordingly.
- Drop any constant references to Claude.

### minimax_spec.rb (the renamed claude_spec.rb)

This is the top-level spec for the public class.

- Rename `Dispatch::Adapter::Claude` → `Dispatch::Adapter::MiniMax`
  (should already be done by phase 01; verify).
- Update constructor examples to the new kwargs (`api_key:`,
  `key_path:`).
- Add a test that:
  - Construction with explicit `api_key:` works.
  - Construction with `ENV["MINIMAX_API_KEY"]` set works (stub via
    `allow(ENV).to receive(:[]).with("MINIMAX_API_KEY").and_return("k")`).
  - Construction with neither raises `ArgumentError`.
- Drop `authenticate!`, `authenticated?`, `logout!`, `usage_report`
  examples (these methods were deleted in phase 02).
- Update `DEFAULT_BASE_URL` and `DEFAULT_MODEL` constant assertions.

## Acceptance criteria

- ALL spec files in `spec/dispatch/adapter/minimax/` pass cleanly.
- `spec/dispatch/adapter/minimax_spec.rb` passes cleanly.
- No `.skip`, no `.pending` anywhere in the spec suite.
- `grep -rn 'ClaudeErrors\|api.anthropic.com\|claude-sonnet\|claude-3\|sk-ant-oat\|is_oauth\|proxy_\|claude-cli\|x-stainless\|anthropic-beta\|anthropic-version\|X-Api-Key\|usage_report\|authenticate!\|claude_code_only\|interleaved_thinking\|extra_betas' spec/`
  returns ZERO matches.
- `bundle exec rubocop --autocorrect-all` exits 0.
- `bundle exec rspec` exits 0 with no skipped or pending examples.

## Verification

Run `run_tests` with `project_path=reference/dispatch-adapter-minimax`.
This is the FIRST phase where the entire test suite must pass cleanly.
If anything fails, fix the implementation (or the test if and only if
the test is asserting on something that no longer exists). NEVER
weaken or skip a test to make it green.