Superbench 2.0 · Выпуск запроса 2.0
Обсерватория Tidal Ledger
Назад ко всем подсказкамВернуться к Superbench 2.0 · Тестовый контракт и критерии оценки. Опубликована одна записанная оценка для этого краткого описания; откройте страницу краткого описания для артефакта и записи сессии для её пределов. Одно сообщение пользователя, один HTML-ответ; без инструментов или корректировок. Не добавляйте руководство оператора версии 1.x.
# 18. Tidal Ledger Observatory
Build an interactive harbor observatory in one self-contained HTML file: three warehouses exchange sealed cargo through a deterministic event ledger, and users can scrub, replay and branch history while inspecting exactly where every unit is held.
This is a tool-free, single-response build. Do not browse, execute code, call tools, ask questions or request approval. Reason privately, check your source, and return only the complete HTML document. Do not claim browser testing; a reviewer performs the checklist later.
## Required features
### 1. Exact ledger semantics
Warehouses A,B,C initially hold 8,4,0 units respectively. Total physical inventory is always 12. A reservation holds units at its source; it does not move them. Available inventory equals physical stock minus the sum of that source's active holds.
Accept a JSON array of up to 100 events. An event has a unique nonempty ASCII alphanumeric id of at most 16 characters, a nonnegative integer seq at most 999, and a type:
- reserve: exactly fields id,seq,type,ref,from,to,qty. ref has the same string restrictions as id; from and to are distinct warehouse IDs; qty is an integer 1–12.
- commit or cancel: exactly fields id,seq,type,ref.
No extra fields or type coercion. Sort by ascending seq, then ASCII id order. IDs identify delivery records; refs identify reservations. Repeated identical events with the same id are collapsed, regardless of object key order. The same id with any different field makes the whole import invalid. Invalid JSON, schema, or size also rejects the entire import without changing the accepted journal, playhead or branch. Explain the error visibly.
Replay sorted unique events from the initial state:
- reserve succeeds only if ref has never belonged to a successful reservation and available source stock is at least qty. On success, create an active hold. A failed reserve does not consume its ref.
- commit succeeds only for an active ref. Subtract qty from source physical stock, add it to destination and release its hold; mark the ref committed.
- cancel succeeds only for an active ref. Release its hold without moving stock; mark the ref cancelled.
- Any semantic rejection is logged as rejected with a reason, makes no state change, and does not prevent later events from being processed. Terminal refs cannot be reused.
Commit must not re-check availability after counting its own hold; its stock was already reserved. All quantities remain nonnegative, and holds cannot exceed source stock. Simultaneous seq values still follow the specified id ordering.
### 2. Inspectable history and branching
Show a visual harbor with three warehouses, physical/held/available counts, active and terminal reservation cards, and a ledger of applied or rejected events with reasons. Animate transfers only as a presentation effect; the discrete ledger determines state.
A playhead k means exactly the first k sorted unique events have been evaluated, including rejected events. Support k=0 through journal length, Previous, Next, Play, Pause and direct seek. Play advances one event per second; pausing or resizing cannot apply an extra event. Backward seek must reconstruct the correct prefix, including reservation statuses and rejection history. Display all events but distinguish the unevaluated suffix from evaluated rows.
At any paused playhead, Branch here retains exactly the first k sorted unique events and discards the suffix. Then allow appending one event through a form or JSON input. Its seq must be greater than the maximum retained seq (or any valid seq if none remain), and its id must be new within the retained journal. Treat schema failures atomically. Semantic rejections are accepted into the branch and shown as rejected during replay. Append places the playhead at the new end. Branching and append must not silently resurrect discarded records.
An accepted full import pauses playback and sets k=0. Provide Load example and Reset: Load example imports the fixture below, and Reset restores an empty journal, initial inventory and k=0. Export selectable JSON containing the accepted unique sorted journal, playhead and computed state. Export is not a second delivered file.
### 3. Built-in example and visible evidence
Include this exact example as the initial loaded journal, paused at k=0:
[
{"id":"a","seq":1,"type":"reserve","ref":"r1","from":"A","to":"B","qty":3},
{"id":"b","seq":2,"type":"reserve","ref":"r2","from":"A","to":"C","qty":6},
{"id":"c","seq":3,"type":"commit","ref":"r1"},
{"id":"d","seq":4,"type":"cancel","ref":"r1"},
{"id":"e","seq":5,"type":"reserve","ref":"r2","from":"B","to":"C","qty":4},
{"id":"f","seq":6,"type":"cancel","ref":"r2"}
]
Display the inventory sum and a numerical reconciliation of physical, held and available quantities. These must be calculated from state, not hard-coded “OK” labels. Unknown-ref, insufficient-stock and terminal-ref rejections must be distinguishable.
### 4. Readable instrument design
Make the harbor an expressive code-drawn illustration, with the ledger and counters as legible as the animation. No color-only statuses. Provide in-app instructions, visible focus, keyboard access to every operation and responsive stacking at 390px width. Reduced motion disables transfer animation without altering timing or state. Respect light/dark preference. Empty journals and rejected imports must leave a usable interface.
## Output constraints
Return exactly one raw index.html document, with inline CSS/JavaScript and no surrounding prose or Markdown fences. No libraries, external assets, fonts, imports, network requests, build step or server. Native HTML/SVG/Canvas only; file:// must work; lang="en" is required. Do not use wall-clock time as a source of ledger truth. No placeholder controls, fabricated audit results or separate verification-state implementation.
## Loop / validation rule
Do not stop drafting until all features are implemented and source-reviewed. Use no tools; make no claim of executed checks. A reviewer will:
1. Open offline and inspect all starting values and instructions. Use the complete UI by keyboard at desktop/mobile widths, reduced motion and both color schemes.
2. Step the example: after a, physical=(8,4,0), held=(3,0,0), available=(5,4,0); b rejects; c yields physical=(5,7,0) and no holds; d rejects; e holds 4 at B; f cancels it. Final physical=(5,7,0), held=(0,0,0), with two rejected events.
3. Scrub end→0→3→end. At k=3, r1 is committed, r2 does not exist, and only b is rejected. Compare state/export with a fresh replay. Play, pause, resize and repeatedly seek without changing results.
4. Import the example in reverse array order with an identical duplicate of c, including reordered object keys. It must produce the same six unique events and state. Change the duplicate's ref instead; the import must fail and preserve the entire previously accepted view.
5. Import two reserves with seq=1, IDs a and z, different refs, both from A, quantities 6 and 3 respectively. Regardless of array order, a succeeds and z rejects. Commit a's ref afterward; the reserved six units must move correctly.
6. Load example, seek k=2, Branch here, then append {"id":"g","seq":3,"type":"cancel","ref":"r1"}. Final physical=(8,4,0), no holds; only b rejects. The discarded c,d,e,f cannot appear in the branch or its export.
7. Reject malformed JSON, wrong types, extra fields, oversized arrays, conflicting duplicate IDs and an invalid append without partial mutation. Try unknown and terminal refs as schema-valid events; they must remain in the journal as semantic rejections. Reset must restore exactly the empty initial state.
If source review exposes any failure, fix it and mentally re-run every check before returning the artifact. Browser failures found later count against this single attempt; there is no repair conversation.