Skip to content

link-cliref: KNOWN_ALIAS_SEGMENTS is unscoped — poe/qos are real menu segments, producing 3 wrong schema links #136

Description

@mobileskyfi

Summary

KNOWN_ALIAS_SEGMENTS in src/link-cliref.ts is a global, unscoped
allowlist: a segment on the list may be dropped from any source_path. Five of
its nineteen entries — acl, controller, poe, qos, route — are real
CLI menu segments
published elsewhere in the very same CLI Reference source.

Result: three cliref_entry_schema_links rows link a published entry to a
different command. The failure is silent, because the alias branch only runs
when the exact path is missing from schema_nodes — which is precisely the
hardware-gated class where nobody has a device to notice.

The bad links

Simulating the current algorithm (exact → single-drop alias → manual-only)
against four typed inspect trees (restraml, extra-packages, x86 + arm64,
7.10.2 → 7.24rc2), 23 alias links fire. Three are wrong:

Published entry Linked to Should be
interface/ethernet/poe/monitor /interface/ethernet/monitor manual-only
interface/ethernet/switch/qos/port /interface/ethernet/switch/port manual-only
interface/ethernet/switch/qos/port/reset-counters /interface/ethernet/switch/port/reset-counters manual-only

These are demonstrably different commands, provable from the publication alone —
their field sets are disjoint:

interface/ethernet/poe/monitor   name poe-out poe-voltage poe-out-status poe-out-voltage
                                 poe-out-current poe-out-power poe-out-power-pair
                                 power-cycle-host-alive power-cycle-after

interface/ethernet/monitor       name status auto-negotiation rate full-duplex
                                 tx-flow-control rx-flow-control fec supported
                                 sfp-* (35 more) phy-regs eeprom ...

interface/ethernet/switch/qos/port publishes ~140 fields (per-queue caps, PFC
thresholds); interface/ethernet/switch/port publishes 15 (vlan-mode,
mirror-*, rates). No overlap beyond name/switch.

Live confirmation that these are gated, not phantom: on CHR 7.23.3 stable and
7.24rc3 testing, /interface/ethernet/poe and /interface/ethernet/switch/qos
are absent over /console/inspect, REST and the native API — consistent with
their published gates (syscap: (poe or poe-in), syscap: multiswitch /
crs_prestera). They are real menus on hardware rosetta has never inspected.

Root cause and fix

The allowlist encodes "this word is an internal module name" as a global
property. It is not global — it is positional. A segment that is itself a
published entry at that point in the path is a real menu, not a doc-internal
module.

Derivable rule, no device needed: never drop segment S at position i
when the prefix ending at S is itself a cliref_entries.source_path.

Applied to the current list:

Segment Prefix published as Verdict
poe interface/ethernet/poe = Directory real menu — reject the drop
qos interface/ethernet/switch/qos = Directory real menu — reject the drop
acl interface/ethernet/switch/acl = Directory real menu — reject the drop
controller zerotier/controller = Directory real menu — reject the drop
route ip/route, routing/route = Directory real menu — reject the drop
cfg chancfg dpathcfg ifaceactual ratescfg remoteap seccfg sta rule easymesh serial-interface ddns ifaces queues internal module — safe

acl, controller and route currently produce correct links by luck (they
fire only in caps-man/… and routing/route/rule, different subtrees), so the
rule costs three links and buys a guarantee.

Suggested implementation:

  1. Add the prefix-scoping check to the alias branch.
  2. Add a field-set-overlap sanity check as a second gate: refuse an alias
    link whose published fields are disjoint from the target's inspect args. This
    would have caught all three independently.
  3. Keep the segment allowlist — it still stops arbitrary normalization; the two
    new checks are additive, and the cli-reference-links.tsv drift gate makes
    the −3 visible for review.

Why this is worth fixing even though it is only three rows

interface/ethernet/poe/monitor is a command real users run on real hardware.
Anything reading cliref_entry_schema_linksrouteros_explain_command,
the command-prose join, the export dataset — currently attributes PoE monitoring
fields to the SFP/ethernet monitor command. Wrong provenance on hardware-only
surfaces is exactly the class nobody can catch from a CHR.

src/extract-cliref.ts itself is not implicated: source_path is the heading
verbatim, it is honestly named source, and an independent re-implementation
reproduced its output byte-for-byte. The defect is confined to the crosswalk.

Found while evaluating CLI Reference as offline evidence for centrs explain:
tikoci/centrs#228 (comment) (§7).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions