Merge ruby-structural-migration: Ruby on the structural matcher

ober

c6a5acd5c2686882e51937fb82abad06c2d20dee

diff --git a/HANDOFF_OPUS_4_8.md b/HANDOFF_OPUS_4_8.md
index cbbb5f1..60b8138 100644
--- a/HANDOFF_OPUS_4_8.md
+++ b/HANDOFF_OPUS_4_8.md
@@ -7,7 +7,7 @@ Packaged Semgrep oracle: `/Users/user/.local/bin/semgrep`
 Branch: `java-structural-migration` (off `main`; carries java+scala+rust); Go
 and PHP migrations already merged.
 
-## Summary: Go, PHP, Java, Scala, Rust all run on the real structural matcher
+## Summary: Go, PHP, Java, Scala, Rust, Ruby all on the real structural matcher
 
 Five languages migrated off the regex generic-matcher approximation onto the
 real tree-sitter structural matcher; `generic-language?` (scan.ss ~809) no
@@ -16,7 +16,7 @@ compiled into `jerboa-treesitter`: go/php/scala/rust (ABI 15), java (ABI 14,
 within the runtime's 13-15 window); scala/rust/php carry external scanners,
 go/java are parser-only. `make test` 321/321; smoke 15/15 (parse case per lang).
 Per-language normalize-oracle fixture results: java 42/42, scala 18/18,
-rust 11/11, php 29/29, go 16/16.
+rust 11/11, ruby 4/4, php 29/29, go 16/16.
 
 ### Java/Scala/Rust migration (branch `java-structural-migration`)
 
@@ -124,8 +124,8 @@ The two remaining fixtures are blocked by the same gap that limits ~12
 languages, so closing them is the tip of the larger work:
 
 1. **AST matching for the "generic" languages (the big one).**
-   python/js/ts/go/php/java/scala/rust now use the tree-sitter structural
-   matcher. Ruby, C#, Swift, Dart, Kotlin, C, C++ remain `generic-language?`
+   python/js/ts/go/php/java/scala/rust/ruby now use the tree-sitter structural
+   matcher. C#, Swift, Dart, Kotlin, C, C++ remain `generic-language?`
    (scan.ss ~809) and use the regex-based `scan-generic-pattern`. That matcher
    approximates patterns with regexes and cannot express several Semgrep
    constructs. Real tree-sitter grammars for these languages would replace the
diff --git a/lib/semgrep/match/structural.sls b/lib/semgrep/match/structural.sls
index 3fb2e84..4fc841b 100644
--- a/lib/semgrep/match/structural.sls
+++ b/lib/semgrep/match/structural.sls
@@ -580,6 +580,9 @@
          [(string=? language "rust")
           (or (string=? type "source_file")
               (string=? type "expression_statement"))]
+         [(string=? language "ruby")
+          (or (string=? type "program")
+              (string=? type "expression_statement"))]
          [else #f]))
   (def (normalized-pattern-root language root)
        (let loop ([current root] [owned '()])
diff --git a/lib/semgrep/parse/parse-target.sls b/lib/semgrep/parse/parse-target.sls
index 433a82f..de71d60 100644
--- a/lib/semgrep/parse/parse-target.sls
+++ b/lib/semgrep/parse/parse-target.sls
@@ -28,6 +28,7 @@
            [(string=? canonical "java") 'java]
            [(string=? canonical "scala") 'scala]
            [(string=? canonical "rust") 'rust]
+           [(string=? canonical "ruby") 'ruby]
            [else
             (error 'parse-target-string
               "unsupported language in current MVP"
diff --git a/lib/semgrep/scan.sls b/lib/semgrep/scan.sls
index 099b7dc..6451762 100644
--- a/lib/semgrep/scan.sls
+++ b/lib/semgrep/scan.sls
@@ -749,7 +749,6 @@
              (string=? canonical "move_on_aptos")
              (string=? canonical "julia")
              (string=? canonical "kotlin")
-             (string=? canonical "ruby")
              (string=? canonical "cpp"))))
   (def (c-language? language)
        (let ([canonical (or (canonical-language language)
diff --git a/src/.jerbuild-hashes b/src/.jerbuild-hashes
index bacd135..cea8124 100644
--- a/src/.jerbuild-hashes
+++ b/src/.jerbuild-hashes
@@ -2,12 +2,12 @@
   ("src/semgrep/result.ss" . "22D23E40B49BA529")
   ("src/semgrep/output/json.ss" . "293881CFA2ADB7BC")
   ("src/semgrep/lang.ss" . "6982E07679D20836")
-  ("src/semgrep/parse/parse-target.ss" . "3FE8E8985B2E3461")
-  ("src/semgrep/scan.ss" . "70E81C1629B569BB")
-  ("src/semgrep/fix.ss" . "2E5B65B1FEF3B2B1")
+  ("src/semgrep/parse/parse-target.ss" . "AD193DA8CA67B2B2")
+  ("src/semgrep/scan.ss" . "82F2DEBA214D9CFD")
   ("src/semgrep/output/text.ss" . "BE476CB84B807FBA")
-  ("src/semgrep/rule.ss" . "E12C108153C181FA")
+  ("src/semgrep/fix.ss" . "2E5B65B1FEF3B2B1")
   ("src/semgrep/schema/lang.ss" . "CAE2CA859C9A9FD0")
-  ("src/semgrep/match/structural.ss" . "331D07881B8C8C56")
+  ("src/semgrep/rule.ss" . "E12C108153C181FA")
+  ("src/semgrep/match/structural.ss" . "3CE2210D6FE588E4")
   ("src/semgrep/main.ss" . "A4EC9E7F2A09D25E")
   ("src/semgrep/cli.ss" . "EBDC4B1DAD3F13CC"))
diff --git a/src/semgrep/match/structural.ss b/src/semgrep/match/structural.ss
index 3d2e185..4a41fb0 100644
--- a/src/semgrep/match/structural.ss
+++ b/src/semgrep/match/structural.ss
@@ -604,6 +604,9 @@
     [(string=? language "rust")
      (or (string=? type "source_file")
          (string=? type "expression_statement"))]
+    [(string=? language "ruby")
+     (or (string=? type "program")
+         (string=? type "expression_statement"))]
     [else #f]))
 
 (def (normalized-pattern-root language root)
diff --git a/src/semgrep/parse/parse-target.ss b/src/semgrep/parse/parse-target.ss
index 3b2b0da..02c38d9 100644
--- a/src/semgrep/parse/parse-target.ss
+++ b/src/semgrep/parse/parse-target.ss
@@ -20,6 +20,7 @@
       [(string=? canonical "java") 'java]
       [(string=? canonical "scala") 'scala]
       [(string=? canonical "rust") 'rust]
+      [(string=? canonical "ruby") 'ruby]
       [else
        (error 'parse-target-string "unsupported language in current MVP" language)])))
 
diff --git a/src/semgrep/scan.ss b/src/semgrep/scan.ss
index bc4e4bd..0f334b8 100644
--- a/src/semgrep/scan.ss
+++ b/src/semgrep/scan.ss
@@ -821,7 +821,6 @@
         (string=? canonical "move_on_aptos")
         (string=? canonical "julia")
         (string=? canonical "kotlin")
-        (string=? canonical "ruby")
         (string=? canonical "cpp"))))
 
 (def (c-language? language)