Skip to content

fix(ci): the invisible-character gate never matched anything - #196

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/empty-linter-pattern-never-matched
Aug 27, 2026
Merged

fix(ci): the invisible-character gate never matched anything#196
hyperpolymath merged 1 commit into
mainfrom
fix/empty-linter-pattern-never-matched

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Measured 2026-08-27: this gate caught 0 of 6 invisible-character test cases. It has never detected an NBSP, zero-width space, BOM, soft hyphen, bidi override or word joiner.

Root cause

The pattern used UTF-8 byte sequences (\xc2\xa0) while grep -P matches characters. Bytes c2 a0 are one character U+00A0; \xc2\xa0 asks for two, U+00C2 then U+00A0 — never present.

grep -P '\xc2\xa0'  ->  miss
grep -P '\x{a0}'    ->  MATCH

Only \x00 worked, being single-byte in both readings. The gate ran, passed, and could not see what it exists to see.

Fixed

  • codepoint escapes in place of byte sequences
  • C0 controls \x01-\x08,\x0B,\x0C,\x0E-\x1F added (TAB/LF/CR excluded)
  • grep -a — without it grep skips any NUL-bearing file as binary

The C0 range matters: a stray backspace byte made a workflow unparseable in developer-ecosystem, so it never ran — and this linter called it clean.

Canonical fix: hyperpolymath/empty-linter#70. 1 file(s) here.

Verified: YAML re-parsed, and the corrected pattern was confirmed to catch a real NBSP before the change was kept.

MEASURED 2026-08-27: this gate's pattern caught 0 OF 6 invisible-character test
cases. It has never detected an NBSP, zero-width space, BOM, soft hyphen, bidi
override or word joiner.

ROOT CAUSE: the pattern used UTF-8 BYTE sequences (\xc2\xa0) while grep -P
matches CHARACTERS. Bytes c2 a0 are ONE character U+00A0; \xc2\xa0 asks for TWO
characters, U+00C2 then U+00A0, which is never present.

  grep -P '\xc2\xa0'  ->  miss
  grep -P '\x{a0}'    ->  MATCH

Only \x00 worked, being single-byte in both readings.

FIXED: codepoint escapes; C0 control characters \x01-\x08,\x0B,\x0C,\x0E-\x1F
added (TAB/LF/CR excluded); and grep -a, without which grep skips any NUL-bearing
file as binary.

The C0 range matters: a stray BACKSPACE byte made a workflow unparseable in
developer-ecosystem, so it never ran, and this linter called it clean.

Canonical fix: hyperpolymath/empty-linter#70. 1 file(s) here.
VERIFIED: YAML re-parsed, and the corrected pattern was confirmed to catch a real
NBSP before the change was kept.
@gitar-bot

gitar-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 646d5a75-afa3-4fb2-a62e-a04d0a2fb4b6

📥 Commits

Reviewing files that changed from the base of the PR and between 2ec67b1 and dbf749d.

📒 Files selected for processing (1)
  • .github/workflows/dogfood-gate.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Hypatia Neurosymbolic Analysis
  • GitHub Check: analyze (actions, none)
  • GitHub Check: analyze (cpp, none)
  • GitHub Check: Empty-linter (invisible characters)
  • GitHub Check: validate-correspondence
  • GitHub Check: Validate eclexiaiser manifest
  • GitHub Check: Groove manifest check
  • GitHub Check: Validate A2ML manifests
  • GitHub Check: verify-proofs (Coq build oracle)
  • GitHub Check: property-testing
  • GitHub Check: docs/ECHO-TYPES-OCHRANCE-BRIDGE forbidden-phrases
  • GitHub Check: Validate K9 contracts
  • GitHub Check: verify-z3 (exact-result oracle)
🔇 Additional comments (2)
.github/workflows/dogfood-gate.yml (2)

145-145: LGTM!


134-134: 🎯 Functional Correctness

Do not add a separate leading-BOM check.

grep -aPrl does not strip a leading BOM. A BOM-only file matches a valid PCRE byte pattern. The locale-dependent pattern-compilation failure is a separate issue.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved empty-character scanning to correctly recognise Unicode characters.
    • Enhanced scanning reliability for files containing binary or non-standard data.

Walkthrough

The workflow replaces byte-oriented invisible-character patterns with PCRE Unicode code-point escapes. It also adds binary-safe grep processing with -a.

Changes

Invisible-character gate

Layer / File(s) Summary
Unicode-safe workflow scan
.github/workflows/dogfood-gate.yml
The scan uses Unicode code-point escapes and grep -aPrl for recursive, binary-safe matching.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to dbf74

This PR corrects the workflow gate’s matching behavior for invisible characters and NUL-bearing files. The change is localized, and no actionable merge-blocking risk remains beyond normal checks and review.

Poem

A rabbit checks each hidden mark,
Unicode lights the darker dark.
Binary files now join the queue,
The gate sees what it must review.
Soft spaces twitch; the scan is bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changes address Unicode codepoint escapes and binary-safe scanning, and the description states that C0 controls were added [#70]. However, the provided changeset does not show the required separat… Add a separate byte-wise leading-BOM check. Update stdlib/ByteDetector.affine and config.ncl with the matching C0-control logic, including is_c0_control/1. Add or run tests that verify invisible characters, a leading BOM, NUL and backspace …
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the CI gate defect and the corrective change. It is concise and directly related to the pull request.
Description check ✅ Passed The description explains the detected failure, root cause, implemented fixes, and verification. It is directly related to the changeset.
Out of Scope Changes check ✅ Passed The changes are limited to the CI invisible-character gate and match the requirements in issue #70. No unrelated changes are shown.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Full details: Linked Issues check

Explanation

The changes address Unicode codepoint escapes and binary-safe scanning, and the description states that C0 controls were added [#70]. However, the provided changeset does not show the required separate leading-BOM check or updates to stdlib/ByteDetector.affine and config.ncl for compiled-linter consistency [#70].

Resolution

Add a separate byte-wise leading-BOM check. Update stdlib/ByteDetector.affine and config.ncl with the matching C0-control logic, including is_c0_control/1. Add or run tests that verify invisible characters, a leading BOM, NUL and backspace bytes, clean files, and legitimate TAB, LF and CR characters.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the invisible-character linter gate by transitioning to Unicode codepoint matching using PCRE and ensuring files containing null bytes are not skipped. While these changes address the stated issue of the gate failing to match intended characters, there are two primary areas of concern.

First, there is a total lack of automated regression testing for this change; none of the required test scenarios for character detection or null-byte handling are currently covered. Second, the command implementation is inefficient and potentially unreliable. Using -exec ... {} \; in a large repository will impact performance, and silencing stderr while using the PCRE engine risks having the linter silently skip files if the regex engine encounters encoding errors. Codacy analysis indicates the PR is otherwise up to standards.

About this PR

  • The PR lacks automated regression tests or a 'dirty' test file containing the invisible characters (NBSP, BOM, C0 controls, etc.) to ensure the linter functions correctly and prevents future regressions.

Test suggestions

  • Verify detection of Non-Breaking Space (U+00A0) using the new codepoint escape.
  • Verify detection of C0 control characters (e.g., backspace \x08).
  • Verify that files containing null bytes are scanned rather than skipped by grep.
  • Verify detection of Unicode Byte Order Mark (U+FEFF).
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify detection of Non-Breaking Space (U+00A0) using the new codepoint escape.
2. Verify detection of C0 control characters (e.g., backspace \x08).
3. Verify that files containing null bytes are scanned rather than skipped by grep.
4. Verify detection of Unicode Byte Order Mark (U+FEFF).

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

-o -name '*.idr' -o -name '*.zig' -o -name '*.v' -o -name '*.jl' \
-o -name '*.gleam' -o -name '*.hs' -o -name '*.ml' -o -name '*.sh' \) \
-exec grep -Prl "$PATTERNS" {} \; > /tmp/empty-lint-results.txt 2>/dev/null
-exec grep -aPrl "$PATTERNS" {} \; > /tmp/empty-lint-results.txt 2>/dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: The current command has several areas for improvement:

  1. Performance: Using -exec ... {} \; spawns a separate grep process for every file. Switching to {} + allows find to pass multiple files to a single grep instance, significantly improving speed in large repositories.
  2. Redundancy: The -r flag in grep is unnecessary because find handles the directory traversal.
  3. Reliability: Using 2>/dev/null hides errors from grep -P. If the PCRE engine fails on a malformed file, the error will be swallowed, potentially allowing characters to bypass the check.

Consider this optimization:

find ... -exec grep -aPl "$PATTERNS" {} +

@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 56 issues detected

Severity Count
🔴 Critical 9
🟠 High 29
🟡 Medium 18

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Required file missing (condition: public_repo)",
    "type": "missing_requirement",
    "file": "SECURITY.md",
    "action": "create",
    "rule_module": "cicd_rules",
    "severity": "high"
  },
  {
    "reason": "Agda postulate assumes without proof -- potential soundness hole (1 occurrences, CWE-704)",
    "type": "agda_postulate",
    "file": "/home/runner/work/valence-shell/valence-shell/proofs/agda/FilesystemModel.agda",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "critical"
  },
  {
    "reason": "believe_me undermines formal verification (2 occurrences, CWE-704)",
    "type": "believe_me",
    "file": "/home/runner/work/valence-shell/valence-shell/proofs/idris2/src/Filesystem/Axioms.idr",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "critical"
  },
  {
    "reason": "unsafe block -- requires SAFETY comment (16 occurrences, CWE-676)",
    "type": "unsafe_block",
    "file": "/home/runner/work/valence-shell/valence-shell/impl/rust-cli/src/commands.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "as_ptr exposes raw pointer that may dangle or alias unsafely (6 occurrences, CWE-676)",
    "type": "as_ptr",
    "file": "/home/runner/work/valence-shell/valence-shell/impl/rust-cli/src/commands.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "expect() in hot path (4 occurrences, CWE-754)",
    "type": "expect_in_hot_path",
    "file": "/home/runner/work/valence-shell/valence-shell/impl/rust-cli/src/parser.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "unsafe block -- requires SAFETY comment (2 occurrences, CWE-676)",
    "type": "unsafe_block",
    "file": "/home/runner/work/valence-shell/valence-shell/impl/rust-cli/src/process_sub.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "as_ptr exposes raw pointer that may dangle or alias unsafely (2 occurrences, CWE-676)",
    "type": "as_ptr",
    "file": "/home/runner/work/valence-shell/valence-shell/impl/rust-cli/src/process_sub.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
    "type": "unwrap_without_check",
    "file": "/home/runner/work/valence-shell/valence-shell/impl/rust-cli/src/test_command.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "expect() in hot path (1 occurrences, CWE-754)",
    "type": "expect_in_hot_path",
    "file": "/home/runner/work/valence-shell/valence-shell/impl/rust-cli/src/external.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath
hyperpolymath merged commit 0646ea1 into main Aug 27, 2026
20 checks passed
@hyperpolymath
hyperpolymath deleted the fix/empty-linter-pattern-never-matched branch August 27, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant