Context
The parser doesn't gracefully fail on certain malformed inputs — it loops or blocks instead of emitting a diagnostic and exiting. Two independent observations point at the same underlying issue:
1. Diagnostic snapshot harness (issue #9)
While seeding the diagnostic test corpus at `tests/diagnostics/cases/`, this input was found to hang the parser indefinitely:
fn 123 invalid() {}The case had to be dropped from the corpus, and a 30 s per-case wall-clock timeout was added to the harness so future hangs fail loudly in CI rather than wedging the runner. See `tests/diagnostics/harness.zig` and the `tests/diagnostics/README.md` skipped-categories note.
2. home-os kernel audit (2026-05-01)
Auditing 404 home-os kernel modules with `home ast`, 110 out of 166 parse-failing modules could not be classified by error message because `home ast` hangs after surfacing the first parse error rather than exiting. The audit had to fall back to a 15 s wall-clock timeout per file and bucket those modules as "parse failure, error message unavailable".
This makes the parser-failure bucket essentially un-triagable without additional work — it took ~1 s per OK file and 15 s per failing file, throttling the audit's iteration speed significantly.
Symptoms
- `home ast <bad-file>` and `home check <bad-file>` block past any reasonable timeout
- No diagnostic emitted on stderr before the hang
- Process appears to be doing work (not deadlocked) — likely an infinite loop in the parser's error recovery path
Why this matters
- Tooling that walks a corpus (snapshot harnesses, audits, IDE features, fuzzers) cannot rely on the compiler terminating
- The diagnostic snapshot harness can't include genuinely malformed cases without per-case timeouts
- Future fuzzing work (issue #10) will need every fuzzer-found input wrapped in a timeout, which adds noise to crash classification
Proposal
- Reproduce both inputs (`fn 123 invalid() {}` and a known-hanging kernel module) — start with the simpler one
- Bisect the parser path to find the loop. Likely candidates: error-recovery loop with no progress guard, infinite token-reuse, retry-on-failure without advancing the cursor
- Add a progress-guard invariant: every iteration of the recovery loop must consume at least one token, otherwise bail
- Once fixed, re-run the home-os audit with `home ast`'s 15 s timeout removed and re-classify the previously-timed-out modules; expect a much sharper picture
- Once fixed, attempt to add the dropped `fn 123 invalid()` case back to the diagnostic corpus
Reproduction
```bash cd /path/to/home echo 'fn 123 invalid() {}' > /tmp/hang.home ./zig-out/bin/home-debug ast /tmp/hang.home # hangs ```
For the kernel-module case, see `~/Desktop/home-os-kernel-audit-2026-05-01.tsv` rows where `parse_status=FAIL` and `first_error` is empty.