Haunt
ghostrow haunt generates edge-case rows inside your schema's limits and, with --tests, reports which rows broke which tests. Cases, options, supported test runners and the report format.
ghostrow haunt (Pro and Max) generates the values real users eventually send: the longest string a column accepts, Unicode, a leap day, zero, a parent with no children. Every case stays inside your schema's constraints, so the database accepts it and a failing test points at application code.
ghostrow haunt --schema schema.sql --tests "npm test"
What it does
- Builds a small valid base dataset (30 rows for each table that no other table references) so every case has real parents.
- Builds edge cases from each column's type, length limit and
CHECKconstraints. A case that would break a constraint, a unique key or a rule is dropped. - Without
--tests, delivers the rows and stops. - With
--tests, runs your test command once on the base data (the baseline) and once with every case. Tests that fail only in the second run are new failures. Ghostrow then re-runs the cases in groups, and halves any group that still fails, until each failing test points at the cases of one column, or until its budget of 40 narrowing runs is spent.
Edge cases
Every case has an id (H001, H002, ...), a table, a column, a kind and a description. Primary keys, foreign keys, generated columns and columns computed from others are not changed.
| Column type | Kinds |
|---|---|
| Text | max-length, unicode, emoji, rtl, quotes, whitespace, newline, empty |
| Email (text column understood as email) | email-plus, email-case, email-apostrophe, email-long |
| Integer | zero, int-max, negative, int-min (the last two only for signed columns) |
| Decimal and floating point | zero, smallest-unit, max-precision, negative |
| Date | leap-day, year-end, epoch, y2038, far-past |
| Time | midnight, last-second |
| Timestamp | leap-day, dst-gap, dst-overlap, year-end, epoch, y2038, and tz-east for time-zone columns |
| Enum | rare-enum (the last allowed value) |
| Whole row | all-nulls (every optional column empty), no-children (a parent with none), many-children (one parent with 50 children) |
For text the cases use the column's limit: max-length fills it exactly, and the other values are cut to fit.
--cases <n> caps the number of cases (default 300). Cases are interleaved across tables, so a small cap still touches every table. A five-table shop schema (customers, orders and order lines) gave 112 cases.
Where the rows go
- With
--schema, Ghostrow writes CSV files to./ghostrow-haunt/. After a--testsrun the folder is removed again. - With
--db, the rows are inserted. After a--testsrun Ghostrow deletes exactly those rows by primary key, children first. Without--teststhey stay. The connection is closed while your tests run. Use a test database.
Your test command gets two environment variables:
| Variable | Value |
|---|---|
GHOSTROW_HAUNT_DIR | The folder with the CSV files (--schema runs) |
GHOSTROW_HAUNT_CASES | The path of the case list, <report>.cases.json |
It also gets CI=true (unless already set) and NO_COLOR=1. The command runs through the shell, with a 20-minute limit.
Test runners
Ghostrow reads failing test names from the output of Vitest, Jest, Mocha, Node's test runner (not ok lines), pytest, Go (--- FAIL:), RSpec, PHPUnit, Cargo, Maven Surefire and Gradle, from JUnit XML printed in the output, and from lines such as FAIL path/x.spec.rb:12. If no names are found but the command exits non-zero, the whole command counts as one failing test, named test command (exit N).
Report
--report <file> (default haunt-report.json) is written on every run. The case list goes next to it as haunt-report.cases.json.
{
"engine": "gr-schema-1/1.0",
"seed": 0,
"source": "shop.sql",
"tests": "node check-names.cjs",
"summary": { "cases": 112, "tables": 5, "runs": 42, "failingTests": 1 },
"failures": [
{
"test": "customer names are plain ASCII",
"cases": ["H008", "H012", "H016", "..."],
"columns": ["customers.first_name", "customers.phone", "customers.last_name", "customers.nic"]
}
],
"runs": [{ "label": "baseline", "cases": 0, "exitCode": 0, "failed": [] }],
"cases": [{ "id": "H001", "table": "products", "column": "sku", "kind": "max-length", "description": "exactly 32 characters (the column maximum)", "value": "...", "rows": 1 }]
}
That report came from a throwaway test that fails when customers.csv has non-ASCII text. Lists are shortened here. The terminal output:
ghostrow haunt · shop.sql · 112 edge cases across 5 tables · Max
max-length 9 · int-max 2 · unicode 9 · emoji 9 · rtl 9 · quotes 9 · whitespace 9 · newline 9 · empty 8 · leap-day 4 · …
1 test failed only with edge cases:
✗ customer names are plain ASCII
broken by H008, H012, H016, H092, H093, H094, … e.g. customers.first_name: accents, CJK and Greek characters
report: haunt-report.json
ghostrow: 1 test failed with edge-case data. See haunt-report.json.
Exit codes
| Code | Meaning |
|---|---|
0 | Cases delivered, or --tests found no new failures |
3 | --tests found tests that fail only with edge cases |
4 | The machine does not run a Pro or Max license |
1 | Bad input, for example no schema, or no case fits the schema |
Tests that already fail on the baseline run are not counted. Use --seed to change which base rows the cases are built from.