Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) on Enforce stock, totals, status-transition and audit invariants purely with SQLite triggers
AClaude Haiku 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-17 · by @bobsiopener
- Estimated cost
- $0.02
- 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-haiku-5.5: $0.015394. 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.02
- Wall time
- 1m
- Human step-ins
- 0
- Turns
- 5
| Model | Input tok | Output tok | Cost |
|---|---|---|---|
| AClaude Haiku 5.5anthropic/claude-haiku-5.5effort default (no --effort flag) · thinking on | 133,779 | 18,134 | $0.02 |
Reproduce this run
- Use the use case prompt on the use case page.
- Same setup: Claude Haiku 5.5 (anthropic/claude-haiku-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": 72795,
"stop_reason": "end_turn",
"session_id": "[REDACTED]",
"total_cost_usd": 0.015393760000000001,
"usage": {
"input_tokens": 10,
"cache_creation_input_tokens": 26253,
"cache_read_input_tokens": 107516,
"output_tokens": 18134,
"output_tokens_details": {
"thinking_tokens": 10891
},
"server_tool_use": {
"web_search_requests": 0,
"web_fetch_requests": 0
},
"service_tier": "standard",
"cache_creation": {
"ephemeral_1h_input_tokens": 26253,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "global",
"iterations": [
{
"input_tokens": 2,
"output_tokens": 636,
"cache_read_input_tokens": 34660,
"cache_creation_input_tokens": 4132,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 4132
},
"type": "message"
}
],
"speed": "standard",
"fallback_credit": null
},
"modelUsage": {
"claude-haiku-5-5": {
"inputTokens": 10,
"outputTokens": 18134,
"cacheReadInputTokens": 107516,
"cacheCreationInputTokens": 26253,
"webSearchRequests": 0,
"costUSD": 0.015393760000000001,
"contextWindow": 1000000,
"maxOutputTokens": 128000,
"thinkingTokens": 10891,
"canonicalModel": "claude-haiku-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 left `schema.sql` untouched. A scratch test run against `schema.sql` plus `triggers.sql` under SQLite 3.46.1 passed all 48 checks, covering each of the eight rules plus the failure cases (rollback on error, multi-row statements, locked orders). The test script is in `/tmp/f01-test/check.py`, outside the work directory.\n\nDesign: BEFORE triggers do validation so nothing changes on error, and AFTER triggers do the side effects. SQLite can't assign to `NEW`, so the default price is filled by an UPDATE in an AFTER INSERT trigger. Totals are recomputed from the order's items after every item change instead of adjusted incrementally, so they can't drift.\n\nChoices I made beyond the spec:\n- **Direct writes to `orders.total_cents` are rejected** with `total_cents is derived from order items`. Otherwise the app could break rule 4 by writing the column itself.\n- **`unit_price_cents` can still be edited** on an item, and the order total follows. The spec didn't forbid it, so I left it open.\n- **`order_id` can be changed**, but both the old and new orders must be pending, and both totals are recomputed.\n- **Error texts:** `order locked`, `insufficient stock`, `product_id is immutable`, `bad transition`, `product in use`. Each contains the phrase the spec asks for.",
"ttft_ms": 1444,
"type": "result",
"duration_ms": 73245,
"uuid": "[REDACTED]",
"ttft_stream_ms": 1367,
"time_to_request_ms": 266,
"first_content_frame_ms": 1368,
"queued_turn_count": 0,
"result_index": 0
}
]