Skip to content

[rule-24] Fix verification grep — rg --type svelte not recognized by ripgrep #89

@fedorovvvv

Description

@fedorovvvv

Source: PRD-018 SC-2 audit, finding [Arch-C1].

.claude/rules/24-shared-ui-ownership.md:127

The "Verification" snippet in rule 24 reads:

rg ':global(' src/{entities,widgets,pages,routes} --type svelte -A 1 \
  | rg -P "$PRIMITIVE_CLASSES" \
  && echo "FAIL: ..." \
  || echo "OK: ..."

Two problems:

  1. --type svelte is not a recognized ripgrep type. Default ripgrep ships no svelte filetype; the command exits with unrecognized file type: svelte. The outer || then prints "OK" on every PR, regardless of violations.
  2. Shell logic conflates "no matches" with "command failed." The &&/|| pair fires "OK" both when the inner pipeline returns empty AND when ripgrep errored.

Fix

rg -g '*.svelte' --type-add 'svelte:*.svelte' ':global\(' src/{entities,widgets,pages,routes} -A 1 \
  | rg -P "$PRIMITIVE_CLASSES" \
  | tee /tmp/rule24-hits.txt
test ! -s /tmp/rule24-hits.txt && echo "OK: no upper-layer reaches into primitive internals" || { echo "FAIL: upper-layer Svelte file overrides a primitive class via :global()"; exit 1; }

Or simpler with -q:

if rg -g '*.svelte' ':global\(' src/{entities,widgets,pages,routes} -A 1 | rg -qP "$PRIMITIVE_CLASSES"; then
  echo "FAIL: ..." && exit 1
else
  echo "OK: ..."
fi

Also fix in same edit

  • The forbidden-class regex misses consumer-supplied class names forwarded to a primitive root (.panel-action, .update-btn, .theme-toggle, .notify-toggle, .pane-icon, .error-alert, .tab-badge, .timeline-toggle, .kind, .close, .filter-group). These are the dominant violation pattern in PR feat(ui): integrate shared/ui primitives into widgets/pages (#82 #83 #84) #85; the listed regex catches none of them. Add either explicit names or a structural rule: "any :global(.SOMETHING) whose target is also passed via class=\"SOMETHING\" to a primitive root in the same file."
  • The "Existing violations (known debt)" list omits pages/home/ui/HomePage.svelte (.error-alert) and writes paths without the FSD ui/ segment.

Acceptance

  • Running the verification snippet locally on this repo correctly:
    • returns non-zero + prints FAIL when there's a violation,
    • returns zero + prints OK when there's none.
  • Added to CI as a check (separate issue if scope grows).
  • Existing-violations list refreshed with a fresh grep, including pages/.

Audit traceability

  • Reviewer: Architecture, score 6.5/10
  • File: .claude/rules/24-shared-ui-ownership.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions