# PageLens examples

Generate deterministic files:

~~~bash
python3 scripts/generate_fixtures.py
~~~

Inspect the regular SQLite database:

~~~bash
moon run --target native cmd/pagelens -- inspect fixtures/generated/sample.db
~~~

Expected facts include a 512-byte page size, eight physical pages, a
table-leaf schema root, and no header diagnostics.

Inspect the WAL:

~~~bash
moon run --target native cmd/pagelens -- wal fixtures/generated/snapshot.db-wal
~~~

The generated WAL contains five valid frames in two committed transactions.

Compare the committed snapshot:

~~~bash
moon run --target native cmd/pagelens -- snapshot fixtures/generated/snapshot.db
~~~

The report identifies three changed pages and the newest source frame for each.

Run consistency checking and JSON output:

~~~bash
moon run --target native cmd/pagelens -- check fixtures/generated/sample.db
moon run --target native cmd/pagelens -- check fixtures/generated/sample.db --json
~~~

The regular fixture produces PASS with zero ERROR findings. The JSON form is a
single value suitable for redirection to another tool.

Try damaged inputs:

~~~bash
moon run --target native cmd/pagelens -- check fixtures/generated/invalid-magic.db
moon run --target native cmd/pagelens -- check fixtures/generated/truncated.db
~~~

These commands intentionally return a nonzero status and a DATABASE_INVALID
diagnostic.
