Skip to content

Commit 8117c4d

Browse files
committed
Add native terminfo reader; reconstruct tigetstr/tigetnum/tigetflag
The wisest next move: a real terminfo substrate, so the crate's hardcoded xterm byte sequences are derived from the compiled terminfo entry instead of asserted. src/terminfo/: - A dependency-free reader for the compiled terminfo binary format (legacy i16 and 32-bit-number magics; names, booleans, even-offset pad, numbers, string table). Pure, never panics, #![forbid(unsafe_code)] preserved. - tigetflag/tigetnum/tigetstr with ncurses' exact return semantics (present / absent / cancelled / not-a-capability). - caps.rs: canonical capability-name tables CODEGENNED by `cargo xtask gen` from docs-src/models/terminfo-caps.json (extracted from ncurses' own boolnames/numnames/strnames). The freshness gate now covers codegen too. Evidence (multiple oracles + fixture): - tests/terminfo/xterm: committed xterm entry (sha 83fc9790) for hermetic tests. - NCURSES.TERMINFO.LOOKUP: crate tiget* vs ncurses' own tiget* over ALL 497 standard caps (44 bool + 39 num + 414 str), TERMINFO pinned to the fixture, admitted_match with zero diffs. - Unit tests prove the seed caps (clear/el/ed/el1/cuu1/home/bel/smcup/rmcup/op/ sgr0) equal the parsed terminfo strings. Compass (clang C inventory vs syn Rust inventory) used before/during/after; the syn walker now also indexes inherent-impl methods so curated counterparts can target Terminfo::tiget* and be verified. Result: terminfo group 0 -> 18.2% (6 full). Overall 43/481 (8.9%): 10 full, 9 partial, 15 scaffold, 2 divergent, 6 deferred, 1 n/a. docs/terminfo-atlas.md records method and non-claims (extended caps, setupterm, tparm/tputs, mvcur).
1 parent 6f692ed commit 8117c4d

17 files changed

Lines changed: 1292 additions & 26 deletions

File tree

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ clang C inventory joined with the `syn`-extracted Rust inventory and a curated,
3636
validated counterpart map). `cargo xtask check` is the freshness gate -- it
3737
re-renders in memory and fails if a doc drifted, a counterpart points at a
3838
missing Rust symbol, or a cited court has no receipt. CI and the optional
39-
`.githooks/pre-commit` run it on every change. Measured coverage today: **37 /
40-
481 functions (7.7%)** resolved (4 full, 9 partial, 15 scaffold, 2 divergent, 6
41-
deferred, 1 n/a). Three groups are fully resolved: **Bell** (`curs_beep`) is
39+
`.githooks/pre-commit` run it on every change. Measured coverage today: **43 /
40+
481 functions (8.9%)** resolved (10 full, 9 partial, 15 scaffold, 2 divergent, 6
41+
deferred, 1 n/a), including the terminfo lookup primitives
42+
`tigetflag`/`tigetnum`/`tigetstr` (full, oracle-matched over the whole xterm
43+
entry). Three groups are fully resolved: **Bell** (`curs_beep`) is
4244
reconstructed to full byte parity; **Erase** (`curs_clear`) is complete (6
4345
byte producers oracle-pinned, 3 deferred functions *proven* to emit no immediate
4446
bytes, `is_cleared` n/a); and **Overlap** (`curs_overlay`: `overlay`,
@@ -47,6 +49,20 @@ copy is in-memory, shown by a later refresh). "Resolved" covers both
4749
reconstructed byte producers and these evidence-backed non-output
4850
classifications -- it is not a claim of full API equivalence.
4951

52+
## Terminfo substrate
53+
54+
`src/terminfo/` is a native, dependency-free reader for the compiled terminfo
55+
binary format. It parses the admitted xterm entry and reconstructs the lookup
56+
primitives `tigetflag`/`tigetnum`/`tigetstr` with ncurses' exact return
57+
semantics. The capability-name tables (`src/terminfo/caps.rs`) are generated from
58+
ncurses' own ordered name arrays and freshness-gated. This is the first major
59+
credibility step: the hardcoded byte sequences (`clear`, `el`, `smcup`, `op`, ...)
60+
are now *derived* from the parsed entry, not merely asserted. The reconstruction
61+
is checked against ncurses' own lookup over **all 497** standard capabilities of
62+
the xterm entry (`NCURSES.TERMINFO.LOOKUP`, `admitted_match`, zero diffs). See
63+
[`docs/terminfo-atlas.md`](docs/terminfo-atlas.md) for the method and non-claims
64+
(extended caps, `setupterm`, `tparm`/`tputs`, and `mvcur` are out of scope).
65+
5066
## Oracle receipts
5167

5268
Byte claims are backed by receipts under [`reports/oracle/`](reports/oracle/),

docs-src/models/parity.model.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@
413413
"beep_sp": {"rust": "bell::beep", "status": "full", "courts": ["NCURSES.CAP.BEL"], "note": "Byte-identical to beep; the _sp screen selection is not modeled but emits the same bel byte."},
414414
"flash": {"rust": "bell::flash", "status": "full", "courts": ["NCURSES.CAP.FLASH"], "note": "Emits the flash capability; the $<100/> delay is a real-time pause, not bytes, so the stream is the DECSCNM on/off pair."},
415415
"flash_sp": {"rust": "bell::flash", "status": "full", "courts": ["NCURSES.CAP.FLASH"], "note": "Byte-identical to flash; the _sp screen selection is not modeled."},
416+
"tigetstr": {"rust": "terminfo::Terminfo::tigetstr", "status": "full", "courts": ["NCURSES.TERMINFO.LOOKUP"], "note": "Reconstructed from a native compiled-terminfo reader; matches ncurses tigetstr over every standard string cap of the xterm entry (return semantics: present/absent/not-a-string)."},
417+
"tigetstr_sp": {"rust": "terminfo::Terminfo::tigetstr", "status": "full", "courts": ["NCURSES.TERMINFO.LOOKUP"], "note": "Same lookup; the _sp screen-pointer global state is not modeled but the returned value is identical."},
418+
"tigetnum": {"rust": "terminfo::Terminfo::tigetnum", "status": "full", "courts": ["NCURSES.TERMINFO.LOOKUP"], "note": "Reconstructed terminfo numeric lookup; matches ncurses tigetnum over every standard numeric cap (value / -1 absent / -2 not-a-number)."},
419+
"tigetnum_sp": {"rust": "terminfo::Terminfo::tigetnum", "status": "full", "courts": ["NCURSES.TERMINFO.LOOKUP"], "note": "Same lookup; _sp variant not modeled, value identical."},
420+
"tigetflag": {"rust": "terminfo::Terminfo::tigetflag", "status": "full", "courts": ["NCURSES.TERMINFO.LOOKUP"], "note": "Reconstructed terminfo boolean lookup; matches ncurses tigetflag over every standard boolean cap (1 / 0 / -1 not-a-boolean)."},
421+
"tigetflag_sp": {"rust": "terminfo::Terminfo::tigetflag", "status": "full", "courts": ["NCURSES.TERMINFO.LOOKUP"], "note": "Same lookup; _sp variant not modeled, value identical."},
416422
"mvcur": {"rust": "cursor::mvcur", "status": "partial", "courts": ["NCURSES.CAP.CUP", "NCURSES.CAP.CUU1", "NCURSES.CAP.HOME"], "note": "Reconstructs ncurses relative_move strategy enumeration; the move primitives (CUP/cuu1/home) are byte-pinned to the terminfo oracle. The full capability-cost tie-break is not yet independently oracle-pinned beyond the unit fixtures."},
417423
"mvcur_sp": {"rust": "cursor::mvcur", "status": "scaffold", "note": "Same byte producer; the screen-pointer (_sp) reentrant variant is not modeled."},
418424
"clear": {"rust": "screen::clear", "status": "partial", "courts": ["NCURSES.CAP.CLEAR"], "note": "Emits the clear_screen capability bytes; not the full clear() window-state semantics."},

0 commit comments

Comments
 (0)