Skip to content

[M11] Crash proof tiles that run real recovery in the browser (M11.7) - #96

Merged
ssoufii merged 1 commit into
mainfrom
auto/m11.7-crash-proof-tiles
Nov 17, 2026
Merged

ssoufii merged 1 commit into
mainfrom
auto/m11.7-crash-proof-tiles

Conversation

@ssoufii

@ssoufii ssoufii commented Nov 17, 2026

Copy link
Copy Markdown
Owner

The tile board from section 6: six failures, each one run for real on a copy of the visitor's database inside the worker.

The arrangement that matters

The damage is not demo code. src/ledgerlog/faults.py holds it, tests/test_faults.py drives the same functions to assert the same recoveries, and session.py does nothing but name the directory. Two implementations of "cut the log in half" would be two different claims, and the one on the page would be the one nobody checks. There is one, and both the page and the suite run it.

Each scenario copies the database first. A visitor stages these on the database they have been typing into, so "show me what a crash would do" must not be a way to lose it. A pytest fingerprints every file before and after each of the six scenarios and asserts nothing moved, and a Playwright test asserts the same thing from the page's side.

Every number on a tile is the engine's: LedgerLog.recovery for the log and LedgerLog.discovery for the tables. The page does not compare files or decide what counts as lost.

Acceptance criteria

  • One tile per scenario: torn write, flipped byte, crash mid flush, crash mid compaction, missing footer, expired record, on the board section 6 describes (four across, 8px gaps, about 3:2, heading tile twice as wide in the accent).
  • Each scenario damages a copy in the worker, opens a fresh LedgerLog on it and reports keys before, keys after recovery and what was dropped, from the engine's own reports; the visitor's database is untouched.
  • The scenario code is Python with pytest tests in tests/, each tile names the pytest covering the same failure, and a pytest checks every name in crash-scenarios.json exists.
  • Playwright: after three puts, "torn write" shows recovery keeping the complete records and dropping the torn one.

What ran, and what passed

  • pytest: 1304 passed (40 new). ruff check src tests and ruff format --check src tests: clean.
  • In web/: npm ci, lint, typecheck, build: clean.
  • npx playwright test: 102 passed across both projects. Playwright ran locally, not only in CI.

The six scenarios produce six genuinely different results, which is what makes the board worth having:

tile dropped what the engine said
torn write the torn record only record claims a 25 byte payload but only 8 bytes remain
flipped byte the record the byte landed in a checksum mismatch
crash mid flush nothing SSTable footer magic mismatch ... the footer was never fully written
crash mid compaction nothing both sources loaded again
missing footer nothing SSTable footer checksum mismatch
expired record the expired key nothing rejected: no file was damaged

I drove the board by hand at 1440 and 390 and read the results.

Two findings from reviewing the screenshots

  1. Tiles clipped their own text at 390. overflow: hidden on a grid item zeroes its automatic minimum size, so the 3:2 ratio stopped being a floor and became a cap. Removing it lets the ratio behave as section 6 intends: a shape until there is a result, then whatever the result needs.
  2. The result rows were unreadable at 390, where a fixed label column left the value about one character wide. A container query on the tile stacks the label above the value below 260px.

Decisions taken without asking

  • faults.py is a new module in src/ledgerlog/, which CLAUDE.md's target layout does not list. The criterion asks for Python scenario code with pytest tests that also runs in Pyodide, and the package is the only place that is both importable by pytest and copied into the browser by sync-assets. Nothing in engine.py imports it and it is on no read or write path.
  • "missing footer" is a footer that no longer verifies. The criterion lists it alongside "crash mid flush (SSTable without footer)", so the two have to be different damage, and the engine's other real footer failure is a committed file whose footer fails its own checksum. The engine files both under the same status and distinguishes them in the reason, which is the line the tile shows, so the two tiles read differently.
  • Tile titles use --step-lead (20 to 26px), not the 28 to 32px section 6 names, because 28 to 32px would be a sixth type size and section 4 allows five.
  • The expiry scenario waits out a real 50ms deadline rather than writing a deadline in the past. An expiry is set from the engine's clock at the moment of the write, so letting it arrive is the only version of this the engine would really see.

Closes #85


Generated by Claude Code

…tabase

Story M11.7. Six tiles, one per failure the test suite already covers:
torn write, flipped byte, crash mid flush, crash mid compaction, a footer
that no longer verifies, and an expired record. Pressing one copies the
database inside the worker, damages the copy that way, opens an engine on
it and reports the keys before, the keys after and what recovery dropped,
in the engine's own words from its recovery and discovery reports.

The damage is ledgerlog.faults, not demo code. tests/test_faults.py drives
the same functions to assert the same recoveries, so the demonstration on
the page and the assertion in the suite cannot drift: they are one
implementation. Every scenario is also checked to leave the directory it
was pointed at byte for byte unchanged, because a visitor stages these on
the database they have been typing into.

Each tile names the pytest that covers its failure, and a pytest checks
that every name a tile gives is a test that exists.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWNkuNh5Bysnfo2KrxL9Sp
@ssoufii
ssoufii merged commit 41713c4 into main Nov 17, 2026
9 checks passed
@ssoufii
ssoufii deleted the auto/m11.7-crash-proof-tiles branch November 17, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[M11] Crash proof tiles that run real recovery in the browser (M11.7)

2 participants