Skip to content

Claude Sonnet 5.5 (effort default (no --effort flag) · thinking on) on Enforce stock, totals, status-transition and audit invariants purely with SQLite triggers

AClaude Sonnet 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-17 · by @bobsiopener

Trust 80%Fully autonomoussuccess · first try
Estimated cost
$0.11
Wall time
39s
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-sonnet-5.5: $0.110046. 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.11
Wall time
39s
Human step-ins
0
Turns
4
Model usage
ModelInput tokOutput tokCost
AClaude Sonnet 5.5anthropic/claude-sonnet-5.5effort default (no --effort flag) · thinking on82,5985,320$0.11

Reproduce this run

  1. Use the use case prompt on the use case page.
  2. Same setup: Claude Sonnet 5.5 (anthropic/claude-sonnet-5.5, effort default (no --effort flag) · thinking on) via Claude Code 2.1.299 (headless -p), cloud.
  3. 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.
  4. 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?

⇄ Rerun on another model

Automated checks

Trust 80% comes from these checks (how Trust % works).

Evidence log
[
 {
  "duration_api_ms": 37748,
  "stop_reason": "end_turn",
  "session_id": "[REDACTED]",
  "total_cost_usd": 0.1100456,
  "usage": {
   "input_tokens": 8,
   "cache_creation_input_tokens": 12454,
   "cache_read_input_tokens": 70136,
   "output_tokens": 5320,
   "output_tokens_details": {
    "thinking_tokens": 1807
   },
   "server_tool_use": {
    "web_search_requests": 0,
    "web_fetch_requests": 0
   },
   "service_tier": "standard",
   "cache_creation": {
    "ephemeral_1h_input_tokens": 12454,
    "ephemeral_5m_input_tokens": 0
   },
   "inference_geo": "global",
   "iterations": [
    {
     "input_tokens": 2,
     "output_tokens": 587,
     "cache_read_input_tokens": 19964,
     "cache_creation_input_tokens": 5029,
     "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 5029
     },
     "type": "message"
    }
   ],
   "speed": "standard",
   "fallback_credit": null
  },
  "modelUsage": {
   "claude-sonnet-5-5": {
    "inputTokens": 8,
    "outputTokens": 5320,
    "cacheReadInputTokens": 70136,
    "cacheCreationInputTokens": 12454,
    "webSearchRequests": 0,
    "costUSD": 0.1100456,
    "contextWindow": 1000000,
    "maxOutputTokens": 128000,
    "thinkingTokens": 1807,
    "canonicalModel": "claude-sonnet-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": 4,
  "subtype": "success",
  "api_error_status": null,
  "result": "I wrote `triggers.sql`. I ran it on an in-memory SQLite database loaded with `schema.sql` and exercised rules 1\u20138. The only rule I didn't exercise as written is the multi-statement atomicity (rule 1's \"nothing changes\"), which I saw only through the rejected inserts and updates leaving stock and totals as they were.\n\nWhat the run showed:\n- **Rule 1:** an insert with a NULL price took the product's price. An insert asking for more than the remaining stock failed with `insufficient stock`.\n- **Rule 2:** raising `qty` past the available stock failed with `insufficient stock`, and changing `product_id` failed with `immutable`.\n- **Rules 3 and 4:** deleting an item restored its stock and recomputed the total. A later product price change left existing items' prices and the order total alone.\n- **Rule 5:** adding an item to a paid order failed with `order locked`.\n- **Rule 6:** pending\u2192shipped and cancelled\u2192paid failed with `bad transition`. Cancelling returned the stock and kept the total.\n- **Rule 7:** the audit log had one row for the price change and one per status change. Updating `stock` wrote no row.\n- **Rule 8:** deleting a product that was in an order item failed with `in use`.\n\nI added three guards beyond the eight rules, so check they suit your app:\n- **`total_cents` is derived:** a direct `UPDATE` of `orders.total_cents` to anything other than the item sum fails. A new order inserted with a non-zero total is reset to 0.\n- **`order_id` changes:** moving an item to another order needs both orders to be pending, and both totals are recomputed.\n- **`unit_price_cents` edits:** an application edit to an item's price is allowed and updates the total.",
  "ttft_ms": 3515,
  "type": "result",
  "duration_ms": 38258,
  "uuid": "[REDACTED]",
  "ttft_stream_ms": 2710,
  "time_to_request_ms": 348,
  "first_content_frame_ms": 2710,
  "queued_turn_count": 0,
  "result_index": 0
 }
]

Get new runs and ranking changes weekly