Skip to content

prose-mention rule matches the SUFFIX of multi-segment ids: 'CM-TR-001' warns about 'TR-001' (false trace suggested) and is never itself checked #972

Description

@avrabe

Found while working in synth (RQ-68-ORACLEABI, pulseengine/synth#1277), rivet 0.32.0; the regex is unchanged on main at v0.37.0.

What happens

rivet-core/src/validate.rs:116:

static ID_MENTION_RE: LazyLock<Regex> =
    LazyLock::new(|| Regex::new(r"\b[A-Z][A-Z0-9]*-[0-9]+\b").unwrap());

The pattern only allows a single-segment prefix. A hyphen is a word boundary, so when prose mentions a multi-segment id, the regex matches the id's suffix instead of the id. That gives two failures:

  1. False positive. synth has both TR-001 and CM-TR-001. Prose in CM-TR-002 that says "as CM-TR-001" produced:
    WARN: [CM-TR-002] prose mentions 'TR-001' but no typed link to it; add a link in `links:` or remove the mention
    
    The remediation it suggests (link to TR-001) would create a false trace to an unrelated requirement. Friction marking requirements implemented in a real project (rivet 0.13.3): silent file-skip, validate baseline noise, loop-modify no-op #353's suppression was added to prevent exactly that.
  2. False negative. An id like CM-TR-001 or CM-VER-001 is never matched whole, so a real prose mention with no typed link is never reported.

Repro

In any project with artifacts TR-001 and CM-TR-001 where both types allow a link type between them: put the text see CM-TR-001 in the description of a third artifact with no links, then run rivet validate. You get a warning naming TR-001 and none naming CM-TR-001.

Measured in synth: adding "as CM-TR-001" to three artifacts and "See CM-VER-001" to one moved warnings from 439 to 443. All four new warnings named the suffix (TR-001, VER-001).

Suggested shape

Match the longest id-shaped token, e.g. \b[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-[0-9]+\b, then resolve it against the store. A test pairing TR-001 and CM-TR-001 pins both directions: no suffix warning, and the whole id is detected.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions