# NOT INDEXED is not an independent scan for this WITHOUT ROWID test

This file describes the recorded evidence, not its deployment status.
Recorded: 2026-10-22. Scope: SQLite 3.45.1 and 3.54.1 on one Linux host.

## Finding

In deliberately stale-comparator WITHOUT ROWID fixtures, the normal equality query
and the same query with NOT INDEXED both searched the primary-key tree and missed
an existing row. Agreement between those two answers was therefore not an
independent check. A verified full traversal and an explicit expected set exposed
the miss. Targeted REINDEX repaired every tested changed-comparator fixture,
including WITHOUT ROWID. This is not a newly discovered SQLite defect.

Example: seven rows, 512-byte pages, comparator changed from ascending to
descending ASCII order under the same APP_ORDER name, parameter "k0000":

| Layout and query | Observed access | Complete returned rows |
| --- | --- | --- |
| Ordinary rowid, normal | Index search | [] |
| Ordinary rowid, NOT INDEXED | Table scan | [["k0000", 0]] |
| WITHOUT ROWID, normal | Primary-key search | [] |
| WITHOUT ROWID, NOT INDEXED | Primary-key search | [] |
| WITHOUT ROWID, unary +k | Table scan | [["k0000", 0]] |

The two builds agree on these outcomes. These are constructed cases, not sampled
incidents or an estimate of failure frequency.

## Relation to existing Hesela knowledge

The existing [runtime-dependency analysis](https://hesela.com/analyses/sqlite-index-runtime-dependencies/)
already establishes that changing a collation can stale an index, that quick_check
can pass, and that rebuilding can fail when new equality rules collapse unique
keys. Its rowid-table scan controls remain valid.

This supplement adds a narrower, previously uncovered validation boundary:
do not generalize its NOT INDEXED control to a different table layout.
The existing [collation record](https://hesela.dev/terms/sqlite-collation/) should
gain the version-scoped caveat, not be replaced with a duplicate concept.

## Method and evidence

Each build executes eight fresh schemas: two layouts, two page sizes (512 and
4096 bytes), and two populations (7 and 257 rows). Each schema produces three
closed, independently reopened states: original comparator, reversed comparator
on a byte-identical copy, and a separate copy rebuilt using REINDEX main.sample.
The equality relation stays unchanged; only order is reversed.

Each of 24 states per build runs five bound TEXT probes using three SQL forms:
first, second, middle, last and absent key. That is 360 point lookups per build,
plus complete inventories, query plans, quick checks and full integrity checks.
The expected set is specified outside the database. Source rows are k0000 through
kNNNN with their integer ordinal n. Every full inventory is checked exactly.

All eight changed states per build expose a normal-query mismatch. All four
changed WITHOUT ROWID states per build also expose identical wrong normal and
NOT INDEXED answers. Quick checks pass in every recorded state; full checks reject
all changed states and accept originals and rebuilt copies. Every read-only
observation preserves the complete file hash. Rebuilding succeeds and all tested
point answers then match the explicit expected set.

Two additional in-memory controls per build guard the proposed scan technique:
the stored TEXT key "5" matches integer-bound 5 for k=?, but not for +k=?.
Text-bound "5" matches both. This supplies 12 extra lookups per build and shows
why unary plus is not a semantics-preserving rewrite for arbitrary data.

The complete packet contains 48 retained database states and 720 point lookups
across two builds, plus 24 affinity lookups. It is the same designed matrix twice,
not 48 independent incidents. Original files never become input to a modifying
operation. Rebuilt copies deliberately change bytes.

## Reproduce

Python 3.12 standard library only. Work inside this directory:

```sh
python3 -B observe.py --output my-capture
python3 -B observe.py --verify my-capture --replay
HESELA_CAPTURE=my-capture python3 -B -m unittest -v test_observe
```

Use a new output directory. Existing paths are rejected. No production database
path is accepted. A failed run leaves its private evidence directory for diagnosis;
it is not silently overwritten.

Captured environments include SQLite source IDs, compile options, mapped library
hashes, Python version and kernel identity. capture-system uses the distro's
3.45.1 library, whose source ID ends in alt1. capture-3.54.1 reuses an already
available library without installing or modifying it. These are two native builds
on one host, not cross-platform or independent-laboratory replications.

For exact replay of a recorded capture, select its matching library. EXPLAIN
output and database bytes can legitimately differ across builds. The shared-host
alternate library directory is recorded in capture-3.54.1/results.json; a different machine
must provide its own corresponding runtime, not assume that private path exists.

## Verification and limitations

Twenty tests ran under both libraries with normal Python and Python -O: 80 passed
test executions. Each run reopens retained fixtures, regenerates the complete
matrix and checks every observed field except generation time, plus every database
byte. Negative controls reject missing or extra files, corrupted bytes, symlinks,
missing cases, wrong answers, missing plans, altered bindings and mismatched hashes.

Read validation.json for full commands and results. sources.json preserves nine
primary-source URL/hash identities; capture_sources.py can produce a new inventory
only when no sources.json exists. Upstream documentation is mutable; hashes record
what was retrieved, not a promise that later downloads will match.

No WAL, concurrency, power loss, arbitrary corruption, ICU upgrade, performance,
sampling uncertainty, or recovery of unknown real-world damage is tested. No
claim is made that REINDEX repairs every collation migration. New equality
collisions remain a separate application decision. Do not run recovery commands
against an archival original merely to silence a diagnostic.
