Skip to content

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

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

fix(ci): the invisible-character gate never matched anything#50
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.
@sonarqubecloud

Copy link
Copy Markdown

@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: 300b50aa-0edc-4ded-b02e-d1c33eca62fb

📥 Commits

Reviewing files that changed from the base of the PR and between 7e84c8f and 687b874.

📒 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. (20)
  • GitHub Check: Gitar
  • GitHub Check: governance / Trusted-base reduction policy
  • GitHub Check: governance / Code quality + docs
  • GitHub Check: CodeQL Analysis (actions, none)
  • GitHub Check: governance / Security policy checks
  • GitHub Check: governance / Well-Known (RFC 9116 + RSR)
  • GitHub Check: governance / Guix primary / Nix fallback policy
  • GitHub Check: governance / Workflow security linter
  • GitHub Check: governance / Licence consistency
  • GitHub Check: governance / Language / package anti-pattern policy
  • GitHub Check: governance / Check Workflow Staleness
  • GitHub Check: Groove manifest check
  • GitHub Check: Validate K9 contracts
  • GitHub Check: Validate A2ML manifests
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Empty-linter (invisible characters)
  • GitHub Check: Hypatia Neurosymbolic Analysis
  • GitHub Check: rust-secrets
  • GitHub Check: gitleaks
  • GitHub Check: trufflehog
🔇 Additional comments (1)
.github/workflows/dogfood-gate.yml (1)

126-126: 🎯 Functional Correctness

No change required.

GNU grep does not strip a leading BOM. With -P in a UTF-8 locale, \x{feff} matches U+FEFF, so the existing pattern detects leading BOMs.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of invisible and control characters during automated checks.
    • Ensured binary files are scanned consistently as text, reducing the chance of hidden characters being missed.

Walkthrough

The workflow now detects invisible characters using code-point escapes, includes additional C0 controls, and scans binary files as text.

Changes

Invisible-character gate

Layer / File(s) Summary
Pattern and scan updates
.github/workflows/dogfood-gate.yml
The PATTERNS regex now uses code-point escapes and covers additional C0 control characters. The grep command uses -a so binary files are scanned as text.

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

Merge Risk: ⚪ Minimal · up to 687b8

This localized CI workflow change corrects invisible-character detection, and no actionable merge-blocking risk remains beyond normal checks and review.

Poem

A rabbit checks each hidden mark,
And scans the files from light to dark.
Code points now align in line,
Binary text is checked in time.
The gate can spot what stayed unseen.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements the codepoint escapes, C0 control range, and grep -a requirements from [#70]. It does not implement the required separate leading-BOM byte check or update the compiled linter and con… Add the separate byte-wise leading-BOM detection. Update stdlib/ByteDetector.affine and config.ncl with the matching C0-control logic. Verify that invalid characters are detected and that clean files and files containing tabs, CR, and LF ar…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: fixing the CI invisible-character gate.
Description check ✅ Passed The description directly explains the gate failure, root cause, implemented fixes, and verification results.
Out of Scope Changes check ✅ Passed The changes are limited to the CI invisible-character detection described in [#70]. No unrelated code changes are identified.
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 PR implements the codepoint escapes, C0 control range, and grep -a requirements from [#70]. It does not implement the required separate leading-BOM byte check or update the compiled linter and configuration to use the same C0 range.

Resolution

Add the separate byte-wise leading-BOM detection. Update stdlib/ByteDetector.affine and config.ncl with the matching C0-control logic. Verify that invalid characters are detected and that clean files and files containing tabs, CR, and LF are not flagged.

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.

@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

@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 40 issues detected

Severity Count
🔴 Critical 6
🟠 High 25
🟡 Medium 9

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in push-email-notify.yml",
    "type": "missing_timeout_minutes",
    "file": "push-email-notify.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in scorecard-enforcer.yml",
    "type": "scorecard_publish_with_run_step",
    "file": "scorecard-enforcer.yml",
    "action": "split_scorecard_publish_job",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in instant-sync.yml",
    "type": "secret_action_without_presence_gate",
    "file": "instant-sync.yml",
    "action": "peter-evans/repository-dispatch",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Required file missing (condition: public_repo)",
    "type": "missing_requirement",
    "file": "SECURITY.md",
    "action": "create",
    "rule_module": "cicd_rules",
    "severity": "high"
  },
  {
    "reason": "Download-and-execute pattern (curl|wget pipe to shell) -- verify integrity before execution (3 occurrences, CWE-494)",
    "type": "shell_download_then_run",
    "file": "/home/runner/work/live-files/live-files/setup.sh",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "No SECURITY.md found in live-files",
    "type": "SecurityPolicy",
    "file": "/home/runner/work/live-files/live-files",
    "action": "auto_fix",
    "rule_module": "scorecard",
    "severity": "medium",
    "remediation": "Add SECURITY.md documenting how to report vulnerabilities.",
    "scorecard_check": "Security-Policy"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/scorecard/SecurityPolicy -- Hypatia scorecard: SecurityPolicy -- 3 day(s) old",
    "type": "CSA001",
    "file": "live-files",
    "action": "review",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/cicd_rules/missing_requirement -- Hypatia cicd_rules: missing_requirement -- 3 day(s) old",
    "type": "CSA001",
    "file": "SECURITY.md",
    "action": "update",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 11 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".machine_readable/6a2/PLAYBOOK.a2ml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@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 successfully addresses a configuration issue where the invisible-character gate was ineffective due to invalid regex patterns. By transitioning from UTF-8 byte sequences to Unicode codepoint escapes and adding the -a flag to grep, the CI gate is now capable of detecting NBSP, BOM, and various C0 control characters even in files containing null bytes.

While the logic changes are correct and Codacy reports the PR is up to standards, there is a risk of future regressions because no automated test cases (dummy files with hidden characters) were added to the repository. The current verification remains manual.

About this PR

  • Consider adding automated test files (dummy source files containing specific invisible characters like NBSP, BOM, and C0 controls) to the repository. Without these, it is difficult to programmatically ensure the gate remains functional across future CI changes.

Test suggestions

  • Missing: Detect Non-breaking space (NBSP, U+00A0) in a source file
  • Missing: Detect Zero-width space (U+200B) in a source file
  • Missing: Detect Byte Order Mark (BOM, U+FEFF) in a source file
  • Missing: Detect C0 control characters like Backspace (\x08) in a source file
  • Missing: Scan and detect issues in a file containing null bytes (verifying -a flag functionality)
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Missing: Detect Non-breaking space (NBSP, U+00A0) in a source file
2. Missing: Detect Zero-width space (U+200B) in a source file
3. Missing: Detect Byte Order Mark (BOM, U+FEFF) in a source file
4. Missing: Detect C0 control characters like Backspace (\x08) in a source file
5. Missing: Scan and detect issues in a file containing null bytes (verifying -a flag functionality)

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.

⚪ LOW RISK

Suggestion: Using -exec ... {} \; is inefficient as it forks a new grep process for every file. Batching with {} + improves performance significantly. Additionally, the -r flag is redundant because find handles directory traversal and passes specific file paths to grep directly.

Suggested change
-exec grep -aPrl "$PATTERNS" {} \; > /tmp/empty-lint-results.txt 2>/dev/null
-exec grep -aPl "$PATTERNS" {} + > /tmp/empty-lint-results.txt 2>/dev/null

@hyperpolymath
hyperpolymath merged commit 5fce464 into main Aug 28, 2026
25 of 26 checks passed
@hyperpolymath
hyperpolymath deleted the fix/empty-linter-pattern-never-matched branch August 28, 2026 07:25
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