Skip to content

markers.rs registry is not the single declaration point: 12 consts outside MARKERS, boundaries/user_reachable never read, contains_word_marker_bytes invariant unfalsifiable #728

Closed

Description

@caomengxuan666

Summary

Four gaps between docs/pitfall-taxonomy-and-governance.md §3.1 (markers declared once, each with an encode/decode pair, a consumer-boundary list, user_reachable, and a golden assertion) and the code in src/executor/markers.rs.

Counts are from a static pass over origin/master (d24ee0f0); items marked (verified) I read directly.


1. It is not the single declaration point (verified for the counters)

  • 12 carrier-shaped consts are declared in markers.rs but absent from the MARKERS table (e.g. ANSI_C_IFS_GUARD U+E401, LITERAL_CHAR_ESCAPE U+E400, FAILED_SUBSCRIPT_SENTINEL, plus the *_STR variants). Supporting evidence: code: 0x0* matches zero table rows, so no MARKERS entry has a codepoint below U+0010.
  • 16 business files re-declare marker consts instead of importing them.
  • 3 named sentinels (CASE_PATTERN_*) live in parser/support.rs:297-304.
  • §3.1's "adjacent encode/decode pair" is literally true for ~6 helpers; the other 43 carriers are handled by monolithic match arms.

2. boundaries and user_reachable are never read

MarkerInfo carries both fields and the table fills them, but only m.code is accessed anywhere in the tree. user_reachable — the flag that is supposed to guarantee a user-typed byte gets pair-encoded at entry — is not machine-checked. So §3.1's user-reachability rule is currently a comment, not a gate.

3. contains_word_marker_bytes states a stronger invariant than it implements (verified)

src/executor/markers.rs:399-409:

"the C0 range 0x11..=0x1f hosting every CTLESC/CTLNUL-port marker (see the constants above) … a false negative is impossible because no marker can be encoded without one of these bytes."

The predicate is (0x11..=0x1f).contains(&byte) || byte == 0xEE. But the same file declares markers below 0x11:

markers.rs:142  pub(crate) const PROMPT_IGNORE_START: char = '\u{01}';
markers.rs:145  pub(crate) const PROMPT_IGNORE_END:   char = '\u{02}';

Three callers trust this predicate: command_prepare.rs:12, command_prepare.rs:1216, expand_word.rs:63 (verified by grep).

Counter-argument I cannot settle from outside, and it matters: the file distinguishes domains deliberately — see DIR_STACK_FIELD_SEP (line 411): "Shares the DATA_DOLLAR byte but lives in the env-serialization domain, not word text — do not decode it as a dollar." PROMPT_IGNORE_* may be prompt-domain markers that are legitimately outside this predicate's scope. If that is the intent, the doc should say "every word-text marker", and the scope should be enforced — as written, nothing tells a reader which markers the predicate is supposed to cover, so "false negative is impossible" is unfalsifiable.

4. Raw-literal blind spots

  • 322 raw C0 carrier escapes across 61 files; 102 raw PUA-marker escapes across 9 files (56 in assignment_expansion.rs, including 17 trim_matches('\u{E302}') sites using the literal instead of the const). §3.1's "business code must never write a raw '\x1f'" rule is not enforced.
  • Per-carrier spread matches the governor doc's own hotspot claim: DATA_DOLLAR (\x1f) in 53 files, STORAGE_WORD_PREFIX (\x1d) in 39 (doc says "50+ / 39"), i.e. the structural cause of M1 is still present.

Suggested direction

Not a rewrite. The cheap enforceable step is to make the registry the source of truth for a test rather than for prose: generate the audited set from MARKERS, and fail when (a) a marker const is declared outside it, (b) a const's codepoint falls outside its declared boundaries scope, or (c) a raw carrier literal appears in a file that imports markers::*.

§3.1 already proved this pattern works for the marker declarations; these four gaps are where it stops.

Activity

  1. added
    enhancement
    P2-medium
    area:carrier
    on Oct 17, 2026
  2. arookieofc commented on Oct 19, 2026

    @arookieofc
    Member

    PR #821 is green on all lanes (commit 8aae39a on fix/729-728). The red exp.snap turned out to be a regression in the #729 pattern rewrite, not the registry: flatten_pattern_to_byte_chars() mapped the literal-backslash marker (0x18) to byte 0x18 instead of the backslash byte, so backslash-carrying patterns silently stopped matching. Fixed with the marker arm restored plus a unit test; the registry and MARKERS table are untouched, and no exp.snap update was needed (committed bytes already match WSL GNU bash 5.3.0). Local upstream_suite_slice_snapshots passes 13/13. Details on #729.

  3. added a commit that references this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumarea:carrierenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions