Claude Opus 5.5 (effort default (no --effort flag) · thinking on) on Enforce stock, totals, status-transition and audit invariants purely with SQLite triggers
AClaude Opus 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-17 · by @bobsiopener
- Estimated cost
- $0.27
- Wall time
- 1m
- Human step-ins
- 0
- Outcome
- Pass
Compare with other models on this task →
Summary
Exact prompt
# Task: enforce shop invariants with SQLite triggers `schema.sql` defines products, orders, order_items and audit_log. Write **only** `triggers.sql` (it is executed right after `schema.sql` on an empty database with SQLite 3.46 via Python's `sqlite3`; do not change `schema.sql`). Application code will do plain INSERT/UPDATE/DELETE statements; the database itself must keep these rules: 1. Inserting an order item: if `unit_price_cents` is NULL it is set to the product's current `price_cents`; the product's `stock` decreases by `qty`. If stock is insufficient the statement fails with an error whose message contains `insufficient stock` and nothing changes. 2. Updating an item's `qty` adjusts stock by the difference (same insufficient-stock error). Changing an item's `product_id` is forbidden (error containing `immutable`). 3. Deleting an order item restores its stock. 4. `orders.total_cents` always equals the sum of `qty * unit_price_cents` over its items (0 when none). An item keeps the `unit_price_cents` it got at insert time; later product price changes do not affect existing items or totals. 5. Items can only be inserted, updated or deleted while their order's status is `pending`; otherwise error containing `order locked`. 6. Order status may only change pending->paid, pending->cancelled, paid->shipped, paid->cancelled (same status = no-op allowed). Any other change fails with error containing `bad transition`. Cancelling an order returns the stock of all its items (items stay, total stays). 7. Every change of a product's `price_cents` (old != new) writes one audit_log row: entity 'product', entity_id, field 'price_cents', old and new values as text. Every order status change writes a row with entity 'order', field 'status', old and new status. Updates that leave the value unchanged write no audit row; changes to other columns (e.g. `stock`) are not audited. 8. A product that appears in any order item cannot be deleted (error containing `in use`). Use `RAISE(ABORT, '...')` for errors. No network.
Needs BEFORE vs AFTER trigger choice, RAISE(ABORT) atomicity, NULL-safe comparisons (IS NOT), recomputing totals on insert/update/delete, transition tables and cancel-time stock restoration across duplicate lines. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).
Success criteria: 1. All 13 hidden unittest cases pass (schema.sql + agent triggers.sql in an in-memory SQLite 3.46 DB): price defaulting, stock decrement/insufficient-stock abort, qty delta updates, immutable product_id, delete restores stock, per-order totals, locked non-pending orders, allowed/forbidden status transitions, cancel restores stock, audit rows only on real changes, item price unaffected by later product price change, in-use product delete blocked, schema.sql unchanged.
Setup notes: Use Case Scout batch 6 case f01-sqlite-triggers-invariants (offline fixture). Prepared with batch6/prepare.sh; hidden key/tests kept outside the agent's work dir. Prompt = TASK.md verbatim. Scored with the scout's scorer: `python score.py WORKDIR KEYDIR`. Tools: Read/Write/Edit/Glob/Grep/Bash, web disabled. Single run, no retries. Claude Code's own reported cost for claude-opus-5.5: $0.265245. Score: 13/13. Cost is an ESTIMATE: measured tokens x pricing.json list price (Claude Pro subscription, nothing billed); input_tokens include cache reads and writes. Single run.
Estimated cost List-price estimate; not actually billed.
Metrics
- Estimated cost
- $0.27
- Wall time
- 1m
- Human step-ins
- 0
- Turns
- 5
| Model | Input tok | Output tok | Cost |
|---|---|---|---|
| AClaude Opus 5.5anthropic/claude-opus-5.5effort default (no --effort flag) · thinking on | 108,288 | 6,969 | $0.27 |
Reproduce this run
- Use the use case prompt on the use case page.
- Same setup: Claude Opus 5.5 (anthropic/claude-opus-5.5, effort default (no --effort flag) · thinking on) via
Claude Code 2.1.299 (headless -p), cloud. - It counts as a success only if it meets every success criterion: 1. All 13 hidden unittest cases pass (schema.sql + agent triggers.sql in an in-memory SQLite 3.46 DB): price defaulting, stock decrement/insufficient-stock abort, qty delta updates, immutable product_id, delete restores stock, per-order totals, locked non-pending orders, allowed/forbidden status transitions, cancel restores stock, audit rows only on real changes, item price unaffected by later product price change, in-use product delete blocked, schema.sql unchanged.
- Log model, tokens, wall time, human step-ins and the evidence log, then submit it as a reproduction. A different model? Submit a head-to-head rerun.
How runs are scored: Methodology.
Was this useful?
Automated checks
Trust 80% comes from these checks (how Trust % works).
- Run date is not in the future : passed
- Model is in the dated pricing table : passed
- Cost recomputed from tokens matches : passed
- Cached tokens are consistent : passed
- Output throughput is plausible : passed
- Autonomy matches step-ins : passed
- Step-ins do not exceed turns : passed
- Retries agree with first-try result : passed
- Evidence log SHA-256 matches : passed
- Evidence log is substantial : passed
Evidence log
[
{
"duration_api_ms": 67393,
"stop_reason": "end_turn",
"session_id": "[REDACTED]",
"total_cost_usd": 0.26524460000000005,
"usage": {
"input_tokens": 10,
"cache_creation_input_tokens": 13355,
"cache_read_input_tokens": 94923,
"output_tokens": 6969,
"output_tokens_details": {
"thinking_tokens": 2287
},
"server_tool_use": {
"web_search_requests": 0,
"web_fetch_requests": 0
},
"service_tier": "standard",
"cache_creation": {
"ephemeral_1h_input_tokens": 13355,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "global",
"iterations": [
{
"input_tokens": 2,
"output_tokens": 748,
"cache_read_input_tokens": 24282,
"cache_creation_input_tokens": 1219,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 1219
},
"type": "message"
}
],
"speed": "standard",
"fallback_credit": null
},
"modelUsage": {
"claude-opus-5-5": {
"inputTokens": 10,
"outputTokens": 6969,
"cacheReadInputTokens": 94923,
"cacheCreationInputTokens": 13355,
"webSearchRequests": 0,
"costUSD": 0.26524460000000005,
"contextWindow": 1000000,
"maxOutputTokens": 128000,
"thinkingTokens": 2287,
"canonicalModel": "claude-opus-5-5",
"provider": "firstParty",
"costBasis": "list"
}
},
"permission_denials": [],
"terminal_reason": "completed",
"fast_mode_state": "off",
"fast_mode_disabled_reason": "sdk_opt_in_required",
"subagent_stats": {
"spawned": 0,
"requested": {
"background": 0,
"foreground": 0,
"unset": 0
},
"started_in_background": 0,
"max_depth": 0,
"spawned_by_subagents": 0,
"completed": 0,
"failed": 0,
"killed": {
"parent": 0,
"user": 0,
"system": 0
},
"refused": {
"depth_limit": 0,
"concurrency_limit": 0,
"budget": 0
},
"by_type": {}
},
"safety_stops": 0,
"is_error": false,
"num_turns": 5,
"subtype": "success",
"api_error_status": null,
"result": "I wrote `triggers.sql` and ran it against SQLite 3.46.1 through Python's `sqlite3`. I tested every rule with a throwaway script (kept outside the work folder), and all checks passed. `schema.sql` is unchanged.\n\n**What the triggers do**\n- **Adding an item:** it checks that the order is `pending` and that there is enough stock, then fills a NULL `unit_price_cents` from the product's current price, lowers the stock and recalculates the order total. A failed check rolls the whole statement back.\n- **Updating an item:** changing `product_id` fails with an \"immutable\" error. Changing `qty` moves stock by the difference, with the same insufficient-stock check. Totals are recalculated for the old and new order, in case `order_id` was changed.\n- **Deleting an item:** the stock is put back and the total recalculated.\n- **Locking:** inserting, updating or deleting an item fails with `order locked` unless the order is `pending`.\n- **Status changes:** only the four allowed transitions work; anything else fails with `bad transition`, and setting the same status again does nothing. Cancelling returns the stock of every item in the order; the items and total stay as they were. Each real status change writes one audit row.\n- **Price audit:** a real change to `price_cents` writes one audit row with the old and new values as text. Changes to other columns, such as `stock`, and updates that leave the price the same write nothing.\n- **Product deletion:** deleting a product that appears in any order item fails with `in use`.\n\n**Two things I added that you didn't ask for:**\n1. **`unit_price_cents` can't be changed once set.** Changing it after the initial fill raises an \"immutable\" error. I read rule 4 (\"an item keeps the price it got at insert time\") as meaning it shouldn't change. If you want the application to be able to change it, delete that one check.\n2. **Direct writes to `orders.total_cents` are overwritten.** Any value written there directly is reset to the correct sum, and a new order always starts at 0. I chose to correct the value silently rather than raise an error, so a statement that updates status and total together still succeeds.\n\nAll checks for each event are in a single BEFORE trigger, because SQLite doesn't guarantee the order in which several triggers on the same event fire.",
"ttft_ms": 4886,
"type": "result",
"duration_ms": 67815,
"uuid": "[REDACTED]",
"ttft_stream_ms": 3871,
"time_to_request_ms": 258,
"first_content_frame_ms": 3872,
"queued_turn_count": 0,
"result_index": 0
}
]