|
| 1 | +# shiftlock |
| 2 | + |
| 3 | +Find out whether your own prompts, tool calls and JSON outputs still work before you switch LLM |
| 4 | +models: a forced deprecation, a version bump or a provider change. |
| 5 | + |
| 6 | +shiftlock replays your real requests on the current model (baseline) and the replacement |
| 7 | +(candidate), runs deterministic checks, and returns one of four verdicts: **go**, **conditional**, |
| 8 | +**no-go** or **inconclusive**. It also writes an HTML report showing every case that got worse. |
| 9 | + |
| 10 | +> Status: early alpha (v0.1). It supports OpenAI and Anthropic, and imports OpenAI-style JSONL. |
| 11 | +
|
| 12 | +## Quick start |
| 13 | + |
| 14 | +```bash |
| 15 | +uv tool install . # from a clone; not on PyPI yet |
| 16 | +shiftlock init # creates shiftlock.yaml and .shiftlock/ |
| 17 | +shiftlock import requests.jsonl # your own requests; nothing leaves your machine |
| 18 | +# edit shiftlock.yaml: set the baseline and candidate model IDs |
| 19 | +shiftlock estimate # calls, tokens and worst-case cost, no API calls |
| 20 | +export ANTHROPIC_API_KEY=... # and/or OPENAI_API_KEY |
| 21 | +export ANTHROPIC_WORKSPACE_ID=... # only if your key isn't scoped to a workspace |
| 22 | +shiftlock run # asks before spending, then prints the verdict |
| 23 | +shiftlock report # show the latest verdict again |
| 24 | +``` |
| 25 | + |
| 26 | +`examples/sample.jsonl` holds four synthetic cases you can try it on. |
| 27 | + |
| 28 | +## Input |
| 29 | + |
| 30 | +The input is a JSONL file in one of two OpenAI chat-completions shapes: |
| 31 | + |
| 32 | +- **Batch API:** `{"custom_id": ..., "body": {"messages": [...], "tools": [...], "response_format": {...}}}`. |
| 33 | + Settings such as `temperature`, `tool_choice` and `max_completion_tokens` are replayed as |
| 34 | + given. |
| 35 | +- **Fine-tuning:** `{"messages": [...], "tools": [...]}`. A final assistant message becomes the |
| 36 | + expected answer, and its tool calls are compared exactly. |
| 37 | + |
| 38 | +Anthropic runs use the same file: shiftlock translates messages, tools and JSON schemas for you. |
| 39 | + |
| 40 | +## Checks |
| 41 | + |
| 42 | +| Check | When it runs | Effect | |
| 43 | +|---|---|---| |
| 44 | +| `json_valid`, `schema_match` | The request had a JSON schema or JSON mode | Blocking | |
| 45 | +| `tool_calls_valid` | The request offered tools; arguments must match the tool's schema | Blocking | |
| 46 | +| `tool_call_match` | The case has an expected tool call | Blocking | |
| 47 | +| `same_tools_as_baseline` | The request offered tools, with no expected call | Advisory | |
| 48 | +| `contains`, `not_contains`, `regex`, `max_latency_ms`, `max_cost_usd` | You add them in `shiftlock.yaml` | Advisory unless `blocking: true` | |
| 49 | + |
| 50 | +## Verdict rules (v1, strict) |
| 51 | + |
| 52 | +1. **no-go:** any blocking check that passed on the baseline fails on the candidate. One case is |
| 53 | + enough. |
| 54 | +2. **inconclusive:** |
| 55 | + - fewer than `min_cases` usable cases (default 20); |
| 56 | + - or more than `max_error_rate` of calls failed (default 10%). |
| 57 | + - Truncated and errored outputs don't count as usable. |
| 58 | +3. **conditional:** an advisory check regressed, or cost or median latency rose by more than 20%. |
| 59 | +4. **go:** none of the above. |
| 60 | + |
| 61 | +Exit codes: |
| 62 | +- `0` go |
| 63 | +- `1` no-go |
| 64 | +- `2` conditional |
| 65 | +- `3` inconclusive |
| 66 | +- `4` cost cap reached |
| 67 | +- `10` and above: errors |
| 68 | + |
| 69 | +`--fail-on` chooses which verdicts fail CI. |
| 70 | + |
| 71 | +## Cost |
| 72 | + |
| 73 | +Customers bring their own keys, so every run spends credit on your provider account. |
| 74 | +- `shiftlock estimate` gives a worst-case figure without calling any API. |
| 75 | +- `max_cost_usd` stops the run before a call could exceed the cap. |
| 76 | +- Prices come from `src/shiftlock/data/prices.yaml`, which is hand-maintained. Each entry needs |
| 77 | + a source URL and the date it was checked. |
| 78 | +- If a model isn't listed, cost shows as "unknown" rather than being guessed. Add prices under |
| 79 | + `prices:` in `shiftlock.yaml`. |
| 80 | + |
| 81 | +## Privacy |
| 82 | + |
| 83 | +There is no telemetry. Keys are read only from environment variables and are redacted from all |
| 84 | +output. See [SECURITY.md](SECURITY.md). |
| 85 | + |
| 86 | +## Development |
| 87 | + |
| 88 | +```bash |
| 89 | +uv sync |
| 90 | +uv run ruff check . && uv run ruff format --check . |
| 91 | +uv run mypy src |
| 92 | +uv run pytest # offline; `-m live` runs the opt-in tests that spend API credit |
| 93 | +``` |
| 94 | + |
| 95 | +## License |
| 96 | + |
| 97 | +MIT |
0 commit comments